Class: Mesh

THING.Mesh(param)

Mesh The mesh object.

Constructor

new Mesh(param)

The mesh object that with custom geometry info in scene.
Parameters:
Name Type Description
param Object The initial parameters.
Source:

Extends

Members

active :Boolean

Get/Set active state, would not change any children active.
Type:
  • Boolean
Overrides:
Source:
Example
let box = new THING.Box();
	let box2 = new THING.Box({parent: box});
	box.active = false;
	// @expect(box2.active == true);
	// @expect(box.active == false);

alwaysOnTop :Boolean

Enable/Disable always on top.
Type:
  • Boolean
Overrides:
Source:
Example
// Keep object render as the top of render layer
object.alwaysOnTop = true;

angles :Array.<Number>

Get/Set angles of the world space.
Type:
  • Array.<Number>
Overrides:
Source:

app :THING.App

Get application.
Type:
Overrides:
Source:
Example
let object = new THING.BaseObject();
let app = object.app;
let ret = app == THING.App.current;
// @expect(ret == true)

body :THING.BodyObject

Get the body object.
Type:
Overrides:
Source:

boundingBox :THING.Box3

Get bounding box recursively.
Type:
  • THING.Box3
Overrides:
Source:
Example
let boundingBox = object.boundingBox;
	if (boundingBox.halfSize[1] > 100) {
		console.log('The object is so tall');
	}

brothers :THING.Selector

Get the brothers.
Type:
Overrides:
Source:
Example
let box1 = new THING.Box();
	let box2 = new THING.Box({parent: box1});
	let box3 = new THING.Box({parent: box1});
	let brothers = box3.brothers;
 // @expect(brothers.length == 1);

children :THING.Selector

Get children.
Type:
Overrides:
Source:
Example
let object = new THING.BaseObject();
let child= new THING.BaseObject({parent: object});
let children = object.children;
let ret = children.length == 1;
// @expect(ret == true)

(readonly) components :Map.<String, THING.BaseComponent>

Get all components.
Type:
Overrides:
Source:
Example
let obj = new THING.BaseObject();;
obj.addComponent(new THING.BaseComponent(), 'component1');
obj.addComponent(new THING.BaseComponent(), 'component2');
// @expect(obj.components.size == 2)

data :Object

Get mesh data.
Type:
  • Object
Source:

id :String

Get/Set id.
Type:
  • String
Overrides:
Source:
Example
let object = new THING.BaseObject();
object.id = 'DEVICE_007';
// @expect(object.id == 'DEVICE_007')

inherit :InheritData

Get the inherit.
Type:
Overrides:
Source:
Example
object.inherit.style = THING.InheritType.Jump;
	object.inherit.visible = THING.InheritType.Break;
	object.inherit.pickable = THING.InheritType.Stop;

isFlying :Boolean

Get the flying state.
Type:
  • Boolean
Overrides:
Source:

isMesh :Boolean

Check whether it's Mesh type or inherit from it.
Type:
  • Boolean
Source:

keepSize :Boolean

Keep object's size in screen(auto adjust object's scale).
Type:
  • Boolean
Overrides:
Source:
Example
let keepSize = object.keepSize;
	if (keepSize) {
		console.log('object is keep size to render');
	}

layerMask :Number

Get/Set layer mask, it would use AND operator to test with camera's layer mask. If it's equals to 0 then indicates it can not render in this camera. The default value is 1. It CAN NOT work with instanced drawing mode for now.
Type:
  • Number
Overrides:
Source:
Example
// Hide object by changing layer mask
object.layerMask = 0;

localAngles :Array.<Number>

Get/Set angles of the inertial space.
Type:
  • Array.<Number>
Overrides:
Source:

localPosition :Array.<Number>

Get/Set local(offset) position of the parent space.
Type:
  • Array.<Number>
Overrides:
Source:

localQuaternion :Array.<Number>

Get/Set quaternion of the inertial space.
Type:
  • Array.<Number>
Overrides:
Source:

localRotation :Array.<Number>

Get/Set angles of the inertial space.
Type:
  • Array.<Number>
Overrides:
Source:

localScale :Array.<Number>

Get/Set scale of the self coordinate system.
Type:
  • Array.<Number>
Overrides:
Source:

name :String

Get/Set name.
Type:
  • String
Overrides:
Source:
Example
object.name = 'MyObject';

orientedBox :OrientedBoxResult

Get oriented box recursively.
Type:
Overrides:
Source:
Example
let orientedBox = object.orientedBox;
	if (orientedBox.angles[1] > 0) {
		console.log('The object has rotated by Y-axis');
	}

parent :THING.BaseObject

Get/Set parent.
Type:
Overrides:
Source:
Example
let parent = new THING.BaseObject();
 let child = new THING.BaseObject({parent: parent});
	let ret = child.parent == parent;
	// @expect(ret == true);

