loading animation

This commit is contained in:
Lee-Orr
2024-02-08 19:01:18 -05:00
parent 5ce86b6f9b
commit 725a56aa5a
5 changed files with 52 additions and 12 deletions
+18
View File
@@ -1,7 +1,10 @@
#![allow(clippy::type_complexity)]
use bevy::{
pbr::{CascadeShadowConfigBuilder, DirectionalLightShadowMap},
prelude::*,
};
use bevy_facial_mocap::{CSVAnimationLoader, CSVAnimationLoaderSettings};
use bevy_inspector_egui::quick::WorldInspectorPlugin;
fn main() {
@@ -9,10 +12,15 @@ fn main() {
.insert_resource(DirectionalLightShadowMap { size: 4096 })
.add_plugins(DefaultPlugins)
.add_plugins(WorldInspectorPlugin::new())
.init_asset_loader::<CSVAnimationLoader>()
.add_systems(Startup, setup)
.add_systems(Update, setup_animation)
.run();
}
#[derive(Component)]
struct AnimationRunning(Handle<AnimationClip>);
fn setup(mut commands: Commands, asset_server: Res<AssetServer>) {
commands.spawn(Camera3dBundle {
transform: Transform::from_xyz(0.7, 0.7, 1.0).looking_at(Vec3::new(0.0, 0.3, 0.0), Vec3::Y),
@@ -42,3 +50,13 @@ fn setup(mut commands: Commands, asset_server: Res<AssetServer>) {
..default()
});
}
fn setup_animation(mut commands: Commands, asset_server: Res<AssetServer>, mut players: Query<Entity, (With<MorphWeights>, Without<AnimationRunning>)>) {
for entity in &mut players {
let handle = asset_server.load_with_settings("20240205_shapekey_BevyImplementationFaceCap_5/shapekey_BevyImplementationFaceCap_5_ScottiPhone_raw.morph_anim.csv", |s: &mut CSVAnimationLoaderSettings| { s.0.parts = vec![Name::new("pascal_Head")]; });
let mut player = AnimationPlayer::default();
player.play(handle.clone()).repeat();
commands.entity(entity).insert((AnimationRunning(handle), player));
}
}