Skip to main content

Events

on

on(event: string, callback: Function)

Adds a listener function to an event. Parameters passed to the callback will depend on the event. See Events for more information.

api.on('viewer.ready', function() {
console.log('Viewer is ready');
});

once

once(event: string, callback: Function)

Adds a listener function to an event and is removed after one event. Parameters passed to the callback will depend on the event. See Events for more information.

api.once('viewer.ready', function() {
console.log('Viewer is ready');
});

off

off(event: string)

Remove a listener function from an event.

api.off('viewer.ready');

Events

Viewer

viewer.ready

This event is triggered when the viewer is ready.

viewer.start

This event is triggered when the viewer is started.

viewer.stop

This event is triggered when the viewer is stopped.

Mouse

click

This event is triggered when the user clicks or taps in the viewer.

The event listener callback receives a JSON object with the following attributes:

{
"screen_coordinates": [100, 100],
"world_coordinates": [1, 5, 2],
"nodeId": 1234
}

Camera

Work in Progress

This events are currently not available in the API, but will be available soon.

camera.start

This event is triggered when the camera begins to move.

camera.stop

This event is triggered when the camera stops moving.

camera.position

This event is triggered every second and contains the current position of the camera.

Avatars

avatar.click

This event is triggered when a avatar is clicked.

avatar.hover

This event is triggered when a avatar is clicked.

avatar.nearby

This event is triggered in intervals containing all nearby avatars.

avatar.enter

This event is triggered when a avatar is entering the space.

avatar.leave

This event is triggered when a avatar left space and is disposed.

avatar.meshcode.changed

This event is triggered when a avatar configuration is finished.

for the above events the event listener callback receives a JSON object or an array with multiple objects with the following attributes:

{
"id": "a1234-b567-c890",
"externalId": "a1234-b567-c890",
"name": "AvatarsName",
"position": [1, 2, 3]
}