By default (scene.useRightHandedSystem = false), createNormals will produce standard results
But if scene.useRightHandedSystem = true, createNormals doesn’t work properly
Here’s the [PG] “https://www.babylonjs-playground.com/#LL5BIQ#569”
Note: Don’t think this affects GLTF imports, but affects .babylon ones
Hi! Will take a look at this.
Ok, I think I understand what’s going on now The calculation for computeNormals already does take into account the scene orientation: Babylon.js/mesh.vertexData.ts at master · BabylonJS/Babylon.js (github.com), so it properly computes the normals in right handed orientation. When we load a GLTF, its positions and indices are always in right handed orientation by definition, so to properly display it in Babylon, we add to it a root node that applies a transformation to go from right to left handedness.
But when we load a .babylon file, we assume we are loading coordinates in left-handed orientation, so no such transformation is applied. Then when calling createNormal with useRightHandedSystem = true, it’s calculating normals in a right-handed system using left-handed data, which won’t be correct. Unfortunately, there’s no way to always know when vertices are specified in left or right handed systems so we always have to be aware of it.
Aah, so then to work around this, instead of calling createNormals() which uses scene.useRightHandedSystem, you can call ComputeNormals directly and pass false for the useRightHandedSystem option like on lines 40-42, if you know the model was loaded from .babylon and so uses left handed system…
This is super helpful, thank you both @carolhmj @Blake !
So…there’s no other way around this then other than to just ‘know’ it’s .babylon vs .gltf etc?
That’s right, .gltf always uses right-handed while .babylon uses left-handed. It’s still better than .obj because then there is no way to know without knowing which program generated it