/** * InstancedMeshManager.ts * * GPU instancing system for rendering massive numbers of similar objects. * Reduces draw calls from 10,000 to ~10 for extreme performance. * * Performance Impact: * - Without instancing: 1,000 objects = 1,000 draw calls = ~30 FPS * - With instancing: 10,000 objects = ~10 draw calls = 60 FPS */ import * as THREE from 'three'; export interface InstancedObjectData { /** Unique instance ID */ id: string; /** Position [x, y, z] */ position: [number, number, number]; /** Rotation [x, y, z] (Euler angles) */ rotation: [number, number, number]; /** Scale [x, y, z] */ scale: [number, number, number]; /** Color (hex string or RGB) */ color?: string | [number, number, number]; /** Custom user data */ userData?: any; } export interface InstanceBatchConfig { /** Geometry type */ geometryType: 'box' | 'sphere' | 'cylinder' | 'custom'; /** Geometry parameters (e.g., size for box) */ geometryParams?: any; /** Material configuration */ material: { type: 'standard' | 'basic' | 'physical'; color?: string; metalness?: number; roughness?: number; emissive?: string; opacity?: number; transparent?: boolean; }; /** Maximum instances this batch can hold */ maxInstances: number; /** Custom geometry (if geometryType is 'custom') */ customGeometry?: THREE.BufferGeometry; } export interface InstanceBatchStats { /** Number of active instances */ activeCount: number; /** Maximum capacity */ maxInstances: number; /** Utilization percentage */ utilization: number; /** Geometry type */ geometryType: string; /** Material type */ materialType: string; } /** * Manages multiple batches of instanced meshes */ export declare class InstancedMeshManager { private readonly batches; private readonly instanceToBatch; private batchCounter; /** * Create a batch key from config */ private getBatchKey; /** * Create or get existing batch */ private getOrCreateBatch; /** * Add instanced object */ addInstance(data: InstancedObjectData, config: InstanceBatchConfig): boolean; /** * Update instance */ updateInstance(id: string, data: Partial): boolean; /** * Remove instance */ removeInstance(id: string): boolean; /** * Get all meshes for adding to scene */ getMeshes(): THREE.InstancedMesh[]; /** * Get overall statistics */ getStats(): { totalBatches: number; totalInstances: number; batches: Map; }; /** * Clear all instances */ clear(): void; /** * Dispose all resources */ dispose(): void; } //# sourceMappingURL=InstancedMeshManager.d.ts.map