Examples
// ScenePlugin installs spawnScenes in Update/CoreSystems.End.
app.registerPlugin(new ScenePlugin())
// SceneInstance hooks queue asset IDs; each available scene is then
// restored beneath its live instance root during the update.Function
spawnScenes(world: World): voidRestores queued scene instances whose scene assets are available.
ScenePlugin registers this function directly in the repeating
AppSchedule.Update schedule’s
CoreSystems.End group,
after the scene asset event updater. It iterates the pending asset IDs from
SceneSpawner#assets and resolves each one through the typed
SceneAssets pool with getByAssetId(assetId).
If a scene asset is not available, the system skips that asset immediately
and leaves its spawner entry queued for a later update. For an available
scene, it gets the queued packed entity IDs from SceneSpawner,
converts each with EntityHandle.from, and looks up the live
SceneInstance through a Query. A missing or stale entity is
skipped without restoration. After the lookup, an instance with a filter
handle resolves it through SceneFilterAssets; no handle, or a handle
that no longer resolves, supplies undefined as the optional filter.
Before restoring each live instance, the system clears its
SceneInstance#entityMap. It then calls Scene#toWorld with the
world, instance, TypeRegistry, instance root entity, and resolved
filter. toWorld repopulates the mapping while restoring the scene beneath
that root. Once every queued entity for an available asset has been visited,
SceneSpawner#clear removes that asset ID from the pending map,
including entries whose queued entities were no longer live. Missing scene
assets are the exception because the system continues before clear.
// ScenePlugin installs spawnScenes in Update/CoreSystems.End.
app.registerPlugin(new ScenePlugin())
// SceneInstance hooks queue asset IDs; each available scene is then
// restored beneath its live instance root during the update.