Skip to content

Commit

Permalink
fix(trackball): rotate was wrong on mouse drag (#424)
Browse files Browse the repository at this point in the history
* created new vector for the image, changed the vector used in this.rotateCamers()

* cleaning up code

* removing unneeded code

* removing leftVec of image, using rightVec for forwardVec calculation

* removed unsused library

* fixed x-axis rotation issue with polyData actor example
  • Loading branch information
NeilMacPhee authored Feb 10, 2023
1 parent 7381a5c commit 99c1a0a
Showing 1 changed file with 10 additions and 7 deletions.
17 changes: 10 additions & 7 deletions packages/tools/src/tools/TrackballRotateTool.ts
Original file line number Diff line number Diff line change
Expand Up @@ -113,20 +113,23 @@ class TrackballRotateTool extends BaseTool {
rotateIncrementDegrees;

const upVec = camera.viewUp;
const atV = camera.viewPlaneNormal;
const rightV: Types.Point3 = [0, 0, 0];
const forwardV: Types.Point3 = [0, 0, 0];

vtkMath.cross(upVec, atV, rightV);
vtkMath.normalize(rightV);

vtkMath.cross(atV, rightV, forwardV);
vtkMath.normalize(forwardV);
vtkMath.normalize(upVec);

this.rotateCamera(viewport, centerWorld, upVec, angleX);
this.rotateCamera(viewport, centerWorld, forwardV, angleX);

const angleY =
(normalizedPreviousPosition[1] - normalizedPosition[1]) *
rotateIncrementDegrees;

const atV = camera.viewPlaneNormal;
const upV = camera.viewUp;
const rightV: Types.Point3 = [0, 0, 0];
vtkMath.cross(upV, atV, rightV);
vtkMath.normalize(rightV);

this.rotateCamera(viewport, centerWorld, rightV, angleY);

viewport.render();
Expand Down

0 comments on commit 99c1a0a

Please sign in to comment.