Skip to content

Commit

Permalink
feat: lottie required components
Browse files Browse the repository at this point in the history
  • Loading branch information
simbleau committed Feb 10, 2025
1 parent 6d73312 commit ae5cc9e
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 9 deletions.
13 changes: 6 additions & 7 deletions examples/lottie/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,10 @@ fn main() {
fn load_lottie(mut commands: Commands, asset_server: ResMut<AssetServer>) {
commands.spawn((Camera2d, VelloView));

// Yes, it's this simple.
commands.spawn(VelloLottieBundle {
asset: VelloLottieHandle(asset_server.load("embedded://lottie/assets/Tiger.json")),
debug_visualizations: DebugVisualizations::Visible,
transform: Transform::from_scale(Vec3::splat(0.5)),
..default()
});
// You can also use `VelloLottieBundle`
commands
.spawn(VelloLottieHandle(
asset_server.load("embedded://lottie/assets/Tiger.json"),
))
.insert(Transform::from_scale(Vec3::splat(0.5)));
}
13 changes: 11 additions & 2 deletions src/integrations/lottie/asset.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,18 @@
use super::{LottiePlayer, PlaybackOptions, Playhead};
use crate::prelude::*;
use bevy::{prelude::*, reflect::TypePath};
use std::sync::Arc;

#[derive(Component, Default, Debug, Clone, Deref, DerefMut, PartialEq, Eq)]
#[require(Playhead, PlaybackOptions, LottiePlayer)]
#[require(
VelloLottieAnchor,
CoordinateSpace,
Playhead,
PlaybackOptions,
LottiePlayer,
Transform,
DebugVisualizations,
Visibility
)]
pub struct VelloLottieHandle(pub Handle<VelloLottie>);

#[derive(Asset, TypePath, Clone)]
Expand Down
6 changes: 6 additions & 0 deletions src/integrations/lottie/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,12 @@ pub struct VelloLottieBundle {
pub asset_anchor: VelloLottieAnchor,
/// The coordinate space in which this vector should be rendered.
pub coordinate_space: CoordinateSpace,
/// The current playhead for the animation
pub playhead: Playhead,
/// The playback options for the animation
pub playback_options: PlaybackOptions,
/// The player used for advanced state machine transitions and playback control.
pub player: LottiePlayer,
/// A transform to apply to this vector
pub transform: Transform,
/// Whether to render debug visualizations
Expand Down

0 comments on commit ae5cc9e

Please sign in to comment.