/** * @holoscript/core LOD Manager * * Runtime LOD selection, management, and state tracking. * Handles automatic LOD transitions based on camera distance, * screen coverage, and performance metrics. */ import { LODConfig, LODState, LODGroup, LODMetrics } from './LODTypes'; export type LODEventType = 'levelChanged' | 'transitionStart' | 'transitionEnd' | 'configUpdated' | 'groupCreated' | 'groupRemoved'; export interface LODEvent { type: LODEventType; objectId?: string; groupId?: string; previousLevel?: number; newLevel?: number; timestamp: number; } export type LODEventHandler = (event: LODEvent) => void; export interface LODManagerOptions { /** Target frame rate for performance-based LOD */ targetFrameRate: number; /** Enable automatic LOD updates each frame */ autoUpdate: boolean; /** Update frequency (updates per second) */ updateFrequency: number; /** Global LOD bias (-1 to 1, affects all objects) */ globalBias: number; /** Maximum transition time (seconds) */ maxTransitionTime: number; /** Enable LOD metrics collection */ collectMetrics: boolean; /** Camera field of view (degrees) */ cameraFOV: number; /** Screen height for coverage calculation */ screenHeight: number; /** Enable debug logging */ debug: boolean; } export declare const DEFAULT_MANAGER_OPTIONS: LODManagerOptions; /** * LOD Manager for runtime LOD selection and management */ export declare class LODManager { private options; private configs; private states; private groups; private eventHandlers; private objectPositions; private metrics; private cameraPosition; private lastUpdateTime; private frameTime; private running; private workerPool; private workerEnabled; private spatialHashGrid; private transitionQueue; private maxTransitionsPerFrame; private gridCellSize; constructor(options?: Partial); /** * Register LOD configuration for an object */ registerConfig(objectId: string, config: LODConfig): void; /** Convenience alias: register an object with config and optional initial position */ register(objectId: string, config: LODConfig, position?: [number, number, number]): void; /** * Unregister LOD configuration */ unregisterConfig(objectId: string): void; /** Convenience alias for unregisterConfig */ unregister(objectId: string): void; /** Convenience alias for setObjectPosition */ updatePosition(objectId: string, position: [number, number, number]): void; /** * Get LOD configuration for an object */ getConfig(objectId: string): LODConfig | undefined; /** * Update LOD configuration */ updateConfig(objectId: string, updates: Partial): void; /** * Set forced LOD level (for debugging) */ setForcedLevel(objectId: string, level: number | undefined): void; /** * Create LOD group for multiple objects */ createGroup(group: LODGroup): void; /** * Remove LOD group */ removeGroup(groupId: string): void; /** * Get LOD group */ getGroup(groupId: string): LODGroup | undefined; /** * Add object to existing group */ addToGroup(groupId: string, objectId: string): void; /** * Remove object from group */ removeFromGroup(groupId: string, objectId: string): void; /** * Get current LOD state for an object */ getState(objectId: string): LODState | undefined; /** * Get current LOD level for an object */ getCurrentLevel(objectId: string): number; /** * Check if object is transitioning */ isTransitioning(objectId: string): boolean; /** * Get transition progress (0-1) */ getTransitionProgress(objectId: string): number; /** * Set camera position for distance calculations */ setCameraPosition(position: [number, number, number]): void; /** * Set an object's world position for distance-based LOD calculations */ setObjectPosition(objectId: string, position: [number, number, number]): void; /** * Update LOD for all registered objects. * Accepts either a deltaTime (number) or a camera position ([x,y,z] array). */ update(deltaTimeOrCameraPos: number | [number, number, number]): void; /** * Update LOD for single object */ private updateObject; /** * Update LOD for a group of objects */ private updateGroup; /** * Select LOD level based on strategy */ private selectLevel; /** * Select LOD level based on performance */ private selectLevelByPerformance; /** * Start LOD transition */ private startTransition; /** * Update transition progress */ private updateTransition; /** * Complete LOD transition */ private completeTransition; /** * Get object position from stored positions or default to origin */ private getObjectPosition; /** * Get current LOD metrics */ getMetrics(): LODMetrics; /** * Reset metrics */ resetMetrics(): void; /** * Subscribe to LOD events */ on(event: LODEventType, handler: LODEventHandler): () => void; /** * Emit LOD event */ private emit; /** * Start automatic LOD updates */ start(): void; /** * Stop automatic LOD updates */ stop(): void; /** * Check if manager is running */ isRunning(): boolean; /** * Clear all registered objects and groups */ clear(): void; /** * Get manager options */ getOptions(): LODManagerOptions; /** * Update manager options */ setOptions(updates: Partial): void; /** * Get all registered object IDs */ getRegisteredObjects(): string[]; /** * Get all group IDs */ getGroups(): string[]; /** * Enable multi-threaded LOD selection using Web Workers */ enableMultiThreading(workerCount?: number): void; /** * Disable multi-threading and cleanup workers */ disableMultiThreading(): void; /** * Generate Web Worker code for LOD distance calculations */ private generateWorkerCode; /** * Handle worker message with distance calculation results */ private handleWorkerMessage; /** * Batch update multiple objects efficiently */ updateBatch(objectIds: string[], deltaTime: number): void; /** * Single-threaded batch update with SIMD-style optimizations */ private updateBatchSingleThreaded; /** * Multi-threaded batch update using worker pool */ private updateBatchMultiThreaded; /** * Queue a transition with priority based on distance */ private queueTransition; /** * Process transition queue (max transitions per frame to prevent stuttering) */ private processTransitionQueue; /** * Query nearby objects using spatial hash grid */ queryNearby(position: [number, number, number], radius: number): string[]; /** * Update spatial hash grid for an object */ private updateSpatialHash; /** * Set object position and update spatial hash */ setObjectPositionOptimized(objectId: string, position: [number, number, number]): void; /** * Set maximum transitions per frame (prevent stuttering) */ setMaxTransitionsPerFrame(max: number): void; /** * Get maximum transitions per frame */ getMaxTransitionsPerFrame(): number; /** * Check if multi-threading is enabled */ isMultiThreadingEnabled(): boolean; /** * Get worker pool size */ getWorkerPoolSize(): number; /** * Clear spatial hash grid */ clearSpatialHash(): void; /** * Rebuild spatial hash grid for all objects */ rebuildSpatialHash(): void; } /** * Create LOD manager with default options */ export declare function createLODManager(options?: Partial): LODManager; /** * Create LOD manager optimized for VR */ export declare function createVRLODManager(): LODManager; /** * Create LOD manager optimized for mobile */ export declare function createMobileLODManager(): LODManager; //# sourceMappingURL=LODManager.d.ts.map