Cooler animations
This commit is contained in:
4
Cargo.lock
generated
4
Cargo.lock
generated
@@ -1993,9 +1993,9 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "stardust-xr-molecules"
|
name = "stardust-xr-molecules"
|
||||||
version = "0.21.1"
|
version = "0.22.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "4c16d448b75aff896519f94910a525bf5588a53cf54d5256a7eef05f604ffce4"
|
checksum = "5fe2979f1816d21c3d1a88351f92e1a011992b166072a5fbc73221d6d4557a8e"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"color-rs",
|
"color-rs",
|
||||||
"glam 0.23.0",
|
"glam 0.23.0",
|
||||||
|
|||||||
@@ -20,7 +20,7 @@ nix = "0.26.1"
|
|||||||
resvg = "0.29.0"
|
resvg = "0.29.0"
|
||||||
rustc-hash = "1.1.0"
|
rustc-hash = "1.1.0"
|
||||||
stardust-xr-fusion = "0.38.1"
|
stardust-xr-fusion = "0.38.1"
|
||||||
stardust-xr-molecules = "0.21.1"
|
stardust-xr-molecules = "0.22.0"
|
||||||
tokio = { version = "1.24.1", features = ["full"] }
|
tokio = { version = "1.24.1", features = ["full"] }
|
||||||
tracing-subscriber = { version = "0.3.16", features = ["env-filter"] }
|
tracing-subscriber = { version = "0.3.16", features = ["env-filter"] }
|
||||||
tween = "2.0.0"
|
tween = "2.0.0"
|
||||||
|
|||||||
@@ -62,6 +62,7 @@ pub struct ProtoStar {
|
|||||||
grabbable_grow: Option<Tweener<f32, f64, QuartInOut>>,
|
grabbable_grow: Option<Tweener<f32, f64, QuartInOut>>,
|
||||||
execute_command: String,
|
execute_command: String,
|
||||||
currently_shown: bool,
|
currently_shown: bool,
|
||||||
|
grabbabe_move: Option<Tweener<f32, f64, QuartInOut>>,
|
||||||
}
|
}
|
||||||
impl ProtoStar {
|
impl ProtoStar {
|
||||||
pub fn create_from_desktop_file(
|
pub fn create_from_desktop_file(
|
||||||
@@ -144,6 +145,7 @@ impl ProtoStar {
|
|||||||
grabbable_grow: None,
|
grabbable_grow: None,
|
||||||
execute_command,
|
execute_command,
|
||||||
currently_shown: true,
|
currently_shown: true,
|
||||||
|
grabbabe_move: None,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
pub fn content_parent(&self) -> &Spatial {
|
pub fn content_parent(&self) -> &Spatial {
|
||||||
@@ -151,17 +153,39 @@ impl ProtoStar {
|
|||||||
}
|
}
|
||||||
pub fn toggle(&mut self) {
|
pub fn toggle(&mut self) {
|
||||||
if self.currently_shown {
|
if self.currently_shown {
|
||||||
self.grabbable_shrink = Some(Tweener::quart_in_out(1.0, 0.0001, 0.25)); //TODO make the scale a parameter
|
self.grabbabe_move = Some(Tweener::quart_in_out(1.0, 0.0001, 0.25)); //TODO make the scale a parameter
|
||||||
} else {
|
} else {
|
||||||
self.grabbable_grow = Some(Tweener::quart_in_out(0.0001, 1.0, 0.25));
|
self.grabbable
|
||||||
|
.content_parent()
|
||||||
|
.set_scale(None, Vector3::from([1.0; 3]))
|
||||||
|
.unwrap();
|
||||||
|
self.grabbabe_move = Some(Tweener::quart_in_out(0.0001, 1.0, 0.25));
|
||||||
}
|
}
|
||||||
self.currently_shown = !self.currently_shown;
|
self.currently_shown = !self.currently_shown;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
impl RootHandler for ProtoStar {
|
impl RootHandler for ProtoStar {
|
||||||
fn frame(&mut self, info: FrameInfo) {
|
fn frame(&mut self, info: FrameInfo) {
|
||||||
|
|
||||||
self.grabbable.update(&info);
|
self.grabbable.update(&info);
|
||||||
|
|
||||||
|
if let Some(grabbabe_move) = &mut self.grabbabe_move {
|
||||||
|
if !grabbabe_move.is_finished() {
|
||||||
|
let scale = grabbabe_move.move_by(info.delta);
|
||||||
|
self.grabbable
|
||||||
|
.content_parent()
|
||||||
|
.set_position(None, [self.position.x*scale, self.position.y*scale, self.position.z*scale])
|
||||||
|
.unwrap();
|
||||||
|
} else {
|
||||||
|
if grabbabe_move.final_value() == 0.0001 {
|
||||||
|
self.grabbable
|
||||||
|
.content_parent()
|
||||||
|
.set_scale(None, Vector3::from([0.001; 3]))
|
||||||
|
.unwrap();
|
||||||
|
}
|
||||||
|
self.grabbabe_move = None;
|
||||||
|
}
|
||||||
|
}
|
||||||
if let Some(grabbable_shrink) = &mut self.grabbable_shrink {
|
if let Some(grabbable_shrink) = &mut self.grabbable_shrink {
|
||||||
if !grabbable_shrink.is_finished() {
|
if !grabbable_shrink.is_finished() {
|
||||||
let scale = grabbable_shrink.move_by(info.delta);
|
let scale = grabbable_shrink.move_by(info.delta);
|
||||||
@@ -172,6 +196,8 @@ impl RootHandler for ProtoStar {
|
|||||||
} else {
|
} else {
|
||||||
if self.currently_shown {
|
if self.currently_shown {
|
||||||
self.grabbable_grow = Some(Tweener::quart_in_out(0.0001, 1.0, 0.25)); //TODO make the scale a parameter
|
self.grabbable_grow = Some(Tweener::quart_in_out(0.0001, 1.0, 0.25)); //TODO make the scale a parameter
|
||||||
|
self.grabbable.cancel_angular_velocity();
|
||||||
|
self.grabbable.cancel_linear_velocity();
|
||||||
}
|
}
|
||||||
self.grabbable_shrink = None;
|
self.grabbable_shrink = None;
|
||||||
self.grabbable
|
self.grabbable
|
||||||
|
|||||||
Reference in New Issue
Block a user