question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

FBXLoader inverts geometry if Lcl Scaling is negative

See original GitHub issue

I’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:

post_fix

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

correct

Polygon from right foot, has the same material, position, scaling, orientation etc but displays dark grey and is not affected by lights

incorrect

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:closed
  • Created 6 years ago
  • Comments:26 (10 by maintainers)

github_iconTop GitHub Comments

3reactions
WestLangleycommented, Aug 9, 2017

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.

2reactions
WestLangleycommented, Aug 9, 2017

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.

Read more comments on GitHub >

github_iconTop Results From Across the Web

[ISSUE]FBX model shows abnormal - Questions - three.js forum
Yes, the model is exported from 3DS, but if I imported to blender then exported again, ... FBXLoader inverts geometry if Lcl Scaling...
Read more >
negative scaling - FBX Community - Autodesk Forums
I've downloaded a number of models that have negative scaling in their global transformation matrices. This causes rendering problems.
Read more >
Threejs FBXLoader is scaling in 100 - Stack Overflow
When I import my object, it's working, but it's scaling in 100. Why does not it stay in the original size? I'm using...
Read more >
Negative scaled static meshes, normals, and FBX export
I'm trying to process some geometry I've exported from a level as an FBX file. I need good normal information. The editor allows...
Read more >
three Matrix4 JavaScript Examples - ProgramCreek.com
This page shows JavaScript code examples of three Matrix4. ... metadata, geometry, material, position, rotation, scale, isgltf); this.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found