I looked around the web if this person had the same problem. I work with three.js. I have a 3DObject that can contain holes. Faces are triangulated. Let's say I want to see this from above: my goal is to get a Polygon, which is the perimeter of the upper face (for me this means no more triangulated faces, but only 1 polygon). My approach so far has been this: I used the Three.js "EdgesGeometry" function over the geometry of the shape to get a collection of unsorted lines that, connected with self-writing, will build a closed polygon. The problem starts with holes. Because after using the "EdgesGeometry" function, I donβt know if the lines are the outer lines of the polygon or the inner lines around the hole. So I have a couple of questions:
- How can I find out if ShapeGeometry contains a hole from triangulated shapes? (nice to know, but this does not solve the problem).
- Is there a function that converts a triangular shape (ShapeGeometry) into a polygon with or without holes? (of course, they would be a different structure or definition)
- Can I do wrong to achieve my goal?
My ideal result would look like this:
- a set of sorted segments that describe the perimeter of the polygon and from 0 to n collections of sorted segments that describe the holes.
- a set of sorted points that describes the perimeter of a polygon and from 0 to n collections of sorted points that describe holes.
All of these questions relate to three.js.
I hope my question is clear enough.
Thanks for attention. Have a good day.
PS I examined the use of point-to-poly algorithms after my function in the case of holes, but I think that this is not a performance indicator, but complexity (designation O) will increase.
Swisx
source share