@@ -171,11 +171,11 @@ class OrbitControls extends EventDispatcher {
171171 // this method is exposed, but perhaps it would be better if we can make it private...
172172 this . update = function ( ) {
173173
174- const offset = new Vector3 ( ) ;
174+ let quat = new Quaternion ( ) ;
175+ let quatInverse = quat . clone ( ) . invert ( ) ;
176+ const yAxisUp = new Vector3 ( 0 , 1 , 0 ) ;
175177
176- // so camera.up is the orbit axis
177- const quat = new Quaternion ( ) . setFromUnitVectors ( object . up , new Vector3 ( 0 , 1 , 0 ) ) ;
178- const quatInverse = quat . clone ( ) . invert ( ) ;
178+ const offset = new Vector3 ( ) ;
179179
180180 const lastPosition = new Vector3 ( ) ;
181181 const lastQuaternion = new Quaternion ( ) ;
@@ -189,12 +189,13 @@ class OrbitControls extends EventDispatcher {
189189
190190 offset . copy ( position ) . sub ( scope . target ) ;
191191
192+ // so camera.up is the orbit axis
193+ quat = new Quaternion ( ) . setFromUnitVectors ( object . up , yAxisUp ) ;
194+ quatInverse = quat . clone ( ) . invert ( ) ;
195+
192196 // rotate offset to "y-axis-is-up" space
193197 offset . applyQuaternion ( quat ) ;
194198
195- // angle from z-axis around y-axis
196- spherical . setFromVector3 ( offset ) ;
197-
198199 if ( scope . autoRotate && state === STATE . NONE ) {
199200
200201 rotateLeft ( getAutoRotationAngle ( deltaTime ) ) ;
0 commit comments