Class
JSONSceneExporter
View sourceExtendsExporter
Exports Scene snapshot assets as JSON through the inherited
Exporter contract.
The serialized document contains entity component snapshots under entities
and world resource snapshots under resources. Registry-backed snapshot
methods are applied while building those sections; this class does not
restore scenes or mutate the source asset.
Constructor
View source
Methods
serialize(asset: Scene, typeRegistry: TypeRegistry): Promise<string>
View sourceSerializes a Scene snapshot asset to JSON text.
Entity snapshots are written under entities as object properties keyed
by the entity IDs in Scene#entities. Each entity’s component
snapshots become properties keyed by their live type IDs. Resource
snapshots are written under resources, keyed by the live type IDs in
Scene#resources.
For each component or resource snapshot, the matching
TypeRegistry entry’s serialize method is used when it returns a
non-nullish value; otherwise the original snapshot is passed through.
Because this method is async, the final
JSON.stringify result is returned as a Promise<string>; serialization
errors from the registry method or JSON conversion are not caught here.
Examples
const exporter = new JSONSceneExporter()
const json = await exporter.serialize(scene, typeRegistry)
console.log(exporter.getExtensions()) // ['json']getExtensions(): string[]
View sourceReturns the extension labels supported by this exporter.
This exporter supports JSON output through the json label, without a
leading dot.
