Skip to content

Commit

Permalink
build: player settings
Browse files Browse the repository at this point in the history
  • Loading branch information
simbleau committed Feb 1, 2024
1 parent f2ad94a commit ea6073d
Showing 1 changed file with 10 additions and 7 deletions.
17 changes: 10 additions & 7 deletions src/animation_controller.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,11 @@ impl LottiePlayer {
self.states.values()
}

/// The states in the player
pub fn states_mut(&mut self) -> impl Iterator<Item = &mut AnimationState> {
self.states.values_mut()
}

/// Transition to the next state.
pub fn transition(&mut self, state: &'static str) {
self.next_state.replace(state);
Expand Down Expand Up @@ -252,16 +257,15 @@ pub mod systems {
mut assets: ResMut<Assets<VelloAsset>>,
) {
for (mut player, mut playback_settings, asset_handle) in query.iter_mut() {
let asset = assets.get_mut(asset_handle.id()).unwrap();
let VelloAsset {
let Some(VelloAsset {
data:
Vector::Lottie {
composition,
first_frame: _,
rendered_frames,
},
..
} = asset
}) = assets.get_mut(asset_handle.id())
else {
continue;
};
Expand Down Expand Up @@ -391,16 +395,15 @@ pub mod systems {
}

// Continue, assuming we are currently playing.
let asset = assets.get_mut(asset_handle.id()).unwrap();
let VelloAsset {
let Some(VelloAsset {
data:
Vector::Lottie {
composition,
first_frame, // Set on render
rendered_frames,
},
..
} = asset
}) = assets.get_mut(asset_handle.id())
else {
continue;
};
Expand Down Expand Up @@ -572,7 +575,7 @@ pub mod systems {
Vector::Svg { first_frame, .. }
| Vector::Lottie { first_frame, .. } => first_frame,
};
if started.is_some_and(|s| s.elapsed().as_secs_f32() > *secs) {
if started.is_some_and(|s| s.elapsed().as_secs_f32() >= *secs) {
controller.next_state = Some(state);
break;
}
Expand Down

0 comments on commit ea6073d

Please sign in to comment.