parents :THING.Selector

Get the parents.
Type:
Overrides:
Source:
Example
let box1 = new THING.Box();
	let box2 = new THING.Box({parent: box1});
	let parents = box2.parents;
 // @expect(parents.length == 2);

pickable :Boolean

Get/Set the pickable state.
Type:
  • Boolean
Overrides:
Source:
Example
let object = new THING.Box();
	object.pickable = false;

pivot :Array.<Number>

Get/Set pivot in self oriented box from [left, bottom, back].
Type:
  • Array.<Number>
Overrides:
Source:
Example
// Make object origin to [right, top, front] position
	object.pivot = [1, 1, 1];

position :Array.<Number>

Get/Set world position of the world space.
Type:
  • Array.<Number>
Overrides:
Source:

quaternion :Array.<Number>

Get/Set quaternion of the world space.
Type:
  • Array.<Number>
Overrides:
Source:

queryable :Boolean

Enable/Disable queryable.
Type:
  • Boolean
Overrides:
Source:
Example
let object = new THING.BaseObject();
object.name = 'Hidden';
let ret = app.query('Hidden');
// @expect(ret[0].name = 'Hidden')
object.queryable = false;
ret = app.query('Hidden');
// @expect(ret.length = 0)

relationships :Array.<THING.Relationship>

Get/Set relationships.
Type:
Overrides:
Source:
Example
let object = new THING.Object3D();
let source = new THING.Object3D();
let target = new THING.Object3D();
let relationship = new THING.Relationship({
     type: 'control',
     source: source,
     target: target
});
object.addRelationship(relationship);
let ret = object.relationships[0].type == 'control';
// @expect(ret == true)

rotation :Array.<Number>

Get/Set angles of the world space.
Type:
  • Array.<Number>
Overrides:
Source:

scale :Array.<Number>

Get/Set scale of the world coordinate system.
Type:
  • Array.<Number>
Overrides:
Source:

style :THING.Style

Get/Set style.
Type:
Overrides:
Source:
Example
let style = object.style;
	style.color = 'red';
	style.opacity = 0.1;

tags :Set.<String>

Get/Set tags.
Type:
  • Set.<String>
Overrides:
Source:
Example
// Get tags
	let tags = object.tags;
 console.log(tags);

 // Set tags by array
 object.tags = ['one','two','three'];

 // Set tags by set
 object.tags = new Set(['one','two','three']);

type :String

Get type.
Type:
  • String
Overrides:
Source:
Example
let object = new THING.BaseObject();
let type = object.type;
// @expect(type == 'BaseObject')

userData :Object

Get/Set user data.
Type:
  • Object
Overrides:
Source:
Example
let object = new THING.BaseObject();
object.userData['Notebook'] = {
	name: 'FlyingCar',
	price: 100
};
let name = object.userData['Notebook'].name;
// @expect(name == 'FlyingCar')
let price = object.userData['Notebook'].price
// @expect(price == 100)

uuid :String

Get/Set uuid.
Type:
  • String
Overrides:
Source:
Example
let object = new THING.BaseObject({uuid: 10000});
// @expect(object.uuid == 10000)
object.uuid = THING.Math.generateUUID();
// @expect(object.id != 10000)

visible :Boolean

Get/Set visible state.
Type:
  • Boolean
Overrides:
Source:
Example
let object = new THING.Box();
	// @expect(object.visible == true)
	object.visible = false;
	// @expect(object.visible == false)

Methods

add(object, options) → {Boolean}

Add object as child.
Parameters:
Name Type Description
object THING.BaseObject The object what you want to add.
options Object The options.
Properties
Name Type Attributes Default Description
subNodeName String The sub node name.
localPosition Array.<Number> The local position of parent or sub node.
attachMode Boolean <optional>
true True indicates to keep world transform.
ignoreScale Boolean <optional>
false True indicates ignore scale when add it as child.
Overrides:
Source:
Returns:
Type
Boolean
Example
// Keep local transform of box to be added to object
	object.add(new THING.Box({ localPosition: [0, 10, 0]}), { attachMode: false });

addComponent(component, name, args?) → {Boolean}

Add component.
Parameters:
Name Type Description
component THING.BaseComponent | Object The component class or component object.
name String The name.
args? Object The initial arguments to create component.
Overrides:
Source:
Returns:
Type
Boolean
Example
let obj = new THING.BaseObject();;
obj.addComponent(new THING.BaseComponent(), 'myComponent');
// @expect(obj.myComponent != null)

clone(recursive, parent) → {THING.Object3D}

Clone the object, if the clone target has been loaded, clone the node directly, otherwise use url clone.
Parameters:
Name Type Description
recursive Boolean True indicates to load all children resources.
parent THING.BaseObject The parent object, default is app root object.
Overrides:
Source:
Returns:
Type
THING.Object3D
Example
// Clone the object and move up
	let otherObject = object.clone();
	otherObject.translateY(10);

