diff --git a/src/display3d.rs b/src/display3d.rs index b2638cb..09563ea 100644 --- a/src/display3d.rs +++ b/src/display3d.rs @@ -170,16 +170,18 @@ fn hydrate_camera( assets_map: Res, gltfs: Res>, state: Res>, + _clips: Res>, mut players: Query<&mut AnimationPlayer>, mut commands: Commands, ) { events .iter() - .filter(|(name, _)| name.as_str() == "GameCam") - .for_each(|(_, entity)| { + .find(|(name, _)| name.as_str() == "GameCam") + .iter() + .for_each(|(_name, entity)| { info!("Initialize 3d camera"); // Populate the components for the camera - commands.entity(entity).insert(( + commands.entity(*entity).insert(( Display3d, DisplayState::Display3d, Camera3dBundle { @@ -208,15 +210,19 @@ fn hydrate_camera( let gltf = gltfs.get(&assets_map.models).expect("Load GLTF content"); // Set it to the default position by starting the initial animation - if let Ok(mut player) = players.get_mut(entity) { + if let Ok(mut player) = players.get_mut(*entity) { debug!("Animations: {:?}", gltf.named_animations.keys()); // GameCamIntro1, GameCamIntro2, GameCamSide1>2, GameCamSide2>1 + info!("Animation 1: {:?}", _clips.get(gltf.named_animations.get("GameCamIntro1").unwrap())); + info!("Animation 2: {:?}", _clips.get(gltf.named_animations.get("GameCamIntro2").unwrap())); let animation = match state.get() { game::TurnState::SideA => gltf.named_animations.get("GameCamIntro1"), game::TurnState::SideB => gltf.named_animations.get("GameCamIntro2"), - }; + }.expect("Camera startup"); + info!("Compatible: {:?}", _clips.get(animation).unwrap().compatible_with(_name)); + info!("Entity: {:?}", *entity); player - .play(animation.expect("Camera Startup").clone()) + .play(animation.clone()) .pause(); } });