CesiumGS / obj2gltf

Convert OBJ assets to glTF
Apache License 2.0
1.71k stars 307 forks source link

Faces get flipped on conversion #212

Open silvainSayduck opened 5 years ago

silvainSayduck commented 5 years ago

Hi,

We have had issue with some of our OBJs, and after taking the time to look into this a lot more deeply, I'm at a loss to what is happening.

Here is a very simple example OBJ

It looks like this

When I convert it with the command obj2gltf.js -i test_original.obj -o test_original.gltf, I get a glTF that looks like this

As you can see, the faces with normals along the X axis get flipped.

Where things get even weirder, is that my original OBJ has the following vertex normals:

vn 0 0 1
vn 1 0 -0
vn 1 0 0
vn -1 0 -0

If I go and replace it with (manually flipping the X axis)

vn 0 0 1
vn -1 0 -0
vn -1 0 0
vn 1 0 -0

I get this OBJ, and visually, it is the same as my original (which I don't really get).

In any case, converting it to glTF gives me the expected visual result now

As a bit of context, my original OBJ is in fact a triangulation (by importing/exporting to Three.js using their OBJLoader and OBJExporter) from an OBJ with quads. Could it be that the axis orientation that is expected by obj2gltf (or glTF itself) is different from what Three.js uses?

Would you have any other idea of why only some faces get flipped?