constructor(handle: HandleSnapshot)
View sourceCreates material-instance persistence data.
The supplied HandleSnapshot is stored as-is. This constructor does
not clone the snapshot or resolve an asset.
Class
Value object that represents the serialized material reference of a
BasicMaterialInstance. It carries material-instance persistence
data across serialization and restoration; it is not an ECS component and
does not hold a live material handle.
// `materialInstance` is a BasicMaterialInstance in `world`.
const serial = BasicMaterialInstanceSnapshot.serialize(
BasicMaterialInstance.toSnapshot(materialInstance, world)
)
const restored = BasicMaterialInstance.fromSnapshot(
BasicMaterialInstanceSnapshot.deserialize(serial), world, sceneAssetId
)constructor(handle: HandleSnapshot)Creates material-instance persistence data.
The supplied HandleSnapshot is stored as-is. This constructor does
not clone the snapshot or resolve an asset.
Snapshot of the material handle held by
BasicMaterialInstance.
The nested HandleSnapshot is persistence data rather than a live
asset handle.
default(): BasicMaterialInstanceSnapshotfromSnapshot(snapshot: BasicMaterialInstanceSnapshot, world: World, sceneAssetId?: AssetId): BasicMaterialInstanceRestores a BasicMaterialInstance from this persistence data.
Path-backed snapshots are restored through the world’s
AssetServer. Numeric snapshots require sceneAssetId and a
matching scene asset mapping. If that mapping is unavailable, nested
restoration returns undefined, and this method still constructs a
component whose handle is undefined.
serialize(value: BasicMaterialInstanceSnapshot): BasicMaterialInstanceSnapshotSerialConverts this snapshot to plain persistence data.
The returned object contains the serialized nested handle. This method
does not access a World, use an AssetServer, or restore
a live handle.
deserialize(value: BasicMaterialInstanceSnapshotSerial, out?: BasicMaterialInstanceSnapshot): BasicMaterialInstanceSnapshotRehydrates a snapshot from plain persistence data.
This does not restore a live handle. When out is supplied, this method
updates and returns that same snapshot and passes its existing handle to
nested deserialization, so the same nested handle object is reused;
otherwise it creates and returns a new snapshot.