From 53efecdfbd10f9b668a30ebbd153a15b7c2962ab Mon Sep 17 00:00:00 2001 From: Bowei Han Date: Wed, 23 Aug 2023 14:19:16 -0400 Subject: [PATCH] feat(OrbitControls): reverse horizontal and vertical orbits separately (#280) --- src/controls/OrbitControls.ts | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/controls/OrbitControls.ts b/src/controls/OrbitControls.ts index 266399fa..034fd6b8 100644 --- a/src/controls/OrbitControls.ts +++ b/src/controls/OrbitControls.ts @@ -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 @@ -398,7 +400,7 @@ class OrbitControls extends EventDispatcher { } function rotateLeft(angle: number): void { - if (scope.reverseOrbit) { + if (scope.reverseOrbit || scope.reverseHorizontalOrbit) { sphericalDelta.theta += angle } else { sphericalDelta.theta -= angle @@ -406,7 +408,7 @@ class OrbitControls extends EventDispatcher { } function rotateUp(angle: number): void { - if (scope.reverseOrbit) { + if (scope.reverseOrbit || scope.reverseVerticalOrbit) { sphericalDelta.phi += angle } else { sphericalDelta.phi -= angle