APIGENERAL
SPACES OVERVIEW
Introduction
Spaces Changelog
DESIGNING SPACES

World Creation

Overview
Creating Models
Importing Objects
Adjusting Looks
Recommended external tools

World Constraints

Scene Limitations
Health Monitor

Using Plugins

Media: Audio
Places
PLUGINS IN SPACES

Build & Publish

Overview
Publishing
Support & Feedback
Examples

Plugin Guides

Creating a Plugin
Creating a Component
Custom Avatars

Plugin Core API

Globals
App
Audio
Menus
Messages
Objects
Paths
Textures
User
World

Plugin Hooks

Hooks
General Hooks
Media Playback Hooks
Change LogForum

Hooks

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.*

Functions

addHandler(name: string, callback: Function) : void

Adds a hook handler.

FieldTypeDescriptionExample
namestringName to use when triggering the hook'controls.key.down'
callbackFunctionFunction to execute when handler is triggered. If this function returns a truthy value, the hook is interruptedfunction handler(event) { console.log('hook triggered') }

Example

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.

FieldTypeDescriptionExample
namestringName of the hook to remove'controls.key.down'
callbackFunctionSame function used when adding the handlerfunction handler(event) { console.log('hook triggered') }

Example

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.

FieldTypeDescriptionExample
namestringName of the hook to trigger'my-custom-hook'
dataanyData that needs to be passed to the handler{ color: '#FFFFFF' }

Example

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.

FieldTypeDescriptionExample
namestringName of the hook to trigger'my-custom-hook'
dataanyData that needs to be passed to the handlers{ color: '#FFFFFF' }

Example

const values = await this.hooks.triggerAll('my-custom-hook', { color: '#FFFFFF' })

General Hooks

The following general hooks are exposed from the core app and available to use in any plugins or components.

Hook IDTriggered When
controls.key.downTriggered when a key is pressed.
controls.key.upTriggered when a key is released.
controls.jumpTriggered when the user has started the jump animation.
core.space.change.startTriggered when a user has started the transition to another space.
core.space.change.completeTriggered when a user has arrived in a new space.
core.space.enterTriggered immediately before a user enters a space.
core.user.audio.mute-changeTriggered when the microphone toggles between muted and unmuted.
debug.textAppends debug text, which can be viewed by pressing Shift + ~.
gestures.quick-move.startTriggered on start of quick-move to a location within the space.
gestures.quick-move.completeTriggered when quick-move is completed.
user.place.arriveTriggered when a user has arrived at a place (when using the Places menu).
user.video.startTriggered when a user has turned on their webcam.
user.video.stopTriggered when a user has turned off their webcam.

Media Playback Hooks

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 IDTriggered When
plugins.media-playback.createdTriggered when a media object has been created inside the space.
plugins.media-playback.removedTriggered when a media object has been removed from the space.
plugins.media-playback.updatedTriggered every second when a media object is active.
plugins.media-playback.properties.setCan trigger to update the properties of attached object.
plugins.media-playback.list-sourcesCan trigger to fetch a list of active media sources.
plugins.media-playback.sources.${objectID}.playCan trigger to play media.
plugins.media-playback.sources.${objectID}.pauseCan trigger to pause media.
plugins.media-playback.sources.${objectID}.stopCan trigger to stop media.
plugins.media-playback.sources.${objectID}.playPauseToggleCan trigger to toggle between play and pause.
plugins.media-playback.sources.${objectID}.seekCan trigger to seek to timestamp within media.