Skip to content

Commit

Permalink
feat(geom-api): add Tessellation type, update Tessellator
Browse files Browse the repository at this point in the history
BREAKING CHANGE: update Tessellator behavior & signature

- Tessellators now collect/append results to a Tessellation object, consisting of
  a single point array and an array of face vertex IDs
  • Loading branch information
postspectacular committed Jun 6, 2024
1 parent 307cb3d commit 5b0b2ec
Showing 1 changed file with 19 additions and 7 deletions.
26 changes: 19 additions & 7 deletions packages/geom-api/src/tessel.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,20 @@
import type { ReadonlyVec, Vec } from "@thi.ng/vectors";
import type { Fn2 } from "@thi.ng/api";
import type { ReadonlyVec } from "@thi.ng/vectors";

/**
* Tessellation function. Receives a point array representing a polygon
* / cell and yields an array of point arrays, representing the
* subdivided cells.
*/
export type Tessellator = (points: ReadonlyVec[]) => Vec[][];
export type Tessellator = Fn2<Tessellation, number[], Tessellation>;

export interface Tessellation {
/**
* Points referenced by {@link Tessellation.indices}.
*
* @remarks
* If a {@link Tessellator} is creating new points as part of its
* processing, these are to be appended to this array.
*/
points: ReadonlyVec[];
/**
* Array of per-face point IDs/indices, referencing
* {@link Tessellation.points}.
*/
indices: number[][];
}

0 comments on commit 5b0b2ec

Please sign in to comment.