import { BufferGeometry, Matrix4, Mesh } from 'three'; import { MeshStandardNodeMaterial } from 'three/webgpu'; import type { CellComplex, HyperplaneSlice4, TransformN } from '@holotope/core'; export interface SlicedComplexGPUOptions { /** Material for the section mesh; positionNode is installed on it. */ material?: MeshStandardNodeMaterial; /** * Signed-distance snap threshold for the degeneracy policy. The kernel * runs in Float32, so the default is coarser than the CPU slicer's 1e-9. */ epsilon?: number; } /** Minimal slice of the WebGPURenderer API this product needs. */ export interface ComputeCapableRenderer { compute(node: unknown): void; getArrayBufferAsync(attribute: unknown): Promise; } /** * GPU render product: marching-tetrahedra cross-sections computed **in a * compute shader**. The tetrahedra and 4D positions upload once; each * frame a WGSL kernel classifies every tet against the hyperplane and * writes the section triangles into a storage buffer that the vertex * stage reads directly — the geometry never round-trips through the CPU. * * Instead of atomic compaction, every tetrahedron owns a fixed window of * 6 output vertices (2 triangles worst case). Non-crossing tets write * zeros: degenerate zero-area triangles the rasterizer discards for * free. This keeps the kernel atomic-free and makes provenance implicit * — triangle `f` came from tet `f >> 1`, matching the CPU slicer's * emission order exactly (same epsilon snap, same crossing-edge order), * so the two paths are comparable triangle-for-triangle. * * Output vertices are in the slice's own display frame (like * `SlicedComplex3D` without a projection), with the source tet index in * each vertex's w component for readback verification. * * Requires a true WebGPU backend — compute shaders have no WebGL2 * fallback. Check `renderer.backend.isWebGPUBackend` before constructing. */ export declare class SlicedComplexGPU { readonly complex: CellComplex; readonly slice: HyperplaneSlice4; readonly geometry: BufferGeometry; readonly object: Mesh; /** Number of tetrahedra marched per dispatch. */ readonly tetCount: number; private readonly computeNode; private readonly triangleBuffer; private readonly rotationUniform; private readonly translationUniform; private readonly frameUniform; private readonly offsetUniform; private readonly identity; constructor(complex: CellComplex, slice: HyperplaneSlice4, options?: SlicedComplexGPUOptions); /** * Writes the 4D transform and slice frame to uniforms, then dispatches * the marching kernel — no CPU geometry work, no buffer re-upload. * Without a renderer this only updates uniforms (useful for tests). */ update(transform?: TransformN, renderer?: ComputeCapableRenderer): void; /** * Reads the section back from the GPU: packed vec4 vertices (xyz = * slice-frame position, w = source tet index), 6 per tetrahedron with * all-zero padding for non-emitted slots. For verification against the * CPU slicer, not for the render path. */ readSection(renderer: ComputeCapableRenderer): Promise; /** Uniform snapshot of the hyperplane frame — rows b0, b1, b2, normal. */ get frameMatrix(): Matrix4; dispose(): void; } //# sourceMappingURL=sliced-complex-gpu.d.ts.map