Press n or j to go to the next uncovered block, b, p or k for the previous block.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 | 25x 25x 25x 25x 25x 25x 1x 25x 25x 25x 25x 25x 1x | import macro from 'vtk.js/Sources/macros'; import { subtract } from 'vtk.js/Sources/Common/Core/Math'; // ---------------------------------------------------------------------------- // vtkAbstractManipulator methods // ---------------------------------------------------------------------------- function vtkAbstractManipulator(publicAPI, model) { // Set our className model.classHierarchy.push('vtkAbstractManipulator'); model._prevWorldCoords = []; publicAPI.getOrigin = (callData) => { if (model.userOrigin) return model.userOrigin; if (model.useCameraFocalPoint) return callData.pokedRenderer.getActiveCamera().getFocalPoint(); if (model.handleOrigin) return model.handleOrigin; if (model.widgetOrigin) return model.widgetOrigin; return [0, 0, 0]; }; publicAPI.getNormal = (callData) => { if (model.userNormal) return model.userNormal; if (model.useCameraNormal) return callData.pokedRenderer .getActiveCamera() .getDirectionOfProjection(); if (model.handleNormal) return model.handleNormal; if (model.widgetNormal) return model.widgetNormal; return [0, 0, 1]; }; model._computeDeltaFromPrevCoords = (curWorldCoords) => { if (!model._prevWorldCoords?.length || !curWorldCoords?.length) return [0, 0, 0]; return subtract(curWorldCoords, model._prevWorldCoords, []); }; model._addWorldDeltas = (manipulatorResults) => { const { worldCoords: curWorldCoords } = manipulatorResults; const worldDelta = model._computeDeltaFromPrevCoords(curWorldCoords); if (curWorldCoords) model._prevWorldCoords = curWorldCoords; const deltas = { worldDelta, }; return { ...manipulatorResults, ...deltas, }; }; } // ---------------------------------------------------------------------------- // Object factory // ---------------------------------------------------------------------------- const DEFAULT_VALUES = { // userOrigin: null, // handleOrigin: null, // widgetOrigin: null, // userNormal: null, // handleNormal: null, // widgetNormal: null useCameraFocalPoint: false, useCameraNormal: false, }; // ---------------------------------------------------------------------------- export function extend(publicAPI, model, initialValues = {}) { Object.assign(model, DEFAULT_VALUES, initialValues); macro.obj(publicAPI, model); macro.setGet(publicAPI, model, ['useCameraFocalPoint', 'useCameraNormal']); macro.setGetArray( publicAPI, model, [ 'userOrigin', 'handleOrigin', 'widgetOrigin', 'userNormal', 'handleNormal', 'widgetNormal', ], 3 ); vtkAbstractManipulator(publicAPI, model); } // ---------------------------------------------------------------------------- export const newInstance = macro.newInstance(extend, 'vtkAbstractManipulator'); // ---------------------------------------------------------------------------- export default { extend, newInstance }; |