manthrax/THREE-CSGMesh

[question]: Getting position information and UV coordinates for the intersection of meshes

yure-r opened this issue · 2 comments

Hi Manthrax!

I've been looking into how meshes intersect and discovered this library. I wanted to use the intersection of two meshes to update a UV map and apply a dot texture by intersecting a sphere with a really complicated and unpredictably shaped mesh.

I was wondering if it was possible to get the coordinates and/or UV coordinates of the result of the intersection operation on the surface of the target mesh, but not turn that intersection into a mesh or add it to the scene, just to use that information for texture mapping purposes, that could be used to index position information and UV information on the target mesh?

thank you for reading, please let me know if you have any guidance on this

Hi again!

I've been working with your library and I know there are different ways to categorize polygons, but basically my problem is kind of simple, yet I can't figure it out:

Screen Shot 2023-03-04 at 1 16 41 PM

The far left side of the image is a union operation, and the far right is an intersect operation.

The idea is that I'm looking to leave with only the original silhouette, the cube shape, but the materials changed where they share vertices. So I need to combine operations, or trim away the non-intersecting part of the union operation on the far left side, but keep the non intersecting part of the union operation for the cube.

Is there a way to only trim away one geometry but keep the material change?

Thank you

I don't think so. But if you don't care about efficiency.. you can merge the results of 2 operations and get something that looks identical to what you describe.
Do the intersect like you have on the right.. then swap the order and do it again to get the outer cube part.. and merge the 2 results into a single mesh using geometry.merge.
The final mesh will have multiple materials in its .material field (as an array [ material1,material2,material3]) and you can re-order/replace them as you see fit.