An AnimationClip is a reusable set of keyframe tracks which represent an animation.

For an overview of the different elements of the Verge3D animation system, see the Animation System section of the manual.


AnimationClip(name : String, duration : Float, tracks : Array, blendMode : Constant)

name — a name for this clip.
duration — the duration of this clip (in seconds). If a negative value is passed, the duration will be calculated from the passed tracks array.
tracks — an array of KeyframeTracks.
blendMode — (optional) defines how the animation is blended/combined when two or more animations are simultaneously played. Default is v3d.NormalAnimationBlendMode.

Note: Instead of instantiating an AnimationClip directly with the constructor, you can use one of its static methods to create AnimationClips: from JSON (parse), from morph target sequences (CreateFromMorphTargetSequence, CreateClipsFromMorphTargetSequences) or from animation hierarchies (parseAnimation) — if your model doesn't already hold AnimationClips in its geometry's animations array.


.blendMode : Constant

Defines how the animation is blended/combined when two or more animations are simultaneously played. Valid values are NormalAnimationBlendMode (default) and AdditiveAnimationBlendMode.

.duration : Float

The duration of this clip (in seconds). This can be calculated from the tracks array via resetDuration.

.name : String

A name for this clip. A certain clip can be searched via findByName.

.tracks : Array

An array containing a KeyframeTrack for each property that are animated by this clip.

.uuid : String

The UUID of this clip instance. It gets automatically assigned and shouldn't be edited.


.clone() → AnimationClip

Returns a copy of this clip.

.optimize() → this

Optimizes each track by removing equivalent sequential keys (which are common in morph target sequences).

.resetDuration() → this

Sets the duration of the clip to the duration of its longest KeyframeTrack.

.trim() → this

Trims all tracks to the clip's duration.

.validate() → Boolean

Performs minimal validation on each track in the clip. Returns true if all tracks are valid.

Static Methods

.CreateClipsFromMorphTargetSequences(name : String, morphTargetSequence : Array, fps : Float, noLoop : Boolean) → Array

Returns an array of new AnimationClips created from the morph target sequences of a geometry, trying to sort morph target names into animation-group-based patterns like "Walk_001, Walk_002, Run_001, Run_002 ...".

.CreateFromMorphTargetSequence(name : String, morphTargetSequence : Array, fps : Float, noLoop : Boolean) → AnimationClip

Returns a new AnimationClip from the passed morph targets array of a geometry, taking a name and the number of frames per second.

The fps parameter is required, but the animation speed can be overridden in an AnimationAction via animationAction.setDuration.

.findByName(objectOrClipArray : Object, name : String) → AnimationClip

Searches for an AnimationClip by name, taking as its first parameter either an array of AnimationClips, or a mesh or geometry that contains an array named "animations".

.parse(json : Object) → AnimationClip

Parses a JSON representation of a clip and returns an AnimationClip.

.parseAnimation(animation : Object, bones : Array) → AnimationClip

Parses the animation.hierarchy format and returns an AnimationClip.


You can also employ animation puzzles which can be easier to use than AnimationClip API.


For more info on how to obtain the source code of this module see this page.