[][src]Module three::animation

Animation system.

Introduction

The three animation system is designed around three structures, namely Action, Clip, and Mixer.

Action

An Action controls the playback properties of an animation. Methods such as play, pause, and disable are provided to control an single animation at runtime.

Actions must be created and updated by a Mixer.

Mixer

An animation Mixer schedules the playback of actions.

The user is expected to create actions from a mixer with the Mixer::action function and update actions with the Mixer::update function.

Clip

An animation Clip defines the keyframes and target of an animation. Clips are usually imported from 3D formats such as glTF.

Walkthrough

Creating a mixer

First, we create a Mixer to play our animation.

// Initialization omitted.
let mut mixer = three::animation::Mixer::new();

Loading some animation clips

Now, we load some clips from an animated glTF scene.

This example is not tested
let gltf = window.factory.load_gltf("AnimatedScene.gltf");
window.scene.add(&gltf);

Creating animation actions

Now, we schedule the playback of the clips by creating actions.

The created actions are enabled by default in the 'play' state. This means that when calling Mixer::update the created actions will begin to be played back immediately.

This example is not tested
let actions: Vec<three::animation::Action> = gltf.clips
    .into_iter()
    .map(|clip| mixer.action(clip))
    .collect();

Playing the animation back

Finally, we run the animation actions by updating their Mixer in the main game loop.

This example is not tested
while window.update() {
    mixer.update(window.input.delta_time());
    window.render(&camera);
}

Putting it all together

See the gltf-animation example for the full code.

Structs

Action

Controls the playback properties of an animation

Clip

A reusable set of keyframe tracks which represent an animation.

Mixer

Scheduler for the playback of animation actions.

Track

A track of animation keyframes.

Enums

Binding

Describes the target property of an animation.

Interpolation

Describes the interpolation behaviour between keyframes.

LoopMode

Describes the looping behaviour of an Action.

Values

The keyframe values of a Track.

Type Definitions

Target

A target of an animation.