bevyengine/bevy
Animation
Skeletal and morph-target animation, the animation graph, and how bevy_gltf's animation clips drive entity properties.
Pieces
bevy_animation— clips, players, graph.bevy_math—Curvetrait, easing functions.bevy_reflect— path-based property access.bevy_gltf— typical clip source.
Concepts
| Concept | Where |
|---|---|
AnimationClip |
A bag of curves keyed by reflectable paths. Asset. |
AnimationGraph |
A DAG of clip / blend / add nodes that produces a single output sample. Asset. |
AnimationPlayer |
Component on an entity. Ticks the graph each frame, applies the result. |
AnimationTarget |
Component on every entity whose properties an animation can drive. Identifies the entity in path-based lookups. |
How it works
sequenceDiagram
participant gltf as bevy_gltf
participant Asset as Assets<AnimationClip>
participant Player as AnimationPlayer
participant Graph as AnimationGraph
participant Targets as AnimationTarget
gltf->>Asset: load .gltf clips
Player->>Graph: tick(time)
Graph->>Asset: sample curves
Graph-->>Player: animated values
Player->>Targets: write via reflect pathEach frame:
- The
AnimationPlayeradvances time and asks itsAnimationGraphfor samples. - Graph nodes compose results: a
Clipnode samples one clip; anAddnode mixes two; aBlendnode weights them. - The output is a map of
(target id, property path) → animated value. - The player walks each entry, finds the entity with that target id, and writes the value through reflection.
Path-based access
A path looks like Transform.translation or MeshMaterial3d<StandardMaterial>.base_color. The path resolves through bevy_reflect's GetPath trait, which walks fields by name.
AnimationTarget carries a unique id assigned at clip-build time. The player can re-locate the same target after re-spawning a hierarchy by hashing the joint name.
Skinned meshes
A skinned mesh has bones (entities with Transforms) and joint indices/weights baked into the mesh vertex attributes. The renderer (bevy_pbr) uses the bone transforms each frame to compute joint matrices and apply them in the vertex shader.
bevy_gltf builds the skin hierarchy as part of importing a glTF file. bevy_animation ticks the bone transforms; bevy_pbr reads them on the GPU side.
Morph targets
MorphWeights is a per-mesh component holding per-target weights. The animation system writes to it, and the vertex shader sums per-vertex morph deltas weighted by these values. Used for facial animation and other shape-based deformation.
Easing and curves
The Curve framework in bevy_math produces samples at parameter t. EaseFunction provides ~30 built-in easings. For animation, the typical curve is a cubic spline keyframe (Hermite or Bezier), implemented in crates/bevy_animation/src/gltf_curves.rs.
Triggering events at clip times
AnimationEvents can be inserted into a clip; they fire when the player's time crosses the event's marker. Used to trigger sound effects, particle emitters, or gameplay events at specific animation moments.
See also
bevy_animation— implementation.bevy_gltf— clip source.bevy_math—Curvetrait.bevy_reflect— path-based access.examples/animation/.
Built by Factory AutoWiki from public repository content. It is a generated preview for codebase exploration, not source-maintained documentation.