How to remove the vertices without a face

I made myself a cube. By: THREE.BoxGeometry
I wanted to get rid of some of the faces, and I did that too. Next, I wanted to remove the vertices that are not connected to the faces. And here was the problem. Once removed, the indexing changes and the indexing of the vertices in the faces does not.
So I had a smart idea to add those vertices that have no faces to those that do, and then remove them using this method: cube_geom.mergeVertices();
Unfortunately, it does not work very well because some faces are missing (this is what it looks like).
Is there any simple way to get rid of vertices that have no faces assigned without breaking the entire cube structure?

Please show what you do with a live example:

For clarification: When using BoxGeometry, the vertices property only has eight entries which represent the corner vertices of the box. So all vertices are shared between multiple faces. If you remove faces, it should be sufficient to call mergeVertices().

If you remove faces, it should be sufficient to call mergeVertices() .

It’s not true. I deleted all faces except two on one side and still have 8 vertices after using: mergeVertices ()

1 Like

Live example:

You’re right. After studying the code, mergeVertices() only ensures unique vertices. It does not remove vertices which are currently not in use (which is actually a valid implementation).

Seems like you have to implement the removal by yourself e.g. by writing your own version of mergeVertices().

I wrote code that removes unnecessary vertices.
The only thing i don’t understand is why when i set face 0 and 1 on face 6 and 7 it doesn’t show me one face.