API reference
API reference
Select your platform
No SDKs available
No versions available

Triangulator Class

Provides methods for triangulating polygons and clipping polygons with holes.

Static Member Functions

Triangulates a set of points using the ear clipping algorithm.
This method uses unsafe code to interface with native functions for optimal performance.The triangulation algorithm expects polygons to be defined in a consistent winding order. Edge cases such as self-intersecting polygons or degenerate triangles may produce unexpected results. The method allocates new arrays for the output parameters on each call.
Parameters
vertices
The list of vertices that define the outline of a polygon to triangulate. Must not be null or empty, and should contain at least 3 vertices for a valid polygon.
holes
The list of internal polygon holes that should not be triangulated. Can be null if no holes are present. If provided, must not contain null lists, and each hole should contain at least 3 vertices.
outVertices
The list of vertices created from the triangulation. Will be populated with the triangulated mesh vertices.
outIndices
The list of indices created from the triangulation. Will be populated with triangle indices referencing the output vertices.
Exceptions
ArgumentNullException
Thrown when vertices is null, or when holes contains a null list.
ArgumentException
Thrown when vertices is empty, or when any hole list is empty.