import * as THREE from "three"; import type { VoxelChunk } from "../world/VoxelChunk.ts"; import type { BlockRegistry } from "../blocks/BlockRegistry.ts"; import type { BlockShapeRegistry } from "../blocks/BlockShapeRegistry.ts"; /** * Minimal interface for Rapier3D static descriptors needed by this builder. * Using a structural interface avoids importing the WASM module at the library * level — the consumer provides the already-initialised Rapier namespace. */ export interface RapierColliderDesc { setTranslation(x: number, y: number, z: number): this; } export interface RapierRigidBody { readonly handle: number; } export interface RapierCollider { readonly handle: number; } export interface RapierWorld { createRigidBody(desc: RapierRigidBodyDesc): RapierRigidBody; createCollider(desc: RapierColliderDesc, parent?: RapierRigidBody): RapierCollider; removeCollider(collider: RapierCollider, wakeUp: boolean): void; removeRigidBody(body: RapierRigidBody): void; } export interface RapierRigidBodyDesc { setTranslation(x: number, y: number, z: number): this; } /** The subset of the Rapier module's static API required by this builder. */ export interface RapierAPI { RigidBodyDesc: { fixed(): RapierRigidBodyDesc; }; ColliderDesc: { cuboid(hx: number, hy: number, hz: number): RapierColliderDesc; trimesh(vertices: Float32Array, indices: Uint32Array): RapierColliderDesc; }; } export interface VoxelColliderBuilderOptions { rapier: RapierAPI; world: RapierWorld; blockRegistry: BlockRegistry; shapeRegistry: BlockShapeRegistry; } /** * Builds Rapier3D collision shapes for voxel chunks. * * Strategy selection per chunk: * - If all solid blocks report collisionHint === "box" → compound cuboids * (one cuboid per solid voxel, attached to a static RigidBody at the chunk origin). * - If any block uses collisionHint === "trimesh" → single trimesh built from * the chunk's already-computed THREE.BufferGeometry (cheaper than re-traversing). * - If all blocks are "none" → no collider. * * Trimesh note: Rapier trimeshes are accurate for complex shapes but may suffer * ghost collisions on internal edges. For full-cube worlds, compound cuboids * are significantly more robust and performant. */ export declare class VoxelColliderBuilder { #private; constructor(options: VoxelColliderBuilderOptions); /** * Builds (or re-builds) the collider for one chunk. * Returns the created Rapier Collider, or null if the chunk has no solid geometry. * * The caller is responsible for removing the old collider (if any) before calling this. */ buildChunkCollider(chunk: VoxelChunk, geometry: THREE.BufferGeometry | null, layerOffset?: { x: number; y: number; z: number; }): RapierCollider | null; } //# sourceMappingURL=VoxelColliderBuilder.d.ts.map