import { Quaternion, Scene, StaticSound, TransformNode, Vector3 } from '@babylonjs/core'; import { LevelConfig, LevelContext } from "../interfaces/level.d.ts"; import { GameEntity } from "./entity.d.ts"; import { Level } from "./level.d.ts"; /** * Metadata collected from a spawn point node. * Transforms are normalized to canonical Babylon space — the source level's __root__ * conversion is removed so these values are clean for any entity type. */ interface SpawnPointData { name: string; position: Vector3; rotation: Quaternion; scaling: Vector3; node: TransformNode; } /** * Metadata collected from an entity node */ interface EntityNodeData { type: string; node: TransformNode; } /** * Default Level implementation that loads from YAML configuration. * Supports property handlers for processing scene node metadata. */ export declare class GameLevel extends Level { /** The level configuration */ protected _config: LevelConfig; /** Collected spawn points from the scene */ protected _spawnPoints: SpawnPointData[]; /** Collected entity nodes from the scene */ protected _entityNodes: EntityNodeData[]; /** Entities spawned by this level */ protected _spawnedEntities: GameEntity[]; /** Level-scoped sounds created from config */ protected _levelSounds: Map; /** Sounds that were playing before deactivation (for resume on activate) */ private _playingSoundsBeforeDeactivate; /** * Create a GameLevel from a configuration object * * @param config * @param context */ constructor(config: LevelConfig, context: LevelContext); get config(): LevelConfig; get spawnedEntities(): readonly GameEntity[]; /** * Build the scene by loading assets, processing node metadata, and spawning entities. */ protected buildScene(): Promise; /** * Import all meshes from the configured scene file (GLB/GLTF/Babylon) into the scene. */ private _loadSceneFile; /** * Extract the scene file path from the config, which can be a string or SceneConfig object. */ private _getScenePath; /** * Check if the scene config specifies a right-handed coordinate system. */ private _isRightHanded; /** * Set up the scene environment: IBL (image-based lighting) for PBR reflections and/or a visible skybox. */ private _processEnvironment; /** * Create an environment texture from an HDR or env file. */ private _createEnvironmentTexture; private _getFileExtension; /** * Process cameras: apply YAML overrides to imported cameras, create new ones, and set the active camera. * If no YAML cameras config exists, the first imported camera (if any) is activated. */ private _processCameras; /** * Create a new camera from a YAML definition. */ private _createCamera; /** * Apply shared camera properties from a config to an existing camera. */ private _applyCameraConfig; /** * Process lights: apply YAML overrides to imported lights and create new ones. * If no YAML lights config exists, imported lights are left unchanged. */ private _processLights; /** * Create a new light from a YAML definition. */ private _createLight; /** * Apply shared light properties from a config to an existing light. */ private _applyLightConfig; /** * Set up clustered lighting: create a container, move eligible lights into it, * and fix PBR material falloff for compatibility. */ private _setupClustering; private _toColor3; /** * Configure and enable the Havok physics plugin with the level's gravity settings. */ private _enablePhysics; /** * Walk all transform nodes and meshes, normalizing glTF metadata and dispatching to property handlers. */ private _processNodeProperties; /** * Get normalized metadata from a node, handling glTF extras. * * Babylon.js stores glTF custom properties in node.metadata.gltf.extras, * so we need to extract them for easier access. */ private _getNormalizedMetadata; /** * Check a node's metadata for spawn/entity markers and run any registered property handlers. */ private _processNodeMetadata; /** * Run registered property handlers on a node. */ private _runPropertyHandlers; /** * Match collected spawn points against the level config's spawn definitions and instantiate entities. */ private _processSpawnPoints; /** * Spawn an entity at the given spawn point and dispose of the placeholder node. */ private _processSpawnPoint; /** * Apply debug collider visualization to an entity if configured. * Level/spawn config takes priority over the entity definition's debugCollider. */ private _applyDebugCollider; /** * Create an entity from a spawn definition, inheriting position/rotation/scaling from the spawn point. */ private _spawnEntity; /** * Build or import a mesh from the entity definition and attach it to the entity. * Supports primitive shapes (box/sphere/capsule/cylinder) and GLB/GLTF file paths. */ private _createEntityMesh; /** * Create game entities for all nodes marked with the 'entity' metadata property. */ private _processEntityNodes; /** * Create a game entity for an entity-tagged node, attaching the existing scene node to it. */ private _processEntityNode; /** * Create level-scoped sounds from YAML config. Sounds are tracked for lifecycle management * (pause on deactivate, resume on activate, dispose on unload). */ private _processLevelSounds; /** * Pause all playing level sounds when the level is deactivated. * Subclasses that override this must call `super.onDeactivate()`. */ onDeactivate(): Promise; /** * Resume previously playing level sounds when the level is reactivated. * Subclasses that override this must call `super.onActivate()`. */ onActivate(): Promise; /** * Dispose of this level's resources */ $dispose(): Promise; } export {};