Triangulation
| Source guide | Project README |
Triangulates polygon contours and holes, cleaning rings and normalizing their winding while retaining indices into the original input vertices.
Polygon to triangles
flowchart LR
Rings["Outer contour + holes"] --> Clean["Clean + normalize winding"]
Clean --> Bridge["Connect holes"]
Bridge --> Clip["Clip ears"]
Clip --> Triangles["Triangles indexed into original inputs"]
Input rings omit the repeated closing vertex. Indices still refer to the original contour followed by holes after cleanup; preserve that contract. MVT has a separate fallback for quantized rings.
- triangulate.js: triangulate a polygon.
- polygonRings.js: clean and normalize rings.
- clipEars.js: generate triangles by ear clipping.