/** * Clips triangles against a fixed ground-plane grid (planes at x = k*size and * z = k*size, anchored at the world origin), interpolating every vertex * attribute, so each output triangle lies inside exactly one cell. * * Why clip instead of bucketing a triangle by its centroid: a floor or wall * triangle can be tens of metres across. Bucketed by centroid it would land in * one cell and leave a hole in every neighbour, including the spawn core, and * the cell bounds would sprawl across the map. Clipped, every cell holds * exactly the surface that lies in it. * * Determinism and cracks: an intersection is always computed from the two * ORIGINAL endpoints of the edge in a canonical order (lexicographic by * position), never from the direction the polygon happens to walk the edge. Two * triangles that share an edge therefore compute bit-identical points on it, so * the seam between neighbouring fragments has no T-junction crack. */ /** A vertex is a flat array: [x, y, z, ...attributes]. */ export type ClipVertex = number[]; export type ClipLayout = { stride: number; /** Offset and width of attributes that need renormalising after interpolation. */ normal?: number; tangent?: number; }; export type ClippedPiece = { cx: number; cz: number; triangles: ClipVertex[][]; }; /** Cell index of a coordinate; a value exactly on a plane belongs to the cell above it. */ export declare function cellIndex(value: number, size: number): number; /** * Clips one triangle. A triangle that already lies in one cell is returned * as-is without being touched. Slivers with no area are dropped. */ export declare function clipTriangleToGrid(triangle: [ClipVertex, ClipVertex, ClipVertex], size: number, layout: ClipLayout): ClippedPiece[];