Skip to content

Commit

Permalink
feat(geom): update tessellate(), add TESSELLATE_TRI_FAN_BOUNDARY
Browse files Browse the repository at this point in the history
  • Loading branch information
postspectacular committed Jun 12, 2024
1 parent c2ec98b commit 1c0d1ce
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion packages/geom/src/tessellate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import {
MeshTessellation,
} from "@thi.ng/geom-tessellate/tessellation";
import { triFan } from "@thi.ng/geom-tessellate/tri-fan";
import { triFanBoundary } from "@thi.ng/geom-tessellate/tri-fan-boundary";
import { triFanSplit } from "@thi.ng/geom-tessellate/tri-fan-split";
import type { IShape, ITessellation, Tessellator } from "./api.js";
import type { ComplexPolygon } from "./api/complex-polygon.js";
Expand Down Expand Up @@ -58,6 +59,7 @@ import { vertices } from "./vertices.js";
* - {@link TESSELLATE_QUAD_FAN}
* - {@link TESSELLATE_RIM_TRIS}
* - {@link TESSELLATE_TRI_FAN}
* - {@link TESSELLATE_TRI_FAN_BOUNDARY}
* - {@link TESSELLATE_TRI_FAN_SPLIT}
*
* @param shape
Expand Down Expand Up @@ -91,7 +93,11 @@ export const tessellate: MultiFn2O<
children.map((c) => c.points)
);
tess = tess || new BasicTessellation();
const faces = earCutComplex(holes)(tess, tess.addPoints(points));
const faces = earCutComplex(holes)(
tess,
[],
tess.addPoints(points)
);
fns = ensureArray(fns);
return (<Tessellator[]>fns).length
? tessellateFaces(tess, faces, fns)
Expand Down Expand Up @@ -144,6 +150,11 @@ export const TESSELLATE_RIM_TRIS = rimTris;
* [`triFan`](https://docs.thi.ng/umbrella/geom-tessellate/functions/triFan.html)
*/
export const TESSELLATE_TRI_FAN = triFan;
/**
* Alias for thi.ng/geom-tessellate
* [`triFanBoundary`](https://docs.thi.ng/umbrella/geom-tessellate/functions/triFanBoundary.html)
*/
export const TESSELLATE_TRI_FAN_BOUNDARY = triFanBoundary;
/**
* Alias for thi.ng/geom-tessellate
* [`triFanSplit`](https://docs.thi.ng/umbrella/geom-tessellate/functions/triFanSplit.html)
Expand Down

0 comments on commit 1c0d1ce

Please sign in to comment.