copy(object) → {Promise.<any>}

Copy from object (except UUID attribute and parent). It would reload resource.
Parameters:
Name Type Description
object THING.BaseObject The source object.
Overrides:
Source:
Returns:
Type
Promise.<any>
Example
// Copy the object from query result
	let sourceObject = app.query('#master')[0];
	if (sourceObject) {
		object.copy(sourceObject);
	}

destroy() → {Boolean}

Destroy.
Overrides:
Source:
Returns:
Type
Boolean
Example
let object = new THING.BaseObject();
// @expect(object.destroyed == false);
object.destroy();
// @expect(object.destroyed == true)

distanceTo(target) → {Number}

Get the distance to world position.
Parameters:
Name Type Description
target THING.Object3D | Array.<Number> The target object or world position.
Overrides:
Source:
Returns:
Type
Number
Example
let distance = object.distanceTo([0, 10, 0]);
	if (distance > 5000) {
		console.log('object is so far from specified position');
	}

fadeIn(param)

Fade object in.
Parameters:
Name Type Description
param LerpArgs The parameters.
Overrides:
Source:

fadeOut(param)

Fade object out.
Parameters:
Name Type Description
param LerpArgs The parameters.
Overrides:
Source:

fit(param)

Auto set it to best position of object.
Parameters:
Name Type Description
param Object The parameters.
Properties
Name Type Description
target THING.BaseObject The target object.
Overrides:
Source:
Example
THING.App.current.camera.fit(otherTarget);

flyTo(param)

Fly to specified position in duration.
Parameters:
Name Type Description
param THING.BaseObject | LerpFlyToArgs The object or parameters.
Overrides:
Source:
Example
object.flyTo({
		target: otherTarget,
		horzAngle: 0,
		vertAngle: 45
	});

getAllComponents() → {Array.<THING.BaseComponent>}

Get all components(it would create all registered components).
Overrides:
Source:
Returns:
Type
Array.<THING.BaseComponent>
Example
let obj = new THING.BaseObject();;
obj.addComponent(new THING.BaseComponent(), 'component1');
obj.addComponent(new THING.BaseComponent(), 'component2');
let components = obj.getAllComponents();
// @expect(components.length == 2)

getAttribute(name) → {*}

Get attribute value.
Parameters:
Name Type Description
name String The attribute name, it can use like 'a/b/c' to access attribute.
Overrides:
Source:
Returns:
Type
*
Example
let object = new THING.BaseObject();
object.userData['power'] = 100;
let power = object.getAttribute('userData/power');
// @expect(power == 100)

getComponentByName(name) → {THING.BaseComponent}

Get component by name.
Parameters:
Name Type Description
name String The name.
Overrides:
Source:
Returns:
Type
THING.BaseComponent
Example
let obj = new THING.BaseObject();;
obj.addComponent(new THING.BaseComponent(), 'myComponent');
let component = obj.getComponentByName('myComponent');
// @expect(component != null)

getComponentByType(type) → {THING.BaseComponent}

Get component by type.
Parameters:
Name Type Description
type * The component type.
Overrides:
Source:
Returns:
Type
THING.BaseComponent
Example
let obj = new THING.BaseObject();;
obj.addComponent(new THING.BaseComponent(), 'myComponent');
let component = obj.getComponentByType(THING.BaseComponent);
// @expect(component != null)

getComponentsByType(type) → {Array.<THING.BaseComponent>}

Get components by type.
Parameters:
Name Type Description
type * The component type.
Overrides:
Source:
Returns:
Type
Array.<THING.BaseComponent>
Example
let obj = new THING.BaseObject();;
obj.addComponent(new THING.BaseComponent(), 'component1');
obj.addComponent(new THING.BaseComponent(), 'component2');
let components = obj.getComponentsByType(THING.BaseComponent);
// @expect(components.length == 2)

getNormal() → {Float32Array}

Get the vertex normal of the mesh.
Source:
Returns:
Type
Float32Array

getPosition() → {Float32Array}

Get the vertex of the mesh.
Source:
Returns:
Type
Float32Array

getUv() → {Float32Array}

Get the vertex uv of the mesh.
Source:
Returns:
Type
Float32Array

getVisible() → {Boolean}

Get visible state.
Overrides:
Source:
Returns:
Type
Boolean
Example
let visible = object.getVisible();
	if (visible) {
		console.log('object is showing');
	}

hasAttribute(name) → {Boolean}

Check whether has attribute.
Parameters:
Name Type Description
name String The attribute name, it can use like 'a/b/c' to access attribute.
Overrides:
Source:
Returns:
Type
Boolean
Example
let object = new THING.BaseObject();
object.userData['power'] = 100;
let ret = object.hasAttribute('userData/power');
// @expect(ret == true)

