I have complex, procedurally (at runtime) generated geometries that get merged down to one single BufferGeometry using BufferGeometryUtils.mergeGeometries .
The resulting geometry has lots of interpenetration that I would like to reduce, i. e. there are triangles that will never be visible because they are completely enclosed by opaque volumes of geometry. I would like to remove those triangles from the geometry.
Is there a free library that would help with this task? Can you recommend an efficient approach?
The solution of my dreams would be an algorithm/library that can actually reduce the geometries to a single continuous surface, ideally with variable smoothness at the seams.
There’s no one-shot method I’m aware of that will cleanly reduce arbitrary triangle soups into a single watertight surface, but there are a few tools and concepts that can help depending on how structured your geometry is.
If your meshes already form proper closed volumes, CSG libraries (like three-bvh-csg) can help eliminate internal faces. These typically rely on BSP trees or acceleration structures to classify and clip geometry.
But if you’re working with non-volumetric triangle soup — single planes, intersecting slabs, disconnected pieces — then defining an “interior” becomes ambiguous. A triangle by itself doesn’t enclose anything, whereas a tetrahedron is the minimal volumetric primitive.
Convex hulls are another tool that can approximate outer boundaries, but only work well for convex-ish shapes and don’t preserve details. (threejs: ConvexGeometry)
For topological reasoning, half-edge data structures (DCELs) can be helpful for navigating edges and face adjacency. (Look for halfEdge in threejs docs/repo)
As for your idea of “variable smoothness at seams,” that sounds like an edge split modifier, common in tools like Blender, which lets you preserve hard edges while smoothing others. (There is also a version of this modifier available in threejs)
In short, there’s no silver bullet for this, but combining volumetric structure, CSG, convex hulls, and maybe voxelization + surface extraction (marching cubes) can get you closer, especially if you’re willing to preprocess offline.