FBXLoader inverts geometry if Lcl Scaling is negative
See original GitHub issueI’m attempting to load a complex rigged model, and finding that some parts of the geometry appear to have flipped normals, as you can see here:
However, the normals on the flipped parts of the geometry are actually correct, and neither inverting them nor applying double sided material fixes the issue. Aside from this, I checked the model in Windows Paint3D and it loads correctly.
So, I isolated the two feet, and then took a single polygon from each, scaled them and rotated them to match and positioned them both at (0,0,0). At this point the only difference I can see in my modelling program are the pivots being oriented differently. But when I load them with the FBXLoader, I get this:
Polygon from left foot, displays correctly and is affected by lights
Polygon from right foot, has the same material, position, scaling, orientation etc but displays dark grey and is not affected by lights
The two FBX files, one polygon from each foot, are here foot pieces.zip
And running them through a diff checker, the only important difference I can see is the line:
Left foot (correct)
P: "Lcl Scaling", "Lcl Scaling", "", "A",1.00000095367432,0.999999701976776,1.00000035762787
Right foot (incorrect)
P: "Lcl Scaling", "Lcl Scaling", "", "A",-1.00000107288361,-0.999999761581421,-1.00000035762787
Sure enough, removing the minus signs from this line causes the model to load correctly.
Issue Analytics
- State:
- Created 6 years ago
- Comments:26 (10 by maintainers)
three.js does not support reflections in the object matrix; reflections leave the vertex normals and winding order in an inconsistent state. The normals will look correct, but the winding order is reversed.
I believe in the official OBJ format – for example – the front face is determined by the face normal or vertex normals when specified. three.js/webGL uses the winding order to determine the front face.
After loading, you could try traversing your model and flip the winding order for all faces having
matrixWorld
with a negative determinant. But that is just a guess.We should identify all loaders/formats from other vendors that handle this sort of thing (with examples) and figure out what technique they use.