import type { XYPoint } from "../utils/types.ts"; import type { Vector2d } from "./vector2d.ts"; /** * Normalize a vertex array to fit within a unit cube centered at the origin. * Vertices are scaled uniformly so that the largest axis spans [-0.5, 0.5]. * Modifies the array in place. * @param vertices - vertex positions as x,y,z triplets */ export declare function normalizeVertices(vertices: Float32Array): void; /** * Project 3D vertices through a 4x4 matrix with perspective divide, * mapping the result to a 2D display area. * @param src - source vertex positions (x,y,z triplets) * @param dst - destination array (x,y,z triplets, written in place) * @param count - number of vertices to project * @param matrix - 4x4 matrix values (column-major, 16 elements) * @param width - display width to map projected x to * @param height - display height to map projected y to * @param offsetX - x offset added to each projected vertex * @param offsetY - y offset added to each projected vertex * @param zScale - scale factor for Z output (0 = don't compute Z) */ export declare function projectVertices(src: Float32Array, dst: Float32Array, count: number, matrix: Float32Array, width: number, height: number, offsetX?: number, offsetY?: number, zScale?: number): void; /** * Extend an axis-aligned bounding box by a set of 3D vertices transformed * through a 4x4 matrix (translation included). `min` / `max` are updated in * place, so the function can be called repeatedly to accumulate the bounds of * many transformed vertex sets (e.g. every node of a scene graph). Seed `min` * with `+Infinity` and `max` with `-Infinity` before the first call. * @param src - source vertex positions (x,y,z triplets) * @param count - number of vertices to read from `src` * @param matrix - 4x4 matrix values (column-major, 16 elements) * @param min - `[x,y,z]` lower corner, extended in place * @param max - `[x,y,z]` upper corner, extended in place */ export declare function transformedBounds(src: Float32Array, count: number, matrix: ArrayLike, min: number[], max: number[]): void; /** * Compute the bounding-sphere radius of a set of 3D vertices around the local * origin — the distance to the farthest vertex. When a matrix is supplied, * each vertex is taken through its rotation/scale columns (the translation is * ignored, so the radius stays centered on the transform's own origin). Handy * for frustum / culling bounds on a transformed mesh. * @param src - source vertex positions (x,y,z triplets) * @param count - number of vertices to read from `src` * @param [matrix] - optional 4x4 matrix (column-major); only the upper 3x3 rotation/scale is applied * @returns the radius of the smallest origin-centered sphere enclosing the vertices */ export declare function boundingRadius(src: Float32Array, count: number, matrix?: ArrayLike): number; /** * Compute the averaged perpendicular normal at a vertex in a 2D polyline. * At interior vertices, normals from both adjacent edges are averaged * to produce a smooth miter direction. * @param points - the polyline vertices * @param index - the vertex index * @param out - output object to write into (avoids allocation) * @returns unit normal */ export declare function computeVertexNormal(points: XYPoint[], index: number, out?: XYPoint): XYPoint; /** * Compute the convex hull of a set of 2D points using the Graham scan algorithm. * The input array is sorted in place. Returns a subset of the input points * forming the convex hull in counter-clockwise order. * @param points - array of 2D points (modified in place by sorting) * @returns convex hull vertices in CCW order */ export declare function convexHull(points: Vector2d[]): Vector2d[]; /** * Compute per-vertex surface normals for indexed triangle geometry. * * Each triangle's normal is accumulated into its three vertices weighted by * the triangle's area — that falls out of using the raw cross product rather * than a normalized one — and the result is normalized at the end. Area * weighting keeps a large face from being outvoted by a fan of slivers meeting * at the same vertex. * * One algorithm covers both shading styles, because the answer depends on the * geometry rather than on a flag: where vertices are shared between faces the * accumulation averages them and the surface shades smoothly, and where every * triangle carries its own three vertices (a triangle soup, which is how most * hand-built geometry comes out) each vertex belongs to exactly one face, so * the average IS that face's normal and the surface shades flat. * * Degenerate triangles contribute a zero-length cross product and so drop out * on their own; a vertex touched only by degenerate faces is left at zero * rather than becoming NaN. * @param vertices - vertex positions as x,y,z triplets * @param indices - triangle vertex indices * @param out - optional destination, sized `vertices.length` * @returns unit normals as x,y,z triplets, one per vertex */ export declare function generateNormals(vertices: Float32Array, indices: Uint16Array | Uint32Array | number[], out?: Float32Array): Float32Array; //# sourceMappingURL=vertex.d.ts.map