Hi, I’m looking for solutions for visualizing model files on the web side, such as common CAD formats like STP and IGS. The triangular meshes generated from model meshing are so numerous that the frame rate is extremely low. Since it is necessary to support the selection of each face, InstancedMesh and mergeBufferGeometries are not applicable.
Is BufferGeometry.setAttribute same as mergeBufferGeometries ? The triangular meshes form a surface. Is it possible to merge multiple triangular meshes to form a single surface in order to improve performance?
Can anyone give some suggestions? Thanks!
STP is an extremely inefficient format storage- and performance-wise. That’s because each face is stored independently of its neighbor faces. Vertices, which are used by multiple adjacent faces thus get transformed multiple times.
IGS, better known under the acronym of IGES, has not seen any new development since almost thirty years (1996, to be precise).
The exchange format of choice, especially for high performance interactive 3D visualisation, is glTF.
Thanks for your reply. The formats I want to use are STP、BREP and IGS, and I rarely deal with the glTF format.
I think to render CAD formats effectively, instancing or batching (e.g. InstancedMesh and BatchedMesh) are strictly necessary. This makes selection and interactivity more complex, but that can be solved.
Personally I would start by either modifying a loader, or re-writing the output of a loader, into one or more BatchedMesh instances. With BatchedMesh you can…
- position/rotate/scale
- raycast
- show/hide
- set color
… for any number of instances of any number of geometries. To do more complex things (like making specific instances transparent) you may need to reallocate some objects in another BatchedMesh instance.
Thanks for your advice.
Maybe my question is a bit simple. InstancedMesh requires same geometry but it can’t be guaranteed , BatchedMesh can’t select a single object. Could you please tell me how to solve this problem? And if I want to form a face with many triangular meshes, are the effects of BufferGeometry.setAttribute and BufferGeometryUtils.mergeBufferGeometries the same?
BufferGeometry.setAttribute and BufferGeometryUtils.mergeBufferGeometries are completely different functions.
setAttribute just sets an array into one part of the geometry, like “position”, “uv”, or "normal’
mergeBufferGeometries takes an array of geometries and combines them into 1 geometry.
Here’s some cad/step rendering/viewing middleware:
three.js has no concept of “selection” – just various features like coloring objects, showing/hiding objects, raycasting, and so on, which can be used to implement something users will understand as “selection” in your application. All of those things can be done with the instances drawn by a BatchedMesh, even if they aren’t discrete THREE.Object3D objects.
My understanding is that if I want to use triangular meshes to form a face, I should use BufferGeometryUtils.mergeBufferGeometries to merge all of the meshes to form a face, rather than use BufferGeometry.setAttribute to set the position of the triangular meshes to the position of the face. Excuse me, is this correct?
Thanks for your explanation. For the sake of simplicity, I use “selection” instead. Can each mesh be selected individually by raycaster after using BufferGeometryUtils.mergeBufferGeometries to merge geometries? I know that InstanceMesh can be distinguished by the index.
No, mergeBufferGeometries does not preserve any reference to the original geometries unless you use the groups option, and with that option enabled there’s no performance benefit.
The .setAttribute
method is not really relevant to this thread at all.
BatchedMesh is the API you are looking for to merge geometries while still being able to reference them and raycast them.
Thank you very much. I’ll take a look.