realizeSceneAsync function
Future<Node>
realizeSceneAsync(
- SceneDocument document, {
- FsceneComponentRegistry? registry,
- AssetBundle? bundle,
- ResourceRealizer? resources,
Realizes document into a live Node graph, first asynchronously loading
any external image assets, encoded image payloads, and fmat materials it
references (from bundle, default rootBundle).
Use this (over realizeScene) when a document may reference such
resources; the .fscene / .fsceneb asset loaders do.
Pass resources to share realized GPU resources (geometry, materials,
textures) across multiple realizations of the same document, instancing
a scene cheaply. It must wrap document and already be preloaded; the
realizer is constructed and preloaded here only when resources is null.
Implementation
Future<Node> realizeSceneAsync(
SceneDocument document, {
FsceneComponentRegistry? registry,
AssetBundle? bundle,
ResourceRealizer? resources,
}) async {
assert(
resources == null || identical(resources.document, document),
'A shared ResourceRealizer must wrap the realized document',
);
var realizer = resources;
if (realizer == null) {
realizer = ResourceRealizer(document, bundle: bundle);
await realizer.preload();
}
return _realizeWith(
document,
registry ?? defaultComponentRegistry(),
realizer,
);
}