Skip to main content

Interface: FilamentAnimator

Updates matrices according to glTF animation and skin definitions.

Animator can be used for two things:

  • Updating matrices in filament::TransformManager components according to glTF animation definitions.
  • Updating bone matrices in filament::RenderableManager components according to glTF skin definitions.

For a usage example, see the documentation for AssetLoader.

Methods​

addToSyncList()​

addToSyncList(instance): number

Will apply all transforms of the animation to the same entities/bones when calling updateBoneMatrices. This is useful if you have multiple assets sharing the same skeleton and you want to animate them in sync (e.g. clothing). Internally calls applyAnimationToInstance.

Parameters​

• instance: FilamentInstance

Returns​

number

The id of the instance in the sync list.

Note​

Entities / bones are identified by name.

Defined in​

src/types/Animator.ts:59


applyAnimation()​

applyAnimation(animIndex, time): void

Applies rotation, translation, and scale to entities that have been targeted by the given animation definition. Uses filament::TransformManager.

Parameters​

• animIndex: number

• time: number

Elapsed time of interest in seconds.

Returns​

void

Defined in​

src/types/Animator.ts:20


applyCrossFade()​

applyCrossFade(previousAnimIndex, previousAnimTime, alpha): void

Applies a blended transform to the union of nodes affected by two animations. Used for cross-fading from a previous skinning-based animation or rigid body animation.

First, this stashes the current transform hierarchy into a transient memory buffer.

Next, this applies previousAnimIndex / previousAnimTime to the actual asset by internally calling applyAnimation().

Finally, the stashed local transforms are lerped (via the scale / translation / rotation components) with their live counterparts, and the results are pushed to the asset.

To achieve a cross fade effect with skinned models, clients will typically call animator methods in this order: (1) applyAnimation (2) applyCrossFade (3) updateBoneMatrices. The animation that clients pass to applyAnimation is the "current" animation corresponding to alpha=1, while the "previous" animation passed to applyCrossFade corresponds to alpha=0.

Parameters​

• previousAnimIndex: number

• previousAnimTime: number

• alpha: number

Returns​

void

Defined in​

src/types/Animator.ts:39


getAnimationCount()​

getAnimationCount(): number

Returns the number of animation definitions in the glTF asset.

Returns​

number

Defined in​

src/types/Animator.ts:74


getAnimationDuration()​

getAnimationDuration(animIndex): number

Returns the number of animation definitions in the asset.

Parameters​

• animIndex: number

Returns​

number

Defined in​

src/types/Animator.ts:77


getAnimationName()​

getAnimationName(animIndex): string

Returns the name of the specified animation, or an empty string if none was specified.

Parameters​

• animIndex: number

Returns​

string

Defined in​

src/types/Animator.ts:83


removeFromSyncList()​

removeFromSyncList(instanceId): void

Will remove the instance from the sync list.

Parameters​

• instanceId: number

Returns​

void

Defined in​

src/types/Animator.ts:64


resetBoneMatrices()​

resetBoneMatrices(): void

Pass the identity matrix into all bone nodes, useful for returning to the T pose.

NOTE: this operation is independent of animation.

Returns​

void

Defined in​

src/types/Animator.ts:71


updateBoneMatrices()​

updateBoneMatrices(): void

Computes root-to-node transforms for all bone nodes, then passes the results into filament::RenderableManager::setBones. Uses filament::TransformManager and filament::RenderableManager.

NOTE: this operation is independent of animation.

Returns​

void

Defined in​

src/types/Animator.ts:48