fscene library
The .fscene serialized scene format: an in-memory document model, JSON
read/write, and realization to and from a live Node graph.
Load a scene with loadFsceneAsset (or build a SceneDocument in code, write it with writeFscene, and read it back with readFscene). Realize a document into a node graph with realizeScene, or serialize a live graph back with serializeScene. Register app-defined component types with a FsceneComponentRegistry.
Classes
- AnimationChannelSpec
- One animation channel: a keyframe timeline driving one property of one target node.
- AnimationSpec
- A named animation: a set of channels driving target nodes.
- AssetEnvironment
- An environment built from an external image asset.
- AssetRef
- A reference to an external asset by its source-path key.
- BoolValue
- A boolean value.
- BoundsSpec
- An axis-aligned bounding box in a resource's local space.
- ColorValue
- A linear RGBA color.
- ComponentCodec
- Translates between a serialized ComponentSpec and a live Component of one type.
- ComponentSpec
- A serialized component: a stable type name plus a typed property bag.
- CuboidGeometrySpec
- A box of the given extents, optionally with per-corner debug colors.
- DocumentId
- A 128-bit document identifier, minted once when a document is created.
- DoubleValue
- A floating-point scalar value.
- EmptyEnvironment
- An empty (black) environment.
- EnvironmentSkySpec
- Shows the scene's image-based-lighting environment, optionally blurred.
- EnvironmentSpec
- The image-based-lighting environment for a scene.
- FmatSkySpec
-
A sky
.fmatloaded by source path, with optional parameter overrides applied to the loaded sky's parameters by name. - FsceneComponentRegistry
- A registry of ComponentCodecs, keyed by component type name.
- GeometryResource
-
Mesh geometry, sourced either from a binary
payloadchunk (imported content) or a procedural descriptor (a runtime primitive). Exactly one source is set. Carries optional local bounds. - GradientSkySpec
- The built-in stylized gradient sky.
- IdAllocator
- Mints fresh LocalIds for one editing session of a document.
- IntValue
- An integer value.
- ListValue
- An ordered list of values.
- LocalId
- A compact, document-scoped identifier for a node, resource, skin, animation, or payload.
- MapValue
- A string-keyed map of values (a nested property bag).
- MaterialResource
-
A material: a type (for example
physicallyBased,unlit,fmat) plus typed properties. Anfmatmaterial references its.fmatsource via asset. - Matrix4Value
- A 4x4 matrix.
- MatrixTransform
- A transform stored as an explicit 4x4 matrix.
- NodeChange
- What changed about a node present in both documents.
- NodeRefValue
- A reference to another node in the same document, by its LocalId.
- NodeSpec
- A node in the document's scene graph.
- PayloadSpec
- A binary chunk in the document's payload manifest: a descriptor plus, when the document's payloads are loaded, the chunk bytes.
- PhysicalSkySpec
- The built-in physically based daylight sky.
- PlaneGeometrySpec
- A flat plane in the XZ plane.
- PrefabInstanceSpec
-
The data that makes a NodeSpec a prefab instance: a reference to another
.fsceneplus the per-instance delta (overrides and added/removed content). The prefab composer applies these against the referenced document; a plain node leaves NodeSpec.instance null. - ProceduralGeometry
- A procedural geometry the runtime builds from parameters (rather than from baked vertex buffers). Compact and editable; no payload needed.
- PropertyOverride
- One per-instance override of a prefab: set the property at path on the node target (in the prefab's local id space) to value.
- PropertyValue
- A typed value carried by a component field, a material parameter, or a prefab override.
- QuaternionValue
-
A rotation quaternion (
x, y, z, w). - RealizeContext
- Context handed to a ComponentCodec when realizing a ComponentSpec into a live Component. Carries the source document and a resources realizer so a codec (for example a mesh) can resolve referenced geometry and materials.
- RenderTextureResource
-
An offscreen render target a serialized render view draws into and
materials sample by id (the runtime
RenderTexture). - RenderViewSpec
-
One serialized view of the scene: a camera node bound to a target and
the view's render settings (the runtime
RenderView). - ResourceRealizer
- 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.
- ResourceRefValue
- A reference to a resource (geometry, material, texture, ...) in the same document, by its LocalId.
- ResourceSpec
- A shared, id-keyed resource referenced by nodes (and other resources).
- SceneDiff
- The set of changes between two documents.
- SceneDocument
-
The in-memory
.fscenedocument: a GPU-free, encoding-independent description of a scene that the encoders serialize and the realizer turns into a liveNodegraph. - SerializeContext
- Context handed to a ComponentCodec when serializing a live Component into a ComponentSpec. Carries the destination document so a codec can register resources or mint ids.
- SkinSpec
- A skin: the joint nodes it drives, its inverse-bind matrices (a binary chunk), and the optional skeleton root.
- SkyboxSpec
- The stage skybox: the visible background drawn behind all geometry.
- SkyEnvironmentSpec
- Sky-driven lighting: bakes a shader sky into the scene's image-based lighting on a refresh policy.
- SkySourceSpec
- What a stage sky looks like, serialized.
- SphereGeometrySpec
- A UV sphere.
- StageMetadata
- Scene-wide, non-spatial render settings (lights and cameras are per-node components, not stage data).
- StringValue
- A string value.
- StudioEnvironment
- The built-in procedural studio environment.
- TextureResource
- A texture sourced either from an embedded payload chunk or an external image asset.
- TransformSpec
-
A node's local transform, stored either as a 4x4
matrixor as a decomposed translation/rotation/scale (TrsTransform). The importer emits TRS for clean diffs; the runtime composes aMatrix4. - TrsTransform
- A transform stored as decomposed translation, rotation, and scale.
- Vec2Value
- A 2-component vector.
- Vec3Value
- A 3-component vector.
- Vec4Value
- A 4-component vector.
Enums
- AnimationProperty
- The transform channel an animation drives on its target node.
- Handedness
- The chirality of the coordinate system a document's positions and geometry are expressed in. Drives the scene-root mirror the realizer applies, kept as metadata rather than a literal node transform.
- LoadPolicy
- Whether a prefab instance's content loads eagerly with the scene or is streamed in on demand.
- PayloadEncoding
- How a binary payload chunk's bytes are interpreted.
- UpAxis
- The up axis convention a document was authored in.
Constants
- currentFsceneVersion → const int
-
The current
.fsceneformat version this build reads and writes. - kFscenebVersion → const int
-
The current
.fscenebcontainer version this build reads and writes. -
supportedFeatures
→ const Set<
String> -
The format feature flags this build understands. A document that lists a
feature outside this set in its
featuresRequiredis refused.
Functions
-
composeScene(
SceneDocument document, {required PrefabResolver resolve}) → SceneDocument -
Expands every prefab instance in
document, returning a new document with no instance nodes. A document with no instances is returned unchanged. -
composeSceneAsync(
SceneDocument document, {required AsyncPrefabLoader load}) → Future< SceneDocument> -
Loads every prefab document
documentreferences (transitively, breadth first, each source loaded once) viaload, then composes synchronously. -
decodeBase32(
String token) → Uint8List -
Decodes a Crockford base32
tokento bytes (most significant bit first), the inverse of encodeBase32. Case-insensitive; trailing bits that do not fill a byte are dropped. Throws a FormatException on an invalid character. -
defaultComponentRegistry(
) → FsceneComponentRegistry - Returns a registry preloaded with the built-in component codecs.
-
diffScene(
SceneDocument oldDocument, SceneDocument newDocument) → SceneDiff -
Computes the node-id-keyed diff turning
oldDocumentintonewDocument. -
encodeBase32(
Uint8List bytes) → String -
Encodes
bytesas an unpadded Crockford base32 string, most significant bit first. Stays web-safe by never accumulating more than ~13 bits. -
isLazySubtree(
Node node) → bool -
Whether
nodeis a lazy prefab placeholder. -
isSubtreeLoaded(
Node node) → bool -
Whether
nodeis a lazy placeholder whose content is currently loaded. -
loadFsceneAsset(
String assetPath, {FsceneComponentRegistry? registry, AssetBundle? bundle}) → Future< Node> -
Loads a
.fscenetext asset byassetPathand realizes it into a live node graph, loading any external assets /fmatmaterials it references. -
loadFscenebAsset(
String assetPath, {FsceneComponentRegistry? registry, AssetBundle? bundle}) → Future< Node> -
Loads a
.fscenebbinary asset byassetPathand realizes it into a live node graph, loading any external assets /fmatmaterials it references. -
loadFscenebBytes(
Uint8List bytes, {FsceneComponentRegistry? registry}) → Node -
Parses and realizes a
.fscenebbinary container frombytesinto a live node graph (synchronously). -
loadFscenebBytesAsync(
Uint8List bytes, {FsceneComponentRegistry? registry, AssetBundle? bundle}) → Future< Node> -
Parses a
.fscenebcontainer frombytesand realizes it, first loading any external assets, encoded image payloads, andfmatmaterials it references (frombundle, defaultrootBundle). -
loadFsceneString(
String source, {FsceneComponentRegistry? registry}) → Node -
Parses and realizes a
.fscenedocument fromsourcetext into a live node graph (synchronously). -
loadSubtree(
Node node, {required AsyncPrefabLoader load, FsceneComponentRegistry? registry, AssetBundle? bundle}) → Future< void> -
Instantiates a lazy placeholder
node's prefab content under it. -
readBool(
Map< String, PropertyValue> props, String key, bool fallback) → bool -
Reads a
boolproperty, or returnsfallback. -
readColor(
Map< String, PropertyValue> props, String key) → Vector4? -
Reads a ColorValue as a
Vector4(RGBA), or returnsfallback. -
readDouble(
Map< String, PropertyValue> props, String key, double fallback) → double -
Typed readers over a component or material property bag, with fallbacks
for missing or mistyped values. Shared by component codecs and the
resource realizer.
Reads a
doubleproperty, accepting an int too, or returnsfallback. -
readFscene(
String source, {List< FsceneMigration> ? migrations}) → SceneDocument -
Parses a
.fscenedocument fromsource. -
readFsceneb(
Uint8List bytes) → SceneDocument -
Parses a
.fscenebcontainer frombytesinto a SceneDocument with each embedded payload's PayloadSpec.bytes attached. -
readInt(
Map< String, PropertyValue> props, String key, int fallback) → int -
Reads an
intproperty, or returnsfallback. -
readString(
Map< String, PropertyValue> props, String key, String fallback) → String -
Reads a string property, or returns
fallback. -
readVec3(
Map< String, PropertyValue> props, String key, Vector3 fallback) → Vector3 -
Reads a
Vector3property (a copy), or returns a copy offallback. -
realizeScene(
SceneDocument document, {FsceneComponentRegistry? registry}) → Node -
Realizes
documentinto a live Node graph. -
realizeSceneAsync(
SceneDocument document, {FsceneComponentRegistry? registry, AssetBundle? bundle, ResourceRealizer? resources}) → Future< Node> -
Realizes
documentinto a live Node graph, first asynchronously loading any external image assets, encoded image payloads, andfmatmaterials it references (frombundle, defaultrootBundle). -
realizeStage(
SceneDocument document, Scene scene, {AssetBundle? bundle}) → Future< void> -
Applies
document's stage render settings toscene: environment, environment intensity, exposure, tone mapping, skybox, and sky lighting. -
realizeViews(
SceneDocument document, Scene scene, Node root) → void -
Realizes
document's serialized render views intoscene's view list. -
registerBuiltinComponentCodecs(
FsceneComponentRegistry registry) → void -
Registers the component codecs the format ships with (mesh, directional
light, camera) into
registry. -
reloadScene(
Node liveRoot, SceneDocument oldDocument, SceneDocument newDocument, {FsceneComponentRegistry? registry, AssetBundle? bundle}) → Future< SceneDiff> -
Patches the live graph rooted at
liveRoot(as returned byrealizeScene, orloadScene) fromoldDocumenttonewDocumentin place. -
serializeScene(
Node root, {FsceneComponentRegistry? registry}) → SceneDocument -
Serializes the live Node graph rooted at
rootinto a new SceneDocument. -
serializeStage(
Scene scene, SceneDocument document) → void -
Reads
scene's stage render settings back intodocument's stage. -
serializeViews(
Scene scene, SceneDocument document) → void -
Serializes
scene's view list intodocument'sviewsarray, replacing any existing entries. -
unloadSubtree(
Node node) → void -
Detaches a loaded lazy subtree
node's content; it can be loaded again with loadSubtree. No-op ifnodeis not a lazy placeholder. -
writeFscene(
SceneDocument doc) → String -
Serializes
docto canonical.fsceneJSON text. -
writeFsceneb(
SceneDocument document) → Uint8List -
Serializes
documentto a.fscenebcontainer: the document's JSON manifest followed by one chunk per payload.
Typedefs
-
AsyncPrefabLoader
= Future<
SceneDocument> Function(AssetRef ref) - Asynchronously loads a prefab AssetRef's (uncomposed) SceneDocument.
- PrefabResolver = SceneDocument Function(AssetRef ref)
- Resolves a prefab AssetRef to its (uncomposed) SceneDocument.
Exceptions / Errors
- FscenebFormatException
-
Thrown when a
.fscenebcontainer is malformed. - FsceneFormatException
-
Thrown when a
.fscenedocument is malformed. - FsceneUnsupportedFeatureException
- Thrown when a document requires a format feature this build does not support.
- FsceneVersionException
- Thrown when a document's version cannot be loaded (newer than supported, or missing a migration step).