How to get a polygon from a triangulated face in Three.js?

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.

+1
javascript geometry polygon 3d
source share

No one has answered this question yet.

See similar questions:

8
Three JS - Find all points where the grid intersects the plane

or similar:

7494
How to remove a specific element from an array in JavaScript?
5722
How to remove a property from a JavaScript object?
5129
How to return a response from an asynchronous call?
3796
How do you get the timestamp in JavaScript?
2701
How to get query string values ​​in JavaScript?
2170
How to get children from the $ (this) selector?
2132
Get selected text from drop-down list (select field) using jQuery
2102
How to get current date in JavaScript?
6
Triangulation of three .js polygons fails at pseudo-duplicate points
3
Holes in polygons lead to triangulation failure in Three.js

All Articles