# ModelAnimation

#### internal constructor new Cesium.ModelAnimation()
engine/Source/Scene/Model/ModelAnimation.js 25

Create animations by calling `ModelAnimationCollection#add`. Do not call the constructor directly.
An active animation derived from a glTF asset. An active animation is an animation that is either currently playing or scheduled to be played due to being added to a model's `ModelAnimationCollection`. An active animation is an instance of an animation; for example, there can be multiple active animations for the same glTF animation, each with a different start time.

##### See:

- ModelAnimationCollection#add

### Members

#### animationTime : ModelAnimation.AnimationTimeCallback
engine/Source/Scene/Model/ModelAnimation.js 338

If this is defined, it will be used to compute the local animation time instead of the scene's time.

Default Value: `undefined`

#### readonly delay : number
engine/Source/Scene/Model/ModelAnimation.js 253

The delay, in seconds, from `ModelAnimation#startTime` to start playing.

Default Value: `undefined`

#### readonly loop : ModelAnimationLoop
engine/Source/Scene/Model/ModelAnimation.js 323

Determines if and how the animation is looped.

Default Value: ``ModelAnimationLoop.NONE``

#### readonly multiplier : number
engine/Source/Scene/Model/ModelAnimation.js 291

Values greater than `1.0` increase the speed that the animation is played relative to the scene clock speed; values less than `1.0` decrease the speed. A value of `1.0` plays the animation at the speed in the glTF animation mapped to the scene clock speed. For example, if the scene is played at 2x real-time, a two-second glTF animation will play in one second even if `multiplier` is `1.0`.

Default Value: `1.0`

#### readonly name : string
engine/Source/Scene/Model/ModelAnimation.js 154

The name that identifies this animation in the model, if it exists.

#### removeOnStop : boolean
engine/Source/Scene/Model/ModelAnimation.js 42

When `true`, the animation is removed after it stops playing. This is slightly more efficient that not removing it, but if, for example, time is reversed, the animation is not played again.

Default Value: `false`

#### readonly reverse : boolean
engine/Source/Scene/Model/ModelAnimation.js 307

When `true`, the animation is played in reverse.

Default Value: `false`

#### start : Event
engine/Source/Scene/Model/ModelAnimation.js 64

The event fired when this animation is started. This can be used, for example, to play a sound or start a particle system, when the animation starts.

This event is fired at the end of the frame after the scene is rendered.

Default Value: `new Event()`

##### Example:

    animation.start.addEventListener(function(model, animation) {
      console.log(`Animation started: ${animation.name}`);
    });

#### readonly startTime : JulianDate
engine/Source/Scene/Model/ModelAnimation.js 237

The scene time to start playing this animation. When this is `undefined`, the animation starts at the next frame.

Default Value: `undefined`

#### stop : Event
engine/Source/Scene/Model/ModelAnimation.js 100

The event fired when this animation is stopped. This can be used, for example, to play a sound or start a particle system, when the animation stops.

This event is fired at the end of the frame after the scene is rendered.

Default Value: `new Event()`

##### Example:

    animation.stop.addEventListener(function(model, animation) {
      console.log(`Animation stopped: ${animation.name}`);
    });

#### readonly stopTime : JulianDate
engine/Source/Scene/Model/ModelAnimation.js 271

The scene time to stop playing this animation. When this is `undefined`, the animation is played for its full duration and perhaps repeated depending on `ModelAnimation#loop`.

Default Value: `undefined`

#### update : Event
engine/Source/Scene/Model/ModelAnimation.js 83

The event fired when on each frame when this animation is updated. The current time of the animation, relative to the glTF animation time span, is passed to the event, which allows, for example, starting new animations at a specific time relative to a playing animation.

This event is fired at the end of the frame after the scene is rendered.

Default Value: `new Event()`

##### Example:

    animation.update.addEventListener(function(model, animation, time) {
      console.log(`Animation updated: ${animation.name}. glTF animation time: ${time}`);
    });

### Type Definitions

#### Cesium.ModelAnimation.AnimationTimeCallback(duration, seconds) → number
engine/Source/Scene/Model/ModelAnimation.js 401

A function used to compute the local animation time for a ModelAnimation.

Name | Type | Description
--- | --- | ---
`duration` | number | The animation's original duration in seconds.
`seconds` | number | The seconds since the animation started, in scene time.

##### Returns:

Returns the local animation time.

##### Examples:

    // Use real time for model animation (assuming animateWhilePaused was set to true)
    function animationTime(duration) {
        return Date.now() / 1000 / duration;
    }

    // Offset the phase of the animation, so it starts halfway through its cycle.
    function animationTime(duration, seconds) {
        return seconds / duration + 0.5;
    }

Need help? The fastest way to get answers is from the community and team on the Cesium Forum.