edgeGeometry mergeVertices

I’m creating edges for my models (which can contain 50+ meshes), in a loop in the following way…

 let edges = new THREE.EdgesGeometry(mesh[i].geometry, 40);
 let bufferGeometry = new THREE.BufferGeometry();
 bufferGeometry.attributes = edges.attributes;
 lines = new THREE.LineSegments(bufferGeometry, lineBasicMaterial);

it works fine however on some models it hangs for 1-2 minutes creating the edges, causing chrome to moan about it being unresponsive. When running the chrome performance tools I could see it was mergeVertices that was causing the delay when it creates the new THREE.edges geometry.

so my questions…

  1. Can I control the mergeVertices that is occurring at all in the hope to improve performance (change the tolerance maybe?)?
  2. What factors affect the mergeVertices, is it purley the quantity?
  3. Is the above still the appropriate way to create edges for my meshes (each mesh has to have separate edge lines so i can fiddle with them independently later)

No, since the merge is required to produce unique edges.

Yes. The more vertices and faces a geometry has, the more complex is the processing. However, the runtime complexity is manageable. It should be something like O(n+m) where n is the number of vertices and m the number of faces.

Yes :blush:.

Great, thanks for the response.

I’m thinking of investigating webworkers to hopefully improve performance. On my quick and simple experiment I can see I will run into issues (for example passing buffer geometry to it)… before I go off and dedicate time to look further, it would be handy if anyone knows whether it’s a complete non starter/waste of time to do such a task in a webworker.

Well that depends. It always a matter if an existing unit of work is large enough for a thread in order to outweigh the thread communication overhead. For this particular use case, it makes probably only sense for very complex geometries. I guess you have to try and see how it goes.