Triangulates a simple polygon by ear clipping, writing triangle indices into
out as [i0, i1, i2, i3, i4, i5, ...], where each index refers to a vertex
of the input polygon. Either winding is accepted (normalised internally).
out must have room for at least 3 * (n - 2) indices. A complete
triangulation returns exactly n - 2 triangles; a smaller count indicates
the polygon could not be fully triangulated (e.g. degenerate input).
Parameters
out: number[]
output array of triangle indices
vertices: number[]
polygon vertices as a flat array [x0, y0, x1, y1, ...]
Triangulates a simple polygon by ear clipping, writing triangle indices into
outas[i0, i1, i2, i3, i4, i5, ...], where each index refers to a vertex of the input polygon. Either winding is accepted (normalised internally).outmust have room for at least3 * (n - 2)indices. A complete triangulation returns exactlyn - 2triangles; a smaller count indicates the polygon could not be fully triangulated (e.g. degenerate input).