<!-- Do not edit this file. It is automatically generated by API Documenter. -->

[Home](./index.md) &gt; [server](./server.md) &gt; [SceneUI](./server.sceneui.md)

## SceneUI class

UI rendered within the 3D space of a world's game scene.

**Signature:**

```typescript
export default class SceneUI extends EventRouter implements protocol.Serializable 
```
**Extends:** [EventRouter](./server.eventrouter.md)

**Implements:** protocol.Serializable

## Remarks

SceneUI instances are created directly as instances. They support a variety of configuration options through the [SceneUIOptions](./server.sceneuioptions.md) constructor argument.

<h2>Events</h2>

This class is an EventRouter, and instances of it emit events with payloads listed under [SceneUIEventPayloads](./server.sceneuieventpayloads.md)

## Example


```typescript
const sceneUI = new SceneUI({
  templateId: 'player-health-bar',
  attachedToEntity: playerEntity,
  offset: { x: 0, y: 1, z: 0 },
});
```

## Constructors

<table><thead><tr><th>

Constructor


</th><th>

Modifiers


</th><th>

Description


</th></tr></thead>
<tbody><tr><td>

[(constructor)(options)](./server.sceneui._constructor_.md)


</td><td>


</td><td>

Constructs a new instance of the `SceneUI` class


</td></tr>
</tbody></table>

## Properties

<table><thead><tr><th>

Property


</th><th>

Modifiers


</th><th>

Type


</th><th>

Description


</th></tr></thead>
<tbody><tr><td>

[attachedToEntity](./server.sceneui.attachedtoentity.md)


</td><td>

`readonly`


</td><td>

[Entity](./server.entity.md) \| undefined


</td><td>

The entity to which the SceneUI is attached if explicitly set.


</td></tr>
<tr><td>

[id](./server.sceneui.id.md)


</td><td>

`readonly`


</td><td>

number \| undefined


</td><td>

The unique identifier for the SceneUI.


</td></tr>
<tr><td>

[isLoaded](./server.sceneui.isloaded.md)


</td><td>

`readonly`


</td><td>

boolean


</td><td>

Whether the SceneUI is loaded into the world.


</td></tr>
<tr><td>

[offset](./server.sceneui.offset.md)


</td><td>

`readonly`


</td><td>

[Vector3Like](./server.vector3like.md) \| undefined


</td><td>

The offset of the SceneUI from the attached entity or position.


</td></tr>
<tr><td>

[position](./server.sceneui.position.md)


</td><td>

`readonly`


</td><td>

[Vector3Like](./server.vector3like.md) \| undefined


</td><td>

The position of the SceneUI in the world if explicitly set.


</td></tr>
<tr><td>

[state](./server.sceneui.state.md)


</td><td>

`readonly`


</td><td>

Readonly&lt;object&gt;


</td><td>

The state of the SceneUI.


</td></tr>
<tr><td>

[templateId](./server.sceneui.templateid.md)


</td><td>

`readonly`


</td><td>

string


</td><td>

The template ID of the SceneUI.


</td></tr>
<tr><td>

[viewDistance](./server.sceneui.viewdistance.md)


</td><td>

`readonly`


</td><td>

number \| undefined


</td><td>

The maximum view distance the SceneUI will be visible to the player.


</td></tr>
<tr><td>

[world](./server.sceneui.world.md)


</td><td>

`readonly`


</td><td>

[World](./server.world.md) \| undefined


</td><td>

The world the SceneUI is loaded into.


</td></tr>
</tbody></table>

## Methods

<table><thead><tr><th>

Method


</th><th>

Modifiers


</th><th>

Description


</th></tr></thead>
<tbody><tr><td>

[load(world)](./server.sceneui.load.md)


</td><td>


</td><td>

Loads the SceneUI into the world.


</td></tr>
<tr><td>

[setAttachedToEntity(entity)](./server.sceneui.setattachedtoentity.md)


</td><td>


</td><td>

Sets the entity to which the SceneUI is attached, following its position.


</td></tr>
<tr><td>

[setOffset(offset)](./server.sceneui.setoffset.md)


</td><td>


</td><td>

Sets the spatial offset of the SceneUI relative to the attached entity or position.


</td></tr>
<tr><td>

[setPosition(position)](./server.sceneui.setposition.md)


</td><td>


</td><td>

Sets the position of the SceneUI. Will detach from entity if attached.


</td></tr>
<tr><td>

[setState(state)](./server.sceneui.setstate.md)


</td><td>


</td><td>

Sets the state of the SceneUI by performing a shallow merge with existing state.


</td></tr>
<tr><td>

[setViewDistance(viewDistance)](./server.sceneui.setviewdistance.md)


</td><td>


</td><td>

Sets the view distance of the SceneUI.


</td></tr>
<tr><td>

[unload()](./server.sceneui.unload.md)


</td><td>


</td><td>

Unloads the SceneUI from the world.


</td></tr>
</tbody></table>
