Skip to content

Commit

Permalink
feat(OrbitControls): reverse horizontal and vertical orbits separately (
Browse files Browse the repository at this point in the history
  • Loading branch information
boweihan authored Aug 23, 2023
1 parent e7dad43 commit 53efecd
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 @@ -62,6 +62,8 @@ class OrbitControls extends EventDispatcher {
autoRotate = false
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
reverseHorizontalOrbit = false // true if you want to reverse the horizontal orbit direction
reverseVerticalOrbit = false // true if you want to reverse the vertical orbit direction
// The four arrow keys
keys = { LEFT: 'ArrowLeft', UP: 'ArrowUp', RIGHT: 'ArrowRight', BOTTOM: 'ArrowDown' }
// Mouse buttons
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 53efecd

Please sign in to comment.