Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2,009 changes: 1,015 additions & 994 deletions Cargo.lock

Large diffs are not rendered by default.

11 changes: 4 additions & 7 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,15 @@ repository = "https://github.com/nixon-voxell/bevy_motiongfx"
readme = "README.md"

[workspace.dependencies]
bevy = { version = "0.14", default-features = false }
bevy_vello_graphics = { version = "0.1.0", git = "https://github.com/voxell-tech/bevy_vello_graphics" }
bevy = { version = "0.15", default-features = false , features = ["bevy_color", "bevy_asset", "bevy_pbr", "bevy_sprite"]}
smallvec = "1"

[package]
name = "bevy_motiongfx"
categories = ["graphics", "gui", "rendering", "motion-graphics", "vector-graphics"]
description = "Motion graphics creation tool in Bevy. (Highly inspired by Motion Canvas and Manim)"
exclude = ["/assets/", "/.github/", "/examples/"]
keywords = ["motion-graphics", "game", "gamedev", "graphics", "bevy", "vello"]
keywords = ["motion-graphics", "game", "gamedev", "graphics", "bevy"]
version.workspace = true
edition.workspace = true
license.workspace = true
Expand All @@ -29,16 +28,14 @@ readme.workspace = true
[dependencies]
motiongfx_core = { version = "0.1.0", path = "crates/motiongfx_core" }
motiongfx_common = { version = "0.1.0", path = "crates/motiongfx_common", optional = true }
motiongfx_vello = { version = "0.1.0", path = "crates/motiongfx_vello", optional = true }
bevy = { workspace = true }

[features]
default = ["common", "vello_graphics"]
default = ["common"]
common = ["dep:motiongfx_common"]
vello_graphics = ["dep:motiongfx_vello", "motiongfx_core/vello_graphics"]

[dev-dependencies]
bevy = "0.14"
bevy = "0.15"

[workspace.lints.clippy]
redundant_type_annotations = "warn"
Expand Down
7 changes: 0 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,13 +41,6 @@ Bevy MotionGfx also comes with built-in easing functions which are crucial for a

*Associated example [here](./examples/easings.rs)!*

## Vector Graphics

In Bevy MotionGfx, all vector graphics are rendered using [Bevy Vello](https://github.com/linebender/bevy_vello).

![vello_basic_gif](./.github/assets/vello_basic.gif)

*Associated example [here](./examples/vello_basic.rs)!*

## Typst Integration (Coming soon...)

Expand Down
61 changes: 29 additions & 32 deletions crates/motiongfx_common/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
use bevy::{
ecs::system::{EntityCommand, EntityCommands},
prelude::*,
};
use bevy::prelude::*;
use motiongfx_core::{prelude::*, UpdateSequenceSet};

pub mod motion;
Expand All @@ -11,7 +8,7 @@ pub mod prelude {
motion::{
standard_material_motion::StandardMaterialMotion, transform_motion::TransformMotion,
},
AddNewAssetCommandExt, MotionGfxCommonPlugin,
MotionGfxCommonPlugin,
};
}

Expand All @@ -27,41 +24,41 @@ impl Plugin for MotionGfxCommonPlugin {
update_component::<Transform, f32>,
update_component::<Sprite, Color>,
update_component::<Sprite, f32>,
update_asset::<StandardMaterial, Color>,
update_asset::<StandardMaterial, LinearRgba>,
update_asset::<StandardMaterial, f32>,
update_asset::<ColorMaterial, Color>,
update_asset::<ColorMaterial, f32>,
update_asset::<MeshMaterial3d<_>, StandardMaterial, Color>,
update_asset::<MeshMaterial3d<_>, StandardMaterial, LinearRgba>,
update_asset::<MeshMaterial3d<_>, StandardMaterial, f32>,
update_asset::<MeshMaterial2d<_>, ColorMaterial, Color>,
update_asset::<MeshMaterial2d<_>, ColorMaterial, f32>,
)
.in_set(UpdateSequenceSet),
);
}
}

pub trait AddNewAssetCommandExt<A: Asset> {
/// Adds a new asset and attach the handle to this entity.
fn add_new_asset(&mut self, asset: A) -> &mut Self;
}
// pub trait AddNewAssetCommandExt<A: Asset> {
// /// Adds a new asset and attach the handle to this entity.
// fn add_new_asset(&mut self, asset: A) -> &mut Self;
// }

