Class
ScenePlugin
View sourceExtendsPlugin
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
Methods
register(app: App): void
View sourceAdds 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.
requires(): TypeId[]
View sourceReturns the plugins required directly by scene support.
Scene restoration uses CorePlugin, ReflectPlugin, and
HierarchyPlugin. The JSON asset adapters registered by
register also require AssetServerPlugin, so that plugin
must be registered with the app as well. The app validates these
dependencies and does not install them automatically.
