API/core/Entity/

Entity

Entity, be used as components container.

Hierarchy: EngineObject

constructor 

new Entity(engine: Engine, name: string)

Create a entity.

Parameters

  • engine

    The engine the entity belongs to.

  • optionalname

instanceId ReadOnly

instanceId: number = ++EngineObject._instanceIdCounter

Engine unique id.

layer 

layer: Layer = ...

The layer the entity belongs to.

name 

name: string

The name of entity.

transform ReadOnly

transform: Transform

Transform component.

childCount 

get childCount(): number

Number of the children entities

children 

get children(): readonly <Entity[]>

The children entities

engine 

get engine(): Engine

Get the engine which the object belongs.

isActive 

get isActive(): boolean

Whether to activate locally.

set isActive(boolean): void

isActiveInHierarchy 

get isActiveInHierarchy(): boolean

Whether it is active in the hierarchy.

parent 

get parent(): Entity

The parent entity.

set parent(Entity): void

position 

get position(): Vector3

deprecated Use transform.position instead.

set position(Vector3): void

rotation 

get rotation(): Quaternion

deprecated Use transform.rotationQuaternion instead.

set rotation(Quaternion): void

scale 

get scale(): Vector3

deprecated Use transform.scale instead.

set scale(Vector3): void

scene 

get scene(): Scene

The scene the entity belongs to.

worldPosition 

get worldPosition(): Vector3

deprecated Use transform.worldPosition instead.

set worldPosition(Vector3): void

addChild 

addChild(child: Entity): void

Add child entity.

Parameters

  • child

    The child entity which want to be added.

addComponent 

addComponent<T extends Component>(type: T): T

Add component based on the component type.

Parameters

  • type

    The type of the component.

Returns

The component which has been added.

clearChildren 

clearChildren(): void

Clear children entities.

clone 

clone(): Entity

Clone

Returns

Cloned entity.

createChild 

createChild(name: string): Entity

Create child entity.

Parameters

  • optionalname

    The child entity's name.

Returns

The child entity.

destroy 

destroy(): void

Destroy self.

findByName 

findByName(name: string): Entity

Find child entity by name.

Parameters

  • name

    The name of the entity which want to be finded.

Returns

The component which be finded.

findByPath 

findByPath(path: string): Entity

Find the entity by path.

Parameters

  • path

    The path fo the entity eg: /entity.

Returns

The component which be finded.

getChild 

getChild(index: number): Entity

Find child entity by index.

Parameters

  • index

    The index of the child entity.

Returns

The component which be finded.

getComponent 

getComponent<T extends Component>(type: T): T

Get component which match the type.

Parameters

  • type

    The type of the component.

Returns

The first component which match type.

getComponents 

getComponents<T extends Component>(type: T, results: T[]): T[]

Get components which match the type.

Parameters

  • type

    The type of the component.

  • results

    The components which match type.

Returns

The components which match type.

getComponentsIncludeChildren 

getComponentsIncludeChildren<T extends Component>(type: T, results: T[]): T[]

Get the components which match the type of the entity and it's children.

Parameters

  • type

    The component type.

  • results

    The components collection.

Returns

The components collection which match the type.

getInvModelMatrix 

getInvModelMatrix(): Matrix

deprecated

removeChild 

removeChild(child: Entity): void

Remove child entitiy.

Parameters

  • child

    The child entity which want to be removed.