I need to rotate a mesh on pointer move (not with ArcRotateCamera because I don’t want the lights to move too). So that part is working, I found a PG that uses mouse listeners to change the rotation of my mesh using quaternions.
But, I’d like to limit (block) the rotation so the mesh is never rotated more than 90° (in the example, on the y axis, the cube should stop at the pink side). That limit should work front and back.
If I try various conditions (if meshmodel.rotationQuaternion.x > 0.7 && angleX > 0), it doesn’t work on all sides. Should I use euler angles instead for my conditions?
Yes, it will probably be easier to use Euler angles, because you only need to limit the value of rotation around the Y axis. With quaternions, you don’t have as direct a relationship between the components of the quaternion and the rotation about each axis.
We should not be able to go further than the pink side of the cube, it works only if you rotate slowly and it doesn’t work if you rotate “on the side” and behind. Somehow I find myself with negative values for the rotation…
Any ideas how to know easily if the cube is upside down?
Unfortunately no… I’ve tried that before but the rotation is “broken” without quaternions : on the blue side, if you mouse drag down you have the pink face. But if you slide to the right to the red side, when you mouse drag down, the red side is rotating on itself.