Class: Entity
Defined in: livelink.js/sources/scene/Entity.ts:45
An entity in a scene.
An entity is a collection of components.
This class embeds a proxy to monitor component access and mark the entity as dirty when a component is added, modified or deleted.
All relevant modifications to entities are batched and automatically sent to the server and
broadcasted to other clients if the auto_broadcast
property is set to "on".
On top of providing direct access to the components, this class provides helper methods to retrieve the parent entity and the children entities.
This class cannot be instantiated directly. Use the Scene.newEntity or Scene.newEntities methods on an existing scene to create an entity.
Extends
EntityTransformHandler
Accessors
id
Get Signature
get id(): UUID
Defined in: livelink.js/sources/scene/Entity.ts:94
The UUID of the entity.
Note that multiple entities can share the same UUID if they are different instances of the same entity brought by multiple instances of the same scene.
Returns
name
Get Signature
get name(): string
Defined in: livelink.js/sources/scene/Entity.ts:101
The name of the entity.
Returns
string
auto_broadcast
Get Signature
get auto_broadcast(): boolean
Defined in: livelink.js/sources/scene/Entity.ts:109
Deprecated
Whether the entity has its components updates broadcasted to other clients.
Returns
boolean
Set Signature
set auto_broadcast(state: boolean): void
Defined in: livelink.js/sources/scene/Entity.ts:117
Deprecated
Set whether the entity has its components updates broadcasted to other clients.
Parameters
Parameter | Type |
---|---|
state | boolean |
Returns
void
is_visible
Get Signature
get is_visible(): boolean
Defined in: livelink.js/sources/scene/Entity.ts:127
Whether the entity is visible.
Returns
boolean
Set Signature
set is_visible(is_visible: boolean): void
Defined in: livelink.js/sources/scene/Entity.ts:134
Set whether the entity is visible.
Parameters
Parameter | Type |
---|---|
is_visible | boolean |
Returns
void
parent
Get Signature
get parent(): null | Entity
Defined in: livelink.js/sources/scene/Entity.ts:143
The parent entity of this entity or null if it has no parent.
Returns
null
| Entity
Set Signature
set parent(parent: null | Entity): void
Defined in: livelink.js/sources/scene/Entity.ts:150
Re-parent the entity by setting a parent entity.
Parameters
Parameter | Type |
---|---|
parent | null | Entity |
Returns
void
Overrides
EntityTransformHandler.parent;
local_transform
Get Signature
get local_transform(): Transform
Defined in: livelink.js/sources/scene/Entity.ts:157
Local transform of the entity.
Returns
Set Signature
set local_transform(local_transform: Partial<Transform>): void
Defined in: livelink.js/sources/scene/Entity.ts:164
Set the local transform of the entity.
Parameters
Parameter | Type |
---|---|
local_transform | Partial <Transform > |
Returns
void
Overrides
EntityTransformHandler.local_transform;
global_transform
Get Signature
get global_transform(): Transform
Defined in: livelink.js/sources/scene/Entity.ts:171
Global transform of the entity.
Returns
Set Signature
set global_transform(global_transform: Partial<Transform>): void
Defined in: livelink.js/sources/scene/Entity.ts:178
Set the global transform of the entity.
Parameters
Parameter | Type |
---|---|
global_transform | Partial <Transform > |
Returns
void
Overrides
EntityTransformHandler.global_transform;
ls_to_ws
Get Signature
get ls_to_ws(): readonly [number, number, number, number, number, number, number, number, number, number, number, number, number, number, number, number]
Defined in: livelink.js/sources/scene/Entity.ts:185
The local space to world space matrix of the entity.
Returns
readonly [number
, number
, number
, number
, number
, number
, number
, number
, number
, number
, number
, number
, number
, number
, number
, number
]
Overrides
EntityTransformHandler.ls_to_ws;
ws_to_ls
Get Signature
get ws_to_ls(): readonly [number, number, number, number, number, number, number, number, number, number, number, number, number, number, number, number]
Defined in: livelink.js/sources/scene/Entity.ts:192
The world space to local space matrix of the entity.
Returns
readonly [number
, number
, number
, number
, number
, number
, number
, number
, number
, number
, number
, number
, number
, number
, number
, number
]
Overrides
EntityTransformHandler.ws_to_ls;
Methods
getChildren()
getChildren(): Promise<Entity[]>
Defined in: livelink.js/sources/scene/Entity.ts:249
Returns
Promise
<Entity
[]>
addScriptEventListener()
addScriptEventListener(params: {
event_map_id: UUID;
event_name: string;
onReceived: (evt: ScriptEventReceived) => void;
onEmitted: (evt: ScriptEventEmitted) => void;
}): void
Defined in: livelink.js/sources/scene/Entity.ts:263
Add an event listener for a script event. Script events are triggered by the server when a script attached to an entity emits an event.
Parameters
Parameter | Type | Description |
---|---|---|
params | { event_map_id : UUID ; event_name : string ; onReceived : (evt : ScriptEventReceived ) => void ; onEmitted : (evt : ScriptEventEmitted ) => void ; } | |
params.event_map_id | UUID | The ID of the event map. |
params.event_name | string | The name of the event. |
params.onReceived ? | (evt : ScriptEventReceived ) => void | The callback to be called when the current entity is targetted by the script event. |
params.onEmitted ? | (evt : ScriptEventEmitted ) => void | The callback to be called when the current entity emits the script event. |
Returns
void
removeScriptEventListener()
removeScriptEventListener(params: {
event_map_id: UUID;
event_name: string;
onReceived: (evt: ScriptEventReceived) => void;
onEmitted: (evt: ScriptEventEmitted) => void;
}): void
Defined in: livelink.js/sources/scene/Entity.ts:292
Remove an event listener for a script event.
Parameters
Parameter | Type | Description |
---|---|---|
params | { event_map_id : UUID ; event_name : string ; onReceived : (evt : ScriptEventReceived ) => void ; onEmitted : (evt : ScriptEventEmitted ) => void ; } | |
params.event_map_id | UUID | The ID of the event map. |
params.event_name | string | The name of the event. |
params.onReceived ? | (evt : ScriptEventReceived ) => void | A previously registered callback. |
params.onEmitted ? | (evt : ScriptEventEmitted ) => void | A previously registered callback. |
Returns
void
assignClientToScripts()
assignClientToScripts(__namedParameters: {
client_uuid: UUID;
}): Promise<void>
Defined in: livelink.js/sources/scene/Entity.ts:315
Experimental
Parameters
Parameter | Type |
---|---|
__namedParameters | { client_uuid : UUID ; } |
__namedParameters.client_uuid | UUID |
Returns
Promise
<void
>