Pregunta

I'm new to Three.js; Is there a way to get separate objects (elements/shells) from a Mesh or Geometry object?

If there's no native way to do that, how could I implement a method for separating faces that are not connected to an ensemble and then detaching them so they form there own Mesh object?

Background: I'm loading a 3d model and would like to be able to unify this model using ThreeBSP, I need to separate the objects before applying the boolean operations.

Thank you

¿Fue útil?

Solución

Dig into the Geometry object. It has an array of faces. I don't think there is a native way to check to see which ones are contiguous.

Shooting from the hip, "contagious" in this case means faces that share points with something something that shares points with something that shares points etc. So pick a face. Store it's defining points, find any faces that also use those points, store there points, find all the face that share any of the expanded points etc. Check out the "Flood Fill" function for some direction how to use recursion, as well as how to do the bookkeeping needed to avoid duplicates from keeping you searching in a loop forever.

Good Luck

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top