Skip to content

Commit

Permalink
support reversing horizontal and vertical orbit separately
Browse files Browse the repository at this point in the history
  • Loading branch information
boweihan committed Aug 23, 2023
1 parent e7dad43 commit 88e7d0b
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/controls/OrbitControls.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,8 @@ class OrbitControls extends EventDispatcher {
autoRotateSpeed = 2.0 // 30 seconds per orbit when fps is 60
reverseOrbit = false // true if you want to reverse the orbit to mouse drag from left to right = orbits left
// The four arrow keys
reverseHorizontalOrbit = false // true if you want to reverse the horizontal orbit direction
reverseVerticalOrbit = false // true if you want to reverse the vertical orbit direction
keys = { LEFT: 'ArrowLeft', UP: 'ArrowUp', RIGHT: 'ArrowRight', BOTTOM: 'ArrowDown' }
// Mouse buttons
mouseButtons: Partial<{
Expand Down Expand Up @@ -398,15 +400,15 @@ class OrbitControls extends EventDispatcher {
}

function rotateLeft(angle: number): void {
if (scope.reverseOrbit) {
if (scope.reverseOrbit || scope.reverseHorizontalOrbit) {
sphericalDelta.theta += angle
} else {
sphericalDelta.theta -= angle
}
}

function rotateUp(angle: number): void {
if (scope.reverseOrbit) {
if (scope.reverseOrbit || scope.reverseVerticalOrbit) {
sphericalDelta.phi += angle
} else {
sphericalDelta.phi -= angle
Expand Down

0 comments on commit 88e7d0b

Please sign in to comment.