Skip to main content

ModelAnimator

class ModelAnimator

Component that manages animations of the 3D Model

constructor

new ModelAnimator(view3D)

Create new ModelAnimator instance

PARAMETERTYPEOPTIONALDEFAULTDESCRIPTION
view3DView3D

Properties

clips

readonly

Three.js AnimationClips that stored

Type: THREE.AnimationClip

mixer

readonly

THREE.AnimationMixer instance

Type: THREE.AnimationMixer

actions

readonly

An array of active AnimationActions

Type: THREE.AnimationAction

animationCount

readonly

Current length of animations

Type: number

activeAnimation

Infomation of the animation currently playing, null if there're no animation or stopped.

Type: THREE.AnimationClip | null

See:

activeAction

THREE.AnimationAction instance of the animation currently playing, null if there're no animation or stopped.

Type: THREE.AnimationAction | null

See:

activeAnimationIndex

readonly

An index of the animation currently playing.

Type: number

paused

readonly

An boolean value indicating whether the animations are paused

Type: boolean

animating

readonly

An boolean value indicating whether at least one of the animation is playing

Type: boolean

timeScale

Global time scale for animations

Type: number

Methods

init

Initialize ModelAnimator

destroy

Destroy ModelAnimator instance

setClips

Store the given clips

Returns: void

PARAMETERTYPEOPTIONALDEFAULTDESCRIPTION
clipsTHREE.AnimationClip[]Three.js AnimationClips of the model
// After loading model
view3d.animator.setClips(model.animations);

play

Play one of the model's animation

Returns: void

PARAMETERTYPEOPTIONALDEFAULTDESCRIPTION
indexnumberIndex of the animation to play

crossFade

async

Crossfade animation from one to another

Returns: Promise<boolean>

  • A promise that resolves boolean value that indicates whether the crossfade is fullfilled without any inference
PARAMETERTYPEOPTIONALDEFAULTDESCRIPTION
indexnumberIndex of the animation to crossfade to
durationnumberDuration of the crossfade animation, in milisec
Partial<{synchronize: boolean}>✔️{}

fadeOut

async

Fadeout active animation, and restore to the default pose

Returns: Promise<boolean>

  • A promise that resolves boolean value that indicates whether the fadeout is fullfilled without any inference
PARAMETERTYPEOPTIONALDEFAULTDESCRIPTION
durationnumberDuration of the crossfade animation, in milisec

pause

Pause all animations
If you want to stop animation completely, you should call stop instead
You should call resume to resume animation

Returns: void

resume

Resume all animations
This will play animation from the point when the animation is paused

Returns: void

stop

Fully stops one of the model's animation

Returns: void

update

Update animations

Returns: void

PARAMETERTYPEOPTIONALDEFAULTDESCRIPTION
deltanumbernumber of seconds to play animations attached

updateRepeatMode

Update animation repeat mode of the animation actions

reset

Reset the instance and remove all cached animation clips attached to it

Returns: void