CesiumGS / CesiumGS/obj2gltf

Faces get flipped on conversion

Open
#212 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
JavaScript
Stars
1.9k
Forks
311
PR merge metrics
No merged PRs in 30d

Description

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](https://github.com/AnalyticalGraphicsInc/obj2gltf/files/3672586/test_original.obj.zip)

It looks like this
![](https://i.imgur.com/DrEU3na.png)
![](https://i.imgur.com/t6BAgBO.png)

When I convert it with the command `obj2gltf.js -i test_original.obj -o test_original.gltf`, I get [a glTF](https://github.com/AnalyticalGraphicsInc/obj2gltf/files/3672648/test_original.gltf.zip) that looks like this
![](https://i.imgur.com/31a3jBE.png)
![](https://i.imgur.com/j3Pso1J.png)

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](https://github.com/AnalyticalGraphicsInc/obj2gltf/files/3672628/test_original_x_flipped.obj.zip), and visually, it is the same as my original (which I don't really get).

In any case, converting it to [glTF](https://github.com/AnalyticalGraphicsInc/obj2gltf/files/3672647/test_original_x_flipped.gltf.zip) gives me the expected visual result now
![](https://i.imgur.com/QRP38HV.png)
![](https://i.imgur.com/5RKK84I.png)

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?

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.