Rotation around y on root node

Hi folks,

So I know about the right handed system problematic of the gltf import, which leads to a “root” node for conversion.
According to some code parts I analyzed it seems like BabylonJS flips the “z” axes when switching between left and right handed coordinate system (scene.useRightHandedSystem).
So the negative z scaling in the root node makes perfect sense to me.

But what I don’t get is the 180° rotation around y.
It kinda creates an inversion around “x” instead.
Also when I compare some glb with babylon models (all Blender exported), they appear different in the scene.
Check out this PG example.
On the right side there is the correct babylon model, on the left side the GLB import, which is rotated differentely. I’d expect that both are identical after the import.

I also saw that the sandbox adds a 180° rotation in the default camera as well, if the model is a GLB import. Seems like the camera should fix the 180° rotation of the root node?

GLB upload:

Babylon upload:

Both look identical, but the camera value is different.

So my question is: why not just create a root node with -1 in scaling.z and NO rotation at all?
The imports would appear identical, even in the same scene without any camera workarounds.
See this PG example.

Looking forward to your response!
Best regards
Markus

I think the Y rotation is just so that the Z axis aligns with the left-handed Z axis, but let me consult @sebavan or @Evgeni_Popov :slight_smile:

The 180° rotation around Y and -Z scaling is the same thing as a -X scaling. Look at the console log from this PG:

There are multiple ways to transform a left-handed coordinate system to a right-handed one, but we use this one because it is the coordinate system for glTF files:

https://registry.khronos.org/glTF/specs/2.0/glTF-2.0.html#coordinate-system-and-units

which should answer your question:

I’m not sure why we do 180° around Y and -Z scaling instead of just -X scaling, though… Maybe @bghgary knows?

@Evgeni_Popov
Thanks a lot for the quick resonse.

So BabylonJS is inverting the x axis when transforming between the 2 systems.
Would be interesting to know why the z scale / y rotation is used instead of x scale but it’s not that important to me.

I just was expecting that the babylon and glb look the same when exporting it from the same Blender file and importing it into the same scene.
But it seems like this is not the case, as seen here.
However they would look the same if the inversion was done in z direction, as seen here.

Perhaps this is related to the conversion performed by the blender to .babylon plugin? As Blender doesn’t use the same axis coordinate system as Babylon.js, the data must also be converted in this case.

Mostly legacy. I didn’t realize this was just a -X when I wrote this but I couldn’t change it due to backwards compatibility.

Maybe it wasn’t a problem before so I didn’t notice it.
Models exported from blender will appear in this scaling.z = -1
If I just correct by setting scaling.z = 1,there will be problems with the position of child meshes

Is there a more reliable way to solve this?

scene.useRightHandedSystem = true
This solved my problem