loadScene function

Future<Node> loadScene(
  1. String sourcePath, {
  2. String? package,
  3. AssetBundle? bundle,
  4. FsceneComponentRegistry? registry,
  5. SceneReloadCallback? onReload,
  6. Scene? applyStageTo,
})

Loads a DataAssets-backed .fsceneb scene by its source path relative to the owning package's root (for example assets/levels/forest.glb).

Loading the same scene again instantiates a fresh node graph that shares the first load's GPU resources, so per-instance loads are cheap.

Pass applyStageTo to also apply the document's stage render settings (environment, exposure, tone mapping, skybox, and sky lighting) to that scene, kept fresh across hot reloads. Pass package to disambiguate when the same source path is provided by more than one package, a custom registry to realize app-defined component types, and onReload to re-apply per-instance customizations after a hot reload patches the returned scene in place.

Implementation

Future<Node> loadScene(
  String sourcePath, {
  String? package,
  AssetBundle? bundle,
  FsceneComponentRegistry? registry,
  SceneReloadCallback? onReload,
  Scene? applyStageTo,
}) async {
  final sceneRegistry = await SceneRegistry.load(bundle: bundle);
  return sceneRegistry.loadScene(
    sourcePath,
    package: package,
    bundle: bundle,
    registry: registry,
    onReload: onReload,
    applyStageTo: applyStageTo,
  );
}