An implementation of the earcut polygon triangulation algorithm. The code is a port of mapbox/earcut.
See:
Triangulates the given shape definition by returning an array of triangles.
data
An array with 2D points.
holeIndices
An array with indices defining holes.
dim
The number of coordinates per vertex in the input array.
Default is 2.
Returns: An array representing the triangulated faces. Each face is defined by three consecutive numbers representing vertex indices.