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
Parameter | Type | Description |
---|---|---|
params | { name : string ; components : ComponentsManifest ; options : { delete_on_client_disconnection : boolean ; auto_broadcast : boolean ; auto_update : boolean ; }; parent : null | Entity ; } | |
params.name | string | The name of the entity. |
params.components | ComponentsManifest | The 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 ? | boolean | Whether to delete the entity when the client disconnects. |
params.options.auto_broadcast ? | boolean | Deprecated Whether to broadcast the entity automatically. |
params.options.auto_update ? | boolean | Deprecated 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
Parameter | Type | Description |
---|---|---|
params | { components_array : ComponentsManifest []; options : { delete_on_client_disconnection : boolean ; auto_broadcast : boolean ; auto_update : boolean ; }; } | |
params.components_array | ComponentsManifest [] | 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 ? | boolean | Whether to delete the entity when the client disconnects. |
params.options.auto_broadcast ? | boolean | Deprecated Whether to broadcast the entity automatically. |
params.options.auto_update ? | boolean | Deprecated 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
Parameter | Type | Description |
---|---|---|
params | { entity_uuid : UUID ; linkage : UUID []; } | |
params.entity_uuid | UUID | The 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
Parameter | Type | Description |
---|---|---|
params | { entity_uuid : UUID ; } | |
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: {
entities: Entity[];
}): Promise<void>
Defined in: livelink.js/sources/scene/Scene.ts:270
Delete a batch of entities.
Parameters
Parameter | Type | Description |
---|---|---|
params | { entities : Entity []; } | |
params.entities | Entity [] | 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
Parameter | Type | Description |
---|---|---|
params | { entities : Entity []; keep_old_selection : boolean ; } | |
params.entities | Entity [] | The entities to highlight. |
params.keep_old_selection ? | boolean | Whether 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
Parameter | Type | Description |
---|---|---|
params | { event_map_id : UUID ; event_name : string ; emitter_entity : Entity ; target_entities : Entity []; data_object : ScriptDataObject ; } | |
params.event_map_id | UUID | The UUID of the event map. |
params.event_name | string | The name of the event. |
params.emitter_entity ? | Entity | The 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 ? | ScriptDataObject | The 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
Parameter | Type |
---|---|
__namedParameters | { name : string ; value : string ; } |
__namedParameters.name | string |
__namedParameters.value | string |
Returns
void
toggleFilter()
toggleFilter(__namedParameters: {
name: string;
enabled: boolean;
}): void
Defined in: livelink.js/sources/scene/Scene.ts:348
Experimental
Parameters
Parameter | Type |
---|---|
__namedParameters | { name : string ; enabled : boolean ; } |
__namedParameters.name | string |
__namedParameters.enabled | boolean |
Returns
void
removeFilter()
removeFilter(__namedParameters: {
name: string;
}): void
Defined in: livelink.js/sources/scene/Scene.ts:355
Experimental
Parameters
Parameter | Type |
---|---|
__namedParameters | { name : string ; } |
__namedParameters.name | string |
Returns
void
findEntitiesByNames()
findEntitiesByNames(__namedParameters: {
entity_names: string[];
}): Promise<Entity[]>
Defined in: livelink.js/sources/scene/Scene.ts:362
Parameters
Parameter | Type |
---|---|
__namedParameters | { entity_names : string []; } |
__namedParameters.entity_names | string [] |
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
Parameter | Type |
---|---|
__namedParameters | { mandatory_components : keyof ComponentsRecord []; forbidden_components : keyof ComponentsRecord []; } |
__namedParameters.mandatory_components | keyof ComponentsRecord [] |
__namedParameters.forbidden_components ? | keyof ComponentsRecord [] |
Returns
Promise
<Entity
[]>