Request by sending an email to developer@vatom.com
Allows events to be passed between plugins and the core app, as well as allowing plugins to augment or replace certain behaviour.
When extending BasePlugin, these functions can be accessed via this.hooks.*
When extending BaseComponent, these functions can be accessed via this.plugin.hooks.*
addHandler(name: string, callback: Function) : void
Adds a hook handler.
Field | Type | Description | Example |
---|---|---|---|
name | string | Name to use when triggering the hook | 'controls.key.down' |
callback | Function | Function to execute when handler is triggered. If this function returns a truthy value, the hook is interrupted | function handler(event) { console.log('hook triggered') } |
function onKeyDown(evt) {
console.log('key pressed', evt.code)
}
//
this.hooks.addHandler('controls.key.down', onKeyDown)
removeHandler(name: string, callback: Function) : void
Removes a hook handler.
Field | Type | Description | Example |
---|---|---|---|
name | string | Name of the hook to remove | 'controls.key.down' |
callback | Function | Same function used when adding the handler | function handler(event) { console.log('hook triggered') } |
function onKeyDown(evt) {
console.log('key pressed', evt.code)
}
//
this.hooks.removeHandler('controls.key.down', onKeyDown)
trigger(name: string, data: any) : Promise<any>
Triggers a hook and returns the first truthy value. Note that listeners are able to modify the contents of the data
object parameter.
Field | Type | Description | Example |
---|---|---|---|
name | string | Name of the hook to trigger | 'my-custom-hook' |
data | any | Data that needs to be passed to the handler | { color: '#FFFFFF' } |
const value = await this.hooks.trigger('my-custom-hook', { color: '#FFFFFF' })
triggerAll(name: string, data: any) : Promise<any[]>
Triggers a hook and returns all truthy values. Note that listeners are able to modify the contents of the data
object parameter.
Field | Type | Description | Example |
---|---|---|---|
name | string | Name of the hook to trigger | 'my-custom-hook' |
data | any | Data that needs to be passed to the handlers | { color: '#FFFFFF' } |
const values = await this.hooks.triggerAll('my-custom-hook', { color: '#FFFFFF' })
The following general hooks are exposed from the core app and available to use in any plugins or components.
Hook ID | Triggered When |
---|---|
controls.key.down | Triggered when a key is pressed. |
controls.key.up | Triggered when a key is released. |
controls.jump | Triggered when the user has started the jump animation. |
core.space.change.start | Triggered when a user has started the transition to another space. |
core.space.change.complete | Triggered when a user has arrived in a new space. |
core.space.enter | Triggered immediately before a user enters a space. |
core.user.audio.mute-change | Triggered when the microphone toggles between muted and unmuted. |
debug.text | Appends debug text, which can be viewed by pressing Shift + ~ . |
gestures.quick-move.start | Triggered on start of quick-move to a location within the space. |
gestures.quick-move.complete | Triggered when quick-move is completed. |
user.place.arrive | Triggered when a user has arrived at a place (when using the Places menu). |
user.video.start | Triggered when a user has turned on their webcam. |
user.video.stop | Triggered when a user has turned off their webcam. |
A function to invoke Media Playback UI and a set of hooks exist to expose features within Vatom's own Media Share plugin.
The Media Playback plugin includes a component that has the ability to present UI allowing the user to select a media source. It can be invoked with the media-source-picker component action.
In addition, the following Media Playback hooks are supported:
Hook ID | Triggered When |
---|---|
plugins.media-playback.created | Triggered when a media object has been created inside the space. |
plugins.media-playback.removed | Triggered when a media object has been removed from the space. |
plugins.media-playback.updated | Triggered every second when a media object is active. |
plugins.media-playback.properties.set | Can trigger to update the properties of attached object. |
plugins.media-playback.list-sources | Can trigger to fetch a list of active media sources. |
plugins.media-playback.sources.${objectID}.play | Can trigger to play media. |
plugins.media-playback.sources.${objectID}.pause | Can trigger to pause media. |
plugins.media-playback.sources.${objectID}.stop | Can trigger to stop media. |
plugins.media-playback.sources.${objectID}.playPauseToggle | Can trigger to toggle between play and pause. |
plugins.media-playback.sources.${objectID}.seek | Can trigger to seek to timestamp within media. |