MASSIVE BUG: gizmo + rotationquaternion

Hey ya’ll,

I’ve found a major bug with the gizmos + rotation quaternion, after spending plenty of hours debugging :upside_down_face:.

I’ve created a PG:

Simply drag the position gizmo back-n-forth, and the world matrix determinant keeps getting smaller and smaller, which should never happen. This error does not occur if .rotation is used.

In this specific case, the world matrix determinant decreases and stabilizes around 0.86 (after 3 seconds of dragging). There have been cases where it blows up and keeps increasing well beyond 5x and counting. This ofc has major implications on the overall position, rotation + scaling

I can confirm that this bug exists in alpha.3 as well (and apparently all the way back to 4.2)

Adding @Cedric

I’m taking a look.

Typical issue with unnormalized quaternion.
Fixed here in this PG:
MASSIVE BUG: GIZMO + SCALE | Babylon.js Playground
I’ll do a PR to automate that.

1 Like

Thanks Cedric! Does this mean each time we would have to normalize all nodes that use .rotationQuaternion in the render loop? Or would the PR address this by forcing normalization in the node class itself?

the second. I’ll normalize the quaternion (if any) for nodes that are modified by a gizmo.

Cool! Is this because the gizmos are affecting the quaternion (also why is positionGizmo affecting the quaternion xD)? Or is this more fundamental i.e. should be adjusted each cycle regardless if it’s from gizmo or not
Interested to learn the internals :slight_smile:

gizmos work mostly with matrices and matrix is decomposed into translation/rotation and scale once done.
After a while, the conversion between matrix and quaternion drifts a little and you have to normalize it.


PR is live Normalize quat/update matrix for drag behavior by CedricGuillemet · Pull Request #9968 · BabylonJS/Babylon.js · GitHub