alessandro ferrini
alessandro ferrini

Reputation: 31

Gimbal lock at y axis 90 degrees

I found a problem with rotations. Using the transform controls helper, if I rotate a mesh on the Y axis, when I reach 90 degrees everything is flipped by -180 degrees.

I think this is due to the software avoiding gimbal lock, how to avoid it? That is, I would like the x- and z-angles to remain 0 degrees in the display.

I tried even on the threejs editor (https://threejs.org/editor/) and it occurs even there. Please help me :)!

Upvotes: 2

Views: 2315

Answers (1)

WestLangley
WestLangley

Reputation: 104793

What you are describing is has nothing to do with Gimbal lock.

three.js is quaternion-based. An equivalent Euler angle representation is provided for convenience.

Euler angles are not unique; there are many Euler angles that represent the same orientation. See this answer for info on how Euler angles work in three.js.

If you want to rotate an object on the y-axis only, and have object.rotation.y be continuous, you can do so by changing the rotation order like so:

object.rotation.order = 'YXZ';

three.js r.87

Upvotes: 4

Related Questions