Skip to main content

Scene

OBR.scene

A scene is an infinite space for you to lay out images, drawings, fog and more.

Reference

Methods

isReady

async isReady()

Returns true if there is a scene opened and it is ready to interact with.


onReadyChange

onReadyChange(callback);

Parameters

NAMETYPEDESCRIPTION
callback(ready: boolean) => voidA callback for when the current scene changes its ready state

Returns a function that when called will unsubscribe from change events.

Example

/**
* Use an `onReadyChange` event with a React `useEffect`.
* `onReadyChange` returns an unsubscribe event to make this easy.
*/
useEffect(
() =>
OBR.scene.onReadyChange((ready) => {
if (ready) {
// interact with the scene
}
}),
[]
);

getMetadata

async getMetadata()

Get the current metadata for this scene.

returns a Metadata object.


setMetadata

async setMetadata(update)

Update the metadata for this scene.

See Metadata for best practices when updating metadata.

Parameters

NAMETYPEDESCRIPTION
updatePartial<Metadata>A partial update to this scenes metadata. The included values will be spread among the current metadata to avoid overriding other values.

onMetadataChange

onMetadataChange(callback);

Parameters

NAMETYPEDESCRIPTION
callback(metadata: Metadata) => voidA callback for when the metadata changes

Returns a function that when called will unsubscribe from change events.

Example

/**
* Use an `onMetadataChange` event with a React `useEffect`.
* `onMetadataChange` returns an unsubscribe event to make this easy.
*/
useEffect(
() =>
OBR.scene.onMetadataChange((metadata) => {
// React to metadata changes
}),
[]
);