Rotation / Orientation

I want to use the Rotation Gizmo to orientate a mesh save new orientation to DB and reuse it later when I load up the saved DB data apply it to the mesh the Rotation Gizmo stops working if the saved data is applied to the mesh.

I read that Quaternion is applied than XYZ euler angles stop I am assuming that is why the Rotation Gizmo stops working.

Any suggestions to get a current orientation to be saved to DB and how to apply it back to the mesh latter would be so helpful as I am on day 3 of attempting to get this right.

Thanks

Adam Wilson

Hello Adam Wilson, you can do it like this:

  1. Make sure the mesh has a quaternion:
    mesh.rotationQuaternion = BABYLON.Quaternion.Identity();
  2. Rotate the mesh with the gizmo
  3. Save the quaternion’s x, y, z, and w values to your DB
  4. Load the mesh and set:
    mesh.rotationQuaternion = new BABYLON.Quaternion(x, y, z, w);
1 Like

Thanks So much that is exactly what I was looking for the missing pieces of the puzzle.
– > mesh.rotationQuaternion = BABYLON.Quaternion.Identity();

1 Like