feat: animation on launch and proper close
This commit is contained in:
118
Cargo.lock
generated
118
Cargo.lock
generated
@@ -8,6 +8,17 @@ version = "0.11.4"
|
|||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "fe438c63458706e03479442743baae6c88256498e6431708f6dfc520a26515d3"
|
checksum = "fe438c63458706e03479442743baae6c88256498e6431708f6dfc520a26515d3"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "ahash"
|
||||||
|
version = "0.7.6"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "fcb51a0695d8f838b1ee009b3fbf66bda078cd64590202a864a8f3e8c4315c47"
|
||||||
|
dependencies = [
|
||||||
|
"getrandom",
|
||||||
|
"once_cell",
|
||||||
|
"version_check",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "aho-corasick"
|
name = "aho-corasick"
|
||||||
version = "0.7.20"
|
version = "0.7.20"
|
||||||
@@ -322,6 +333,15 @@ dependencies = [
|
|||||||
"cxx-build",
|
"cxx-build",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "instant"
|
||||||
|
version = "0.1.12"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "7a5bbe824c507c5da5956355e86a746d82e0e1464f65d862cc5e71da70e94b2c"
|
||||||
|
dependencies = [
|
||||||
|
"cfg-if",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "js-sys"
|
name = "js-sys"
|
||||||
version = "0.3.60"
|
version = "0.3.60"
|
||||||
@@ -389,6 +409,15 @@ version = "2.5.0"
|
|||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "2dffe52ecf27772e601905b7522cb4ef790d2cc203488bbd0e2fe85fcb74566d"
|
checksum = "2dffe52ecf27772e601905b7522cb4ef790d2cc203488bbd0e2fe85fcb74566d"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "memoffset"
|
||||||
|
version = "0.6.5"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "5aa361d4faea93603064a027415f07bd8e1d5c88c9fbf68bf56a285428fd79ce"
|
||||||
|
dependencies = [
|
||||||
|
"autocfg",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "mint"
|
name = "mint"
|
||||||
version = "0.5.9"
|
version = "0.5.9"
|
||||||
@@ -419,6 +448,20 @@ dependencies = [
|
|||||||
"rand",
|
"rand",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "nix"
|
||||||
|
version = "0.25.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "e322c04a9e3440c327fca7b6c8a63e6890a32fa2ad689db972425f07e0d22abb"
|
||||||
|
dependencies = [
|
||||||
|
"autocfg",
|
||||||
|
"bitflags",
|
||||||
|
"cfg-if",
|
||||||
|
"libc",
|
||||||
|
"memoffset",
|
||||||
|
"pin-utils",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "num-integer"
|
name = "num-integer"
|
||||||
version = "0.1.45"
|
version = "0.1.45"
|
||||||
@@ -498,6 +541,17 @@ dependencies = [
|
|||||||
"syn",
|
"syn",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "parking_lot"
|
||||||
|
version = "0.11.2"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "7d17b78036a60663b797adeaee46f5c9dfebb86948d1255007a1d6be0271ff99"
|
||||||
|
dependencies = [
|
||||||
|
"instant",
|
||||||
|
"lock_api",
|
||||||
|
"parking_lot_core 0.8.5",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "parking_lot"
|
name = "parking_lot"
|
||||||
version = "0.12.1"
|
version = "0.12.1"
|
||||||
@@ -505,7 +559,21 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
|||||||
checksum = "3742b2c103b9f06bc9fff0a37ff4912935851bee6d36f3c02bcc755bcfec228f"
|
checksum = "3742b2c103b9f06bc9fff0a37ff4912935851bee6d36f3c02bcc755bcfec228f"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"lock_api",
|
"lock_api",
|
||||||
"parking_lot_core",
|
"parking_lot_core 0.9.4",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "parking_lot_core"
|
||||||
|
version = "0.8.5"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "d76e8e1493bcac0d2766c42737f34458f1c8c50c0d23bcb24ea953affb273216"
|
||||||
|
dependencies = [
|
||||||
|
"cfg-if",
|
||||||
|
"instant",
|
||||||
|
"libc",
|
||||||
|
"redox_syscall",
|
||||||
|
"smallvec",
|
||||||
|
"winapi",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
@@ -527,6 +595,12 @@ version = "0.2.9"
|
|||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "e0a7ae3ac2f1173085d398531c705756c94a4c56843785df85a60c1a0afac116"
|
checksum = "e0a7ae3ac2f1173085d398531c705756c94a4c56843785df85a60c1a0afac116"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "pin-utils"
|
||||||
|
version = "0.1.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "8b870d8c151b6f2fb93e84a13146138f05d02ed11c7e7c54f8826aaaf7c9f184"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "ppv-lite86"
|
name = "ppv-lite86"
|
||||||
version = "0.2.17"
|
version = "0.2.17"
|
||||||
@@ -579,16 +653,18 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "protostar"
|
name = "protostar"
|
||||||
version = "0.1.0"
|
version = "0.2.0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"anyhow",
|
"anyhow",
|
||||||
"glam 0.22.0",
|
"glam 0.22.0",
|
||||||
"manifest-dir-macros",
|
"manifest-dir-macros",
|
||||||
"mint",
|
"mint",
|
||||||
|
"nix",
|
||||||
"rustc-hash",
|
"rustc-hash",
|
||||||
"stardust-xr-molecules",
|
"stardust-xr-molecules",
|
||||||
"tokio",
|
"tokio",
|
||||||
"tween",
|
"tween",
|
||||||
|
"ustr",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
@@ -687,18 +763,18 @@ checksum = "9c8132065adcfd6e02db789d9285a0deb2f3fcb04002865ab67d5fb103533898"
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "serde"
|
name = "serde"
|
||||||
version = "1.0.147"
|
version = "1.0.148"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "d193d69bae983fc11a79df82342761dfbf28a99fc8d203dca4c3c1b590948965"
|
checksum = "e53f64bb4ba0191d6d0676e1b141ca55047d83b74f5607e6d8eb88126c52c2dc"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"serde_derive",
|
"serde_derive",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "serde_derive"
|
name = "serde_derive"
|
||||||
version = "1.0.147"
|
version = "1.0.148"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "4f1d362ca8fc9c3e3a7484440752472d68a6caa98f1ab81d99b5dfe517cec852"
|
checksum = "a55492425aa53521babf6137309e7d34c20bbfbbfcfe2c7f3a047fd1f6b92c0c"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"proc-macro2",
|
"proc-macro2",
|
||||||
"quote",
|
"quote",
|
||||||
@@ -754,7 +830,7 @@ dependencies = [
|
|||||||
"flatbuffers",
|
"flatbuffers",
|
||||||
"flexbuffers",
|
"flexbuffers",
|
||||||
"mint",
|
"mint",
|
||||||
"parking_lot",
|
"parking_lot 0.12.1",
|
||||||
"rustc-hash",
|
"rustc-hash",
|
||||||
"serde",
|
"serde",
|
||||||
"stardust-xr-schemas",
|
"stardust-xr-schemas",
|
||||||
@@ -765,9 +841,9 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "stardust-xr-fusion"
|
name = "stardust-xr-fusion"
|
||||||
version = "0.22.0"
|
version = "0.23.1"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "ce1305463319add3ce6f9bd2864d79a3a836c752929f052743b8a1e90f3d62d8"
|
checksum = "357475624cc78941af592c755fd51a7f6b85b3323df10542c53993030fbea5a8"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"anyhow",
|
"anyhow",
|
||||||
"buildstructor",
|
"buildstructor",
|
||||||
@@ -777,7 +853,7 @@ dependencies = [
|
|||||||
"glam 0.22.0",
|
"glam 0.22.0",
|
||||||
"mint",
|
"mint",
|
||||||
"nanoid",
|
"nanoid",
|
||||||
"parking_lot",
|
"parking_lot 0.12.1",
|
||||||
"rustc-hash",
|
"rustc-hash",
|
||||||
"serde",
|
"serde",
|
||||||
"serde_repr",
|
"serde_repr",
|
||||||
@@ -789,9 +865,9 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "stardust-xr-molecules"
|
name = "stardust-xr-molecules"
|
||||||
version = "0.5.2"
|
version = "0.5.4"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "59264c72fa87768563ba781264843b1412aaf3bdb4dcec19d7b1b15fbc3027a5"
|
checksum = "e04616f27e92c2d40595c0fbe4f96e5788adca3a855611794c6f202bf2c0ddd0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"color-rs",
|
"color-rs",
|
||||||
"flexbuffers",
|
"flexbuffers",
|
||||||
@@ -833,9 +909,9 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "syn"
|
name = "syn"
|
||||||
version = "1.0.103"
|
version = "1.0.104"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "a864042229133ada95abf3b54fdc62ef5ccabe9515b64717bcb9a1919e59445d"
|
checksum = "4ae548ec36cf198c0ef7710d3c230987c2d6d7bd98ad6edc0274462724c585ce"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"proc-macro2",
|
"proc-macro2",
|
||||||
"quote",
|
"quote",
|
||||||
@@ -894,7 +970,7 @@ dependencies = [
|
|||||||
"memchr",
|
"memchr",
|
||||||
"mio",
|
"mio",
|
||||||
"num_cpus",
|
"num_cpus",
|
||||||
"parking_lot",
|
"parking_lot 0.12.1",
|
||||||
"pin-project-lite",
|
"pin-project-lite",
|
||||||
"signal-hook-registry",
|
"signal-hook-registry",
|
||||||
"socket2",
|
"socket2",
|
||||||
@@ -961,6 +1037,18 @@ version = "0.1.10"
|
|||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "c0edd1e5b14653f783770bce4a4dabb4a5108a5370a5f5d8cfe8710c361f6c8b"
|
checksum = "c0edd1e5b14653f783770bce4a4dabb4a5108a5370a5f5d8cfe8710c361f6c8b"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "ustr"
|
||||||
|
version = "0.9.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "371436099f2980de56dc385b615696d3eabbdac9649a72b85f9d75f68474fa9c"
|
||||||
|
dependencies = [
|
||||||
|
"ahash",
|
||||||
|
"byteorder",
|
||||||
|
"lazy_static",
|
||||||
|
"parking_lot 0.11.2",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "version_check"
|
name = "version_check"
|
||||||
version = "0.9.4"
|
version = "0.9.4"
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "protostar"
|
name = "protostar"
|
||||||
version = "0.1.0"
|
version = "0.2.0"
|
||||||
edition = "2021"
|
edition = "2021"
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
@@ -8,7 +8,9 @@ anyhow = "1.0.66"
|
|||||||
glam = { version = "0.22.0", features = ["mint"] }
|
glam = { version = "0.22.0", features = ["mint"] }
|
||||||
manifest-dir-macros = "0.1.16"
|
manifest-dir-macros = "0.1.16"
|
||||||
mint = "0.5.9"
|
mint = "0.5.9"
|
||||||
|
nix = "0.25.0"
|
||||||
rustc-hash = "1.1.0"
|
rustc-hash = "1.1.0"
|
||||||
stardust-xr-molecules = "0.5.2"
|
stardust-xr-molecules = "0.5.2"
|
||||||
tokio = { version = "1.22.0", features = ["full"] }
|
tokio = { version = "1.22.0", features = ["full"] }
|
||||||
tween = "1.0.1"
|
tween = "1.0.1"
|
||||||
|
ustr = "0.9.0"
|
||||||
|
|||||||
@@ -11,15 +11,14 @@ async fn main() {
|
|||||||
client.set_base_prefixes(&[directory_relative_path!("res")]);
|
client.set_base_prefixes(&[directory_relative_path!("res")]);
|
||||||
|
|
||||||
let _root = client.wrap_root(ProtoStar::new(
|
let _root = client.wrap_root(ProtoStar::new(
|
||||||
&client,
|
client.clone(),
|
||||||
PathBuf::from_str(&args().nth(2).unwrap()).unwrap(),
|
PathBuf::from_str(&args().nth(2).unwrap()).unwrap(),
|
||||||
0.1,
|
0.1,
|
||||||
PathBuf::from_str(&args().nth(1).unwrap()).unwrap(),
|
PathBuf::from_str(&args().nth(1).unwrap()).unwrap(),
|
||||||
));
|
));
|
||||||
|
|
||||||
tokio::select! {
|
tokio::select! {
|
||||||
_ = tokio::signal::ctrl_c() => Ok(()),
|
_ = tokio::signal::ctrl_c() => (),
|
||||||
_ = event_loop => Err(anyhow::anyhow!("Server crashed")),
|
e = event_loop => e.unwrap().unwrap(),
|
||||||
}
|
}
|
||||||
.unwrap();
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
use glam::Quat;
|
use glam::Quat;
|
||||||
use mint::Vector3;
|
use mint::Vector3;
|
||||||
|
use nix::unistd::{execv, fork};
|
||||||
use stardust_xr_molecules::{
|
use stardust_xr_molecules::{
|
||||||
fusion::{
|
fusion::{
|
||||||
client::{Client, LifeCycleHandler, LogicStepInfo},
|
client::{Client, LifeCycleHandler, LogicStepInfo},
|
||||||
@@ -10,11 +11,13 @@ use stardust_xr_molecules::{
|
|||||||
},
|
},
|
||||||
Grabbable,
|
Grabbable,
|
||||||
};
|
};
|
||||||
use std::{path::PathBuf, process::Command};
|
use std::{ffi::CString, path::PathBuf, sync::Arc};
|
||||||
use tween::{QuartInOut, Tweener};
|
use tween::{QuartInOut, Tweener};
|
||||||
|
use ustr::ustr;
|
||||||
|
|
||||||
pub struct ProtoStar {
|
pub struct ProtoStar {
|
||||||
grabbable: Option<Grabbable>,
|
client: Arc<Client>,
|
||||||
|
grabbable: Grabbable,
|
||||||
field: SphereField,
|
field: SphereField,
|
||||||
icon: Model,
|
icon: Model,
|
||||||
icon_shrink: Option<Tweener<QuartInOut<f32, f64>>>,
|
icon_shrink: Option<Tweener<QuartInOut<f32, f64>>>,
|
||||||
@@ -22,7 +25,7 @@ pub struct ProtoStar {
|
|||||||
executable_path: PathBuf,
|
executable_path: PathBuf,
|
||||||
}
|
}
|
||||||
impl ProtoStar {
|
impl ProtoStar {
|
||||||
pub fn new(client: &Client, icon: PathBuf, size: f32, executable_path: PathBuf) -> Self {
|
pub fn new(client: Arc<Client>, icon: PathBuf, size: f32, executable_path: PathBuf) -> Self {
|
||||||
let field = SphereField::builder()
|
let field = SphereField::builder()
|
||||||
.spatial_parent(client.get_root())
|
.spatial_parent(client.get_root())
|
||||||
.radius(size * 0.5)
|
.radius(size * 0.5)
|
||||||
@@ -39,7 +42,8 @@ impl ProtoStar {
|
|||||||
.build()
|
.build()
|
||||||
.unwrap();
|
.unwrap();
|
||||||
ProtoStar {
|
ProtoStar {
|
||||||
grabbable: Some(grabbable),
|
client,
|
||||||
|
grabbable,
|
||||||
field,
|
field,
|
||||||
icon,
|
icon,
|
||||||
icon_shrink: None,
|
icon_shrink: None,
|
||||||
@@ -50,37 +54,41 @@ impl ProtoStar {
|
|||||||
}
|
}
|
||||||
impl LifeCycleHandler for ProtoStar {
|
impl LifeCycleHandler for ProtoStar {
|
||||||
fn logic_step(&mut self, info: LogicStepInfo) {
|
fn logic_step(&mut self, info: LogicStepInfo) {
|
||||||
if let Some(grabbable) = &mut self.grabbable {
|
self.grabbable.update();
|
||||||
grabbable.update();
|
if self.grabbable.grab_action().actor_stopped() {
|
||||||
if grabbable.grab_action().actor_stopped() {
|
let startup_settings =
|
||||||
let startup_settings =
|
StartupSettings::create(&self.field.spatial.client().unwrap()).unwrap();
|
||||||
StartupSettings::create(&self.field.spatial.client().unwrap()).unwrap();
|
self.grabbable
|
||||||
grabbable
|
.content_parent()
|
||||||
.content_parent()
|
.set_rotation(
|
||||||
.set_rotation(
|
Some(&self.field.client().unwrap().get_root()),
|
||||||
Some(&self.field.client().unwrap().get_root()),
|
Quat::IDENTITY,
|
||||||
Quat::IDENTITY,
|
)
|
||||||
)
|
.unwrap();
|
||||||
.unwrap();
|
self.icon
|
||||||
startup_settings
|
.set_spatial_parent_in_place(self.client.get_root())
|
||||||
.set_root(grabbable.content_parent())
|
.unwrap();
|
||||||
.unwrap();
|
startup_settings
|
||||||
drop(self.grabbable.take());
|
.set_root(self.grabbable.content_parent())
|
||||||
self.icon_shrink = Some(Tweener::new(QuartInOut::new(self.size..=0.0, 0.25)));
|
.unwrap();
|
||||||
let future = startup_settings.generate_desktop_startup_id().unwrap();
|
self.icon_shrink = Some(Tweener::new(QuartInOut::new(self.size..=0.0, 0.25)));
|
||||||
let mut command = Command::new(self.executable_path.clone());
|
let future = startup_settings.generate_desktop_startup_id().unwrap();
|
||||||
tokio::task::spawn(async move {
|
let executable = self.executable_path.clone();
|
||||||
command.env("DESKTOP_STARTUP_ID", future.await.unwrap());
|
tokio::task::spawn(async move {
|
||||||
command.spawn().unwrap();
|
std::env::set_var("DESKTOP_STARTUP_ID", future.await.unwrap());
|
||||||
drop(startup_settings);
|
if unsafe { fork() }.unwrap().is_parent() {
|
||||||
});
|
let executable = ustr(executable.to_str().unwrap());
|
||||||
}
|
execv::<CString>(executable.as_cstr(), &[]).unwrap();
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
if let Some(icon_shrink) = &mut self.icon_shrink {
|
if let Some(icon_shrink) = &mut self.icon_shrink {
|
||||||
if let Some(scale) = icon_shrink.update(info.delta) {
|
if let Some(scale) = icon_shrink.update(info.delta) {
|
||||||
self.icon
|
self.icon
|
||||||
.set_scale(None, Vector3::from([scale; 3]))
|
.set_scale(None, Vector3::from([scale; 3]))
|
||||||
.unwrap();
|
.unwrap();
|
||||||
|
} else {
|
||||||
|
self.client.stop_loop();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user