import { AbstractMesh, AssetContainer, InstancedMesh, Mesh } from '@babylonjs/core'; import { GameEventBus } from "../classes/eventBus.d.ts"; import { SceneEngine } from "../engines/scene.d.ts"; import { Disposable } from "../interfaces/lifecycle.d.ts"; import { LoggingUtility } from "../utils/logger.d.ts"; /** * Central asset cache with preloading, GLB fragment extraction, mesh instancing, and reference counting. * * Supports fragment syntax (`models/props.glb#chest_lid`) to extract individual meshes from a shared container. * Containers are reference-counted and only disposed when all consumers release them. */ export declare class AssetManager implements Disposable { private _eventBus; private _sceneEngine; private _log; /** Full GLB/GLTF asset containers, keyed by base path (without fragment) */ private _containers; /** Extracted fragment meshes (source meshes for instancing), keyed by full fragment path */ private _sourceMeshes; constructor(eventBus: GameEventBus, sceneEngine: SceneEngine, logger?: LoggingUtility); /** * Split a path on `#` into base path and optional fragment name. */ private _parsePath; /** * Load (or retrieve from cache) the AssetContainer for a base path. * Increments refCount. */ private _loadContainer; /** * Find a mesh by name inside a container. Throws if not found. */ private _findMeshInContainer; /** * Load an asset, caching the result. Supports fragment syntax (`path#meshName`). * * - Without fragment: loads and caches the full AssetContainer, returns it. * - With fragment: loads the container, finds the named mesh, caches it as a source mesh, returns the mesh. * * Increments refCount on the underlying container each time. */ load(path: string): Promise; /** * Create an InstancedMesh from a cached source mesh. The path must have been loaded first. */ instance(path: string): InstancedMesh; /** * Clone a cached source mesh into an independent copy. The path must have been loaded first. */ clone(path: string): Mesh; /** * Preload a batch of asset paths. Emits `asset:progress` after each and `asset:complete` when finished. */ preload(paths: string[]): Promise; /** * Decrement refCount for the container backing this path. * When refCount hits 0, dispose the container and clean up all fragment meshes from it. */ dispose(path: string): void; /** * Dispose all cached containers and fragment meshes. */ disposeAll(): void; /** * Lifecycle teardown — disposes all assets. */ $teardown(): Promise; }