ScenePlugin

View source

ExtendsPlugin

Adds scene asset loading and scene instantiation support to an App.

ScenePlugin makes Scene assets available through the asset pipeline. It registers JSONSceneImporter and JSONSceneExporter for JSON scene data, and makes SceneFilter available as an asset type for optional filtering during scene restoration.

The plugin provides the SceneSpawner resource and the SceneAssets and SceneFilterAssets resource aliases. Add a SceneInstance component to an entity to restore the referenced scene beneath that entity when its asset becomes available. A SceneFilter handle can limit which component and resource types are restored, and changes to a loaded scene are reflected in its live instances. The component hooks track pending instances and release their asset handles when an instance is removed.

Use world.getResource with SceneAssets for scene handles and with SceneFilterAssets for filter handles. The aliases refer to the shared asset pools used by the scene pipeline.

Register AssetServerPlugin, CorePlugin, ReflectPlugin, and HierarchyPlugin with the app alongside ScenePlugin. The app validates these dependencies but does not install missing plugins automatically.

Examples

import { App } from '@wimaengine/app'
import { AssetServerPlugin } from '@wimaengine/asset'
import { CorePlugin } from '@wimaengine/core'
import { HierarchyPlugin } from '@wimaengine/hierarchy'
import { ReflectPlugin } from '@wimaengine/reflect'
import { ScenePlugin } from '@wimaengine/scene'

new App()
  .registerPlugin(new ReflectPlugin())
  .registerPlugin(new CorePlugin())
  .registerPlugin(new AssetServerPlugin())
  .registerPlugin(new HierarchyPlugin())
  .registerPlugin(new ScenePlugin())
  .setRunner(() => {})
  .run()

Constructor


constructor()

Methods


register(app: App): void

View source

Adds scene asset adapters, resources, aliases, and component hooks to an App.

JSON scene data is connected to the asset pipeline through JSONSceneImporter and JSONSceneExporter. The plugin also registers scene lifecycle events, makes SceneFilter a loadable asset type, and provides SceneSpawner for pending scene instances. SceneAssets and SceneFilterAssets identify the corresponding typed asset pools.

Hooks for SceneInstance queue a referenced scene until its asset is available, restore it beneath the instance entity, apply its optional filter, and release its handles when the component is removed. Existing instances are restored from the current scene asset when that asset is modified.

Parameters

NameDescriptionDefault
app

App receiving scene support.

—