log flag for logging ray cast info

This commit is contained in:
Val Erastov 2019-02-08 18:03:16 -08:00
parent 491e3695d5
commit 872b0c173b
6 changed files with 38 additions and 18 deletions

View file

@ -1,6 +1,6 @@
import {enableAnonymousActionHint} from './anonHint';
import * as stream from 'lstream';
import {DEBUG_FLAGS} from '../debugFlags';
import {LOG_FLAGS} from '../logFlags';
export function activate(context) {
@ -24,7 +24,7 @@ export function activate(context) {
return;
}
if (state.enabled) {
if (DEBUG_FLAGS.ACTION_RUN) {
if (LOG_FLAGS.ACTION_RUN) {
console.log("RUNNING ACTION: " + id);
}
runner(context, data);

View file

@ -1,5 +0,0 @@
export const DEBUG_FLAGS = {
ACTION_RUN: false
};

View file

@ -10,7 +10,7 @@ import {toLoops} from '../brep/io/brepLoopsFormat';
import {contributeComponent} from './dom/components/ContributedComponents';
import BrepDebuggerWindow, {BREP_DEBUG_WINDOW_VISIBLE} from '../brep/debug/debugger/BrepDebuggerWindow';
import curveTess from '../brep/geom/impl/curve/curve-tess';
import {DEBUG_FLAGS} from './debugFlags';
import {LOG_FLAGS} from './logFlags';
export function activate({bus, services, streams}) {
@ -19,7 +19,7 @@ export function activate({bus, services, streams}) {
services.action.registerActions(DebugActions);
services.menu.registerMenus([DebugMenuConfig]);
services.debug = {
FLAGS: DEBUG_FLAGS
LOG_FLAGS
};
streams.ui.controlBars.left.update(actions => [...actions, 'menu.debug']);

6
web/app/cad/logFlags.js Normal file
View file

@ -0,0 +1,6 @@
export const LOG_FLAGS = {
ACTION_RUN: false,
PICK: false
};

View file

@ -1,5 +1,6 @@
import {setSketchPrecision} from './sketch/sketchReader';
import {runSandbox} from './sandbox';
import {LOG_FLAGS} from './logFlags';
export const STORAGE_GLOBAL_PREFIX = 'TCAD';
const STORAGE_PREFIX = `${STORAGE_GLOBAL_PREFIX}.projects.`;
@ -96,11 +97,18 @@ function parseHints(hints) {
return [id, params];
}
function processParams({sketchPrecision, sandbox}, context) {
if (sketchPrecision) {
function processParams(params, context) {
if (params.sketchPrecision) {
setSketchPrecision(parseInt(sketchPrecision));
}
if (sandbox) {
if (params.sandbox) {
setTimeout(() => runSandbox(context));
}
const DEBUG_FLAGS_PREFIX = "DEBUG.";
Object.keys(params).forEach(key => {
if (key.startsWith(DEBUG_FLAGS_PREFIX)) {
LOG_FLAGS[key.substring(DEBUG_FLAGS_PREFIX.length)] = true
}
})
}

View file

@ -1,6 +1,7 @@
import * as mask from 'gems/mask'
import {getAttribute, setAttribute} from 'scene/objectData';
import {FACE, EDGE, SKETCH_OBJECT, DATUM, SHELL, DATUM_AXIS, LOOP} from '../entites';
import {LOG_FLAGS} from '../../logFlags';
export const PICK_KIND = {
FACE: mask.type(1),
@ -23,7 +24,10 @@ const DEFAULT_SELECTION_MODE = Object.freeze({
export function activate(context) {
const {services, streams} = context;
const defaultHandler = (model, event) => {
const defaultHandler = (model, event, rayCastData) => {
if (LOG_FLAGS.PICK) {
printPickInfo(model, rayCastData);
}
const type = model.TYPE;
let selectionMode = DEFAULT_SELECTION_MODE;
let modelId = model.id;
@ -129,7 +133,7 @@ export function activate(context) {
if (mask.is(kind, PICK_KIND.SKETCH)) {
let sketchObjectV = getAttribute(pickResult.object, SKETCH_OBJECT);
if (sketchObjectV) {
return !visitor(sketchObjectV.model, event);
return !visitor(sketchObjectV.model, event, pickResult);
}
}
return false;
@ -138,7 +142,7 @@ export function activate(context) {
if (mask.is(kind, PICK_KIND.EDGE)) {
let edgeV = getAttribute(pickResult.object, EDGE);
if (edgeV) {
return !visitor(edgeV.model, event);
return !visitor(edgeV.model, event, pickResult);
}
}
return false;
@ -147,7 +151,7 @@ export function activate(context) {
if (mask.is(kind, PICK_KIND.LOOP) && !!pickResult.face) {
let faceV = getAttribute(pickResult.face, LOOP);
if (faceV) {
return !visitor(faceV.model, event);
return !visitor(faceV.model, event, pickResult);
}
}
return false;
@ -156,7 +160,7 @@ export function activate(context) {
if (mask.is(kind, PICK_KIND.FACE) && !!pickResult.face) {
let faceV = getAttribute(pickResult.face, FACE);
if (faceV) {
return !visitor(faceV.model, event);
return !visitor(faceV.model, event, pickResult);
}
}
return false;
@ -165,7 +169,7 @@ export function activate(context) {
if (mask.is(kind, PICK_KIND.DATUM_AXIS)) {
let datumAxisV = getAttribute(pickResult.object, DATUM_AXIS);
if (datumAxisV) {
return !visitor(datumAxisV.model, event);
return !visitor(datumAxisV.model, event, pickResult);
}
}
return false;
@ -187,3 +191,10 @@ export function activate(context) {
setPickHandler, deselectAll, pick
};
}
function printPickInfo(model, rayCastData) {
console.log("PICKED MODEL:");
console.dir(model);
console.log("PICK RAYCAST INFO:");
console.dir(rayCastData);
}