# Animation

Class · category: Animation (Legacy)

Source: https://github.com/playcanvas/engine/blob/f059dc005842f76e052cdf44d8370c8c7ec475ac/src/scene/animation/animation.js#L36

An Animation contains the data that defines how a [Skeleton](https://api.playcanvas.com/engine/classes/Skeleton.md) animates over time. The
Animation contains an array of [AnimationNode](https://api.playcanvas.com/engine/classes/AnimationNode.md)s, where each AnimationNode targets a
specific [GraphNode](https://api.playcanvas.com/engine/classes/GraphNode.md) referenced by a [Skeleton](https://api.playcanvas.com/engine/classes/Skeleton.md).

An Animation can be played back by an [AnimationComponent](https://api.playcanvas.com/engine/classes/AnimationComponent.md).

## Constructors

### constructor

```ts
new Animation()
```

Create a new Animation instance.

## Properties

### duration

```ts
duration: number = 0
```

Duration of the animation in seconds.

### name

```ts
name: string = ''
```

Human-readable name of the animation.

## Accessors

### nodes

```ts
get nodes(): AnimationNode[]
```

A read-only property to get array of animation nodes.

## Methods

### addNode

```ts
addNode(node: AnimationNode): void
```

Adds a node to the internal nodes array.

**Parameters**

- `node` ([`AnimationNode`](https://api.playcanvas.com/engine/classes/AnimationNode.md)): The node to add.

### getNode

```ts
getNode(name: string): AnimationNode
```

Gets a [AnimationNode](https://api.playcanvas.com/engine/classes/AnimationNode.md) by name.

**Parameters**

- `name` (`string`): The name of the [AnimationNode](https://api.playcanvas.com/engine/classes/AnimationNode.md).

**Returns** [`AnimationNode`](https://api.playcanvas.com/engine/classes/AnimationNode.md): The [AnimationNode](https://api.playcanvas.com/engine/classes/AnimationNode.md) with the specified name.
