Skip to content

@tmrw-realityos/world


@tmrw-realityos/world / Entity

Class: Entity

Defined in: world/entity.ts:31

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

Constructor

new Entity(): Entity

Defined in: world/entity.ts:55

Returns

Entity

Overrides

ComponentsContainer.constructor

Properties

children

children: Entity[] = []

Defined in: world/entity.ts:45


components

components: BaseComponent[] = []

Defined in: world/components.ts:49

Inherited from

ComponentsContainer.components


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 Signature

get transform(): Transform

Defined in: world/entity.ts:51

Returns

Transform

Methods

addChild()

addChild(child): void

Defined in: world/entity.ts:95

Parameters

child

Entity

Returns

void


addComponent()

addComponent(component): BaseComponent

Defined in: world/components.ts:53

Parameters

component

BaseComponent

Returns

BaseComponent

Inherited from

ComponentsContainer.addComponent


clear()

clear(): void

Defined in: world/entity.ts:62

Returns

void


configure()

configure(o): void

Defined in: world/entity.ts:132

Parameters

o

EntityDescriptor

Returns

void


configureComponents()

configureComponents(info): void

Defined in: world/components.ts:101

Parameters

info
components?

[string, BaseComponent][]

Returns

void

Inherited from

ComponentsContainer.configureComponents


executeMethodInComponents()

executeMethodInComponents(func_name, data): void

Defined in: world/entity.ts:197

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

Parameters

func_name

string

data

unknown

Returns

void


findChildById()

findChildById(uid): undefined | Entity

Defined in: world/entity.ts:83

Parameters

uid

string

Returns

undefined | Entity


findChildByName()

findChildByName(name): undefined | Entity

Defined in: world/entity.ts:89

Parameters

name

string

Returns

undefined | Entity


findComponent()

findComponent<Type>(ctor): undefined | Type

Defined in: world/entity.ts:173

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

Type Parameters

Type

Type extends BaseComponent

Parameters

ctor

(...args) => Type

Returns

undefined | Type


findComponentByName()

findComponentByName(class_name): undefined | BaseComponent

Defined in: world/entity.ts:186

Search a component in this entity and its children

Parameters

class_name

string

Returns

undefined | BaseComponent


getComponent()

getComponent<Type>(ctor): undefined | Type

Defined in: world/components.ts:81

Type Parameters

Type

Type extends BaseComponent

Parameters

ctor

(...args) => Type

Returns

undefined | Type

Inherited from

ComponentsContainer.getComponent


getComponentByName()

getComponentByName(class_name): undefined | BaseComponent

Defined in: world/components.ts:89

Parameters

class_name

string

Returns

undefined | BaseComponent

Inherited from

ComponentsContainer.getComponentByName


onAddedToWorld()

onAddedToWorld(_w): void

Defined in: world/entity.ts:69

Parameters

_w

World

Returns

void


onClick()

onClick(): void

Defined in: world/entity.ts:161

executes the action of onClick in all components

Returns

void


onUpdate()?

optional onUpdate(dt): void

Defined in: world/entity.ts:49

Parameters

dt

number

Returns

void


removeAllComponents()

removeAllComponents(): void

Defined in: world/components.ts:96

Returns

void

Inherited from

ComponentsContainer.removeAllComponents


removeChild()

removeChild(child): void

Defined in: world/entity.ts:115

Parameters

child

Entity

Returns

void


removeComponent()

removeComponent(component): void

Defined in: world/components.ts:64

Parameters

component

BaseComponent

Returns

void

Inherited from

ComponentsContainer.removeComponent


serialize()

serialize(): void

Defined in: world/entity.ts:130

Returns

void


update()

update(dt): void

Defined in: world/entity.ts:72

propagate the update action into components and children

Parameters

dt

number

Returns

void