Skip to content

Commit

Permalink
Split up animated_fox example (#17191)
Browse files Browse the repository at this point in the history
# Objective

Our `animated_fox` example used to be a bare-bones example of how to
spawn an animated gltf and play a single animation.

I think that's a valuable example, and the current `animated_fox`
example is doing way too much. Users who are trying to understand how
our animation system are presented with an enormous amount of
information that may not be immediately relevant.

Over the past few releases, I've been migrating a simple app of mine
where the only animation I need is a single gltf that starts playing a
single animation when it is loaded. It has been a slight struggle to
wade through changes to the animation system to figure out the minimal
amount of things required to accomplish this.

Somewhat motivated by this [recent reddit
thread](https://www.reddit.com/r/rust/comments/1ht93vl/comment/m5c0nc9/?utm_source=share&utm_medium=mweb3x&utm_name=mweb3xcss&utm_term=1)
where Bevy and animation got a mention.

## Solution

- Split `animated_fox` into three separate examples
  - `animated_fox` - Loads and immediately plays a single animation
  - `animated_fox_control` - Shows how to control animations
- `animated_fox_events` - Shows fancy particles when the fox's feet hit
the ground
- Some minor drive-by tidying of these examples

I have created this PR after playing around with the idea and liking how
it turned out, but the duplication isn't totally ideal and there's some
slight overlap with other examples and inconsistencies:

- `animation_events` is simplified and not specific to "loaded animated
scenes" and seems valuable on its own
- `animation_graph` also uses a fox

I am happy to close this if there's no consensus that it's a good idea /
step forward for these examples.

## Testing

`cargo run --example animated_fox`
`cargo run --example animated_fox_control`
`cargo run --example animated_fox_events`
  • Loading branch information
rparrett authored Jan 6, 2025
1 parent 94596d2 commit 6f68776
Show file tree
Hide file tree
Showing 5 changed files with 543 additions and 314 deletions.
22 changes: 22 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -1291,6 +1291,28 @@ description = "Plays an animation from a skinned glTF"
category = "Animation"
wasm = true

[[example]]
name = "animated_fox_control"
path = "examples/animation/animated_fox_control.rs"
doc-scrape-examples = true

[package.metadata.example.animated_fox_control]
name = "Animated Fox Control"
description = "Plays an animation from a skinned glTF with keyboard controls"
category = "Animation"
wasm = true

[[example]]
name = "animated_fox_events"
path = "examples/animation/animated_fox_events.rs"
doc-scrape-examples = true

[package.metadata.example.animated_fox_events]
name = "Animated Fox Events"
description = "Plays an animation from a skinned glTF with events"
category = "Animation"
wasm = true

[[example]]
name = "animation_graph"
path = "examples/animation/animation_graph.rs"
Expand Down
2 changes: 2 additions & 0 deletions examples/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,8 @@ Example | Description
Example | Description
--- | ---
[Animated Fox](../examples/animation/animated_fox.rs) | Plays an animation from a skinned glTF
[Animated Fox Control](../examples/animation/animated_fox_control.rs) | Plays an animation from a skinned glTF with keyboard controls
[Animated Fox Events](../examples/animation/animated_fox_events.rs) | Plays an animation from a skinned glTF with events
[Animated Transform](../examples/animation/animated_transform.rs) | Create and play an animation defined by code that operates on the `Transform` component
[Animated UI](../examples/animation/animated_ui.rs) | Shows how to use animation clips to animate UI properties
[Animation Events](../examples/animation/animation_events.rs) | Demonstrate how to use animation events
Expand Down
Loading

0 comments on commit 6f68776

Please sign in to comment.