JSONSceneImporter

View source

ExtendsImporter

Imports JSON-backed Scene assets through the Importer contract.

ScenePlugin installs this importer for the json extension.

Examples

const importer = new JSONSceneImporter()
const scene = await importer.deserialize(response, typeRegistry)

Constructor


Methods


deserialize(response: Response, typeRegistry: TypeRegistry): Promise<Scene>

View source

Parses a response body and reconstructs a Scene from its JSON representation. API users can pass the response from a scene asset request together with the app’s TypeRegistry to restore the serialized component and resource values.

The response JSON is awaited, then each entity component and scene resource is resolved through the supplied TypeRegistry: its runtime type ID selects the registry entry, whose deserialize method receives the stored value. Unknown types, non-object deserialization results, invalid entity IDs, and malformed entity/component/resource shapes are warned about or skipped, so the result can be empty or partial while valid data is retained. A valid JSON value that is not an object produces an empty Scene.

Malformed JSON causes response.json() to reject, and an exception thrown by a registered deserializer also propagates because this method does not catch either failure.

Parameters

NameDescriptionDefault
response

Response containing the serialized scene JSON.

—
typeRegistry

Registry used to deserialize component and resource values by runtime type ID.

—

Throws

If response.json() rejects or a registered deserializer throws; neither failure is caught here.

Returns

The reconstructed scene, which may be empty or partial when the JSON contains unsupported or malformed scene data.

getExtensions(): string[]

View source

Returns the file extension handled by this importer.

Returns

The supported extension labels: ['json'].