diff --git a/crates/beet_examples/src/emote_agent/render_texture.rs b/crates/beet_examples/src/emote_agent/render_texture.rs index 8cb9f211..5d50b096 100644 --- a/crates/beet_examples/src/emote_agent/render_texture.rs +++ b/crates/beet_examples/src/emote_agent/render_texture.rs @@ -15,18 +15,16 @@ pub struct RenderTexture { pub const RENDER_TEXTURE_LAYER: usize = 1; -pub fn create_render_camera( - mut commands: Commands, - mut images: ResMut>, - mut materials: ResMut>, -) { +pub fn render_texture_bundle( + images: &mut Assets, + materials: &mut Assets, +) -> impl Bundle { let size = Extent3d { width: 512, height: 512, ..default() }; - // This is the texture that will be rendered to. let mut image = Image { texture_descriptor: TextureDescriptor { label: None, @@ -42,7 +40,6 @@ pub fn create_render_camera( }, ..default() }; - // fill image.data with zeroes image.resize(size); @@ -54,8 +51,7 @@ pub fn create_render_camera( ..default() }); - commands.spawn(( - Camera2d, + ( Camera { order: -1, target: image_handle.into(), @@ -64,5 +60,5 @@ pub fn create_render_camera( }, RenderLayers::layer(RENDER_TEXTURE_LAYER), material_handle, - )); -} + ) +} \ No newline at end of file diff --git a/crates/beet_examples/src/emote_agent/scenes/mod.rs b/crates/beet_examples/src/emote_agent/scenes/mod.rs index 8f1902fe..5607cd3c 100644 --- a/crates/beet_examples/src/emote_agent/scenes/mod.rs +++ b/crates/beet_examples/src/emote_agent/scenes/mod.rs @@ -4,6 +4,6 @@ pub use self::barbarian::*; pub mod inverse_kinematics; #[allow(unused_imports)] pub use self::inverse_kinematics::*; -pub mod phone_screen; +pub mod phone_texture; #[allow(unused_imports)] -pub use self::phone_screen::*; +pub use self::phone_texture::*; diff --git a/crates/beet_examples/src/emote_agent/scenes/phone_screen.rs b/crates/beet_examples/src/emote_agent/scenes/phone_texture.rs similarity index 72% rename from crates/beet_examples/src/emote_agent/scenes/phone_screen.rs rename to crates/beet_examples/src/emote_agent/scenes/phone_texture.rs index 5fa17b70..1ff5856f 100644 --- a/crates/beet_examples/src/emote_agent/scenes/phone_screen.rs +++ b/crates/beet_examples/src/emote_agent/scenes/phone_texture.rs @@ -2,7 +2,7 @@ use crate::prelude::*; use bevy::prelude::*; use bevy::render::view::RenderLayers; -pub fn phone_screen( +pub fn phone_texture( mut commands: Commands, asset_server: Res, mut texture_atlas_layouts: ResMut>, @@ -25,3 +25,15 @@ pub fn phone_screen( RenderLayers::layer(RENDER_TEXTURE_LAYER), )); } + +pub fn phone_texture_camera( + mut commands: Commands, + mut images: ResMut>, + mut materials: ResMut>, +) { + commands.spawn(( + render_texture_bundle(&mut images, &mut materials), + // Camera3d::default(), + Camera2d, + )); +} diff --git a/crates/beet_spatial/src/lib.rs b/crates/beet_spatial/src/lib.rs index 62468808..d5631a21 100644 --- a/crates/beet_spatial/src/lib.rs +++ b/crates/beet_spatial/src/lib.rs @@ -3,6 +3,7 @@ pub mod animation; #[cfg(feature = "assets")] pub mod asset_actions; +pub mod procedural_animation; pub mod inverse_kinematics; pub mod movement; pub mod plugins; @@ -16,6 +17,7 @@ pub mod prelude { pub use crate::animation::*; #[cfg(feature = "assets")] pub use crate::asset_actions::*; + pub use crate::procedural_animation::*; pub use crate::inverse_kinematics::*; pub use crate::movement::*; pub use crate::plugins::*; diff --git a/crates/beet_spatial/src/procedural_animation/mod.rs b/crates/beet_spatial/src/procedural_animation/mod.rs new file mode 100644 index 00000000..9ee91403 --- /dev/null +++ b/crates/beet_spatial/src/procedural_animation/mod.rs @@ -0,0 +1,12 @@ +pub mod play_procedural_animation; +#[allow(unused_imports)] +pub use self::play_procedural_animation::*; +pub mod procedural_animation_plugin; +#[allow(unused_imports)] +pub use self::procedural_animation_plugin::*; +pub mod procedural_animation_shape; +#[allow(unused_imports)] +pub use self::procedural_animation_shape::*; +pub mod procedural_animation_speed; +#[allow(unused_imports)] +pub use self::procedural_animation_speed::*; diff --git a/crates/beet_spatial/src/procedural_animation/play_procedural_animation.rs b/crates/beet_spatial/src/procedural_animation/play_procedural_animation.rs new file mode 100644 index 00000000..516bc955 --- /dev/null +++ b/crates/beet_spatial/src/procedural_animation/play_procedural_animation.rs @@ -0,0 +1,56 @@ +use crate::prelude::*; +use beet_flow::prelude::*; +use bevy::animation::RepeatAnimation; +use bevy::prelude::*; + + +#[derive(Debug, Clone, PartialEq, Component, Reflect, Action)] +#[observers(play_procedural_animation)] +#[reflect(Default, Component, ActionMeta)] +pub struct PlayProceduralAnimation { + pub shape: ProceduralAnimationShape, + pub speed: ProceduralAnimationSpeed, + pub repeat: RepeatAnimation, + pub num_animations: u32, + pub last_t: f32, +} + +impl Default for PlayProceduralAnimation { + fn default() -> Self { + Self { + shape:default(), + repeat: default(), + speed: default(), + num_animations: 0, + last_t: 0.0, + } + } +} + +impl PlayProceduralAnimation { + pub fn get_fraction(&self,time:Res