Skip to content

Commit

Permalink
Merge pull request #455 from Kitware/fix-pan-interactor
Browse files Browse the repository at this point in the history
Fix pan interactor
  • Loading branch information
jourdain authored Dec 9, 2017
2 parents 55779b7 + 195417e commit 4b83c03
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 6 deletions.
10 changes: 5 additions & 5 deletions Sources/Interaction/Manipulators/TrackballPan/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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();
Expand Down
6 changes: 5 additions & 1 deletion Sources/Interaction/Manipulators/TrackballZoom/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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 {
Expand Down

0 comments on commit 4b83c03

Please sign in to comment.