import * as THREE from 'three'; import { Vector2 } from 'three'; import { Vector3 } from 'three'; /** * A THREE.Mesh that can be fractured or sliced into fragments. * Fragments are returned but NOT automatically added to the scene - * you must manually add them using scene.add(...fragments). */ export declare class DestructibleMesh extends THREE.Mesh { private _outsideMaterial?; private _insideMaterial?; constructor(geometry?: THREE.BufferGeometry, outerMaterial?: THREE.Material, innerMaterial?: THREE.Material); /* Excluded from this release type: createFragment */ /** * Fractures the mesh into fragments * @param options Fracture options controlling the fracture behavior * @param onFragment Optional callback called for each fragment for custom setup * @param onComplete Optional callback called once after all fragments are created * @returns The array of created fragment meshes (NOT added to scene) */ fracture(options: FractureOptions, onFragment?: (fragment: DestructibleMesh, index: number) => void, onComplete?: () => void): DestructibleMesh[]; /** * Slices the mesh into top and bottom parts using a plane in local space * @param sliceNormal Normal of the slice plane in local space (points towards the top slice) * @param sliceOrigin Origin of the slice plane in local space * @param options Optional slice options * @param onSlice Optional callback called for each piece for custom setup (material, physics, etc.) * @param onComplete Optional callback called once after all pieces are created * @returns Array of DestructibleMesh pieces created by the slice (NOT added to scene) */ slice(sliceNormal: THREE.Vector3, sliceOrigin: THREE.Vector3, options?: SliceOptions, onSlice?: (piece: DestructibleMesh, index: number) => void, onComplete?: () => void): DestructibleMesh[]; /** * Slices the mesh using a plane defined in world space * @param worldNormal Normal of the slice plane in world space * @param worldOrigin Origin of the slice plane in world space * @param options Optional slice options * @param onSlice Optional callback called for each piece for custom setup (material, physics, etc.) * @param onComplete Optional callback called once after all pieces are created * @returns Array of DestructibleMesh pieces created by the slice (NOT added to scene) */ sliceWorld(worldNormal: THREE.Vector3, worldOrigin: THREE.Vector3, options?: SliceOptions, onSlice?: (piece: DestructibleMesh, index: number) => void, onComplete?: () => void): DestructibleMesh[]; /** * Disposes the mesh geometry and material */ dispose(): void; } /** * Options for the fracture operation */ export declare class FractureOptions { /** * Fracture method to use * - 'voronoi': Natural-looking fracture using Voronoi tessellation (requires voronoiOptions) * - 'simple': Simple plane-based fracturing (fast, lower quality) */ fractureMethod: "voronoi" | "simple"; /** * Number of fragments to generate */ fragmentCount: number; /** * Voronoi-specific options (required when fractureMethod is 'voronoi') */ voronoiOptions?: VoronoiOptions; /** * Simple fracture: specify which planes to fracture in * Only used when fractureMethod is 'simple' */ fracturePlanes: { x: boolean; y: boolean; z: boolean; }; /** * Scale factor to apply to texture coordinates on cut faces */ textureScale: Vector2; /** * Offset to apply to texture coordinates on cut faces */ textureOffset: Vector2; /** * Seed value for random number generation. If not specified, a random seed will be generated. * Using the same seed will produce the same fracture pattern for reproducibility. */ seed?: number; constructor({ fractureMethod, fragmentCount, voronoiOptions, fracturePlanes, textureScale, textureOffset, seed, }?: { fractureMethod?: "voronoi" | "simple"; fragmentCount?: number; voronoiOptions?: VoronoiOptions; fracturePlanes?: { x: boolean; y: boolean; z: boolean; }; textureScale?: Vector2; textureOffset?: Vector2; seed?: number; }); } export declare class SliceOptions { /** * Scale factor to apply to texture coordinates. */ textureScale: Vector2; /** * Offset to apply to texture coordinates. */ textureOffset: Vector2; constructor(); } /** * Voronoi-specific fracture options */ export declare interface VoronoiOptions { /** * Voronoi fracture mode * - '3D': Full 3D Voronoi tessellation (more realistic, slower) * - '2.5D': 2D Voronoi pattern projected through mesh (faster, good for flat objects) */ mode: "3D" | "2.5D"; /** * Custom seed points for Voronoi cells. If not provided, seeds will be generated automatically. */ seedPoints?: Vector3[]; /** * Impact point for fracture in local space. When provided, generates more fragments near this location. */ impactPoint?: Vector3; /** * Radius around impact point where fragment density is highest. * Only used when impactPoint is specified. */ impactRadius?: number; /** * For 2.5D mode: the axis along which to project the 2D Voronoi pattern * 'auto' will choose based on mesh dimensions */ projectionAxis?: "x" | "y" | "z" | "auto"; /** * For 2.5D mode with impact: optional normal vector of the collision surface * If provided, determines the projection plane perpendicular to this normal * This overrides projectionAxis when both are specified */ projectionNormal?: Vector3; /** * Use K-nearest neighbor approximation for performance optimization. * When true, only the nearest neighbors are considered for each Voronoi cell. * * WARNING: Enabling this may cause fragments to overlap! * - false (default): Accurate, no overlaps, but slower O(n²) * - true: Faster, but may cause overlapping fragments * * Recommended: Keep false for <30 seeds, enable for >50 seeds if performance is critical */ useApproximation?: boolean; /** * Number of nearest neighbors to consider when useApproximation is enabled. * Higher values are more accurate but slower. Ignored if useApproximation is false. * Default: 12 */ approximationNeighborCount?: number; } export { }