Contour patch 3D gltf mesh

Hi everyone! Question.
We need to cut the shape of the window in the walls using a Boolean method ala Blender.
The most important thing is that we need a contour patch, which we can use for both 2D and 3D and we need to find points only on the contour of the 3D model.


you can get the shader from drei and make it work in vanilla.

Need exactly the points of the mesh contour to make 2D them further extruded and work

That sounds really hard. I haven’t really seen anything like that implemented before.
I suppose you could just look at the points in 2d like in your diagram and attempt to somehow walk the outer edge vertices… but that won’t work if your objects have additional flashing like you show In your second picture.

If your objects are always convex, you might be able to compute the “convex hull” and use that hull mesh to punch through the wall. The convex hull is like a new mesh that shrink wraps the original mesh…
Here is a threejs class for computing a convex hull mesh of another mesh:

And here is a picture of a convex hull to explain what I mean:

Yes, you’re right about the convex. But we tried it and the problem is that we can’t remove 2D patch from this figure. And we need to work with 3D and also with 2D. And it simplifies the object a lot.

Yeah… I see the issue.It’s starting to sound like your intuition about extracting the profile from walking the edge list might be the way to go…

You extract the perimeter edges, convert to Shape, then extrude that to get your punchthru geometry.

You might be interested in the half-edge datastructure for this kind of geometry manipulation…

We’ll have to work with that and give it a try :thinking:

There is this THREE-CSG library which seems to be for this exact purpose. Have you looked into that as well? I’m actually trying to achieve the same thing right now, that’s why I’m asking.

1 Like

Hehe I wrote/ported that library. It works pretty well… There is also the more modern/faster: GitHub - gkjohnson/three-bvh-csg: A flexible, memory compact, fast and dynamic CSG implementation on top of three-mesh-bvh

But for simple cases, mine might be fine for your purpose. There are also some differences in the kinds of errors each library can produce.

Feel free to DM me with any questions about it…