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
↳
Entity
↳↳
Object3D
Constructors
Properties
Accessors
Methods
- getObjectByName
- addChild
- removeChild
- removeAllChild
- removeSelf
- removeChildByIndex
- hasChild
- removeFromParent
- getChildByIndex
- getChildByName
- noticeComponents
- destroy
- dispatchEvent
- addEventListener
- removeEventListener
- removeEventListenerAt
- removeAllEventListener
- containEventListener
- hasEventListener
Constructors
constructor
• new Entity(): Entity
Returns
Overrides
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
Name | Type |
---|---|
value | IBound |
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
Name | Type | Description |
---|---|---|
name | string | input name |
Returns
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
Name | Type | Description |
---|---|---|
child | Entity | target child entity |
Returns
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
Name | Type | Description |
---|---|---|
child | Entity | Removed 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
Name | Type | Description |
---|---|---|
index | number | assign index |
Returns
void
Defined in
src/core/entities/Entity.ts:189
hasChild
▸ hasChild(child
): boolean
Does the current object contain a certain object
Parameters
Name | Type | Description |
---|---|---|
child | Entity | certain 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
Name | Type | Description |
---|---|---|
index | number | matching index |
Returns
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
Name | Type | Default value | Description |
---|---|---|---|
name | string | undefined | matching name |
loopChild | boolean | true | Whether 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
Name | Type |
---|---|
key | keyof IComponent |
data | any |
Returns
void
Defined in
src/core/entities/Entity.ts:328
destroy
▸ destroy(force?
): void
release current object
Parameters
Name | Type |
---|---|
force? | boolean |
Returns
void
Overrides
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
Name | Type |
---|---|
event | CEvent |
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
Name | Type | Default value | Description |
---|---|---|---|
type | string | number | undefined | {string} event type. |
callback | Function | undefined | {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. |
thisObject | any | undefined | {any} Current registration object, it'll call callback function. |
param | any | null | {any} the data binded to registered event, the default value is null. |
priority | number | 0 | {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
Name | Type | Description |
---|---|---|
type | string | number | {string} event type |
callback | Function | {Function} callback function of event register |
thisObject | any | {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
Name | Type |
---|---|
id | number |
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
Name | Type | Default value |
---|---|---|
eventType | string | number | null |
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
Name | Type | Description |
---|---|---|
type | string | {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
Name | Type | Default value | Description |
---|---|---|---|
type | string | number | undefined | {string} event name. |
callback | Function | null | {Function} callback function of event register. |
thisObject | any | null | {any} The registered object. |
Returns
boolean
Returns a boolean.
Inherited from
CEventDispatcher.hasEventListener