Skip to main content

Scene

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

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.

Methods

newEntity()

newEntity(params: {
name: string;
components: ComponentsManifest;
options: {
delete_on_client_disconnection: boolean;
auto_broadcast: boolean;
auto_update: boolean;
};
parent: null | Entity;
}): Promise<Entity>

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

Create a new entity.

Parameters

ParameterTypeDescription
params{ name: string; components: ComponentsManifest; options: { delete_on_client_disconnection: boolean; auto_broadcast: boolean; auto_update: boolean; }; parent: null | Entity; }
params.namestringThe name of the entity.
params.componentsComponentsManifestThe components to add to the entity with their initial values. If no initial values are provided, the default values are used.
params.options?{ delete_on_client_disconnection: boolean; auto_broadcast: boolean; auto_update: boolean; }Additional options for the entity creation.
params.options.delete_on_client_disconnection?booleanWhether to delete the entity when the client disconnects.
params.options.auto_broadcast?booleanDeprecated Whether to broadcast the entity automatically.
params.options.auto_update?booleanDeprecated Whether to update the entity automatically.
params.parent?null | Entity-

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: {
components_array: ComponentsManifest[];
options: {
delete_on_client_disconnection: boolean;
auto_broadcast: boolean;
auto_update: boolean;
};
}): Promise<Entity[]>

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

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

ParameterTypeDescription
params{ components_array: ComponentsManifest[]; options: { delete_on_client_disconnection: boolean; auto_broadcast: boolean; auto_update: boolean; }; }
params.components_arrayComponentsManifest[]An array of objects with the name and components of each entity.
params.options?{ delete_on_client_disconnection: boolean; auto_broadcast: boolean; auto_update: boolean; }Additional options for the entity creation.
params.options.delete_on_client_disconnection?booleanWhether to delete the entity when the client disconnects.
params.options.auto_broadcast?booleanDeprecated Whether to broadcast the entity automatically.
params.options.auto_update?booleanDeprecated Whether to update the entity automatically.

Returns

Promise<Entity[]>

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


findEntity()

findEntity(params: {
entity_uuid: UUID;
linkage: UUID[];
}): Promise<null | Entity>

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

Find an entity by its UUID and linkage.

Parameters

ParameterTypeDescription
params{ entity_uuid: UUID; linkage: UUID[]; }
params.entity_uuidUUIDThe UUID of the entity to find.
params.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: {
entity_uuid: UUID;
}): Promise<Entity[]>

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

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

ParameterTypeDescription
params{ entity_uuid: UUID; }
params.entity_uuidUUIDThe 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: {
entities: Entity[];
}): Promise<void>

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

Delete a batch of entities.

Parameters

ParameterTypeDescription
params{ entities: Entity[]; }
params.entitiesEntity[]The entities to delete.

Returns

Promise<void>

A promise that resolves when the entities are deleted.


highlightEntities()

highlightEntities(params: {
entities: Entity[];
keep_old_selection: boolean;
}): Promise<void>

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

Highlight a batch of entities.

Parameters

ParameterTypeDescription
params{ entities: Entity[]; keep_old_selection: boolean; }
params.entitiesEntity[]The entities to highlight.
params.keep_old_selection?booleanWhether to keep the old selection or not.

Returns

Promise<void>

A promise that resolves when the message is sent.


fireEvent()

fireEvent(params: {
event_map_id: UUID;
event_name: string;
emitter_entity: Entity;
target_entities: Entity[];
data_object: ScriptDataObject;
}): void

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

Experimental

Fire a script event.

Parameters

ParameterTypeDescription
params{ event_map_id: UUID; event_name: string; emitter_entity: Entity; target_entities: Entity[]; data_object: ScriptDataObject; }
params.event_map_idUUIDThe UUID of the event map.
params.event_namestringThe name of the event.
params.emitter_entity?EntityThe entity that emits the event.
params.target_entities?Entity[]The entities that are the target of the event. Leave empty for global events.
params.data_object?ScriptDataObjectThe data object to pass with the event.

Returns

void

A promise that resolves when the message is sent.


setFilter()

setFilter(__namedParameters: {
name: string;
value: string;
}): void

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

Experimental

Parameters

ParameterType
__namedParameters{ name: string; value: string; }
__namedParameters.namestring
__namedParameters.valuestring

Returns

void


toggleFilter()

toggleFilter(__namedParameters: {
name: string;
enabled: boolean;
}): void

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

Experimental

Parameters

ParameterType
__namedParameters{ name: string; enabled: boolean; }
__namedParameters.namestring
__namedParameters.enabledboolean

Returns

void


removeFilter()

removeFilter(__namedParameters: {
name: string;
}): void

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

Experimental

Parameters

ParameterType
__namedParameters{ name: string; }
__namedParameters.namestring

Returns

void


findEntitiesByNames()

findEntitiesByNames(__namedParameters: {
entity_names: string[];
}): Promise<Entity[]>

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

Parameters

ParameterType
__namedParameters{ entity_names: string[]; }
__namedParameters.entity_namesstring[]

Returns

Promise<Entity[]>

Deprecated


findEntitiesWithComponents()

findEntitiesWithComponents(__namedParameters: {
mandatory_components: keyof ComponentsRecord[];
forbidden_components: keyof ComponentsRecord[];
}): Promise<Entity[]>

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

Parameters

ParameterType
__namedParameters{ mandatory_components: keyof ComponentsRecord[]; forbidden_components: keyof ComponentsRecord[]; }
__namedParameters.mandatory_componentskeyof ComponentsRecord[]
__namedParameters.forbidden_components?keyof ComponentsRecord[]

Returns

Promise<Entity[]>

Deprecated