Animation · class

AnimationStateMachine

Explained in Animation.

class AnimationStateMachine
import { AnimationStateMachine } from '@driftengine/animation';

Constructor

new

constructor(states: readonly AnimationState[], transitions: readonly AnimationTransition[], jointCount: number, bind?: Pose)
ParameterTypeDescription
statesreadonly AnimationState[]
transitionsreadonly AnimationTransition[]
jointCountnumber
bind?PoseThe bind pose, or omitted for one whose channels start at rest. The same reason BlendTree takes one: a crossfade calls blendPoses, which interpolates every channel, so without a bind pose the two sides of a fade start at zero translation and the figure folds toward its own origin for the length of the transition.

Accessors

NameTypeDescription
currentgetstring
transitioninggetbooleanWhether a crossfade is running. A caller wanting to gate input on one asks this.

Methods

set

set(parameter: string, value: number): void

Set a parameter the transitions read.

ParameterTypeDescription
parameterstring
valuenumber
More

Unlike BlendTree.set this accepts any name: the predicates are the consumer's own functions and this class cannot know which keys they read. The tree below it still refuses a name no node declares, which is where a typo that matters is caught.

advance

advance(dtSec: number): void

Advance by a caller-supplied step: the fade, the active state's clock, and any transition whose condition now holds.

ParameterTypeDescription
dtSecnumber

evaluate

evaluate(out: Pose): void

The current pose, crossfaded if a transition is running. Allocates nothing.

ParameterTypeDescription
outPose