nosh247
nosh247

Reputation: 13

THREE.js OrbitControl.js can you change inverse y axis rotation?

I would like to know if there is a way to inverse the rotation of y axis upon dragging using OrbitControls.js. Currently presented a prototype and i was asked to inverse the motion of the drag on Y axis to the opposite as it looks confusing, but i have no idea if there are parameters i can set on OrbitControls to do this.

Im a noob with three.js please bear with me :C

Thanks, Fch

edit: i found a way to do this but im not sure its the best one, on line 405 on the OrbitControls.js i changed it to:

scope.rotateLeft( 2 * -Math.PI * rotateDelta.x / element.clientWidth * scope.rotateSpeed );

and now it rotates the way i wanted it to, added minus to Math.PI.

Upvotes: 1

Views: 2101

Answers (1)

o1sound
o1sound

Reputation: 500

In response to the solution you found, what you did will work but it's not wise to make the change so far down in the code. It might break other functions that won't see your change. What you really want to do is change the rotateLeft itself, as that's what OrbitControls.js seems to use to determine which direction to go horizontally.

this.rotateLeft = function ( angle ) {
    if ( angle === undefined ) {
        angle = getAutoRotationAngle();
    }
    thetaDelta -= angle; // change this to opposite
};

This way the logic is consistent across all instances where OrbitControls.js uses rotateLeft.

Upvotes: 2

Related Questions