diff --git a/Cargo.toml b/Cargo.toml index 659d7a4..acb53d1 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -23,7 +23,7 @@ nodejs = ["wasm", "dep:js-sys", "dep:wasm-bindgen"] [dependencies] bimap = { version = "0.6" } bytecheck = { version = "0.6", optional = true, default-features = false } -glam = { version = "0.27", features = [ "core-simd", "libm" ] } +glam = { version = "0.29", features = [ "core-simd", "libm" ] } js-sys = { version = "0.3", optional = true } rkyv = { version = "0.7", optional = true, features = [ "validation" ] } serde = { version= "1.0", optional = true, features = [ "serde_derive" ] } diff --git a/demo/Cargo.toml b/demo/Cargo.toml index 0346efc..fd99cf6 100644 --- a/demo/Cargo.toml +++ b/demo/Cargo.toml @@ -6,6 +6,6 @@ edition = "2021" resolver = "2" [dependencies] -bevy = "0.14" +bevy = "0.15" ozz-animation-rs = { path = "../" } -reqwest = "0.11" +reqwest = "0.12" diff --git a/demo/src/blend.rs b/demo/src/blend.rs index bc51a5b..ade75c5 100644 --- a/demo/src/blend.rs +++ b/demo/src/blend.rs @@ -122,7 +122,7 @@ impl OzzExample for OzzBlend { fn update(&mut self, time: Time) { let duration = self.sample_job1.animation().unwrap().duration(); - let scaled_time = time.elapsed_seconds() * 0.5; + let scaled_time = time.elapsed_secs() * 0.5; let ratio = (scaled_time % duration) / duration; self.sample_job1.set_ratio(ratio); diff --git a/demo/src/main.rs b/demo/src/main.rs index 555e4a7..4890752 100644 --- a/demo/src/main.rs +++ b/demo/src/main.rs @@ -20,12 +20,8 @@ const BONE_COUNT: usize = 256; fn main() { App::new() .add_plugins(DefaultPlugins) - .add_systems(Startup, setup) - .add_systems(Startup, setup_ui) - .add_systems(Update, update_ozz_animation) - .add_systems(Update, update_camera) - .add_systems(Update, update_bones) - .add_systems(Update, draw_spines) + .add_systems(Startup, (setup, setup_ui)) + .add_systems(Update, (update_ozz_animation, update_camera, update_bones, draw_spines)) .run(); } @@ -85,81 +81,73 @@ fn setup(mut commands: Commands, mut meshes: ResMut>, mut materials commands.spawn(oc); // ground - commands.spawn(PbrBundle { - mesh: meshes.add(Rectangle::new(20.0, 30.0)), - material: materials.add(Color::srgb(1.0, 0.96, 0.95)), - transform: Transform::from_rotation(Quat::from_rotation_x(-std::f32::consts::FRAC_PI_2)) + commands.spawn(( + Mesh3d(meshes.add(Rectangle::new(20.0, 30.0))), + MeshMaterial3d(materials.add(Color::srgb(1.0, 0.96, 0.95))), + Transform::from_rotation(Quat::from_rotation_x(-std::f32::consts::FRAC_PI_2)) .with_translation(Vec3::new(-2.0, 0.0, -5.0)), - ..default() - }); + )); // bones let bone_mesh = meshes.add(build_bone_mesh()); let bone_material = materials.add(Color::srgb(0.68, 0.68, 0.8)); for i in 0..BONE_COUNT { commands.spawn(( - PbrBundle { - mesh: bone_mesh.clone(), - material: bone_material.clone(), - transform: Transform::from_xyz(0.0, 0.0, 0.0), - visibility: Visibility::Hidden, - ..default() - }, + Mesh3d(bone_mesh.clone()), + MeshMaterial3d(bone_material.clone()), + Transform::from_xyz(0.0, 0.0, 0.0), + Visibility::Hidden, BoneIndex(i), )); } // camera - commands.spawn(Camera3dBundle { - transform: Transform::from_xyz(1.5, 1.0, 3.0).looking_at(Vec3::new(0.0, 1.0, -0.0), Vec3::Y), - ..default() - }); + commands.spawn(( + Camera3d::default(), + Transform::from_xyz(1.5, 1.0, 3.0).looking_at(Vec3::new(0.0, 1.0, -0.0), Vec3::Y), + )); // Sky commands.spawn(( - PbrBundle { - mesh: meshes.add(Cuboid::new(2.0, 1.0, 1.0)), - material: materials.add(StandardMaterial { - base_color: Color::srgb(0.4, 0.61, 0.98), - unlit: true, - cull_mode: None, - ..default() - }), - transform: Transform::from_scale(Vec3::splat(30.0)), + Mesh3d(meshes.add(Cuboid::new(2.0, 1.0, 1.0))), + MeshMaterial3d(materials.add(StandardMaterial { + base_color: Color::srgb(0.4, 0.61, 0.98), + unlit: true, + cull_mode: None, ..default() - }, + })), + Transform::from_scale(Vec3::splat(30.0)), NotShadowCaster, )); // Sun - commands.spawn(DirectionalLightBundle { - directional_light: DirectionalLight { + commands.spawn(( + DirectionalLight { color: Color::WHITE, illuminance: 10000.0, shadows_enabled: true, shadow_depth_bias: 0.05, shadow_normal_bias: 0.9, }, - transform: Transform::from_xyz(-3.0, 1.6, -4.0).looking_at(Vec3::new(0.0, 0.0, 0.0), Vec3::Y), - ..default() - }); + Transform::from_xyz(-3.0, 1.6, -4.0).looking_at(Vec3::new(0.0, 0.0, 0.0), Vec3::Y), + )); // light - commands.spawn(PointLightBundle { - point_light: PointLight { + commands.spawn(( + PointLight { shadows_enabled: false, color: Color::WHITE, ..default() }, - transform: Transform::from_xyz(0.0, 5.0, 3.0), - ..default() - }); + Transform::from_xyz(0.0, 5.0, 3.0), + )); } fn update_ozz_animation( keycode: Res>, mut oc_query: Query<&mut OzzComponent>, - mut text_query: Query<&mut Text, With>, + text_query: Query>, + mut writer: TextUiWriter, time: Res