impl<A: Asset> AddNewAssetCommandExt<A> for EntityCommands<'_> {
fn add_new_asset(&mut self, asset: A) -> &mut Self {
self.add(AddNewAssetCommand(asset))
}
}
// impl<A: Asset> AddNewAssetCommandExt<A> for EntityCommands<'_> {
// fn add_new_asset(&mut self, asset: A) -> &mut Self {
// self.queue(AddNewAssetCommand(asset))
// }
// }

pub struct AddNewAssetCommand<A: Asset>(A);
// pub struct AddNewAssetCommand<A: Asset>(A);

impl<A: Asset> EntityCommand for AddNewAssetCommand<A> {
fn apply(self, id: Entity, world: &mut World) {
let mut materials = world.get_resource_mut::<Assets<A>>().unwrap_or_else(|| {
panic!(
"Assets<{}> resource not initialized.",
A::type_ident().unwrap()
)
});
// impl<A: Asset> EntityCommand for AddNewAssetCommand<A> {
// fn apply(self, id: Entity, world: &mut World) {
// let mut materials = world.get_resource_mut::<Assets<A>>().unwrap_or_else(|| {
// panic!(
// "Assets<{}> resource not initialized.",
// A::type_ident().unwrap()
// )
// });

let material = materials.add(self.0);
// let material = materials.add(self.0);

world.entity_mut(id).insert(material);
}
}
// // world.entity_mut(id).insert(material);
// }
// }
2 changes: 0 additions & 2 deletions crates/motiongfx_core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ repository.workspace = true

[dependencies]
bevy = { workspace = true }
bevy_vello_graphics = { workspace = true, optional = true }
smallvec = { workspace = true }
motiongfx_core_macros = { version = "0.1.0", path = "macros" }

Expand All @@ -16,4 +15,3 @@ workspace = true

[features]
default = []
vello_graphics = ["dep:bevy_vello_graphics"]
3 changes: 2 additions & 1 deletion crates/motiongfx_core/src/color_palette.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
use bevy::{prelude::*, utils::HashMap};
use bevy::color::{Color, Srgba};
use bevy::utils::HashMap;
use core::hash::Hash;

#[derive(Clone)]
Expand Down
4 changes: 0 additions & 4 deletions crates/motiongfx_core/src/f32lerp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,6 @@ use bevy::prelude::*;

pub mod bevy_f32lerp;
pub mod math_f32lerp;
#[cfg(feature = "vello_graphics")]
pub mod vello_f32lerp;
#[cfg(feature = "vello_graphics")]
pub mod vello_graphics_f32lerp;

pub trait F32Lerp<T = Self, U = Self> {
/// Lerp between 2 values based on a [`f32`] `t` value.
Expand Down
156 changes: 0 additions & 156 deletions crates/motiongfx_core/src/f32lerp/vello_f32lerp.rs

This file was deleted.

31 changes: 0 additions & 31 deletions crates/motiongfx_core/src/f32lerp/vello_graphics_f32lerp.rs

This file was deleted.

18 changes: 10 additions & 8 deletions crates/motiongfx_core/src/sequence.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
use bevy::prelude::*;

use crate::action::{Action, ActionMeta};
use bevy::prelude::*;

/// Bundle to encapsulate [`Sequence`] and [`SequenceController`].
#[derive(Bundle, Default)]
Expand Down Expand Up @@ -255,15 +254,18 @@ pub fn update_component<U, T>(
}

/// System for mutating the [`Asset`] related [`Action`]s that are inside the [`Sequence`].
pub fn update_asset<U, T>(
q_handles: Query<&Handle<U>>,
mut assets: ResMut<Assets<U>>,
q_actions: Query<&'static Action<T, U>>,
pub fn update_asset<U, A, T>(
q_handles: Query<&U>,
mut assets: ResMut<Assets<A>>,
q_actions: Query<&'static Action<T, A>>,
q_sequences: Query<(&Sequence, &SequenceController)>,
) where
T: Send + Sync + 'static,
U: Asset,
U: Component,
A: Asset,
AssetId<A>: for<'a> From<&'a U>,
{
// let q_handles = q_handles.iter
for (sequence, sequence_controller) in q_sequences.iter() {
if let Some(action) = generate_action_iter(&q_actions, sequence, sequence_controller) {
for (action, action_meta) in action {
Expand Down Expand Up @@ -313,7 +315,7 @@ pub(crate) fn sequence_player(
) {
for (sequence, mut sequence_controller, sequence_player) in q_sequences.iter_mut() {
sequence_controller.target_time = f32::clamp(
sequence_controller.target_time + time.delta_seconds() * sequence_player.time_scale,
sequence_controller.target_time + time.delta_secs() * sequence_player.time_scale,
0.0,
sequence.duration(),
);
Expand Down
Loading
Loading