Skip to content

Commit

Permalink
feat(TrackballZoom): allow zoom on pinch in manipulator
Browse files Browse the repository at this point in the history
triggered by wheel scroll
  • Loading branch information
Alexis Girault committed Jan 15, 2018
1 parent d74c929 commit a7f505c
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions Sources/Interaction/Manipulators/TrackballZoom/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,31 @@ function vtkTrackballZoom(publicAPI, model) {
renderer.resetCameraClippingRange();
}
};

publicAPI.onPinch = (interactor) => {
const { x, y } =
interactor.getAnimationEventPosition(interactor.getPointerIndex()) ||
DEFAULT_POSITION;
const interactorStyle = interactor.getInteractorStyle();
const renderer =
interactorStyle.getCurrentRenderer() ||
interactor.findPokedRenderer(x, y);

const camera = renderer.getActiveCamera();

const dyf = interactor.getScale() / interactor.getLastScale();

if (camera.getParallelProjection()) {
camera.setParallelScale(camera.getParallelScale() / dyf);
} else {
camera.dolly(dyf);
renderer.resetCameraClippingRange();
}

if (interactor.getLightFollowCamera()) {
renderer.updateLightsGeometryToFollowCamera();
}
};
}

// ----------------------------------------------------------------------------
Expand Down

0 comments on commit a7f505c

Please sign in to comment.