Skip to content

Class: Entity

The entity class provides an abstract base class for all scene objects that are considered to have "existence" in the scene, which can be considered as actual objects with positions and sizes. Entity class is an abstract class and cannot be instantiated. If you want to instantiate it, please use the Object 3D class.

Hierarchy

Constructors

Properties

Accessors

Methods

Constructors

constructor

new Entity(): Entity

Returns

Entity

Overrides

CEventDispatcher.constructor

Defined in

src/core/entities/Entity.ts:104

Properties

name

name: string = ''

The name of the object. The default value is an empty string.

Defined in

src/core/entities/Entity.ts:24


transform

transform: Transform

The Transform attached to this object.

Defined in

src/core/entities/Entity.ts:42


renderNode

renderNode: RenderNode

Renderer components

Defined in

src/core/entities/Entity.ts:47


entityChildren

entityChildren: Entity[]

An array containing sub objects of an object

Defined in

src/core/entities/Entity.ts:52


components

components: Map<any, IComponent>

List of components attached to an object

Defined in

src/core/entities/Entity.ts:57

Accessors

instanceID

get instanceID(): string

The unique identifier of the object.

Returns

string

Defined in

src/core/entities/Entity.ts:32


numChildren

get numChildren(): number

Returns the number of child objects of an object

Returns

number

Defined in

src/core/entities/Entity.ts:116


bound

get bound(): IBound

Returns

IBound

Defined in

src/core/entities/Entity.ts:277

set bound(value): void

Parameters

NameType
valueIBound

Returns

void

Defined in

src/core/entities/Entity.ts:282

Methods

getObjectByName

getObjectByName(name): Entity

Starting from the object itself, search for the object and its children, and return the first child object with a matching name. For most objects, the name is an empty string by default. You must manually set it to use this method.

Parameters

NameTypeDescription
namestringinput name

Returns

Entity

result Entity

Defined in

src/core/entities/Entity.ts:81


addChild

addChild(child): Entity

Add an object as a child of this object. You can add any number of objects. Any current parent object on the object passed here will be deleted, as an object can only have at most one parent object.

Parameters

NameTypeDescription
childEntitytarget child entity

Returns

Entity

Defined in

src/core/entities/Entity.ts:127


removeChild

removeChild(child): void

Remove the child objects of the object. You can remove any number of objects.

Parameters

NameTypeDescription
childEntityRemoved objects

Returns

void

Defined in

src/core/entities/Entity.ts:152


removeAllChild

removeAllChild(): void

Remove all children of the current object

Returns

void

Defined in

src/core/entities/Entity.ts:168


removeSelf

removeSelf(): this

Remove the current node from the parent

Returns

this

this

Defined in

src/core/entities/Entity.ts:179


removeChildByIndex

removeChildByIndex(index): void

Search for child nodes of objects and remove child objects with matching indexes.

Parameters

NameTypeDescription
indexnumberassign index

Returns

void

Defined in

src/core/entities/Entity.ts:189


hasChild

hasChild(child): boolean

Does the current object contain a certain object

Parameters

NameTypeDescription
childEntitycertain object

Returns

boolean

boolean

Defined in

src/core/entities/Entity.ts:203


removeFromParent

removeFromParent(): this

Remove the current node from the parent

Returns

this

this

Defined in

src/core/entities/Entity.ts:213


getChildByIndex

getChildByIndex(index): Entity

Search for object children and return the first child object with a matching index.

Parameters

NameTypeDescription
indexnumbermatching index

Returns

Entity

child entity

Defined in

src/core/entities/Entity.ts:227


getChildByName

getChildByName(name, loopChild?): any

Search for object children and return a child object with a matching name.

Parameters

NameTypeDefault valueDescription
namestringundefinedmatching name
loopChildbooleantrueWhether to traverse the children of the child object. The default value is true

Returns

any

result

Defined in

src/core/entities/Entity.ts:242


noticeComponents

noticeComponents(key, data): void

Parameters

NameType
keykeyof IComponent
dataany

Returns

void

Defined in

src/core/entities/Entity.ts:328


destroy

destroy(force?): void

release current object

Parameters

NameType
force?boolean

Returns

void

Overrides

CEventDispatcher.destroy

Defined in

src/core/entities/Entity.ts:339


dispatchEvent

dispatchEvent(event): void

Dispatch an event to all registered objects with a specific type of listener.

Parameters

NameType
eventCEvent

Returns

void

Inherited from

CEventDispatcher.dispatchEvent

Defined in

src/event/CEventDispatcher.ts:24


addEventListener

addEventListener(type, callback, thisObject, param?, priority?): number

register an event listener to event distancher.

Parameters

NameTypeDefault valueDescription
typestring | numberundefined{string} event type.
callbackFunctionundefined{Function} The callback function that handles events. This function must accept an Event3D object as its unique parameter and cannot return any result. for example: function(evt:Event3D):void.
thisObjectanyundefined{any} Current registration object, it'll call callback function.
paramanynull{any} the data binded to registered event, the default value is null.
prioritynumber0{number} The priority of callback function execution, with a larger set value having priority to call

Returns

number

Returns register event id

Inherited from

CEventDispatcher.addEventListener

Defined in

src/event/CEventDispatcher.ts:79


removeEventListener

removeEventListener(type, callback, thisObject): void

Remove Event Listening

Parameters

NameTypeDescription
typestring | number{string} event type
callbackFunction{Function} callback function of event register
thisObjectany{any} The current registered object.

Returns

void

Inherited from

CEventDispatcher.removeEventListener

Defined in

src/event/CEventDispatcher.ts:113


removeEventListenerAt

removeEventListenerAt(id): boolean

Remove an event Listening with id

Parameters

NameType
idnumber

Returns

boolean

Inherited from

CEventDispatcher.removeEventListenerAt

Defined in

src/event/CEventDispatcher.ts:133


removeAllEventListener

removeAllEventListener(eventType?): void

Specify a event type to remove all related event listeners eventType event type, set null to remove all event listeners

Parameters

NameTypeDefault value
eventTypestring | numbernull

Returns

void

Inherited from

CEventDispatcher.removeAllEventListener

Defined in

src/event/CEventDispatcher.ts:153


containEventListener

containEventListener(type): boolean

whether the target presence of a listener with event type.

Parameters

NameTypeDescription
typestring{string} event type.

Returns

boolean

Returns a boolean.

Inherited from

CEventDispatcher.containEventListener

Defined in

src/event/CEventDispatcher.ts:185


hasEventListener

hasEventListener(type, callback?, thisObject?): boolean

whether the target presence of a listener with event type. it associate more registration parameters.

Parameters

NameTypeDefault valueDescription
typestring | numberundefined{string} event name.
callbackFunctionnull{Function} callback function of event register.
thisObjectanynull{any} The registered object.

Returns

boolean

Returns a boolean.

Inherited from

CEventDispatcher.hasEventListener

Defined in

src/event/CEventDispatcher.ts:198