splitEarcut function
dynamic
splitEarcut(
- dynamic start,
- dynamic triangles,
- dynamic dim,
- dynamic minX,
- dynamic minY,
- dynamic invSize,
Implementation
splitEarcut(start, triangles, dim, minX, minY, invSize) {
// look for a valid diagonal that divides the polygon into two
var a = start;
do {
var b = a.next.next;
while (b != a.prev) {
if (a.i != b.i && isValidDiagonal(a, b)) {
// split the polygon in two by the diagonal
var c = splitPolygon(a, b);
// filter colinear points around the cuts
a = filterPoints(a, a.next);
c = filterPoints(c, c.next);
// run earcut on each half
earcutLinked(a, triangles, dim, minX, minY, invSize, null);
earcutLinked(c, triangles, dim, minX, minY, invSize, null);
return;
}
b = b.next;
}
a = a.next;
} while (a != start);
}