# 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:
https://threejs.org/docs/#examples/en/math/convexhull/ConvexHull

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âŚ

https://threejs.org/docs/#examples/en/math/convexhull/HalfEdge

Weâll have to work with that and give it a try

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âŚ

2 Likes