Creation of complex polygons following the pattern of Geojson polygon and multipolygon

Hello, currently I am working on three.js project which would allow user create, edit and view Geojson layer on map layer. Unfortunately I was not able to figure out how to create any complex polygons such as self intersecting polygons and boolean operations on polygons (both shapes and holes) which are needed to visualize geojson polygon and multipolygon.

Here are some expected results captured from

Self intersected polygon

Binary operation between shape and holes

Keep on mind that holes them selfs are creating new areas via binary operation.

Here is example of geojson which i need visualize in three.js
map.geojson (1.1 KB)

Thank you in advance for any help or hints!

What you’re probably looking for is a triangulation library, like delaunator or earcut. In order to visualize geojson in three.js, you will have to slice it up into triangles without self-intersection or holes. Earcut is the place to start I think.

Thanks for advice. I solved my issue by slicing complex polygons to simple polygons with @turf/unkink-polygon lib.