import macro from 'vtk.js/Sources/macros'; import vtkInteractorStyleManipulator from 'vtk.js/Sources/Interaction/Style/InteractorStyleManipulator'; import vtkMouseCameraTrackballZoomManipulator from 'vtk.js/Sources/Interaction/Manipulators/MouseCameraTrackballZoomManipulator';
function vtkMouseCameraTrackballZoomToMouseManipulator(publicAPI, model) { model.classHierarchy.push('vtkMouseCameraTrackballZoomToMouseManipulator');
const superOnButtonDown = publicAPI.onButtonDown; publicAPI.onButtonDown = (interactor, renderer, position) => { superOnButtonDown(interactor, renderer, position); model.zoomPosition = position; };
publicAPI.onMouseMove = (interactor, renderer, position) => { if (!position) { return; }
const dy = model.previousPosition.y - position.y; const k = dy * model.zoomScale; vtkInteractorStyleManipulator.dollyToPosition( 1.0 - k, model.zoomPosition, renderer, interactor );
if (interactor.getLightFollowCamera()) { renderer.updateLightsGeometryToFollowCamera(); }
model.previousPosition = position; };
publicAPI.onScroll = (interactor, renderer, delta, position) => { if (!delta || !position) { return; }
const dyf = 1 - delta * 0.1; vtkInteractorStyleManipulator.dollyToPosition( dyf, position, renderer, interactor );
if (interactor.getLightFollowCamera()) { renderer.updateLightsGeometryToFollowCamera(); } }; }
const DEFAULT_VALUES = { zoomPosition: null, };
export function extend(publicAPI, model, initialValues = {}) { Object.assign(model, DEFAULT_VALUES, initialValues);
vtkMouseCameraTrackballZoomManipulator.extend( publicAPI, model, initialValues );
vtkMouseCameraTrackballZoomToMouseManipulator(publicAPI, model); }
export const newInstance = macro.newInstance( extend, 'vtkMouseCameraTrackballZoomToMouseManipulator' );
export default { newInstance, extend };
|