Inspector rotation quaterning bugging out

When rotating a loaded gltf cube the quaternion is causing the cube to get distorted.

There seems to be a bug causing the rotation to also scale the cube.

To reproduce

Drag and drop this gltf which is a simple cube with no rotation or position.

the quaternion gets set to 0,0,0,1

Then try spinning the cube with the inspector changing any of the x,y,z parameters and you should see it get all distorted.

cube.gltf.zip (1.3 KB)

This is not a bug :slight_smile: but how quaternions works.
A quaternion can store a matrix so it could store rotation AND scaling. so if you randomly change x y or z then you may end up with a non rotation quaternion

Is quaternions different between blender and babylonjs?

In blender i set the rotation mode to quaternion, and then try to change the x,y,z without changing W.
when i do that only the rotation of the cube changes with no distortion.

But when i do it in babylon everything goes haywire.

Maybe the coupling between the inspector and the quaternion is doing something funky?

A quaternion has the form a + xi + yj +zk and not all quaternions are rotation quaternions.

A rotation quaternion should be a unit quaternion.

Here is an example with the quaternion randomized and normalized to produce a unit quaternion

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

and hence the box rotates as expected. ie as DK stated you no longer have scaling. Lose the normalize and you will get distortions. Blender must internally normalize the quaternion before rendering.

So in our case we should normalize the quaternion on update from the inspector so it feels more natural?
Or what do you think?

This is a question for @Deltakosh there may be good reason to keep quaternions not just as rotation quaternions.

Well no good reason just wanted to let everyone input what they want. I can force a normalization but then the UI will be weird as values will change after user input ends

Or we change so the inspector uses degrees which is easier to manipulate.
Or maybe a drop down where you can choose between radians, degrees, and quaternion.

That way you can view the data how ever you want.

you can force the system touse rotation in rad by setting mesh.rotationQuaternion = null