Get non-triangulated faces when import 3D model

I am using various loader (GLTFLoader, FBXLoader, OBJLoader etc…) to let user import 3D model into my app. One critical aspect of my application is that it need to know the face data in the original model but what I received from the loaders is already triangulated. I know that ThreeJs (and WebGL) only works with triangle, I just want to get the original face data before triangulation. Is that possible?

I’m not sure there is an easy solution to this. I have the impression (this means I might be wrong) that some 3D formats are for triangles only – like GLTF. So when a 3D model is created as GLTF it is already triangulated, so the loader cannot do anything. Other formats, like OBJ can have polygons and are pretty simple, so you can parse them by yourself and extract native polygons.

One alternative is to use EdgesGeometry (or its algorithm) to identify co-planar triangles and merge them back into polygons. However, this will also merge two originally co-planar squares into a one rectangle.

1 Like

glTF does not support meshes with quads or n-gons, but it does support lines. If you just want to render the original quads or n-gons as lines that is possible:

Beyond that, as @PavelBoytchev says, three.js loaders are there to create a THREE.Mesh object, and this does not include quad topology. I think you’d need to choose a format, find or modify a loader to identify original faces, and then keep track of the original faces vs. the triangulated faces if you need both.

2 Likes

It’s a surprise that GLTF does not support quad or n-gon. I have done some tests with GLTF and Blender and it seem Blender preserved the quad/n-gon just fine when exporting/re-importing with GLTF.
Anyway OBJ seems to be simple enough so I will go with that option. Thanks for the advices!