Appearance
Kiln API / kiln / animationGraph
Function: animationGraph()
ts
function animationGraph<S, P, T>(spec): AnimationGraph;Defines an animation state graph as data, checked when it is made:
ts
export const HeroAnim = animationGraph({
initial: 'idle',
params: { speed: 0 },
triggers: ['attack'],
states: { idle: {}, run: { events: [{ frame: 1, name: 'footstep' }] }, attack: { loop: 'once' } },
transitions: [
{ from: 'idle', to: 'run', when: { speed: { gt: 0.1 } } },
{ from: 'run', to: 'idle', when: { speed: { lte: 0.1 } } },
{ from: '*', to: 'attack', trigger: 'attack' },
{ from: 'attack', to: 'idle', exitTime: 1 },
],
})Type Parameters
| Type Parameter | Default type |
|---|---|
S extends string | - |
P extends Record<string, number | boolean> | object |
T extends string | never |
Parameters
| Parameter | Type |
|---|---|
spec | AnimationGraphSpec<S, P, T> |