Euler Angle and Quaternion issue

Hello,

We recently decided to switch to quaternions for all the object in our scene in order to make it work with the gizmo. But we still use Euler angle as inputs, so we use the classic function RotationYawPitchRoll in order to go from Euler angles to quaternion and we observe that we don’t have always the same result using that function.

Here is a playground: Babylon.js Playground
You can see we have two cloned mesh and we only use RotationYawPitchRoll on one of them but the rotation is not the same.
I am sorry I am still not an expert in quaternions despite all my experience using it!

Thanks for your help guys :wink:

1 Like

It appears that both meshes are using rotationQuaternion. Unless something has changed in the past couple years, rotation does not get used when using rotationQuaternion. So it doesn’t make sense to copy mesh.rotation from the first shoe to the second shoe.

Yep, once rotationQuaternion is used rotation will not get updated automatically (this is for performance reasons) but I think you can do it manually.

https://playground.babylonjs.com/#J97DIA#1

Yep thanks for your answer, I indeed didn’t think the model loaded already had a rotationQuaternion. I have some other issue but I have to make some test again and another playground. I will get back to you here once this is more clear! :wink:

Ok I managed to make it work!

My problem was that i used the mesh rotation as argument of RotationYawPitchRoll like that:
mesh.rotationQuaternion = BABYLON.Quaternion.RotationYawPitchRoll(mesh.rotation.y, mesh.rotation.x, mesh.rotation.z);
But it seems that mesh.rotation is set to Vector.Zero after setting rotationQuaternion so my rotation values were not good anymore after setting a first time the rotationQuaternion.
So I just had to save my rotation parameter not with mesh.rotation and it works perfectly!

Cheerz :wink:

Maybe I am starting to become an expert!

Maybe :grin:

2 Likes

You are!!!

1 Like