From ae5cc9e53845c17983a03db356c0ef1c695bc807 Mon Sep 17 00:00:00 2001 From: "Spencer C. Imbleau" Date: Sun, 9 Feb 2025 22:54:11 -0500 Subject: [PATCH] feat: lottie required components --- examples/lottie/src/main.rs | 13 ++++++------- src/integrations/lottie/asset.rs | 13 +++++++++++-- src/integrations/lottie/mod.rs | 6 ++++++ 3 files changed, 23 insertions(+), 9 deletions(-) diff --git a/examples/lottie/src/main.rs b/examples/lottie/src/main.rs index 5459cdc..15f59ac 100644 --- a/examples/lottie/src/main.rs +++ b/examples/lottie/src/main.rs @@ -19,11 +19,10 @@ fn main() { fn load_lottie(mut commands: Commands, asset_server: ResMut) { 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))); } diff --git a/src/integrations/lottie/asset.rs b/src/integrations/lottie/asset.rs index 45b0ee7..7b940f3 100644 --- a/src/integrations/lottie/asset.rs +++ b/src/integrations/lottie/asset.rs @@ -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); #[derive(Asset, TypePath, Clone)] diff --git a/src/integrations/lottie/mod.rs b/src/integrations/lottie/mod.rs index 4c5e0cf..5d9c998 100644 --- a/src/integrations/lottie/mod.rs +++ b/src/integrations/lottie/mod.rs @@ -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