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

App

Allows users to interact with the core app.

When extending BasePlugin, these functions can be accessed via this.app.*

When extending BaseComponent, these functions can be accessed via this.plugin.app.*

Functions

hasInputCapture(id: string) : Promise<boolean>

Returns true if the object matching the given identifier has its input captured by a plugin, false otherwise.

FieldTypeDescriptionExample
idstringIdentifier of the object to check'042ed071-649c-4601-9a30-669a59c9e1ee'

Example

const hasCapture = await this.app.hasInputCapture('042ed071-649c-4601-9a30-669a59c9e1ee')
console.log(hasCapture) // => false

requestInputCapture(id: string, callback: Function) : Promise<void>

Requests full input event capture of the object matching the given identifier, sending all input events to the given callback function.

While capture is active, all pointer and keyboard events will be sent to the callback function, and will not be processed by the app. When capturing ends, the callback function will receive one last message with type equal to 'input-capture-ended'.

All events sent to the callback function contain the standard PointerEvent and KeyboardEvent fields, as well as the following extra fields:

  • windowWidth: number - Width of the app window in pixels
  • windowHeight: number - Height of the app window in pixels
  • objectID: string - Identifier of the object that was specified when the request started
  • point: Vector3 - World coordinates of the hit point, in the form { x: number, y: number, z: number }
  • uv: Vector2 - UV coordinates of the hit point, in the form { x: number, y: number }
FieldTypeDescriptionExample
idstringIdentifier of the object to capture input events for'042ed071-649c-4601-9a30-669a59c9e1ee'
callbackFunctionCallback function to receive input eventsfunction onEvent(event) { console.log(event) }

Example

function onEvent(event) {
  console.log(event)
}
//
await this.app.requestInputCapture('042ed071-649c-4601-9a30-669a59c9e1ee', onEvent)

stopInputCapture() : void

Stops the current input capture, if it exists.

Example

this.app.stopInputCapture()