Skip to main content

Scene

@3dverse/livelink v0.8.10


@3dverse/livelink / Scene

Class: Scene

Defined in: livelink.js/sources/scene/Scene.ts:47

The scene class.

It is the main entry point to interact with the entities in the scene. It is responsible for creating, finding, and deleting entities.

This class is not meant to be instantiated directly. Instead, it is created by the Livelink instance and can be accessed through the Livelink.scene property.

Extends

  • EventTarget

Methods

newEntity()

newEntity(params): Promise<Entity>

Defined in: livelink.js/sources/scene/Scene.ts:97

Create a new entity.

Parameters

params
name

string

The name of the entity.

components

ComponentsManifest

The components to add to the entity with their initial values. If no initial values are provided, the default values are used.

options

{ delete_on_client_disconnection: boolean; auto_broadcast: boolean; auto_update: boolean; }

Additional options for the entity creation.

options.delete_on_client_disconnection

boolean

options.auto_broadcast

boolean

options.auto_update

boolean

parent

null | Entity = null

Returns

Promise<Entity>

A promise that resolves to the created entity.

Example

const entity = await scene.newEntity({
name: "My Entity",
components: {
local_transform: {
position: [0, 2, 0],
// default values are used for scale and orientation
},
},
});

newEntities()

newEntities(params): Promise<Entity[]>

Defined in: livelink.js/sources/scene/Scene.ts:128

Create multiple entities at once. This method is more efficient than calling newEntity multiple times. It creates all entities in a single call to the core.

Parameters

params
components_array

ComponentsManifest[]

An array of objects with the name and components of each entity.

options

{ delete_on_client_disconnection: boolean; auto_broadcast: boolean; auto_update: boolean; }

Additional options for the entity creation.

options.delete_on_client_disconnection

boolean

options.auto_broadcast

boolean

options.auto_update

boolean

Returns

Promise<Entity[]>

A promise that resolves to an array of the created entities.


findEntity()

findEntity(params): Promise<null | Entity>

Defined in: livelink.js/sources/scene/Scene.ts:154

Find an entity by its UUID and linkage.

Parameters

params
entity_uuid

UUID

The UUID of the entity to find.

linkage

UUID[] = []

The linkage of the entity to find.

Returns

Promise<null | Entity>

A promise that resolves to the found entity or null if not found.


findEntities()

findEntities(params): Promise<Entity[]>

Defined in: livelink.js/sources/scene/Scene.ts:223

Find entities by their UUID.

This can return multiple entities if the entity is a child of a Components.SceneRef that is instanced multiple times.

Parameters

params
entity_uuid

UUID

The UUID of the entity to find.

Returns

Promise<Entity[]>

A promise that resolves to an array of entities with the given UUID.


deleteEntities()

deleteEntities(params): Promise<void>

Defined in: livelink.js/sources/scene/Scene.ts:244

Delete a batch of entities.

Parameters

params
entities

Entity[]

The entities to delete.

Returns

Promise<void>

A promise that resolves when the entities are deleted.


highlightEntities()

highlightEntities(params): Promise<void>

Defined in: livelink.js/sources/scene/Scene.ts:260

Highlight a batch of entities.

Parameters

params
entities

Entity[]

The entities to highlight.

keep_old_selection

boolean = false

Whether to keep the old selection or not.

Returns

Promise<void>

A promise that resolves when the message is sent.


fireEvent()

fireEvent(params): void

Defined in: livelink.js/sources/scene/Scene.ts:289

Experimental

Fire a script event.

Parameters

params
event_map_id

UUID

The UUID of the event map.

event_name

string

The name of the event.

emitter_entity

Entity

The entity that emits the event.

target_entities

Entity[] = []

The entities that are the target of the event. Leave empty for global events.

data_object

ScriptDataObject = {}

The data object to pass with the event.

Returns

void

A promise that resolves when the message is sent.


setFilter()

setFilter(__namedParameters): void

Defined in: livelink.js/sources/scene/Scene.ts:314

Experimental

Parameters

__namedParameters
name

string

value

string

Returns

void


toggleFilter()

toggleFilter(__namedParameters): void

Defined in: livelink.js/sources/scene/Scene.ts:322

Experimental

Parameters

__namedParameters
name

string

enabled

boolean

Returns

void


removeFilter()

removeFilter(__namedParameters): void

Defined in: livelink.js/sources/scene/Scene.ts:329

Experimental

Parameters

__namedParameters
name

string

Returns

void


findEntitiesByNames()

findEntitiesByNames(__namedParameters): Promise<Entity[]>

Defined in: livelink.js/sources/scene/Scene.ts:336

Parameters

__namedParameters
entity_names

string[]

Returns

Promise<Entity[]>

Deprecated


findEntitiesWithComponents()

findEntitiesWithComponents(__namedParameters): Promise<Entity[]>

Defined in: livelink.js/sources/scene/Scene.ts:347

Parameters

__namedParameters
mandatory_components

keyof ComponentsRecord[]

forbidden_components

keyof ComponentsRecord[]

Returns

Promise<Entity[]>

Deprecated


addEventListener()

addEventListener(type, callback, options?): void

Defined in: node_modules/typescript/lib/lib.dom.d.ts:8303

Appends an event listener for events whose type attribute value is type. The callback argument sets the callback that will be invoked when the event is dispatched.

The options argument sets listener-specific options. For compatibility this can be a boolean, in which case the method behaves exactly as if the value was specified as options's capture.

When set to true, options's capture prevents callback from being invoked when the event's eventPhase attribute value is BUBBLING_PHASE. When false (or not present), callback will not be invoked when event's eventPhase attribute value is CAPTURING_PHASE. Either way, callback will be invoked if event's eventPhase attribute value is AT_TARGET.

When set to true, options's passive indicates that the callback will not cancel the event by invoking preventDefault(). This is used to enable performance optimizations described in § 2.8 Observing event listeners.

When set to true, options's once indicates that the callback will only be invoked once after which the event listener will be removed.

If an AbortSignal is passed for options's signal, then the event listener will be removed when signal is aborted.

The event listener is appended to target's event listener list and is not appended if it has the same type, callback, and capture.

MDN Reference

Parameters

type

string

callback

null | EventListenerOrEventListenerObject

options?

boolean | AddEventListenerOptions

Returns

void

Inherited from

EventTarget.addEventListener


dispatchEvent()

dispatchEvent(event): boolean

Defined in: node_modules/typescript/lib/lib.dom.d.ts:8309

Dispatches a synthetic event event to target and returns true if either event's cancelable attribute value is false or its preventDefault() method was not invoked, and false otherwise.

MDN Reference

Parameters

event

Event

Returns

boolean

Inherited from

EventTarget.dispatchEvent


removeEventListener()

removeEventListener(type, callback, options?): void

Defined in: node_modules/typescript/lib/lib.dom.d.ts:8315

Removes the event listener in target's event listener list with the same type, callback, and options.

MDN Reference

Parameters

type

string

callback

null | EventListenerOrEventListenerObject

options?

boolean | EventListenerOptions

Returns

void

Inherited from

EventTarget.removeEventListener