From cc102d79493d766e503c4424e1e2e389756a828c Mon Sep 17 00:00:00 2001 From: Sebastien Jourdain Date: Sat, 9 Dec 2017 12:32:44 -0700 Subject: [PATCH 1/2] fix(TrackballPan): Fix parallel projection issue --- Sources/Interaction/Manipulators/TrackballPan/index.js | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/Sources/Interaction/Manipulators/TrackballPan/index.js b/Sources/Interaction/Manipulators/TrackballPan/index.js index 3741c055d97..099c02d3074 100644 --- a/Sources/Interaction/Manipulators/TrackballPan/index.js +++ b/Sources/Interaction/Manipulators/TrackballPan/index.js @@ -34,9 +34,9 @@ function vtkTrackballPan(publicAPI, model) { vtkMath.cross(vpn, up, right); // These are different because y is flipped. - const size = interactor.getView().getSize(); - let dx = (pos.x - lastPos.x) / size[1]; - let dy = (lastPos.y - pos.y) / size[1]; + const height = interactor.getView().getSize()[1]; + let dx = (pos.x - lastPos.x) / height; + let dy = (lastPos.y - pos.y) / height; const scale = camera.getParallelScale(); dx *= scale * 2.0; @@ -51,8 +51,8 @@ function vtkTrackballPan(publicAPI, model) { tmp = (right[2] * dx) + (up[2] * dy); camPos[2] += tmp; fp[2] += tmp; - camera.setPosition(camPos); - camera.setFocalPoint(fp); + camera.setPosition(camPos[0], camPos[1], camPos[2]); + camera.setFocalPoint(fp[0], fp[1], fp[2]); } else { const center = model.center; const style = interactor.getInteractorStyle(); From 195417eab4c7ec41757354eeea4f896f825f79ec Mon Sep 17 00:00:00 2001 From: Sebastien Jourdain Date: Sat, 9 Dec 2017 12:33:20 -0700 Subject: [PATCH 2/2] fix(TrackballZoom): Ensure renderer to be found --- Sources/Interaction/Manipulators/TrackballZoom/index.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/Sources/Interaction/Manipulators/TrackballZoom/index.js b/Sources/Interaction/Manipulators/TrackballZoom/index.js index 7f036afccc0..e207d77b595 100644 --- a/Sources/Interaction/Manipulators/TrackballZoom/index.js +++ b/Sources/Interaction/Manipulators/TrackballZoom/index.js @@ -2,6 +2,7 @@ import macro from 'vtk.js/Sources/macro'; import vtkCameraManipulator from 'vtk.js/Sources/Interaction/Manipulators/CameraManipulator'; const { vtkWarningMacro } = macro; +const DEFAULT_POSITION = { x: 0, y: 0 }; // ---------------------------------------------------------------------------- // vtkTrackballZoom methods @@ -15,7 +16,10 @@ function vtkTrackballZoom(publicAPI, model) { const size = interactor.getView().getSize(); try { - const camera = interactor.getInteractorStyle().getCurrentRenderer().getActiveCamera(); + 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(); if (camera.getParallelProjection()) { model.zoomScale = 1.5 / size[1]; } else {