|
|
|
@ -1,6 +1,7 @@
|
|
|
|
use bevy::core_pipeline::{
|
|
|
|
use bevy::core_pipeline::{
|
|
|
|
contrast_adaptive_sharpening::ContrastAdaptiveSharpeningSettings, fxaa::Fxaa,
|
|
|
|
contrast_adaptive_sharpening::ContrastAdaptiveSharpeningSettings, fxaa::Fxaa,
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
use gltf::Animation;
|
|
|
|
|
|
|
|
|
|
|
|
use crate::prelude::*;
|
|
|
|
use crate::prelude::*;
|
|
|
|
|
|
|
|
|
|
|
|
@ -14,7 +15,7 @@ impl Plugin for Display3dPlugin {
|
|
|
|
))
|
|
|
|
))
|
|
|
|
.init_state::<DissolvingAnimation>()
|
|
|
|
.init_state::<DissolvingAnimation>()
|
|
|
|
.init_resource::<PiecePointer>()
|
|
|
|
.init_resource::<PiecePointer>()
|
|
|
|
.insert_resource(AnimationSpeed(1.0))
|
|
|
|
.init_resource::<AnimationSpeed>()
|
|
|
|
.insert_resource(Msaa::Off)
|
|
|
|
.insert_resource(Msaa::Off)
|
|
|
|
.insert_resource(AmbientLight {
|
|
|
|
.insert_resource(AmbientLight {
|
|
|
|
color: Color::WHITE,
|
|
|
|
color: Color::WHITE,
|
|
|
|
@ -202,7 +203,23 @@ enum DissolvingAnimation {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
#[derive(Debug, Resource)]
|
|
|
|
#[derive(Debug, Resource)]
|
|
|
|
struct AnimationSpeed(f32);
|
|
|
|
pub(crate) struct AnimationSpeed {
|
|
|
|
|
|
|
|
pub movement: f32,
|
|
|
|
|
|
|
|
pub text: f32,
|
|
|
|
|
|
|
|
pub dissolve: f32,
|
|
|
|
|
|
|
|
pub light: f32,
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
impl Default for AnimationSpeed {
|
|
|
|
|
|
|
|
fn default() -> Self {
|
|
|
|
|
|
|
|
AnimationSpeed {
|
|
|
|
|
|
|
|
movement: 1.0,
|
|
|
|
|
|
|
|
text: 1.0,
|
|
|
|
|
|
|
|
dissolve: 1.0,
|
|
|
|
|
|
|
|
light: 1.0,
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
#[derive(Debug, Resource, Clone)]
|
|
|
|
#[derive(Debug, Resource, Clone)]
|
|
|
|
struct AssetsMap {
|
|
|
|
struct AssetsMap {
|
|
|
|
@ -1011,15 +1028,20 @@ fn set_animation_speed(
|
|
|
|
keys: Res<ButtonInput<KeyCode>>,
|
|
|
|
keys: Res<ButtonInput<KeyCode>>,
|
|
|
|
mouse: Res<ButtonInput<MouseButton>>,
|
|
|
|
mouse: Res<ButtonInput<MouseButton>>,
|
|
|
|
) {
|
|
|
|
) {
|
|
|
|
animation_speed.0 = if keys.pressed(KeyCode::Enter) || mouse.pressed(MouseButton::Left) {
|
|
|
|
*animation_speed = if keys.pressed(KeyCode::Enter) || mouse.pressed(MouseButton::Left) {
|
|
|
|
let tweak = tweaks
|
|
|
|
let tweak = tweaks
|
|
|
|
.get(tweaks_file.handle.clone())
|
|
|
|
.get(tweaks_file.handle.clone())
|
|
|
|
.expect("Load tweakfile");
|
|
|
|
.expect("Load tweakfile");
|
|
|
|
let speed = tweak.get::<f32>("animation_fast_speed").unwrap();
|
|
|
|
let movement = tweak.get::<f32>("animation_fast_movement_speed").unwrap();
|
|
|
|
speed
|
|
|
|
let text = tweak.get::<f32>("animation_fast_text_speed").unwrap();
|
|
|
|
|
|
|
|
let dissolve = tweak.get::<f32>("animation_fast_dissolve_speed").unwrap();
|
|
|
|
|
|
|
|
let light = tweak.get::<f32>("animation_fast_light_speed").unwrap();
|
|
|
|
|
|
|
|
AnimationSpeed { movement, text, dissolve, light }
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
1.0
|
|
|
|
AnimationSpeed::default()
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
info!("Animation speed: {:?}", animation_speed.movement);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// When an animation starts, or the animation speed changes, update player speed
|
|
|
|
// When an animation starts, or the animation speed changes, update player speed
|
|
|
|
@ -1028,7 +1050,7 @@ fn set_animation_player_speed(
|
|
|
|
animation_speed: Res<AnimationSpeed>,
|
|
|
|
animation_speed: Res<AnimationSpeed>,
|
|
|
|
) {
|
|
|
|
) {
|
|
|
|
players.iter_mut().for_each(|mut p| {
|
|
|
|
players.iter_mut().for_each(|mut p| {
|
|
|
|
p.set_speed(animation_speed.0);
|
|
|
|
p.set_speed(animation_speed.movement);
|
|
|
|
})
|
|
|
|
})
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@ -1331,7 +1353,7 @@ fn dissolve_animation(
|
|
|
|
let percentage = match *dissolving {
|
|
|
|
let percentage = match *dissolving {
|
|
|
|
Dissolving::In(mut sec) => {
|
|
|
|
Dissolving::In(mut sec) => {
|
|
|
|
// Check if seconds is below 0.0
|
|
|
|
// Check if seconds is below 0.0
|
|
|
|
sec = (sec - (time.delta_seconds() * animation_speed.0)).max(0.0);
|
|
|
|
sec = (sec - (time.delta_seconds() * animation_speed.dissolve)).max(0.0);
|
|
|
|
|
|
|
|
|
|
|
|
*dissolving = Dissolving::In(sec);
|
|
|
|
*dissolving = Dissolving::In(sec);
|
|
|
|
|
|
|
|
|
|
|
|
@ -1340,7 +1362,7 @@ fn dissolve_animation(
|
|
|
|
}
|
|
|
|
}
|
|
|
|
Dissolving::Out(mut sec) => {
|
|
|
|
Dissolving::Out(mut sec) => {
|
|
|
|
// Check if seconds is below 0.0
|
|
|
|
// Check if seconds is below 0.0
|
|
|
|
sec = (sec - (time.delta_seconds() * animation_speed.0)).max(0.0);
|
|
|
|
sec = (sec - (time.delta_seconds() * animation_speed.dissolve)).max(0.0);
|
|
|
|
|
|
|
|
|
|
|
|
*dissolving = Dissolving::Out(sec);
|
|
|
|
*dissolving = Dissolving::Out(sec);
|
|
|
|
|
|
|
|
|
|
|
|
@ -1449,21 +1471,14 @@ fn animate_title_light_in(
|
|
|
|
mut t: Local<Timer>,
|
|
|
|
mut t: Local<Timer>,
|
|
|
|
mut started: Local<bool>,
|
|
|
|
mut started: Local<bool>,
|
|
|
|
time: Res<Time>,
|
|
|
|
time: Res<Time>,
|
|
|
|
keys: Res<ButtonInput<KeyCode>>,
|
|
|
|
animation_speed: Res<AnimationSpeed>,
|
|
|
|
mouse: Res<ButtonInput<MouseButton>>,
|
|
|
|
|
|
|
|
) {
|
|
|
|
) {
|
|
|
|
// Over 6 seconds, fade in to 600 intensity
|
|
|
|
// Over 6 seconds, fade in to 600 intensity
|
|
|
|
if !(*started) {
|
|
|
|
if !(*started) {
|
|
|
|
*t = Timer::from_seconds(6.0, TimerMode::Once);
|
|
|
|
*t = Timer::from_seconds(6.0, TimerMode::Once);
|
|
|
|
*started = true
|
|
|
|
*started = true
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
let skip = keys.just_pressed(KeyCode::Enter) || mouse.just_pressed(MouseButton::Left);
|
|
|
|
t.tick(Duration::from_secs_f32(time.delta_seconds() * animation_speed.light));
|
|
|
|
|
|
|
|
|
|
|
|
if skip {
|
|
|
|
|
|
|
|
t.tick(Duration::from_secs(6));
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
t.tick(time.delta());
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
let intensity = t.fraction() * 409800.0;
|
|
|
|
let intensity = t.fraction() * 409800.0;
|
|
|
|
@ -1488,21 +1503,14 @@ fn animate_title_light_out(
|
|
|
|
mut t: Local<Timer>,
|
|
|
|
mut t: Local<Timer>,
|
|
|
|
mut started: Local<bool>,
|
|
|
|
mut started: Local<bool>,
|
|
|
|
time: Res<Time>,
|
|
|
|
time: Res<Time>,
|
|
|
|
keys: Res<ButtonInput<KeyCode>>,
|
|
|
|
animation_speed: Res<AnimationSpeed>,
|
|
|
|
mouse: Res<ButtonInput<MouseButton>>,
|
|
|
|
|
|
|
|
) {
|
|
|
|
) {
|
|
|
|
// Over 6 seconds, fade in to 600 intensity
|
|
|
|
// Over 6 seconds, fade in to 600 intensity
|
|
|
|
if !(*started) {
|
|
|
|
if !(*started) {
|
|
|
|
*t = Timer::from_seconds(3.0, TimerMode::Once);
|
|
|
|
*t = Timer::from_seconds(3.0, TimerMode::Once);
|
|
|
|
*started = true
|
|
|
|
*started = true
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
let skip = keys.just_pressed(KeyCode::Enter) || mouse.just_pressed(MouseButton::Left);
|
|
|
|
t.tick(Duration::from_secs_f32(time.delta_seconds() * animation_speed.light));
|
|
|
|
|
|
|
|
|
|
|
|
if skip {
|
|
|
|
|
|
|
|
t.tick(Duration::from_secs(3));
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
t.tick(time.delta());
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
let intensity = (1.0 - t.fraction()) * 409800.0;
|
|
|
|
let intensity = (1.0 - t.fraction()) * 409800.0;
|
|
|
|
|