Greetings y’all !
When we import a .gltf model, and use gizmos to move objects (Only Move, not rotate, nor scale), the data of the rotationQuaternion changes, even tho’ the 3D model is visually the same.
We may not provide the source-code in full, but using this playground, you may check the console, and see how the mesh being dragged has its rotation changed (even by only moving it around).
When we’re using a right-handedSystem, the issue doesn’t occur in our platform.
But we can’t reproduce that in the playground, because for some reasons, it appears that rotationQuaternions are null/undefined when we use
scene.useRightHandedSystem (as you can see within the same playground)
Any help/insight is welcome.
Enjoy the rest of your week y’all!
Since GLTF is a right-handed coordinate system by default, while Babylon.js is left-handed, every time it imports a GLTF, it has to add a rotation and a scale on the
__root__ node to convert from one to another:
You can do this coordinate change by either rotating 180º on the y axis and then scaling z by -1, or rotating 180º on the z axis and then scaling y by -1. When the GLTF is first loaded the transformation applied is the first one:
But once we move it, the transformations are recalculated, and it ends up being the second case:
When you use
scene.useRightHandedSystem, this conversion doesn’t happen.
About the rotationQuaternion being null, it is null/undefined by default unless it has been set, which happens in the coordinate system conversion. Your platform might be setting it in another way, which then makes it not null A useful property to know is reintegrateRotationIntoRotationQuaternion, which lets you use either rotations or quaternions and keeps the result consistent. Usually, if you use quaternions, updating the rotation property doesn’t have an effect.
Hope this answered your questions!