Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: support reversing horizontal and vertical orbit separately #278

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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