import { DIVE, DIVEBackgroundSettings, DIVEImageBasedLightSettings, DIVERoot, DIVESceneObject } from '../../../index.ts'; import { EntitySchema, MinimalSchema, PartialSchema, StateBackground, StateImageBasedLight } from '../types/index.ts'; /** * The scene properties that are not entities. * * They live on three different engine objects — scene, grid and floor — and * used to be read and written in three places that had already drifted apart. */ export type SceneSettings = { name: string; background: StateBackground; /** * The colour when the background is a colour, otherwise `'transparent'`. * * @deprecated Use `background` instead. */ backgroundColor: string; imageBasedLight: StateImageBasedLight; gridEnabled: boolean; floorEnabled: boolean; floorColor: string; }; /** * What may be written back. * * Colours come out as hex strings but go in either way, because three accepts * both and callers pass whatever they happen to hold. */ export type SceneSettingsPatch = Partial & { /** Wins over `backgroundColor` when both are given. */ background: DIVEBackgroundSettings; /** @deprecated Use `background` instead. */ backgroundColor: string | number; /** `null` turns the image based light off. */ imageBasedLight: Partial | null; floorColor: string | number; }>; /** * #### EngineGateway * is the single seam between the state plugin and the engine. * * The engine holds objects; it does not know what an entity, an action or a * state is. Everything that turns entity data into scene objects passes through * here. * * One direction only. Reports coming back the other way are `watchEntity`'s * business — which is why this class holds no reference to the state and has no * way to command it. * * It is not a facade over the engine API. It offers what the state layer * needs, in the state layer's vocabulary: entities, scene settings, rendering. * * @module */ export declare class EngineGateway { private readonly _engine; /** id -> scene object, so lookups do not walk the tree. */ private readonly _entities; constructor(engine: DIVE); /** The scene root, for everything that needs the subtree as a whole. */ get root(): DIVERoot; /** * Resolves an entity id to its scene object. * * Backed by a map rather than a tree walk: this runs on every frame a gizmo * is dragged, via `object-transform` -> `UPDATE_OBJECT` -> `updateEntity`, * and a `traverse` visits every mesh of every loaded asset on the way. */ findEntity(entity: MinimalSchema): DIVESceneObject | undefined; /** * Puts an empty scene object for this entity into the scene. * * Separate from {@link applyEntity} because of what happens in between: * applying a model schema awaits the asset load, and `object-load` fires * inside that await. Whoever wants to hear it has to be listening — and * registered, or the report writes to an id the state does not know yet. * One combined call left no moment for that. * * Synchronous, so nothing can slip in front of the caller either. * * @returns The scene object, or `undefined` for a state-only entity. */ createEntity(entity: EntitySchema): DIVESceneObject | undefined; /** Writes an entity's data onto the scene object created for it. */ applyEntity(sceneObject: DIVESceneObject, entity: PartialSchema): Promise; updateEntity(patch: PartialSchema): Promise; removeEntity(entity: MinimalSchema): void; /** Forgets every scene object. Listener teardown belongs to the registry. */ dispose(): void; readSceneSettings(): SceneSettings; /** * Writes what the patch carries onto the scene. * * @returns Resolves once every image the patch asked for has loaded. */ applySceneSettings(patch: SceneSettingsPatch): Promise; startRendering(): Promise; registerTicker(ticker: Parameters[0]): void; /** what the state stores of the background */ private _readBackground; /** what the state stores of the image based light */ private _readImageBasedLight; /** * Builds the node for an entity by composing the components its type needs. * * This is the whole "which entity type means which capabilities" mapping. * Note a `scene` light is not one component but two: a hemisphere and a * directional one, each carrying its own intensity factor, which is what * lets {@link _applyLight} stay free of per-type branching. */ private _instantiate; private _instantiateLight; private _apply; private _applyLight; private _applyModel; private _applyPrimitive; private _applyGroup; private _setParent; }