ResourceRealizer class

Turns a document's resources into live, GPU-backed Geometry and Material objects, memoizing each so a resource shared by many nodes is realized once.

Procedural and payload-backed geometry, parameter materials, and embedded rgba8 textures realize synchronously. External image assets, encoded (PNG/JPEG) image payloads, and fmat materials need decoding or asset loading, so they are resolved by preload (await it before realizing); the synchronous path falls back to a placeholder for them.

Constructors

ResourceRealizer(SceneDocument document, {AssetBundle? bundle, EnvironmentAssetLoader? environmentLoader, TextureAssetLoader? textureLoader, FmatMaterialLoader? fmatMaterialLoader})
Creates a realizer over document. bundle (default rootBundle) resolves external image assets and fmat materials during preload. environmentLoader builds an AssetEnvironment from outside the bundle (the editor loads a user-picked file from disk). textureLoader decodes a TextureResource.asset from outside the bundle the same way. fmatMaterialLoader loads compiled .fmat output from outside the bundle.

Properties

bundle → AssetBundle
The asset bundle external assets and fmat materials load from.
final
document → SceneDocument
The document whose resources are realized.
final
environmentLoader → EnvironmentAssetLoader?
Loads an AssetEnvironment from outside the asset bundle, or null to use the bundle. See EnvironmentAssetLoader.
final
fmatMaterialLoader → FmatMaterialLoader?
Loads a compiled .fmat from outside the asset bundle.
final
hashCode → int
The hash code for this object.
no setterinherited
runtimeType → Type
A representation of the runtime type of the object.
no setterinherited
textureLoader → TextureAssetLoader?
Decodes a TextureResource.asset from outside the asset bundle, or null to use the bundle. See TextureAssetLoader.
final

Methods

adoptUnchanged(ResourceRealizer previous) → void
Carries realized resources over from previous (the realizer the live scene was built with) for every resource whose spec and payload bytes are unchanged, so a hot reload rebuilds only what actually changed instead of re-uploading the whole document (seconds for a large scene). Call before preload; preload skips carried-over entries.
environment(LocalId id) → EnvironmentSettings?
The realized look for an EnvironmentResource id, or null when id is not an environment resource. Environments are GPU-bound and async, so they are built in preload; this returns the cached result.
geometry(LocalId id) → Geometry
The live geometry for resource id, realized and memoized on first use. The result is stamped with its origin so the serializer can recover it.
material(LocalId id) → Material
The live material for resource id, realized and memoized on first use.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
preload({bool includeEnvironments = true}) → Future<void>
Resolves the resources that want asynchronous work (every texture, and fmat materials), caching them so the synchronous realize path finds them ready.
reloadMaterial(LocalId id) → Future<Material>
Rebuilds one material while retaining already loaded texture resources.
texture(LocalId id) → Texture
The live texture for resource id, realized and memoized on first use.
toString() → String
A string representation of this object.
inherited

Operators

operator ==(Object other) → bool
The equality operator.
inherited