Class: Component

THING.Component()

Component The component.

Constructor

new Component()

The component that extends some useful interfaces. The interface work flow: 1. onAwake -> onStart/onStartAsync 2. onUpdate -> onLateUpdate
Source:
Example
class MyRotator extends THING.Component {
 onAwake(param) {
  this.speed = param['speed'];
 }

 onStart() {
  this.object.style.color = "0xFF0000";
 }

 onUpdate(deltaTime) {
  this.object.rotateY(this.speed * deltaTime);
 }
}

let box = new THING.Box();
box.addComponent(MyRotator, 'rotator');
box.rotator.speed = 100;

Extends

Members

OnLateUpdate :OnLateUpdateComponentCallback

When update before render.
Type:
Source:

active :Boolean

Active or deactive component.
Type:
  • Boolean
Overrides:
Source:

app :THING.App

Get application.
Type:
Overrides:
Source:

object :THING.BaseObject

Get object.
Type:
Overrides:
Source:

onActiveChange :OnActiveChangeComponentCallback

When active change callback function.
Type:
Overrides:
Source:

onAfterAdd :OnAfterAddComponentCallback

After add.
Type:
Overrides:
Source:

onAfterAddChild :OnAddChildComponentCallback

When after add child callback function.
Type:
Overrides:
Source:

onAfterRemove :OnAfterRemoveComponentCallback

After remove.
Type:
Overrides:
Source:

onAfterRemoveChild :OnRemoveChildComponentCallback

When after remove child callback function.
Type:
Overrides:
Source:

onBeforeAdd :OnBeforeAddComponentCallback

Before add.
Type:
Overrides:
Source:

onBeforeAddChild :OnAddChildComponentCallback

When before add child callback function.
Type:
Overrides:
Source:

onBeforeRemove :OnBeforeRemoveComponentCallback

Before remove.
Type:
Overrides:
Source:

onBeforeRemoveChild :OnRemoveChildComponentCallback

When before remove child callback function.
Type:
Overrides:
Source:

onCopy :OnCopyComponentCallback

When copy callback function.
Type:
Overrides:
Source:

onInit :OnInitComponentCallback

When initialize callback function.
Type:
Overrides:
Source:

onLoadResource :OnLoadResourceComponentCallback

When load resource callback function.
Type:
Overrides:
Source:

onParentChange :OnParentChangeComponentCallback

When change parent callback function.
Type:
Overrides:
Source:

onRefresh :OnRefreshComponentCallback

When refresh callback function.
Type:
Overrides:
Source:

onResize :OnResizeComponentCallback

When resize callback function.
Type:
Overrides:
Source:

onStartAsync :OnStartAsyncComponentCallback

When start to active component(just only once) in async mode and wait for finish, it's after onAwake() interface.
Type:
Source:

onUnloadResource :OnUnloadResourceComponentCallback

When unload resource callback function.
Type:
Overrides:
Source:

onUpdate :OnUpdateComponentCallback

When update callback function.
Type:
Overrides:
Source:

onVisibleChange :OnVisibleChangeComponentCallback

When visible change callback function.
Type:
Overrides:
Source:

startingPromise :Promise.<any>

Get the starting promise.
Type:
  • Promise.<any>
Source:

Methods

onAdd(object)

When add component.
Parameters:
Name Type Description
object THING.BaseObject The object.
Overrides:
Source:

onAwake(args)

When add component(just only once).
Parameters:
Name Type Description
args Object The constructor arguments.
Source:

onDestroy()

When remove component.
Source:

onDisable()

When deactivate it.
Source:

onEnable()

When active it.
Source:

onExport() → {Object}

Export data
Overrides:
Source:
Returns:
Type
Object

onImport(param)

Import data
Parameters:
Name Type Description
param Object The import data.
Overrides:
Source:

onRemove()

When remove component.
Overrides:
Source:

onStart(args)

When start to active component(just only once), it's after onAwake() interface.
Parameters:
Name Type Description
args Object The constructor arguments.
Source: