Class: ModelAnimationComponent

THING.ModelAnimationComponent()

ModelAnimationComponent The model animation component.

Constructor

new ModelAnimationComponent()

The model animation player of entity object.
Source:

Extends

Members

active :Boolean

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

animationNames :Array.<String>

Get the animation names.
Type:
  • Array.<String>
Source:
Example
var UinoSpaceman = new THING.Entity({url:'.assets/models/UinoSpaceman/UinoSpaceman.gltf'});
UinoSpaceman.waitForComplete().then(() => {
  let animations = UinoSpaceman.animationNames;
  let ret = animations[0] == 'Walk';
	 // @expect(ret == true);
});

animations :Array.<AnimationResult>

Get all animations info.
Type:
Source:
Example
var UinoSpaceman = new THING.Entity({url:'.assets/models/UinoSpaceman/UinoSpaceman.gltf'});
UinoSpaceman.waitForComplete().then(() => {
  let animations = UinoSpaceman.animations;
  let ret = animations[0].name == 'Walk';
	 // @expect(ret == true);
});

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:

onExport :OnExportComponentCallback

When export data.
Type:
Overrides:
Source:

onImport :OnImportComponentCallback

When import data.
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:

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:

Methods

hasAnimation(name) → {Boolean}

Check whether has animation by name.
Parameters:
Name Type Description
name String The animation name
Source:
Returns:
Type
Boolean
Example
var UinoSpaceman = new THING.Entity({url:'.assets/models/UinoSpaceman/UinoSpaceman.gltf'});
UinoSpaceman.waitForComplete().then(() => {
  let ret = UinoSpaceman.hasAnimation('Walk');
	 // @expect(ret == true);
});

onAdd(object)

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

onRemove()

When remove component.
Overrides:
Source:

stopAllAnimations()

Stop all animations.
Source:
Example
var UinoSpaceman = new THING.Entity({url:'.assets/models/UinoSpaceman/UinoSpaceman.gltf'});
UinoSpaceman.waitForComplete().then(() => {
  UinoSpaceman.playAnimation({ name: 'Walk', loopType: "Repeat" });
  let ret1 = UinoSpaceman.isAnimationPlaying('Walk');
  UinoSpaceman.stopAllAnimations();
  let ret2 = UinoSpaceman.getAnimationState() == 'Stopped';
	 // @expect(ret1 == true && ret2 == true);
});

stopAnimation(name)

Stop animation.
Parameters:
Name Type Description
name String The animation name.
Source:
Example
var UinoSpaceman = new THING.Entity({url:'.assets/models/UinoSpaceman/UinoSpaceman.gltf'});
UinoSpaceman.waitForComplete().then(() => {
  UinoSpaceman.playAnimation({ name: 'Walk', loopType: "Repeat" });
  let ret1 = UinoSpaceman.isAnimationPlaying('Walk');
  UinoSpaceman.stopAnimation('Walk');
  let ret2 = UinoSpaceman.getAnimationState() == 'Stopped';
	 // @expect(ret1 == true && ret2 == true);
});