You cannot use both a rotation and a rotationQuaternion on a mesh. When a rotationQuaternion is applied to a mesh this overwrites the current and subsequent use of rotation producing the wrong orientation. Should you want to use rotation after a rotationQuaternion has been applied, for example on an imported mesh, then the rotationQuaternion has to be set to null.
To see this effect comment out line 48 in the following playground
In my understanding by commenting out line 48 (which set the rotationQuaternion to null) it is expected that the two boxes will not be aligned anymore. But the example doesn’t seem to do that.
Something seems amiss with my understanding / the example ?
Actually something is missing in the doc.
For convenience and because we faced a lot of questions regarding that problem we allo you to still change the value of rotation even if rotationQuaternion is set.
In this case the system will ADD that rotation to the rotationQuaternion and then set it back to zero (the mesh.rotation will be (0, 0, 0))
rotationQuaterion is set { x: 0.10503269547928776, y: 0.001336730075941206, z: 0.7669894582804743, w: 0.6330035678569939 }
and so rotation is { x: 0, y: 0, z: 0 }
Following this the rotation is set { x: 0.1312985505528809, y: 0.16497104582455158, z: 1.7724948616328908 }
and rotationQuaternion is null
So I think the pattern is
set rotationQuaternion to Q and rotationQuaternion is Q and rotation is zero
Even when rotationQuaternion has been set then setting rotation to R rotation is R and rotationQuaternion is null.
What I described was BEFORE 4.0. Now to make things simpler, we just turn off automatically rotationQuaternion to null if you set the rotation property
I am having the same problem. I am rotating objects with rotation gizmo but when i try to get rotation values of the meshes, it returns “0”. I tried to apply your solutions, set rotationquaternion to null, still couldnot manage. Could you help me understand the problem?
The rotation gizmo will reset the rotation quaternion as it works on quaternion only so you need to use mesh.rotationQuaternion.toEulerAngles() to get the rotation