You are reading Tres v1 docs. Head over tresjs.org for V2 docs.
Skip to content
On this page

useAnimations ^1.5.0

useAnimation is a composable that returns a shallowReactive with all the models actions based on the animations provided. It is a wrapper around the AnimationMixer class.

Loading...

Usage

ts
import { useAnimations } from '@tresjs/cientos'

const { scene: model, animations } = await useGLTF('/models/ugly-naked-bunny.gltf')

// Animations [ { name: 'Greeting'}, { name: 'Idle' } ]

const { actions, mixer } = useAnimations(animations, model)

let currentAction = actions.Greeting

currentAction.play()