Skip to content

Latest commit

 

History

History
401 lines (180 loc) · 4.72 KB

File metadata and controls

401 lines (180 loc) · 4.72 KB

Home > server > SceneUI

SceneUI class

UI rendered within the 3D space of a world's game scene.

Signature:

export default class SceneUI extends EventRouter implements protocol.Serializable 

Extends: EventRouter

Implements: protocol.Serializable

Remarks

SceneUI instances are created directly as instances. They support a variety of configuration options through the SceneUIOptions constructor argument.

Events

This class is an EventRouter, and instances of it emit events with payloads listed under SceneUIEventPayloads

Example

const sceneUI = new SceneUI({
  templateId: 'player-health-bar',
  attachedToEntity: playerEntity,
  offset: { x: 0, y: 1, z: 0 },
});

Constructors

Constructor

Modifiers

Description

(constructor)(options)

Constructs a new instance of the SceneUI class

Properties

Property

Modifiers

Type

Description

attachedToEntity

readonly

Entity | undefined

The entity to which the SceneUI is attached if explicitly set.

id

readonly

number | undefined

The unique identifier for the SceneUI.

isLoaded

readonly

boolean

Whether the SceneUI is loaded into the world.

offset

readonly

Vector3Like | undefined

The offset of the SceneUI from the attached entity or position.

position

readonly

Vector3Like | undefined

The position of the SceneUI in the world if explicitly set.

state

readonly

Readonly<object>

The state of the SceneUI.

templateId

readonly

string

The template ID of the SceneUI.

viewDistance

readonly

number | undefined

The maximum view distance the SceneUI will be visible to the player.

world

readonly

World | undefined

The world the SceneUI is loaded into.

Methods

Method

Modifiers

Description

load(world)

Loads the SceneUI into the world.

setAttachedToEntity(entity)

Sets the entity to which the SceneUI is attached, following its position.

setOffset(offset)

Sets the spatial offset of the SceneUI relative to the attached entity or position.

setPosition(position)

Sets the position of the SceneUI. Will detach from entity if attached.

setState(state)

Sets the state of the SceneUI by performing a shallow merge with existing state.

setViewDistance(viewDistance)

Sets the view distance of the SceneUI.

unload()

Unloads the SceneUI from the world.