Hi, I have an OBJ mesh that has a lot of repeat vertices and vertices that aren’t referenced by the index buffer. I loaded the mesh into a Babylon scene but realized that many of the vertices had been culled. In one case, there are about a quarter of the original number of vertices. I’m guessing there is some optimization in the loader that automatically culls vertices that won’t be rendered, which is great, but I need these vertices preserved for my specific use case. Is there a way to turn this optimization off and force the preservation of the vertices, such that the vertex buffer looks exactly like the input from the raw OBJ file?
Can you share a repro in the playground as I did not think we were removing data while loading.
I was recently working on the OBJ loader and I can confirm that those vertices not referenced by an index are not used in the resulting mesh and there is currently no way to avoid this behavior. As always you can ask for a change in the Feature requests category.
Please provide a simple OBJ which I can use to test - just to double check I’m not giving you false information.
I just tested it with the following simple OBJ file.
v 0.0 0.0 0.0
v 10.0 0.0 0.0
v 0.0 10.0 0.0
v 10.0 10.0 0.0
f 1 2 3
When I load the model and log the vertex positions using .getVerticesData(BABYLON.VertexBuffer.PositionKind)
, I only see the first 3 vertices. The 4th must be culled because it isn’t referenced by the index buffer.
I’ve written my own OBJ loader as a temporary measure. It would be nice to be able to disable such optimizations, especially if the GLTF loader (which is not as easy to write your own parser for) does the same optimizations. I will open a feature request.
I posted the feature request. Thanks for the replies!