Skip to content
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
12 changes: 8 additions & 4 deletions examples/jsm/controls/OrbitControls.js
Original file line number Diff line number Diff line change
Expand Up @@ -171,11 +171,11 @@ class OrbitControls extends EventDispatcher {
// this method is exposed, but perhaps it would be better if we can make it private...
this.update = function () {

const offset = new Vector3();
let quat = new Quaternion();
let quatInverse = quat.clone().invert();
const yAxisUp = new Vector3( 0, 1, 0 );

// so camera.up is the orbit axis
const quat = new Quaternion().setFromUnitVectors( object.up, new Vector3( 0, 1, 0 ) );
const quatInverse = quat.clone().invert();
const offset = new Vector3();

const lastPosition = new Vector3();
const lastQuaternion = new Quaternion();
Expand All @@ -189,6 +189,10 @@ class OrbitControls extends EventDispatcher {

offset.copy( position ).sub( scope.target );

// so camera.up is the orbit axis
quat.setFromUnitVectors( object.up, yAxisUp );
quatInverse.copy(quat).invert();

// rotate offset to "y-axis-is-up" space
offset.applyQuaternion( quat );

Expand Down