hasChildren() → {Boolean}

Check whether has any children.
Overrides:
Source:
Returns:
Type
Boolean
Example
let parent = new THING.BaseObject();
 let child = new THING.BaseObject({parent: parent});
	let ret = parent.hasChildren();
	// @expect(ret == true);

hasComponent(name) → {Boolean}

Check whether has component.
Parameters:
Name Type Description
name String The name.
Overrides:
Source:
Returns:
Type
Boolean
Example
let obj = new THING.BaseObject();;
obj.addComponent(new THING.BaseComponent(), 'myComponent');
let ret = obj.hasComponent('myComponent')
// @expect(ret == true)

isBrotherOf(object) → {Boolean}

Check whether it's brother.
Parameters:
Name Type Description
object THING.BaseObject The object to check.
Overrides:
Source:
Returns:
Type
Boolean
Example
let parent = new THING.BaseObject();
let child1 = new THING.BaseObject({parent: parent});
let child2 = new THING.BaseObject({parent: parent});
let ret = child1.isBrotherOf(child2);
 // @expect(ret == true);

isChildOf(object) → {Boolean}

Check whether it's child.
Parameters:
Name Type Description
object THING.BaseObject The object to check.
Overrides:
Source:
Returns:
Type
Boolean
Example
let parent = new THING.BaseObject();
let child = new THING.BaseObject({parent: parent});
let ret = child.isChildOf(parent);
 // @expect(ret == true);

loadResource(recursiveopt, optionsopt) → {Promise.<any>}

Load resource.
Parameters:
Name Type Attributes Default Description
recursive Boolean <optional>
true True indicates to load all children resources.
options Object <optional>
{} The load options.
Overrides:
Source:
Returns:
Type
Promise.<any>
Example
// Wait the object to load resource completed
	await object.loadResource();

localToWorld(position, ignoreScaleopt) → {Array.<Number>}

Convert local position to world position. same as call parent selfToWorld.
Parameters:
Name Type Attributes Default Description
position Array.<Number> The local position. (The local position is relative to the parent)
ignoreScale Boolean <optional>
false True indicates ignore scale factor.
Overrides:
Source:
Returns:
Type
Array.<Number>
Example
let parentObj = new THING.Object3D({
	position: [0, 5, 0]
});

let childObj = new THING.Object3D({
	localPosition: [0, 10, 0],
 parent: parentObj
});

let worldPos = childObj.localToWorld([0, -5, 0]);

// print [0, 0, 0]
console.log(worldPos);

lookAt(target, param)

Look at object or position.
Parameters:
Name Type Description
target Array.<Number> | THING.Object3D The target what to look at.
param LookAtArgs The parameters.
Overrides:
Source:

makeInstancedDrawing(value, options) → {Boolean}

Make object in instanced drawing mode.
Parameters:
Name Type Description
value Boolean True indicates enable instanced drawing mode.
options Object The options.
Properties
Name Type Attributes Default Description
renderMode String <optional>
'InstancedRendering' The render mode(could be 'SharedRendering/InstancedRendering').
Overrides:
Source:
Returns:
Type
Boolean
Example
// Make object render in instanced drawing mode
	if (object.makeInstancedDrawing()) {
		console.log('Enable instanced drawing');
	}

movePath(value, param)

Move object with path in duration.
Parameters:
Name Type Description
value Array.<Array.<Number>> The path of position.
param MovePathLerpArgs The parameters.
Overrides:
Source:
Example
let path = [
	[100, 0, 0],
	[100, 0, 100],
	[0, 0, 100],
[0, 0, 0],
];

object.movePath(path.map(point => object.selfToWorld(point)), {
	duration: 5 * 1000,
	loopType: THING.LoopType.Repeat,
});

moveTo(value, param)

Move object in duration.
Parameters:
Name Type Description
value Array.<Number> The position.
param MovePathLerpArgs The parameters.
Overrides:
Source:
Example
object.moveTo(object.selfToWorld(THING.Math.randomVector([-200, -5, -200], [200, 5, 200])), {
		loopType: THING.LoopType.PingPong,
		duration: THING.Math.randomInt(1000, 5000)
});

off(type, condition?, tag)

Unregister event.
Parameters:
Name Type Description
type String The event type.
condition? String The condition to select objects.
tag String The event tag.
Overrides:
Source:
Example
let object = new THING.BaseObject();
let markOff = 0;
object.on('testOff', function(ev) {
		markOff = 1;
});
object.trigger('testOff');
// @expect(markOff == 1);
markOff = 0;
object.off('testOff');
object.trigger('testOff');
// @expect(markOff == 0);

on(type, condition, callback, tag, priority, options)

