From 99c1a0a35dd52ddec26551de75656cdda7149b39 Mon Sep 17 00:00:00 2001 From: Neil Date: Fri, 10 Feb 2023 11:34:24 -0500 Subject: [PATCH] fix(trackball): rotate was wrong on mouse drag (#424) * 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 --- packages/tools/src/tools/TrackballRotateTool.ts | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/packages/tools/src/tools/TrackballRotateTool.ts b/packages/tools/src/tools/TrackballRotateTool.ts index ee0eb22df9..2e70a9b921 100644 --- a/packages/tools/src/tools/TrackballRotateTool.ts +++ b/packages/tools/src/tools/TrackballRotateTool.ts @@ -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();