---
title: Model Animation
description: Learn how to animate 3D models in TresJS
thumbnail: /recipes/model-n-animations/model-n-animations.png
---
::examples-model-animation
::
Let's bring your 3D models to life with animations in TresJS. This guide covers loading animated models and controlling their playback.
## Where to find models?
You can find quality 3D models for your projects in various online repositories. Here are some hand picked sources from the TresJS community:
- [poly.pizza](https://poly.pizza/) - A collection of free 3D models.
- [Pmndrs Marketplace](https://market.pmnd.rs/) - A marketplace for 3D assets. All free
- [KayKit Character Packs](https://kaylousberg.itch.io/) - Free and paid character packs. Animated, all CC0, a personal favorite of ours.
For this tutorial we will use a simplified version of the **KayKit Knight character**, you can download it directly from here.

## Loading Animated Models
::steps
### Install cientos
If you haven't already, install the `@tresjs/cientos` package, which provides components for loading 3D models.
```bash
npm install @tresjs/cientos
```
### Load the Model
Use the `useGLTF` composable from `@tresjs/cientos` to load your animated model. Add the downloaded GLB file to your public directory in a subfolder like `/models/knight/`.
```vue [Knight.vue]
```
::read-more{TO="https://cientos.tresjs.org/guide/loaders/use-gltf.html"}
Learn more about the `useGLTF` composable.
::
### Add Rig to the Scene
The Rig is the root object that contains the entire model and its animations. You can access it from the individual nodes.
::tip
The Rig might be named differently depending on the model. Check the model's structure to find the correct root object.
::
```vue [Knight.vue]
```
::
## Animation Control
::steps
### Use the `useAnimations` Composable
The `useAnimations` composable helps manage and play animations from your model. It takes the animations array and the rig as parameters and returns the `AnimationClips` (actions).
```vue [Knight.vue]
```
::read-more{TO="https://cientos.tresjs.org/guide/abstractions/use-animations.html"}
Learn more about the `useAnimations` composable.
::
### Play an Animation
You can play an animation by calling the `play` method on the desired action. For example, to play the "Cheer" animation:
```ts
const { actions } = useAnimations(animations, rig)
actions.value.Cheer?.play()
```
### Set animation loop
You can set the loop mode of an animation using the `setLoop` method. For example, to make the "Cheer" animation loop indefinitely:
```ts
actions.value.Cheer?.setLoop(THREE.LoopRepeat, Infinity)
actions.value.Cheer?.play()
```
### Smooth Animation Transitions
To create smooth transitions between animations, use the `fadeIn` and `fadeOut` methods. This prevents abrupt changes and creates more natural character movement:
```vue [Knight.vue]
```
**Key points about animation transitions:**
- `fadeOut(duration)` gradually reduces the animation's influence over the specified duration
- `fadeIn(duration)` gradually increases the animation's influence over the specified duration
- `reset()` resets the animation to its starting frame
- `setEffectiveWeight(1)` ensures the animation has full influence when active
- Shorter durations (0.1-0.3s) work well for quick actions, longer ones (0.5-1s) for smoother character transitions
::