Register event.
Parameters:
Name Type Description
type String The event type.
condition String The condition to select objects.
callback function The callback function.
tag String The event tag.
priority Number The priority value(default is 0, higher value will be processed first).
options ObjectEventOptions The options.
Overrides:
Source:
Example
let object = new THING.BaseObject();
let mark = 0;
object.on('click', function(ev){
	mark = 1;
}, 'MyClick');
object.trigger('click');
// @expect(mark == 1)
let mark2 = 0;
object.on('click', '.Box', function(ev){
	mark2 = 1;
}, 'MyClick');
// @expect(mark2 == 0)

once(type, condition?, callback?, tag?, priority?, options?)

Register event what just trigger once time.
Parameters:
Name Type Description
type String The event type.
condition? String The condition to select objects.
callback? function The callback function.
tag? String The event tag.
priority? Number The priority value(default is 0, higher value will be processed first).
options? ObjectEventOptions The options.
Overrides:
Source:
Example
let object = new THING.BaseObject();
let markOnce = 0;
object.once('testOnce', function(ev) {
		markOnce = 1;
});
object.trigger('testOnce');
// @expect(markOnce == 1);
markOnce = 0;
object.trigger('testOnce');
// @expect(markOnce == 0);

pauseEvent(type, condition, tag)

Pause event.
Parameters:
Name Type Description
type String The event type.
condition String The condition to select objects.
tag String The event tag.
Overrides:
Source:
Example
let object = new THING.BaseObject();
let markPause = 0;
object.on('testPause', function(ev) {
		markPause = 1;
});
object.trigger('testPause');
// @expect(markPause == 1);
markPause = 0;
object.pauseEvent('testPause');
object.trigger('testPause');
// @expect(markPause == 0);

pauseFlying()

Pause flying.
Overrides:
Source:
Example
object.pauseFlying();

pauseMoving()

Pause moving.
Overrides:
Source:
Example
object.pauseMoving();

pauseRotating()

Pause rotating.
Overrides:
Source:
Example
object.pauseRotating();

pauseScaling()

Pause scaling.
Overrides:
Source:
Example
object.pauseScaling();

pauseUVTransform(slotType)

Pause UV transform.
Parameters:
Name Type Description
slotType ImageSlotType The slot type of style.
Overrides:
Source:
Example
object.pauseUVTransform(THING.ImageSlotType.Map);

promoteNode(name, parent) → {THING.Object3D}

Promote node as child object.
Parameters:
Name Type Description
name String The node name.
parent THING.Object3D The parent object, if it's null then indicates use current object as parent.
Overrides:
Source:
Returns:
Type
THING.Object3D
Example
// Promote all sub nodes
	var nodeNames = entity.body.nodeNames;
	nodeNames.forEach(name => {
		entity.promoteNode(name);
	});

query(condition, options?) → {THING.Selector}

Query children by condition.
Parameters:
Name Type Description
condition String The condition to select objects.
options? ObjectQueryOptions The options.
Overrides:
Source:
Returns:
Type
THING.Selector
Example
let object = new THING.BaseObject();
let child= new THING.BaseObject({parent: object});
child.userData = {power: 1000};
let children = object.children.query('[userData/power>100]');
let ret = children.length == 1;
// @expect(ret == true)

queryById(condition, options) → {THING.Selector}

Query children by id.
Parameters:
Name Type Description
condition String The condition to select objects.
options ObjectQueryOptions The options.
Overrides:
Source:
Returns:
Type
THING.Selector
Example
let object = new THING.BaseObject();
let child1= new THING.BaseObject({parent: object});
child1.id = '10000';
let child2= new THING.BaseObject({parent: object});
let result = object.queryById('10000');
let ret = result[0].id == '10000';
 //@expect(ret == true)

queryByName(condition, options) → {THING.Selector}

Query children by name.
Parameters:
Name Type Description
condition String The condition to select objects.
options ObjectQueryOptions The options.
Overrides:
Source:
Returns:
Type
THING.Selector
Example
let object = new THING.BaseObject();
let child= new THING.BaseObject({parent: object, name: 'liming'});
let result = object.queryByName('liming');
let ret = result[0].name == 'liming';
// @expect(ret == true)

queryByRegExp(condition, options) → {THING.Selector}

Query children by reg exp.
Parameters:
Name Type Description
condition String The condition to select objects.
options ObjectQueryOptions The options.
Overrides:
Source:
Returns:
Type
THING.Selector
Example
let object = new THING.BaseObject();
let child1= new THING.BaseObject({parent: object, name: 'car1'});
let child2= new THING.BaseObject({parent: object, name: 'car2'});
let result = object.queryByRegExp(/car/);
let ret = result.length == 2;
 //@expect(ret == true)

queryByTags(condition, options) → {THING.Selector}

Query children by tag.
Parameters:
Name Type Description
condition String The condition to select objects.
options ObjectQueryOptions The options.
Overrides:
Source:
Returns:
Type
THING.Selector
Example
let object = new THING.BaseObject();
let child1= new THING.Object3D({parent: object, name: 'car1'});
child1.tags.add('testCar');
let child2= new THING.BaseObject({parent: object, name: 'car2'});
let result = object.queryByTags('testCar');
let ret = result.length == 1;
 //@expect(ret == true)

