# Is there a way to force the preservation of vertices when loading an OBJ file?

**URL:** <https://forum.babylonjs.com/t/is-there-a-way-to-force-the-preservation-of-vertices-when-loading-an-obj-file/52963>\
**Category:** Questions\
**Tags:** mesh, obj\
**Created:** [August 22, 2024, 5:57pm UTC](https://forum.babylonjs.com/t/is-there-a-way-to-force-the-preservation-of-vertices-when-loading-an-obj-file/52963 "2024-08-22T17:57:27Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![christian](https://avatars.discourse-cdn.com/v4/letter/c/b2d939/32.png) [@christian](https://forum.babylonjs.com/u/christian)\
**Post date:** [August 22, 2024, 5:57pm UTC](https://forum.babylonjs.com/t/is-there-a-way-to-force-the-preservation-of-vertices-when-loading-an-obj-file/52963/1 "2024-08-22T17:57:27Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![sebavan](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/sebavan/32/57_2.png) [@sebavan](https://forum.babylonjs.com/u/sebavan)\
**Post date:** [August 22, 2024, 8:50pm UTC](https://forum.babylonjs.com/t/is-there-a-way-to-force-the-preservation-of-vertices-when-loading-an-obj-file/52963/2 "2024-08-22T20:50:52Z")

</div>

Can you share a repro in the playground as I did not think we were removing data while loading.

---

<div class="post-metadata">

**Author:** ![roland](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/roland/32/38940_2.png) [@roland](https://forum.babylonjs.com/u/roland)\
**Post date:** [August 23, 2024, 2:15am UTC](https://forum.babylonjs.com/t/is-there-a-way-to-force-the-preservation-of-vertices-when-loading-an-obj-file/52963/3 "2024-08-23T02:15:25Z")

</div>

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.

> **[Feature requests](https://forum.babylonjs.com/c/features/11)**
>
> Please use this category to ask for new features or vote for existing ones.

Please provide a simple OBJ which I can use to test - just to double check I’m not giving you false information.

---

<div class="post-metadata">

**Author:** ![christian](https://avatars.discourse-cdn.com/v4/letter/c/b2d939/32.png) [@christian](https://forum.babylonjs.com/u/christian)\
**Post date:** [August 23, 2024, 1:27pm UTC](https://forum.babylonjs.com/t/is-there-a-way-to-force-the-preservation-of-vertices-when-loading-an-obj-file/52963/4 "2024-08-23T13:27:18Z")

</div>

I just tested it with the following simple OBJ file.

```auto
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.

---

<div class="post-metadata">

**Author:** ![christian](https://avatars.discourse-cdn.com/v4/letter/c/b2d939/32.png) [@christian](https://forum.babylonjs.com/u/christian)\
**Post date:** [August 23, 2024, 1:38pm UTC](https://forum.babylonjs.com/t/is-there-a-way-to-force-the-preservation-of-vertices-when-loading-an-obj-file/52963/5 "2024-08-23T13:38:57Z")

</div>

I posted the feature request. Thanks for the replies!

> [@Disable optimizations when loading meshes](https://forum.babylonjs.com/t/disable-optimizations-when-loading-meshes/52975):
>
> Hi, I have a feature request to optionally disable optimizations when loading a mesh. One example of this happening is when you load 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. I believe the 4th must be culled because it isn’t referenced by the index buffer. This optimization is great normally, bu…
