SceneManager

SceneManager

Object responsible for scene content management.

Extends

Members

scene :Container

Container representing the whole scene.

Type:

sceneTree :string

Printable scene tree.

Type:
  • string

selection :SceneNode|null

Currently selected scene node. Is null if no node is selected.

Type:

Methods

(async) clearScene() → {Promise}

Clears the scene completely, removing every scene node apart from the scene itself and the container for image targets. Also removes any rooms.

Returns:

Promise that resolves when the scene is cleared.

Type
Promise

(async) clearSelection() → {Promise}

Deselects the currently selected object. Does nothing is nothing is selected.

Returns:

Promise that resolves when the object is deselected.

Type
Promise

(async) exportScene(sceneName, format) → {SceneExportResult}

Exports content of the current scene and saves it under the given filename in directory 'CustomFiles'.
If the filename doesn't end with the extension of type, the extension is automatically added to the filename.

Parameters:
Name Type Description
sceneName string

The sceneName used for saving the scene.

format string

The file type of the export (e.g. 'obj' or 'fbx' or 'usd')

Returns:

The scene export's result.

Type
SceneExportResult

findNodeById(id) → {SceneNode|null}

Searches the scene for a node by id.

Parameters:
Name Type Description
id string

unique id of the scene node

Returns:

scene node, if found; null otherwise.

Type
SceneNode | null

(async) getRayIntersections(origin, direction, featurePointRadius) → {RayHits}

Casts a ray on the scene and gets the intersections.

Parameters:
Name Type Description
origin Vector3

Origin vector of the ray.

direction Vector3

Direction vector of the ray.

featurePointRadius int

Radius for feature point detection in mm.

Returns:

The ray intersections with instances, the floor and feature points.

Type
RayHits

getSceneState(parent) → {Object}

Returns a serializable (JSON) representation of the whole scene, including the room description. Modifications of
the returned objects have no effect on the actual scene state.

Parameters:
Name Type Description
parent Container

parent of the scene state. Uses root scene node if nothing given or null.

Returns:

serializable representation of the scene.

Type
Object

(async) getSceneStateSafe(parent) → {Promise.<Object>}

Same as sceneManager.getSceneState, but returns a Promise that resolves with the scene state after all
scene updates have been made.

Parameters:
Name Type Description
parent Container

parent of the scene state. Uses root scene node if nothing given or null.

Returns:

Promise that resolves with serializable representation of the scene.

Type
Promise.<Object>

(async) insertContainer(insertionParams) → {Promise.<Container>}

Inserts a container into the scene according to given parameters.

Parameters:
Name Type Description
insertionParams ContainerInsertionParams

insertion parameters for the container

Returns:

Promise that resolves with the inserted container.

Type
Promise.<Container>

(async) insertModel(model, instanceProps, insertionParams) → {Promise.<(ModelInstance|Configuration)>}

Inserts a model into the scene according to given parameters.

Parameters:
Name Type Description
model Model

model to be inserted

instanceProps ModelInsertionParams

properties of the new instance

insertionParams Object

insertion setting for snapping

Returns:

Promise that resolves with the inserted instance of the model.

Type
Promise.<(ModelInstance|Configuration)>

(async) insertModels(bulkInsertionInfos, onProgress) → {Promise.<Array.<(ModelInstance|Configuration)>>}

Bulk insert a bunch of models at once for performance reasons.

Parameters:
Name Type Description
bulkInsertionInfos Array.<BulkInsertionInfo>

Insertion infos for bulk insertion.

onProgress function

Callback function for download progress between 0 and 100.

Returns:

Promise that resolves with the inserted instances of the models.

Type
Promise.<Array.<(ModelInstance|Configuration)>>

off(eventName, eventHandler)

Inherited From:
Parameters:
Name Type Description
eventName string
eventHandler function

on(eventName, eventHandler)

Inherited From:
Parameters:
Name Type Description
eventName string
eventHandler function

once(eventName, eventHandler)

Inherited From:
Parameters:
Name Type Description
eventName string
eventHandler function

(async) removeNode(node) → {Promise}

Removes given scene node. Attempting to remove the scene will throw an error.

Parameters:
Name Type Description
node SceneNode

scene node to be removed

Throws:

when attempting to remove the scene

Type
Error
Returns:

Promise that resolves when the object is removed.

Type
Promise

(async) select(node) → {Promise.<SceneNode>}

Selects the scene node. Selected nodes can be interacted with to change their pose.

Parameters:
Name Type Description
node SceneNode

scene node to be selected

Returns:

Promise that resolves when the object is selected.

Type
Promise.<SceneNode>

(async) setSceneState(newSceneState, parent) → {Promise}

Same as sceneManager.getSceneState, but returns a Promise that resolves with the scene state after all
scene updates have been made.

Parameters:
Name Type Description
newSceneState Object

scene state, obtained using sceneManager.getSceneState or sceneManager.getSceneStateSafe

parent Container

parent of the scene state. Overwrites root scene if not given or null.

Returns:

Promise that resolves once the scene is updated.

Type
Promise

(async) simulateTouchRay(screenX, screenY, featurePointRadius) → {RayHits}

Simulates a touch on a screen coordinate.

Parameters:
Name Type Description
screenX number

Screen coordinate between 0 and 1 along the x-axis, starting with left side of the screen.

screenY number

Screen coordinate between 0 and 1 along the y-axis, starting with top of the screen.

featurePointRadius int

Radius for feature point detection in mm.

Returns:

The ray intersections with instances, the floor and feature points.

Type
RayHits

(inner) _exportScene()

Outputs the scene tree to the console.

Events

objectTouched

Event that is emitted when an scene node is touched

Parameters:
Name Type Description
node SceneNode

node that was touched

sceneObjectPoseChanged

Event that is emitted when an scene node is moved manually

Parameters:
Name Type Description
node SceneNode

node whose pose was changed

sceneStateUpdateProgress

Event that is emitted when the scene is updated

Parameters:
Name Type Description
current Number

The index of the node currently updated.

total Number

The total amount of nodes to update.

selectionChanged

Event that is emitted when selection changes

Parameters:
Name Type Description
selection SceneNode | null

new selection