queryByType(condition, options) → {THING.Selector}

Query children by type.
Parameters:
Name Type Description
condition String The condition to select objects.
options ObjectQueryOptions The options.
Overrides:
Source:
Returns:
Type
THING.Selector
Example
let object = new THING.BaseObject();
let child1= new THING.Box({parent: object, id: '10000'});
let child2= new THING.BaseObject({parent: object});
let result = object.queryByType('Box');
let ret = result[0].id == '10000';
 //@expect(ret == true)

queryByUUID(condition, options) → {THING.Selector}

Query children by uuid.
Parameters:
Name Type Description
condition String The condition to select objects.
options ObjectQueryOptions The options.
Overrides:
Source:
Returns:
Type
THING.Selector
Example
let object = new THING.BaseObject();
let child1= new THING.BaseObject({parent: object, uuid: '1000'});
let child2= new THING.BaseObject({parent: object});
let result = object.queryByUUID('1000');
let ret = result[0].uuid == '1000';
 //@expect(ret == true)

queryByUserData(condition, options) → {THING.Selector}

Query children by userData.
Parameters:
Name Type Description
condition String The condition to select objects.
options ObjectQueryOptions The options.
Overrides:
Source:
Returns:
Type
THING.Selector
Example
let object = new THING.BaseObject();
let child1= new THING.Box({parent: object});
child1.userData['power'] = 100;
let child2= new THING.BaseObject({parent: object});
let result = object.queryByUserData('power=100');
let ret = result[0].userData.power == 100;
 //@expect(ret == true)

remove(object) → {Boolean}

Remove child object.
Parameters:
Name Type Description
object THING.BaseObject The object what you want to remove.
Overrides:
Source:
Returns:
Type
Boolean
Example
let parent = new THING.BaseObject();
let child = new THING.BaseObject();
parent.add(child);
let ret = child.isChildOf(parent);
 // @expect(ret == true);
	parent.remove(child);
ret = child.isChildOf(parent);
	// @expect(ret == false);

removeAllComponents()

Remove all components.
Overrides:
Source:
Example
let obj = new THING.BaseObject();;
obj.addComponent(new THING.BaseComponent(), 'component1');
obj.addComponent(new THING.BaseComponent(), 'component2');
obj.removeAllComponents();
// @expect(obj.components.size == 0)

removeComponent(name)

Remove component.
Parameters:
Name Type Description
name String The name.
Overrides:
Source:
Example
let obj = new THING.BaseObject();;
obj.addComponent(new THING.BaseComponent(), 'myComponent');
obj.removeComponent('myComponent');
// @expect(obj.components.size == 0)

resumeEvent(type, condition, tag)

Resume event.
Parameters:
Name Type Description
type String The event type.
condition String The condition to select objects.
tag String The event tag.
Overrides:
Source:
Example
let object = new THING.BaseObject();
let markResume = 0;
object.on('testResume', function(ev) {
		markResume = 1;
});
object.trigger('testResume');
// @expect(markResume == 1);
markResume = 0;
object.pauseEvent('testResume');
object.trigger('testResume');
// @expect(markResume == 0);
object.resumeEvent('testResume');
object.trigger('testResume');
// @expect(markResume == 1);

resumeFlying()

Resume flying.
Overrides:
Source:
Example
object.resumeFlying();

resumeMoving()

Resume moving.
Overrides:
Source:
Example
object.resumeMoving();

resumeRotating()

Resume rotating.
Overrides:
Source:
Example
object.resumeRotating();

resumeScaling()

Resume scaling.
Overrides:
Source:
Example
object.resumeScaling();

resumeUVTransform(slotType)

Resume UV transform.
Parameters:
Name Type Description
slotType ImageSlotType The slot type of style.
Overrides:
Source:
Example
object.resumeUVTransform(THING.ImageSlotType.Map);

rotate(axis, angle)

Rotate on axis by angle in self space.
Parameters:
Name Type Description
axis Array.<Number> The axis in self space.
angle Number The degree.
Overrides:
Source:
Example
let box = new THING.Box();
	box.rotate(THING.Utils.xAxis, 45);
	

rotateOnAxis(axis, angle)

Rotate on axis by angle in self space.
Parameters:
Name Type Description
axis Array.<Number> The axis in self space.
angle Number The degree.
Overrides:
Source:
Example
let box = new THING.Box();
	box.rotateOnAxis(THING.Utils.xAxis, 45);
	

rotateTo(value, param)

