earclip
Version:
Triangle mesh designed to be fast, efficient, and sphere capable.
64 lines • 2.21 kB
TypeScript
import earcut from './earcut.js';
export { earcut };
/** Result from earclip tesselation */
export interface EarclipResult {
/** The flattened vertices */
vertices: number[];
/** The indices of the triangulation */
indices: number[];
}
/** Result from flatten */
export interface FlattenResult {
/** The flattened vertices */
vertices: number[];
/** The indices of the triangulation */
holeIndices: number[];
/** The number of dimensions. Either 2 or 3 */
dim: 2 | 3;
}
/** Object with 2D coordinates and m-values */
export interface Point {
x: number;
y: number;
m?: unknown;
}
/** Object with 3D coordinates and m-values */
export interface Point3D {
x: number;
y: number;
z: number;
m?: unknown;
}
/** Indices pointing to a triangle */
export type SplitResult = [i1: number, i2: number, i3: number];
/**
* An earcut polygon generator with tesselation support
* @param polygon - Polygon to tesselate
* @param modulo - Modulo for tesselation
* @param offset - Offset for results
* @returns Tesselated polygon
*/
export declare function earclip(polygon: number[][][] | Point[][] | Point3D[][], modulo?: number, offset?: number): EarclipResult;
/**
* Tesselate the flattened polygon
* @param vertices - flattened vertices to append to
* @param indices - Polygon indices to append to
* @param modulo - Modulo for tesselation
* @param dim - number of dimensions
*/
export declare function tesselate(vertices: number[], indices: number[], modulo: number, dim: number): void;
/**
* Flattens a 2D or 3D array whether its a flat point ([x, y, z]) or object ({ x, y, z })
* @param data - either a 2D or 3D array
* @returns - the flattened array including the holes and dimensions
*/
export declare function flatten(data: number[][][] | Point[][] | Point3D[][]): FlattenResult;
/**
* @param data - either a 2D or 3D array
* @param holeIndices - indices of the holes
* @param dim - number of dimensions
* @param triangles - triangles to append to
* @returns - the deviation
*/
export declare function deviation(data: number[], holeIndices?: number[], dim?: number, triangles?: number[]): number;
//# sourceMappingURL=index.d.ts.map