Skip to content

Commit

Permalink
Better touch rotation for perspective projection
Browse files Browse the repository at this point in the history
  • Loading branch information
Kurtil authored Oct 4, 2024
1 parent e39a468 commit 79fd544
Showing 1 changed file with 12 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -198,20 +198,20 @@ class TouchPanRotateAndDollyHandler {
}

} else {
// if (!absorbTinyFirstDrag) {
if (scene.camera.projection === "perspective") {
const { fov, fovAxis } = scene.camera.perspective;
const fovX = fovAxis === "x" || (fovAxis === "min" && canvasWidth < canvasHeight) ? fov : fov * (canvasWidth / canvasHeight);
const fovY = fovAxis === "y" || (fovAxis === "min" && canvasHeight < canvasWidth) ? fov : fov * (canvasHeight / canvasWidth);

const dx = xPanDelta / canvasWidth * fovX * configs.dragRotationRate / 360;
const dy = yPanDelta / canvasHeight * fovY * configs.dragRotationRate / 360;

updates.rotateDeltaY -= dx;
updates.rotateDeltaX += dy;
} else {
updates.rotateDeltaY -= (xPanDelta / canvasWidth) * (configs.dragRotationRate * 1.0); // Full horizontal rotation
updates.rotateDeltaX += (yPanDelta / canvasHeight) * (configs.dragRotationRate * 1.5); // Half vertical rotation
// } else {
// firstDragDeltaY -= (xPanDelta / canvasWidth) * (configs.dragRotationRate * 1.0); // Full horizontal rotation
// firstDragDeltaX += (yPanDelta / canvasHeight) * (configs.dragRotationRate * 1.5); // Half vertical rotation
// if (Math.abs(firstDragDeltaX) > 5 || Math.abs(firstDragDeltaY) > 5) {
// updates.rotateDeltaX += firstDragDeltaX;
// updates.rotateDeltaY += firstDragDeltaY;
// firstDragDeltaX = 0;
// firstDragDeltaY = 0;
// absorbTinyFirstDrag = false;
// }
// }
}
}

} else if (numTouches === 2) {
Expand Down

0 comments on commit 79fd544

Please sign in to comment.