Skip to content

@tmrw-realityos/worldDocs


@tmrw-realityos/world / Entity

Class: Entity

Entity class is the main class to build Worlds. Entities define objects scattered around the 3D space. Every Entity contains components that define its behaviour:

  • Render a 3D mesh
  • Play sound
  • Interact with the user
  • etc...

Check the components pool for further information.

Entities can also contain other entities inside.

Extends

Constructors

new Entity()

new Entity(): Entity

Returns

Entity

Overrides

ComponentsContainer.constructor

Defined in

world/entity.ts:55

Properties

children

children: Entity[] = []

Defined in

world/entity.ts:45


components

components: BaseComponent[] = []

Inherited from

ComponentsContainer.components

Defined in

world/components.ts:49


enabled

enabled: boolean = true

Defined in

world/entity.ts:39


index

index: number = -1

Defined in

world/entity.ts:36


is_root

is_root: boolean = false

Defined in

world/entity.ts:42


layers

layers: number = 3

Defined in

world/entity.ts:38


name

name: string = ""

Defined in

world/entity.ts:35


node

node: Node

Defined in

world/entity.ts:41


parent?

optional parent: Entity

Defined in

world/entity.ts:44


uid

uid: string = ""

Defined in

world/entity.ts:34


world?

optional world: World

Defined in

world/entity.ts:47


last_index

static last_index: number = 0

Defined in

world/entity.ts:32

Accessors

transform

get transform(): Transform

Returns

Transform

Defined in

world/entity.ts:51

Methods

addChild()

addChild(child): void

Parameters

child: Entity

Returns

void

Defined in

world/entity.ts:95


addComponent()

addComponent(component): void

Parameters

component: BaseComponent

Returns

void

Inherited from

ComponentsContainer.addComponent

Defined in

world/components.ts:53


clear()

clear(): void

Returns

void

Defined in

world/entity.ts:62


configure()

configure(o): void

Parameters

o: EntityDescriptor

Returns

void

Defined in

world/entity.ts:132


configureComponents()

configureComponents(info): void

Parameters

info

info.components?: [string, BaseComponent][]

Returns

void

Inherited from

ComponentsContainer.configureComponents

Defined in

world/components.ts:100


executeMethodInComponents()

executeMethodInComponents(func_name, data): void

executes function with a given name in this component and in all children entities components

Parameters

func_name: string

data: unknown

Returns

void

Defined in

world/entity.ts:197


findChildById()

findChildById(uid): undefined | Entity

Parameters

uid: string

Returns

undefined | Entity

Defined in

world/entity.ts:83


findChildByName()

findChildByName(name): undefined | Entity

Parameters

name: string

Returns

undefined | Entity

Defined in

world/entity.ts:89


findComponent()

findComponent<Type>(ctor): undefined | Type

Search a component in this entity and its children Usage: entity.getComponent( PrefabRenderer );

Type Parameters

Type extends BaseComponent

Parameters

ctor

Returns

undefined | Type

Defined in

world/entity.ts:173


findComponentByName()

findComponentByName(class_name): undefined | BaseComponent

Search a component in this entity and its children

Parameters

class_name: string

Returns

undefined | BaseComponent

Defined in

world/entity.ts:186


getComponent()

getComponent<Type>(ctor): undefined | Type

Type Parameters

Type extends BaseComponent

Parameters

ctor

Returns

undefined | Type

Inherited from

ComponentsContainer.getComponent

Defined in

world/components.ts:80


getComponentByName()

getComponentByName(class_name): undefined | BaseComponent

Parameters

class_name: string

Returns

undefined | BaseComponent

Inherited from

ComponentsContainer.getComponentByName

Defined in

world/components.ts:88


onAddedToWorld()

onAddedToWorld(_w): void

Parameters

_w: World

Returns

void

Defined in

world/entity.ts:69


onClick()

onClick(): void

executes the action of onClick in all components

Returns

void

Defined in

world/entity.ts:161


onUpdate()?

optional onUpdate(dt): void

Parameters

dt: number

Returns

void

Defined in

world/entity.ts:49


removeAllComponents()

removeAllComponents(): void

Returns

void

Inherited from

ComponentsContainer.removeAllComponents

Defined in

world/components.ts:95


removeChild()

removeChild(child): void

Parameters

child: Entity

Returns

void

Defined in

world/entity.ts:115


removeComponent()

removeComponent(component): void

Parameters

component: BaseComponent

Returns

void

Inherited from

ComponentsContainer.removeComponent

Defined in

world/components.ts:63


serialize()

serialize(): void

Returns

void

Defined in

world/entity.ts:130


update()

update(dt): void

propagate the update action into components and children

Parameters

dt: number

Returns

void

Defined in

world/entity.ts:72