Is there any way to crop a 3d model and also export it

What im looking to do is crop the mesh based on the bounding box set by the user
I tired using boolean operations but the results are not as expected, parts of the mesh where there is nothing gets added geometry.

I got expected results by using clipping planes but that does not actually change the geometery of the mesh so cant export the model
Any insights will be helpful

I would have used boolean operations for that, what kind of unexpected geometry are you seeing? Can you share a Playground with it?

the models created are from photogrammetry so they are non manifold meshes, hence the boolean does not give ideal results
Hope this clarifies what I mean
It adds extra geometry when there was nothing there int he initial mesh

I see, thanks for the additional context. Makes sense that CSG won’t work as well on this scenario. I think you’ll need a custom algorithm for that, and some kind of data structure to hold vertex connectivity, such as a half-edge: Half-Edge Data Structures (

I’d try something like this: for each triangle of the mesh, test if its three vertices are inside or outside the cutting box. We have three cases to consider:

  1. The three vertices are inside the box. We keep this triangle.
  2. The three vertices are outside the box. We discard this triangle.
  3. It has vertices inside and vertices outside the box. This is the more complicated case. It would look something like this:
    Where the two orange vertices are outside of the box and the red vertex is inside. In that case, you’ll have to keep the red vertex, but exclude the orange vertices. There would be more than one way to cut up the geometry, but one approach could be to compute the intersections of the crossing edges with the cube, adding two new points in each intersection position, and forming a new triangle with the red vertex:
    Then you could keep this newly created triangle and exclude the existing one.
1 Like

Hey thanks for the explanation, I am already doing something like this in the backend while using bjs in frontend to help users with visualization, Most meshes are very high density so I wanted to avoid this as it will hinder the performance a lot on mobile devices and was looking if someone has done something out of the box magical voodoo that I can use.
Maybe in the future mobile devices will be powerful enough to support this kind of stuff without impacting user experience