diff --git a/Cargo.toml b/Cargo.toml index bc85084c68c6f..05e5a6fb1e76f 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -126,6 +126,14 @@ path = "examples/3d/texture.rs" name = "z_sort_debug" path = "examples/3d/z_sort_debug.rs" +[[example]] +name = "animation_2d" +path = "examples/animation/animation_2d.rs" + +[[example]] +name = "animation_custom" +path = "examples/animation/animation_custom.rs" + [[example]] name = "custom_loop" path = "examples/app/custom_loop.rs" @@ -359,4 +367,3 @@ icon = "@mipmap/ic_launcher" build_targets = ["aarch64-linux-android", "armv7-linux-androideabi"] min_sdk_version = 16 target_sdk_version = 29 - diff --git a/crates/bevy_animation/Cargo.toml b/crates/bevy_animation/Cargo.toml new file mode 100644 index 0000000000000..e119a62752378 --- /dev/null +++ b/crates/bevy_animation/Cargo.toml @@ -0,0 +1,24 @@ +[package] +name = "bevy_animation" +version = "0.3.0" +edition = "2018" +authors = ["Bevy Contributors ", "Carter Anderson "] +description = "Provides spline animation functionality for Bevy Engine" +homepage = "https://bevyengine.org" +repository = "https://github.com/bevyengine/bevy" +license = "MIT" +keywords = ["bevy"] + +# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html + +[dependencies] +bevy_core = { path = "../bevy_core", version = "0.3.0" } +bevy_math = { path = "../bevy_math", version = "0.3.0" } +bevy_app = { path = "../bevy_app", version = "0.3.0" } +bevy_utils = { path = "../bevy_utils", version = "0.3.0" } +bevy_ecs = { path = "../bevy_ecs", version = "0.3.0" } +bevy_transform = { path = "../bevy_transform", version = "0.3.0" } +bevy_render = { path = "../bevy_render", version = "0.3.0" } +bevy_property = { path = "../bevy_property", version = "0.3.0" } + +splines = { version = "3.5.0", features = ["serialization", "impl-glam"] } diff --git a/crates/bevy_animation/src/lib.rs b/crates/bevy_animation/src/lib.rs new file mode 100644 index 0000000000000..9b1315963574d --- /dev/null +++ b/crates/bevy_animation/src/lib.rs @@ -0,0 +1,25 @@ +pub mod plugin; +pub mod spline_group; +pub mod vec3_option; + +pub mod spline_groups { + pub mod one; + pub mod three; + pub mod transform; +} + +pub use plugin::AnimationPlugin; + +pub mod prelude { + pub use crate::{ + plugin::AnimationPlugin, + spline_group::{LoopStyle, SplineGroup}, + spline_groups::{ + one::AnimationSplineOne, + three::AnimationSplineThree, + transform::{AnimationSplineTransform, SplineQuatExt}, + }, + vec3_option::Vec3Option, + }; + pub use splines::{Interpolate, Interpolation, Key, Spline}; +} diff --git a/crates/bevy_animation/src/plugin.rs b/crates/bevy_animation/src/plugin.rs new file mode 100644 index 0000000000000..f14097eff7b01 --- /dev/null +++ b/crates/bevy_animation/src/plugin.rs @@ -0,0 +1,55 @@ +use crate::{ + spline_group::SplineGroup, + spline_groups::{ + one::AnimationSplineOne, three::AnimationSplineThree, transform::AnimationSplineTransform, + }, +}; + +use bevy_app::{AppBuilder, Plugin}; +use bevy_core::Time; +use bevy_ecs::{IntoSystem, Query, Res}; +use bevy_math::Vec3; +use bevy_transform::components::Transform; + +#[derive(Default)] +pub struct AnimationPlugin; + +impl Plugin for AnimationPlugin { + fn build(&self, app: &mut AppBuilder) { + app.add_system(advance_animation_spline) + .add_system(advance_animation_spline_three.system()) + .add_system(advance_animation_transform.system()); + } +} + +fn advance_animation_spline(time: Res