Skip to content

Commit

Permalink
build: checkpoint im tired
Browse files Browse the repository at this point in the history
  • Loading branch information
simbleau committed Jan 24, 2024
1 parent a7bfa25 commit 512d16b
Show file tree
Hide file tree
Showing 14 changed files with 456 additions and 348 deletions.
1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ vello = { git = "https://github.com/linebender/vello", rev = "28914d66f675efecf0
vello-svg = { git = "https://github.com/vectorgameexperts/vello-svg", version = "0.1" }
vellottie = { git = "https://github.com/vectorgameexperts/vellottie", version = "0.1" }
flate2 = "1.0"
web-time = "*"

[target.'cfg(target_arch = "wasm32")'.dev-dependencies]
wasm-bindgen-test = "0.3"
1 change: 1 addition & 0 deletions demo/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ publish = false
bevy-vello = { path = "../", features = ["debug"] }
bevy = { workspace = true }
bevy_pancam = "0.10"
bevy_egui = "0.24"


# These settings are to get the WASM blob smaller for the demo.
Expand Down
138 changes: 51 additions & 87 deletions demo/src/main.rs
Original file line number Diff line number Diff line change
@@ -1,15 +1,17 @@
use bevy::{asset::AssetMetaCheck, prelude::*};
use bevy_egui::EguiPlugin;
use bevy_vello::{
debug::DebugVisualizations, AnimationController, AnimationState, AnimationTransition,
ColorPaletteSwap, PlaybackDirection, PlaybackSettings, VelloAsset, VelloAssetBundle,
VelloPlugin, VelloText, VelloTextBundle,
debug::DebugVisualizations, AnimationDirection, AnimationLoopBehavior, AnimationPlayMode,
AnimationState, AnimationTransition, ColorPaletteSwap, LottiePlayer, PlaybackSettings,
VelloAsset, VelloAssetBundle, VelloPlugin, VelloText, VelloTextBundle,
};

fn main() {
App::new()
.insert_resource(AssetMetaCheck::Never)
.add_plugins(DefaultPlugins)
.add_plugins(VelloPlugin)
.add_plugins(EguiPlugin)
.add_plugins(bevy_pancam::PanCamPlugin)
.add_systems(Startup, setup_vector_graphics)
.add_systems(
Expand All @@ -21,40 +23,41 @@ fn main() {

fn setup_vector_graphics(mut commands: Commands, asset_server: ResMut<AssetServer>) {
commands.spawn((Camera2dBundle::default(), bevy_pancam::PanCam::default()));
commands
.spawn(VelloAssetBundle {
origin: bevy_vello::Origin::Center,
vector: asset_server.load("../assets/squid.json"),
debug_visualizations: DebugVisualizations::Visible,
..default()
})
.insert(
AnimationController::new("slow")
.with_state(
AnimationState::new("slow")
.with_asset(asset_server.load("../assets/squid.json"))
.with_transition(AnimationTransition::OnMouseEnter { state: "fast" })
.with_playback_settings(PlaybackSettings {
autoplay: true,
direction: PlaybackDirection::Normal,
speed: 0.2,
looping: true,
segments: 0.0..96.0,
}),
)
.with_state(
AnimationState::new("fast")
.with_asset(asset_server.load("../assets/squid.json"))
.with_playback_settings(PlaybackSettings {
autoplay: true,
direction: PlaybackDirection::Reverse,
speed: 1.0,
looping: true,
segments: 0.0..96.0,
})
.with_transition(AnimationTransition::OnMouseLeave { state: "slow" }),
),
);

//commands.spawn(VelloAssetBundle {
// origin: bevy_vello::Origin::Center,
// vector: asset_server.load("../assets/squid.json"),
// transform: Transform::from_translation(Vec3::splat(-500.0)),
// debug_visualizations: DebugVisualizations::Visible,
// ..default()
//});
//
//commands
// .spawn(VelloAssetBundle {
// origin: bevy_vello::Origin::Center,
// vector: asset_server.load("../assets/squid.json"),
// debug_visualizations: DebugVisualizations::Visible,
// ..default()
// })
// .insert(
// LottiePlayer::new("slow")
// .with_state(
// AnimationState::new("slow")
// .with_transition(AnimationTransition::OnMouseEnter { state: "fast" })
// .with_playback_settings(PlaybackSettings {
// speed: 0.2,
// ..default()
// }),
// )
// .with_state(
// AnimationState::new("fast")
// .with_playback_settings(PlaybackSettings {
// speed: 0.6,
// ..default()
// })
// .with_transition(AnimationTransition::OnMouseLeave { state: "slow" }),
// ),
// );
commands.spawn(VelloTextBundle {
font: asset_server.load("../assets/Rubik-Medium.vttf"),
text: VelloText {
Expand All @@ -64,56 +67,19 @@ fn setup_vector_graphics(mut commands: Commands, asset_server: ResMut<AssetServe
..default()
});

commands
.spawn(VelloAssetBundle {
origin: bevy_vello::Origin::Center,
vector: asset_server.load("../assets/Front.json"),
transform: Transform::from_translation(Vec3::new(300.0, 200.0, 0.0)),
debug_visualizations: DebugVisualizations::Visible,
..default()
})
.insert(
AnimationController::new("slow")
.with_state(
AnimationState::new("slow")
.with_asset(asset_server.load("../assets/Front.json"))
.with_transition(AnimationTransition::OnMouseEnter { state: "fast" })
.with_playback_settings(PlaybackSettings {
autoplay: true,
direction: PlaybackDirection::Normal,
speed: 0.2,
looping: true,
segments: 0.0..96.0,
}),
)
.with_state(
AnimationState::new("fast")
.with_asset(asset_server.load("../assets/Front.json"))
.with_playback_settings(PlaybackSettings {
autoplay: true,
direction: PlaybackDirection::Reverse,
speed: 1.0,
looping: true,
segments: 0.0..96.0,
})
.with_transition(AnimationTransition::OnMouseLeave { state: "slow" }),
),
);

commands
.spawn(VelloAssetBundle {
origin: bevy_vello::Origin::Center,
vector: asset_server.load("../assets/example.json"),
transform: Transform::from_translation(Vec3::new(-750.0, 0.0, 0.0))
.with_scale(Vec3::splat(30.0)),
transform: Transform::from_translation(Vec3::new(0.0, 0.0, 0.0))
.with_scale(Vec3::splat(20.0)),
debug_visualizations: DebugVisualizations::Visible,
..default()
})
.insert(
AnimationController::new("stopped")
LottiePlayer::new("stopped")
.with_state(
AnimationState::new("stopped")
.with_asset(asset_server.load("../assets/example.json"))
.with_transition(AnimationTransition::OnMouseEnter { state: "play" })
.with_playback_settings(PlaybackSettings {
autoplay: false,
Expand All @@ -122,25 +88,22 @@ fn setup_vector_graphics(mut commands: Commands, asset_server: ResMut<AssetServe
)
.with_state(
AnimationState::new("play")
.with_asset(asset_server.load("../assets/example.json"))
.with_transition(AnimationTransition::OnMouseLeave { state: "rev" })
.with_playback_settings(PlaybackSettings {
autoplay: true,
direction: PlaybackDirection::Normal,
looping: false,
direction: AnimationDirection::Normal,
looping: AnimationLoopBehavior::None,
..default()
}),
})
.reset_playhead_on_transition(false),
)
.with_state(
AnimationState::new("rev")
.with_asset(asset_server.load("../assets/example.json"))
.with_playback_settings(PlaybackSettings {
autoplay: true,
direction: PlaybackDirection::Reverse,
looping: false,
direction: AnimationDirection::Reverse,
..default()
})
.with_transition(AnimationTransition::OnComplete { state: "stopped" }),
.with_transition(AnimationTransition::OnComplete { state: "stopped" })
.reset_playhead_on_transition(true),
),
);
}
Expand All @@ -159,6 +122,7 @@ fn dynamic_color_remapping(
0.5,
);
ColorPaletteSwap::empty()
.add("calendar", color)
.add("suckers ", color)
.add("suckers Flip", color)
});
Expand Down
Loading

0 comments on commit 512d16b

Please sign in to comment.