3D triangulation


I implemented a 2D triangulation fonction using Earcut. This isn’t the result I want because I want to triangulate 3D polygons (because rotations etc are computed somewhere else in the backend and I can’t access to a 2D polygon to triangulate it and then apply rotations with ThreeJS).

I can’t find how to make a 3D triangulation, here’s my code for the moment: https://codepen.io/ads4/pen/PogXzzq

The data used is in 2D, but I will receive 3D data (with the Z axis), so feel free to use any 3D data you want to test.

Thanks for helping.

Maybe this topic will be helpful/useful: Texture on dynamically created object - #8 by prisoner849

I’d try to do it in 3 steps, assuming the polygon is planar:

  • rotate the polygon, so it is parallel to XY (i.e. Z=const)
  • triangulate as 2D polygon
  • rotate back to its original orientation
1 Like

This is what happens in the topic provided above.
Not too elegant though :sweat_smile:

1 Like

Thank you for your answers!
I’m a beginner with 3d development and ThreeJS I have no idea how I can do this. I know that in the backend rotations are made using a pivot point.
There is a big algorithm in the back for advanced calculations, and it provides me the polygon already positioned “so I just need to display it” but it’s quite hard.

Excellent. This increases my chances to be correct.

1 Like