src/VTKViewport/Manipulators/customZoom.js
/**
 * Adjust the zoom based on the mouse movement.
 */
Adjust the zoom based on the mouse movement.
Adjust the zoom based on the mouse movement .
function onMove(publicAPI, model, callData) {
  const position = callData.position;
  const interactor = model.interactor;
  const renderer = interactor.getCurrentRenderer();
  const camera = renderer.getActiveCamera();
  if (!position) {
    return;
  }
  const dy = model.previousPosition.y - position.y;
  if (camera.getParallelProjection()) {
    const k = dy * model.zoomScale;
    camera.setParallelScale((1.0 - k) * camera.getParallelScale());
  } else {
    const cameraPos = camera.getPosition();
    const cameraFp = camera.getFocalPoint();
    const norm = camera.getDirectionOfProjection();
    const k = dy * model.zoomScale;
    let tmp = k * norm[0];
    cameraPos[0] += tmp;
    cameraFp[0] += tmp;
    tmp = k * norm[1];
    cameraPos[1] += tmp;
    cameraFp[1] += tmp;
    tmp = k * norm[2];
    cameraPos[2] += tmp;
    cameraFp[2] += tmp;
    if (!camera.getFreezeFocalPoint()) {
      camera.setFocalPoint(cameraFp[0], cameraFp[1], cameraFp[2]);
    }
    camera.setPosition(cameraPos[0], cameraPos[1], cameraPos[2]);
    renderer.resetCameraClippingRange();
  }
  if (interactor.getLightFollowCamera()) {
    renderer.updateLightsGeometryToFollowCamera();
  }
  model.previousPosition = position;
  publicAPI.updateCrosshairs(model);
}
function onMove ( publicAPI , model , callData ) { const position = callData . position ; const interactor = model . interactor ; const renderer = interactor . getCurrentRenderer ( ) ; const camera = renderer . getActiveCamera ( ) ; if ( ! position ) { return ; } const dy = model . previousPosition . y - position . y ; if ( camera . getParallelProjection ( ) ) { const k = dy * model . zoomScale ; camera . setParallelScale ( ( 1.0 - k ) * camera . getParallelScale ( ) ) ; } else { const cameraPos = camera . getPosition ( ) ; const cameraFp = camera . getFocalPoint ( ) ; const norm = camera . getDirectionOfProjection ( ) ; const k = dy * model . zoomScale ; let tmp = k * norm [ 0 ] ; cameraPos [ 0 ] += tmp ; cameraFp [ 0 ] += tmp ; tmp = k * norm [ 1 ] ; cameraPos [ 1 ] += tmp ; cameraFp [ 1 ] += tmp ; tmp = k * norm [ 2 ] ; cameraPos [ 2 ] += tmp ; cameraFp [ 2 ] += tmp ; if ( ! camera . getFreezeFocalPoint ( ) ) { camera . setFocalPoint ( cameraFp [ 0 ] , cameraFp [ 1 ] , cameraFp [ 2 ] ) ; } camera . setPosition ( cameraPos [ 0 ] , cameraPos [ 1 ] , cameraPos [ 2 ] ) ; renderer . resetCameraClippingRange ( ) ; } if ( interactor . getLightFollowCamera ( ) ) { renderer . updateLightsGeometryToFollowCamera ( ) ; } model . previousPosition = position ; publicAPI . updateCrosshairs ( model ) ; }
Adjust the zoom based on the mouse movement.
Adjust the zoom based on the mouse movement .
// From vtkMouseCameraTrackballZoomManipulator // Fix the crosshairs position.