Hi Guys, Let me brief the scenario,

  1. I need to merge the geometries / reduce draw calls / increase FPS.
  2. I have a scene in which I create custom polygon shapes ( can be of different vertices ) and materials are same.
  3. The problem I face is the as I create more polygons, FPS drops ( increase in draw calls ).
  4. I tried using instanced mesh, but the problem is the geometries for polygons are different, so it doesn’t work
  5. After merging I should be able to select , reposition the mesh

is there any way to increase performance where I use THREE.GEOMETRY() to create shapes/polygon ?

Since your materials are the same, you could use BufferGeometryUtils.mergeBufferGeometries. However, this would turn all your separate polygons into a single geometry, so you’d lose the ability to translate/rotate/scale each one independently.

That’s exactly where I am at now. But I want to select and reposition as well. Any idea for that?

There’s no simple answer for this sorry… if you maintain separate objects they’re easy to reposition but lots of draw calls. If you merge them, repositioning is hard.

The problem is doubly hard with THREE.Geometry, which is less efficient than THREE.BufferGeometry to begin with…

So if I use BufferGeometry the problem can be solved?

The problem remains, but with less memory consumption.

no way I could solve this?

The general approach is to merge all of your geometries (they must share one material to be merged) while keeping track of the ‘offset’ for each geometry so that you can raycast against it later, or update the vertices. This is a more advanced thing to implement, and would likely be many hundred lines of code if including selection and repositioning. I’m not aware of examples to look at for it, other than the mergeBufferGeometries() function itself.

1 Like

I’ve opened a suggestion/request on github for a simplified way of doing this: BatchedMesh: Proposal · Issue #22376 · mrdoob/three.js · GitHub.

1 Like

I am not sure if this is relevant or not, but I once had to create custom geometries where the number of vertices became a problem. I did not have the option to merge the geometries.

What I did is to realize that I could save a lot of vertices by placing more vertices at sharp curves in my models and less in more flat surface areas.

This led me to develop a mathematical approach using a mixed arithmetic + geometric series in the function that builds the geometries. It made a huge difference, while avoiding any edge effects due to insufficient coverage.

can you share the algorithm?