Rotate object in duration.
Parameters:
Name Type Description
value Array.<Number> The angles.
param LerpWithSpaceTypeArgs The parameters.
Overrides:
Source:
Example
object.rotateTo([0, 360, 0], {
	loopType: THING.LoopType.Repeat,
	duration: 10 * 1000
});

rotateX(angle)

Rotate on x-axis in self coordinates.
Parameters:
Name Type Description
angle Number The angle.
Overrides:
Source:

rotateY(angle)

Rotate on y-axis in self coordinates.
Parameters:
Name Type Description
angle Number The angle.
Overrides:
Source:

rotateZ(angle)

Rotate on z-axis in self coordinates.
Parameters:
Name Type Description
angle Number The angle.
Overrides:
Source:

scaleTo(value, param)

Scale object in duration.
Parameters:
Name Type Description
value Array.<Number> The scale.
param LerpWithSpaceTypeArgs The parameters.
Overrides:
Source:
Example
object.scaleTo(THING.Math.randomVector([1, 1, 1], [3, 3, 3]), {
	loopType: THING.LoopType.PingPong,
	duration: THING.Math.randomInt(1000, 5000)
});

selfToWorld(position, ignoreScaleopt) → {Array.<Number>}

Convert self position to world position.
Parameters:
Name Type Attributes Default Description
position Array.<Number> The self position.
ignoreScale Boolean <optional>
false True indicates ignore scale factor.
Overrides:
Source:
Returns:
Type
Array.<Number>
Example
let obj = new THING.Object3D({ position: [0, 15, 0] });
let worldPos = obj.selfToWorld([0, -15, 0]);
// print [0, 0, 0]
console.log(worldPos);

setAttribute(name, value)

Set attribute value.
Parameters:
Name Type Description
name String The attribute name, it can use like 'a/b/c' to access attribute.
value * The attribute value.
Overrides:
Source:
Example
let object = new THING.BaseObject();
object.setAttribute('userData/power', 200);
let power = object.getAttribute('userData/power');
// @expect(power == 200)

setAttributes(attributes, overwriteopt)

Set attribute values.
Parameters:
Name Type Attributes Default Description
attributes Object The attribute values.
overwrite Boolean <optional>
true True indicates overwrite attribute.
Overrides:
Source:
Example
let object = new THING.BaseObject();
object.setAttributes({
  "userData/name": 'Mr.Door',
  "userData/age": 18
})
let name = object.getAttribute('userData/name');
// @expect(name == 'Mr.Door')
let age = object.getAttribute('userData/age');
// @expect(age == 18)

setNormal(array)

Set the vertex normal of the mesh.Use the current interface when the geometry references only itself, and use the attribute (mesh.geometry.normal) interface when the geometry is shared.
Parameters:
Name Type Description
array Array.<Number> | Float32Array
Source:

setPosition(array)

Set the vertex of the mesh.Use the current interface when the geometry references only itself, and use the attribute (mesh.geometry.position) interface when the geometry is shared.
Parameters:
Name Type Description
array Array.<Number> | Float32Array
Source:

setStyle(value, recursiveopt)

Set style values.
Parameters:
Name Type Attributes Default Description
value * The style values.
recursive Boolean <optional>
false True indicates to set all children style values.
Overrides:
Source:
Example
let box1 = new THING.Box();
	let box2 = new THING.Box({parent: box1});
	box1.setStyle({color: 'red'});
	// @expect(box1.style.color[0] == 1);
	// @expect(box1.style.color[1] == 0);
	// @expect(box1.style.color[2] == 0);
	// @expect(box2.style.color == null);

setUv(array)

Set the vertex uv of the mesh.Use the current interface when the geometry references only itself, and use the attribute (mesh.geometry.uv) interface when the geometry is shared.
Parameters:
Name Type Description
array Array.<Number> | Float32Array
Source:

setVisible(value, recursiveopt)

Set visible state.
Parameters:
Name Type Attributes Default Description
value Boolean True indicates show it, otherwise hide it.
recursive Boolean | ProcessObjectCallback <optional>
false If it's boolean value type then means whether process it with all children.
Overrides:
Source:
Example
// Hide object self only, exclude all children
	object.setVisible(false, false);

	// Hide object(s) but exclude children what name equals to 'stone'
	object.setVisible(false, (obj) => {
		if (obj.name == 'stone') {
			return false;
		}
	});

stopFlying()

Stop flying.
Overrides:
Source:
Example
object.stopFlying();

stopMoving()

Stop moving.
Overrides:
Source:
Example
object.stopMoving();

stopRotating()

Stop rotating.
Overrides:
Source:
Example
object.stopRotating();

stopScaling()

Stop scaling.
Overrides:
Source:
Example
object.stopScaling();

stopUVTransform(slotType)

Stop UV transform.
Parameters:
Name Type Description
slotType ImageSlotType The slot type of style.
Overrides:
Source:
Example
object.stopUVTransform(THING.ImageSlotType.Map);

translate(offset)

