quaternionRotation -> update the existing quaternion

Hi guys.

I have this situation

image

Each of these boxes are updating x y z rotation of the mesh. I am using quaternions.

When you input values in the boxes, I am calling this
let quaternion = new BABYLON.Quaternion.RotationAxisToRef(axis, value, mesh.rotationQuaternion)
mesh.rotationQuaternion = quaternion;

Basically, If you input something in X input box, I want to update existing quaternion with the new X value and apply it to the mesh rotation (rotate the mesh).

The issue I have is this

Any ideas on how I should do this?

To cumulate the rotations, you should multiply your current quaternion with the new one obtained by calling RotationAxisToRef.

Thank you for your help. I tried that approach, and it somewhat worked, but I had some specific case problem, so I end up using

BABYLON.Quaternion.RotationYawPitchRoll(yaw, pitch, roll) to solve it

Had to do a research on quaternions to understand what is going on :smiley:

This is the example that helped me

https://www.babylonjs-playground.com/#1ST43U#9

Thanks

1 Like