rotationQuaternion.toEulerAngles is not returning the proper value when we have rotated the perticular mesh in the X-axis by 180° (1π rad).
Example:
Step 1: Create mesh
Step 2: Rotate mesh in X-axis by 180°
mesh.rotateAround(pt, new BABYLON.Vector3(1, 0, 0), Math.PI / 2 * 2);
Step 3: Convert Euler angles that can be used in mesh.rotation by doing rotation quaternion
mesh.rotationQuaternion.toEulerAngles();
In this scenario, expected output for x coordinate is 3.14 but we are getting 4.440892098500626e-16
@JohnK, yes you are right. But I am not facing any issue while doing rotation.
Once we do mesh.rotateAround(), the rotation details will be maintained by mesh.rotationQuaternion property and mesh.rotation will become invalid. As, when a rotationQuaternion is set, the value of rotation is set to (0, 0, 0).
As you can see when you convert the rotationQuaternion to Euler Angles and then use them on the clone of the subComponent the Euler Angles give the same rotation. As DK said for any quaternion there are more than one set of Euler angles that give the same result. It is just that the algorithm used in producing the Euler angles from the quaternion do not produce the ones you expect.