Translate in self coordinates.
Parameters:
Name Type Description
offset Array.<Number> The offset.
Overrides:
Source:

translateX(distance)

Translate on x-axis in self coordinates.
Parameters:
Name Type Description
distance Number The distance.
Overrides:
Source:

translateY(distance)

Translate on y-axis in self coordinates.
Parameters:
Name Type Description
distance Number The distance.
Overrides:
Source:

translateZ(distance)

Translate on z-axis in self coordinates.
Parameters:
Name Type Description
distance Number The distance.
Overrides:
Source:

traverse(callback)

Traverse self and all children.
Parameters:
Name Type Description
callback function The callback function.
Overrides:
Source:
Example
let parent = new THING.BaseObject();
let child1 = new THING.BaseObject({parent: parent});
let child2 = new THING.BaseObject({parent: parent});
let mark = 0;
parent.traverse((child) => {
		mark++;
});
// @expect(mark == 3)

traverseBranch(callback)

Traverse self and all children. (Support for exit at traverse runtime)
Parameters:
Name Type Description
callback function The callback function. (Return false to exit)
Overrides:
Source:
Example
let parent = new THING.BaseObject();
let child1 = new THING.BaseObject({parent: parent});
let child2 = new THING.BaseObject({parent: parent});
let mark = 0;
parent.traverseBranch((child)=>{
	   mark++;
});
// @expect(mark == 3)
mark = 0;
parent.traverseBranch((child)=>{
	   mark++;
    if(child.children.length > 0){
		   return false;
	   }
	   return true;
});
// @expect(mark == 1)

traverseComponentByType(type, callback)

Traverse component by type.
Parameters:
Name Type Description
type * The component type.
callback TraverseComponentByTypeCallback The callback function.
Overrides:
Source:
Example
object.addComponent(new MyComponent(), 'myComponent');
	object.traverseComponentByType(MyComponent, (component, name) => {
		console.log(component, name);
	});

trigger(type, ev, options?) → {*}

Trigger event.
Parameters:
Name Type Description
type String The event type.
ev Object The event info.
options? Object The options.
Properties
Name Type Description
tag String The tag name.
Overrides:
Source:
Returns:
Type
*
Example
let object = new THING.BaseObject();
 let markTrigger = {};
	object.on('myEvent', function(ev) {
		markTrigger = ev;
	});
	object.trigger('myEvent', { result: true });
 let ret = markTrigger.result;
 // @expect(ret == true);

unloadResource(recursiveopt) → {Promise.<any>}

Unload resource.
Parameters:
Name Type Attributes Default Description
recursive Boolean <optional>
true True indicates to unload all children resources.
Overrides:
Source:
Returns:
Type
Promise.<any>
Example
// Wait the object to unload resource completed
	await object.unloadResource();

uvTransformTo(slotType, value, param?)

Start UV transform in duration.
Parameters:
Name Type Description
slotType ImageSlotType The slot type of style.
value StyleUVMatrixResult | LerpArgs The UV transform info.
param? LerpArgs The parameters.
Overrides:
Source:
Example
// Lerp UV offset from [0, 0] to [-1, 0] in 2 seconds by repeat mode
object.uvTransformTo(THING.ImageSlotType.Map, {
	from: { offset: [0, 0] },
	to: { offset: [-1, 0] },
	duration: 2000,
	loopType: THING.LoopType.Repeat,
	times: 3
});

waitForComplete() → {Promise.<any>}

Wait for object load completed.
Overrides:
Source:
Returns:
Type
Promise.<any>
Example
// Wait for object load completed then watch it
	await object.waitForComplete();
	app.camera.fit(object);

worldToLocal(position, ignoreScaleopt) → {Array.<Number>}

Convert world position to local position. same as call parent worldToSelf.
Parameters:
Name Type Attributes Default Description
position Array.<Number> The world position.
ignoreScale Boolean <optional>
false True indicates ignore scale factor.
Overrides:
Source:
Returns:
Returns local position relative to the parent
Type
Array.<Number>
Example
let parentObj = new THING.Object3D({
	position: [0, 5, 0]
});

let childObj = new THING.Object3D({
	localPosition: [0, 10, 0],
	parent: parentObj
});

let localPosition = childObj.worldToLocal([0, 5, 0]);

// print [0, 0, 0]
console.log(localPosition);

worldToSelf(position, ignoreScaleopt) → {Array.<Number>}

Convert world position to self position.
Parameters:
Name Type Attributes Default Description
position Array.<Number> The world position.
ignoreScale Boolean <optional>
false True indicates ignore scale factor.
Overrides:
Source:
Returns:
Type
Array.<Number>
Example
let worldPos = [5, 10, 0];
let obj = new THING.Object3D({position: worldPos});
let selfPos = obj.worldToSelf(worldPos);
// print [0, 0, 0]
console.log(selfPos);