Skip to content

API - User

Allows access to user information.

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

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

Functions

getPosition() : object

Gets the position of the current user.

Returns { x: number, y: number, z: number }

setPosition(x, y, z, instant=false)

Sets the position of the current user.

Field Type Description Example
x number New x position 2
y number New y position (height) 1
z number New z position (depth) 3
instant boolean true to immediately move avatar, false to glide to position false

getRotation() : number

Gets the orientation of the current user's avatar.

Returns the rotation, in radians, in the y direction.

setRotation(r)

Sets the orientation of the current user's avatar.

Field Type Description Example
r number New rotation, in radians, in the y direction 1.5708

getID() : string

Gets the ID of the current user as a string.

getDisplayName() : string

Gets the display name of the current user as a string.

isAdmin() : boolean

Returns true if the user is an admin in this space and false otherwise. Admins are able to edit objects.

getProperty(userID, propertyName) : any

Gets a property value that has been assigned to the specified user. Leave userID blank to get the property on the current user.

Field Type Description Example
userID string Identifier of the user to get a property value for ''
propertyName string Name of the property to retrieve 'color'

getProperties(userID) : object

Gets all property values that have been assigned to the specified user. Leave userID blank to get the properties on the current user.

Field Type Description Example
userID string Identifier of the user to get all property values for ''

setProperties(newProps)

Sets properties on the current user.

Properties will be merged in, and missing fields will not be changed. Prefix property names with space: if you want the value to be specific to an individual space and not carry over into multiple spaces.

Field Type Description Example
newProps object New property values to assign { color: '#2DCA8C' }
Back to top