Appearance
Kiln API / kiln / ModelAnimation
Class: ModelAnimation
A 3D entity's animation: the shared controller (set, trigger, play, state, time, weight) driving a Three.js AnimationMixer on the entity's MeshRef. mixer and action(clip) are there for inspection; the plugin sets every action's time and weight each fixed step.
Extends
Constructors
Constructor
ts
new ModelAnimation(options?): ModelAnimation;Parameters
| Parameter | Type |
|---|---|
options | AnimatorOptions |
Returns
ModelAnimation
Overrides
AnimationController.constructor
Properties
graph
ts
graph: AnimationGraph | null;Inherited from
state
ts
state: string = '';The current state's name ('' until the clips are known).
Inherited from
time
ts
time: number = 0;Seconds of clip time since the state was entered (keeps growing across loops).
Inherited from
speed
ts
speed: number = 1;Playback rate for the whole animator, multiplied with each state's speed.
Inherited from
paused
ts
paused: boolean = false;Holds the playhead (events and transitions wait too).
Inherited from
params
ts
readonly params: Record<string, number | boolean> = {};Parameter values; write them with set().
Inherited from
triggers
ts
readonly triggers: Set<string>;Triggers set since the last animation step.
Inherited from
fade
ts
fade: Fade | null = null;The crossfade in progress, or null.
Inherited from
request
ts
protected request:
| {
state: string;
fade: number | undefined;
restart: boolean;
}
| null = null;play() requests, applied at the start of the next animation step.
Inherited from
startState
ts
protected startState: string | null;The state to enter first, overriding the graph's initial state.
Inherited from
AnimationController.startState
source
ts
source:
| AssetHandle<GLTF>
| readonly AnimationClip[]
| null;Clips given in options, instead of the Model's.
mixer
ts
mixer: AnimationMixer<AnimationMixerEventMap> | null = null;root
ts
root: Object3D<Object3DEventMap> | null = null;The object the mixer animates (the MeshRef).
clipsByName
ts
readonly clipsByName: Map<string, AnimationClip>;Accessors
stateSpec
Get Signature
ts
get stateSpec(): AnimationStateSpec | undefined;The current state's spec.
Returns
AnimationStateSpec | undefined
Inherited from
clip
Get Signature
ts
get clip(): string;The current state's clip name.
Returns
string
Inherited from
loop
Get Signature
ts
get loop(): LoopMode;The current state's loop mode.
Returns
Inherited from
normalizedTime
Get Signature
ts
get normalizedTime(): number;Plays of the current clip so far: 0..1 through the first, 1 at the end of a 'once' clip, 2.5 halfway through a third loop.
Returns
number
Inherited from
AnimationController.normalizedTime
finished
Get Signature
ts
get finished(): boolean;A 'once' clip has reached its end.
Returns
boolean
Inherited from
weight
Get Signature
ts
get weight(): number;The crossfade weight of the current state: 0 just after a faded transition, 1 when settled.
Returns
number
Inherited from
bound
Get Signature
ts
get bound(): boolean;True once the plugin has told the controller about its clips.
Returns
boolean
Inherited from
Methods
set()
ts
set(name, value): this;Sets a parameter declared in the graph's params.
Parameters
| Parameter | Type |
|---|---|
name | string |
value | number | boolean |
Returns
this
Inherited from
get()
ts
get(name): number | boolean | undefined;A parameter's value.
Parameters
| Parameter | Type |
|---|---|
name | string |
Returns
number | boolean | undefined
Inherited from
trigger()
ts
trigger(name): this;Sets a trigger declared in the graph's triggers. It lasts one animation step unless a transition takes it.
Parameters
| Parameter | Type |
|---|---|
name | string |
Returns
this
Inherited from
play()
ts
play(state, options?): this;Enters a state at the next animation step, skipping transitions. Already in it: nothing, unless restart. fade overrides the graph's crossfade seconds.
Parameters
| Parameter | Type |
|---|---|
state | string |
options | { fade?: number; restart?: boolean; } |
options.fade? | number |
options.restart? | boolean |
Returns
this
Inherited from
is()
ts
is(state): boolean;True when the current state is state.
Parameters
| Parameter | Type |
|---|---|
state | string |
Returns
boolean
Inherited from
bind()
ts
bind(clips, what): void;Called by the plugin when the clips are known. Checks every state's clip exists, then enters the first state.
Parameters
| Parameter | Type |
|---|---|
clips | ReadonlyMap<string, ClipInfo> |
what | string |
Returns
void
Inherited from
clipInfo()
ts
clipInfo(name): ClipInfo | undefined;Info for a clip by name.
Parameters
| Parameter | Type |
|---|---|
name | string |
Returns
ClipInfo | undefined
Inherited from
step()
ts
step(dt, out): void;One animation step of dt seconds: play() requests, then transitions, then the playhead and its events.
Parameters
| Parameter | Type |
|---|---|
dt | number |
out | AnimationSink |
Returns
void
Inherited from
toJSON()
ts
toJSON(): Record<string, unknown>;Returns
Record<string, unknown>
Inherited from
action()
ts
action(clip): AnimationAction | undefined;The mixer action for a clip (created on first use), or undefined before the model is bound.
Parameters
| Parameter | Type |
|---|---|
clip | string |
Returns
AnimationAction | undefined
attach()
ts
attach(
root,
clips,
what
): void;Binds to a root object and its clips: makes the mixer, checks the graph's clips exist.
Parameters
| Parameter | Type |
|---|---|
root | Object3D |
clips | readonly AnimationClip[] |
what | string |
Returns
void
detach()
ts
detach(): void;Stops the mixer and frees its cached bindings.
Returns
void
apply()
ts
apply(): void;Writes the playhead and crossfade into the mixer's actions and samples the pose.
Returns
void