Skip to content

Commit

Permalink
feat(geom): add new tessellators presets
Browse files Browse the repository at this point in the history
- add TESSELLATE_TRI_FAN_SPLIT
- add TESSELLATE_TRI_FAN_SPLIT_THRESHOLD
  • Loading branch information
postspectacular committed Jun 4, 2024
1 parent 417123c commit 95d6f70
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 3 deletions.
2 changes: 0 additions & 2 deletions packages/geom/src/polygon.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ export const polygon = (pts?: Iterable<Vec>, attribs?: Attribs) =>
* @param n
* @param profile
* @param attribs
* @returns
*/
export const star = (
r: number,
Expand Down Expand Up @@ -64,7 +63,6 @@ export const star = (
* @param n
* @param profile
* @param attribs
* @returns
*/
export const starWithCentroid = (
pos: Vec,
Expand Down
28 changes: 27 additions & 1 deletion packages/geom/src/tessellate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,18 @@ import { quadFan } from "@thi.ng/geom-tessellate/quad-fan";
import { rimTris } from "@thi.ng/geom-tessellate/rim-tris";
import { tessellate as _tessellate } from "@thi.ng/geom-tessellate/tessellate";
import { triFan } from "@thi.ng/geom-tessellate/tri-fan";
import {
triFanSplit,
triFanSplitWithThreshold,
} from "@thi.ng/geom-tessellate/tri-fan-split";
import { mapcat } from "@thi.ng/transducers/mapcat";
import type { Vec } from "@thi.ng/vectors";
import { Group } from "./api/group.js";
import { __dispatch } from "./internal/dispatch.js";
import { vertices } from "./vertices.js";

/**
* Recursively tessellates shape using provided
* Iteratively tessellates shape using provided
* [`Tessellator`](https://docs.thi.ng/umbrella/geom-api/types/Tessellator.html)
* functions. See
* [thi.ng/geom-tessellate](https://thi.ng/thi.ng/geom-tessellate) package for
Expand All @@ -27,6 +31,18 @@ import { vertices } from "./vertices.js";
* Implemented for all shapes supported by {@link vertices}. For groups, every
* child shape will be tessellated individually.
*
* The following tessellator presets are available:
*
* - {@link TESSELLATE_EARCUT}
* - {@link TESSELLATE_EDGE_SPLIT}
* - {@link TESSELLATE_EDGE_SPLIT_THRESHOLD}
* - {@link TESSELLATE_INSET}
* - {@link TESSELLATE_QUAD_FAN}
* - {@link TESSELLATE_RIM_TRIS}
* - {@link TESSELLATE_TRI_FAN}
* - {@link TESSELLATE_TRI_FAN_SPLIT}
* - {@link TESSELLATE_TRI_FAN_SPLIT_THRESHOLD}
*
* @param shape
* @param tessellators
*/
Expand Down Expand Up @@ -77,3 +93,13 @@ 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
* [`triFanSplit`](https://docs.thi.ng/umbrella/geom-tessellate/functions/triFanSplit.html)
*/
export const TESSELLATE_TRI_FAN_SPLIT = triFanSplit;
/**
* Alias for thi.ng/geom-tessellate
* [`triFanSplitWithThreshold`](https://docs.thi.ng/umbrella/geom-tessellate/functions/triFanSplitWithThreshold.html)
*/
export const TESSELLATE_TRI_FAN_SPLIT_THRESHOLD = triFanSplitWithThreshold;

0 comments on commit 95d6f70

Please sign in to comment.