SceneInstanceSnapshot

View source

Stores persisted scene and optional filter handles for a SceneInstance.

The snapshot is a value object containing HandleSnapshot values instead of live handles. Restoring scene-local numeric handles also requires the owning scene asset ID.

Examples

// `instance` is a live SceneInstance and `ownerSceneAssetId` identifies
// the scene that owns any numeric, scene-local handle locators.
const snapshot = SceneInstance.toSnapshot(instance, world)
const serial = SceneInstanceSnapshot.serialize(snapshot)
const restored = SceneInstanceSnapshot.validateSerial(serial) &&
  SceneInstance.fromSnapshot(SceneInstanceSnapshot.deserialize(serial), world, ownerSceneAssetId)

Constructor


constructor(handle: HandleSnapshot, filter?: HandleSnapshot)

View source

Creates a scene-instance snapshot value.

The nested snapshots are stored exactly as supplied. The constructor does not clone them, validate their serializable shape, or restore live asset handles.

Parameters

NameDescriptionDefault
handle

Snapshot of the scene asset handle.

—
filter?

Optional snapshot of the filter handle.

—

Properties


Methods


staticserialize(value: SceneInstanceSnapshot): SceneInstanceSnapshotSerial

View source

Converts a scene-instance snapshot to plain persistence data.

This delegates both fields to HandleSnapshot.serialize. It returns a new object, keeps the nested type and path-or-index values as-is, and does not access a World, resolve an asset, or retain a live handle. The returned filter property is undefined when this snapshot has no filter.

Parameters

NameDescriptionDefault
value

Snapshot to serialize.

—

Returns

Plain serialized snapshot data.

staticdeserialize(value: SceneInstanceSnapshotSerial, out?: SceneInstanceSnapshot): SceneInstanceSnapshot

View source

Rehydrates a scene-instance snapshot from plain persistence data.

This delegates each nested field to HandleSnapshot.deserialize; it does not access a World, load an asset, or restore a live component. When out is supplied, the same outer snapshot is returned and its existing nested handle snapshot is reused where possible. An omitted serialized filter explicitly clears out.filter.

Parameters

NameDescriptionDefault
value

Plain serialized snapshot data.

—
out?

Snapshot object to populate and return.

...

Returns

The populated snapshot.

staticvalidateSerial(value: unknown): value is SceneInstanceSnapshotSerial

View source

Checks whether a value has the serialized shape expected by SceneInstanceSnapshot.deserialize.

This is a structural check only. It requires a valid serialized HandleSnapshot in handle, and accepts filter when it is absent, undefined, or another valid serialized handle snapshot. It does not check asset registration, path existence, pool indexes, scene mappings, or whether a live handle can be restored.

Parameters

NameDescriptionDefault
value

Value to inspect.

—

Returns

Whether the serialized shape is accepted.