feat: upgrade to new fusion!

This commit is contained in:
Nova
2024-02-09 13:10:26 -05:00
parent e63265eb75
commit 850ca9999d
12 changed files with 295 additions and 205 deletions

133
Cargo.lock generated
View File

@@ -142,7 +142,7 @@ dependencies = [
"clap", "clap",
"color-eyre", "color-eyre",
"color-rs", "color-rs",
"glam", "glam 0.24.2",
"manifest-dir-macros", "manifest-dir-macros",
"mint", "mint",
"protostar", "protostar",
@@ -370,6 +370,15 @@ version = "1.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "acbf1af155f9b9ef647e42cdc158db4b64a1b61f743629225fde6f3e0be2a7c7" checksum = "acbf1af155f9b9ef647e42cdc158db4b64a1b61f743629225fde6f3e0be2a7c7"
[[package]]
name = "convert_case"
version = "0.6.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ec182b0ca2f35d8fc196cf3404988fd8b8c739a4d270ff118a398feb0cbec1ca"
dependencies = [
"unicode-segmentation",
]
[[package]] [[package]]
name = "core-foundation-sys" name = "core-foundation-sys"
version = "0.8.4" version = "0.8.4"
@@ -777,6 +786,15 @@ dependencies = [
"mint", "mint",
] ]
[[package]]
name = "glam"
version = "0.25.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "151665d9be52f9bb40fc7966565d39666f2d1e69233571b71b87791c7e0528b3"
dependencies = [
"mint",
]
[[package]] [[package]]
name = "global_counter" name = "global_counter"
version = "0.2.2" version = "0.2.2"
@@ -851,7 +869,7 @@ dependencies = [
"clap", "clap",
"color-eyre", "color-eyre",
"color-rs", "color-rs",
"glam", "glam 0.25.0",
"manifest-dir-macros", "manifest-dir-macros",
"mint", "mint",
"protostar", "protostar",
@@ -995,6 +1013,17 @@ dependencies = [
"wasm-bindgen", "wasm-bindgen",
] ]
[[package]]
name = "kdl"
version = "4.6.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "062c875482ccb676fd40c804a40e3824d4464c18c364547456d1c8e8e951ae47"
dependencies = [
"miette",
"nom",
"thiserror",
]
[[package]] [[package]]
name = "kurbo" name = "kurbo"
version = "0.8.3" version = "0.8.3"
@@ -1129,6 +1158,29 @@ dependencies = [
"autocfg", "autocfg",
] ]
[[package]]
name = "miette"
version = "5.10.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "59bb584eaeeab6bd0226ccf3509a69d7936d148cf3d036ad350abe35e8c6856e"
dependencies = [
"miette-derive",
"once_cell",
"thiserror",
"unicode-width",
]
[[package]]
name = "miette-derive"
version = "5.10.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "49e7bc1560b95a3c4a25d03de42fe76ca718ab92d1a22a55b9b4cf67b3ae635c"
dependencies = [
"proc-macro2",
"quote",
"syn 2.0.32",
]
[[package]] [[package]]
name = "minimal-lexical" name = "minimal-lexical"
version = "0.2.1" version = "0.2.1"
@@ -1508,9 +1560,9 @@ dependencies = [
[[package]] [[package]]
name = "proc-macro2" name = "proc-macro2"
version = "1.0.66" version = "1.0.78"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "18fb31db3f9bddb2ea821cde30a9f70117e3f119938b5ee630b7403aa6e2ead9" checksum = "e2422ad645d89c99f8f3e6b88a9fdeca7fabeac836b1002371c4367c8f984aae"
dependencies = [ dependencies = [
"unicode-ident", "unicode-ident",
] ]
@@ -1525,7 +1577,7 @@ dependencies = [
"dirs 5.0.1", "dirs 5.0.1",
"ez-pixmap", "ez-pixmap",
"freedesktop-icons-greedy", "freedesktop-icons-greedy",
"glam", "glam 0.24.2",
"image", "image",
"itertools 0.12.0", "itertools 0.12.0",
"lazy_static", "lazy_static",
@@ -1560,9 +1612,9 @@ dependencies = [
[[package]] [[package]]
name = "quote" name = "quote"
version = "1.0.32" version = "1.0.35"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "50f3b39ccfb720540debaa0164757101c08ecb8d326b15358ce76a62c7e85965" checksum = "291ec9ab5efd934aaf503a6466c5d5251535d108ee747472c3977cc5acc868ef"
dependencies = [ dependencies = [
"proc-macro2", "proc-macro2",
] ]
@@ -1998,7 +2050,7 @@ dependencies = [
"clap", "clap",
"color-eyre", "color-eyre",
"color-rs", "color-rs",
"glam", "glam 0.24.2",
"manifest-dir-macros", "manifest-dir-macros",
"mint", "mint",
"protostar", "protostar",
@@ -2022,7 +2074,7 @@ dependencies = [
"clap", "clap",
"color-eyre", "color-eyre",
"color-rs", "color-rs",
"glam", "glam 0.24.2",
"manifest-dir-macros", "manifest-dir-macros",
"mint", "mint",
"protostar", "protostar",
@@ -2059,10 +2111,16 @@ dependencies = [
"lock_api", "lock_api",
] ]
[[package]]
name = "split-iter"
version = "0.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2f2b15926089e5526bb2dd738a2eb0e59034356e06eb71e1cd912358c0e62c4d"
[[package]] [[package]]
name = "stardust-xr" name = "stardust-xr"
version = "0.14.1" version = "0.14.1"
source = "git+https://github.com/StardustXR/core.git#975331f9739a9f6cb90ec75813b7720c86225848" source = "git+https://github.com/StardustXR/core.git#ddb2953f6acac01ee9c4ccfae2d4b7eb959a07a2"
dependencies = [ dependencies = [
"cluFlock", "cluFlock",
"color-rs", "color-rs",
@@ -2082,7 +2140,7 @@ dependencies = [
[[package]] [[package]]
name = "stardust-xr-fusion" name = "stardust-xr-fusion"
version = "0.43.2" version = "0.43.2"
source = "git+https://github.com/StardustXR/core.git#975331f9739a9f6cb90ec75813b7720c86225848" source = "git+https://github.com/StardustXR/core.git#ddb2953f6acac01ee9c4ccfae2d4b7eb959a07a2"
dependencies = [ dependencies = [
"color-eyre", "color-eyre",
"color-rs", "color-rs",
@@ -2096,18 +2154,32 @@ dependencies = [
"serde_repr", "serde_repr",
"serde_with", "serde_with",
"stardust-xr", "stardust-xr",
"stardust-xr-fusion-codegen",
"thiserror", "thiserror",
"tokio", "tokio",
"tracing", "tracing",
] ]
[[package]]
name = "stardust-xr-fusion-codegen"
version = "0.1.0"
source = "git+https://github.com/StardustXR/core.git#ddb2953f6acac01ee9c4ccfae2d4b7eb959a07a2"
dependencies = [
"convert_case",
"mint",
"proc-macro2",
"quote",
"split-iter",
"stardust-xr-schemas",
]
[[package]] [[package]]
name = "stardust-xr-molecules" name = "stardust-xr-molecules"
version = "0.29.0" version = "0.29.0"
source = "git+https://github.com/StardustXR/molecules.git#2e60ed7f75a1a79d89b83237dea4d208bc1ab01c" source = "git+https://github.com/StardustXR/molecules.git#8681d8f60bf49bcb73e5fb32c89c4f441b94533b"
dependencies = [ dependencies = [
"color-rs", "color-rs",
"glam", "glam 0.24.2",
"lazy_static", "lazy_static",
"lerp", "lerp",
"map-range", "map-range",
@@ -2117,17 +2189,17 @@ dependencies = [
"stardust-xr-fusion", "stardust-xr-fusion",
"tokio", "tokio",
"tracing", "tracing",
"xkbcommon",
] ]
[[package]] [[package]]
name = "stardust-xr-schemas" name = "stardust-xr-schemas"
version = "1.5.3" version = "1.5.3"
source = "git+https://github.com/StardustXR/core.git#975331f9739a9f6cb90ec75813b7720c86225848" source = "git+https://github.com/StardustXR/core.git#ddb2953f6acac01ee9c4ccfae2d4b7eb959a07a2"
dependencies = [ dependencies = [
"flatbuffers", "flatbuffers",
"flexbuffers", "flexbuffers",
"glam", "glam 0.24.2",
"kdl",
"manifest-dir-macros", "manifest-dir-macros",
"mint", "mint",
"ouroboros", "ouroboros",
@@ -2322,7 +2394,6 @@ dependencies = [
"bytes", "bytes",
"libc", "libc",
"mio", "mio",
"num_cpus",
"parking_lot 0.12.1", "parking_lot 0.12.1",
"pin-project-lite", "pin-project-lite",
"signal-hook-registry", "signal-hook-registry",
@@ -2507,12 +2578,24 @@ version = "0.5.5"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7d817255e1bed6dfd4ca47258685d14d2bdcfbc64fdc9e3819bd5848057b8ecc" checksum = "7d817255e1bed6dfd4ca47258685d14d2bdcfbc64fdc9e3819bd5848057b8ecc"
[[package]]
name = "unicode-segmentation"
version = "1.11.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d4c87d22b6e3f4a18d4d40ef354e97c90fcb14dd91d7dc0aa9d8a1172ebf7202"
[[package]] [[package]]
name = "unicode-vo" name = "unicode-vo"
version = "0.1.0" version = "0.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b1d386ff53b415b7fe27b50bb44679e2cc4660272694b7b6f3326d8480823a94" checksum = "b1d386ff53b415b7fe27b50bb44679e2cc4660272694b7b6f3326d8480823a94"
[[package]]
name = "unicode-width"
version = "0.1.11"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e51733f11c9c4f72aa0c160008246859e340b00807569a0da0e7a1079b27ba85"
[[package]] [[package]]
name = "ustr" name = "ustr"
version = "0.10.0" version = "0.10.0"
@@ -2773,22 +2856,6 @@ version = "2.5.2"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "213b7324336b53d2414b2db8537e56544d981803139155afa84f76eeebb7a546" checksum = "213b7324336b53d2414b2db8537e56544d981803139155afa84f76eeebb7a546"
[[package]]
name = "xkbcommon"
version = "0.6.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c286371c44b3572d19b09196c129a8fff47d7704d6494daefb44fec10f0278ab"
dependencies = [
"libc",
"xkeysym",
]
[[package]]
name = "xkeysym"
version = "0.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "054a8e68b76250b253f671d1268cb7f1ae089ec35e195b2efb2a4e9a836d0621"
[[package]] [[package]]
name = "xmlparser" name = "xmlparser"
version = "0.13.5" version = "0.13.5"

View File

@@ -1,2 +1,13 @@
[workspace] [workspace]
members = ["app_grid", "hexagon_launcher", "protostar", "single", "sirius"] members = ["app_grid", "hexagon_launcher", "protostar", "single", "sirius"]
[workspace.dependencies]
tokio = { version = "1.32.0", features = ["rt", "tokio-macros", "sync"] }
[workspace.dependencies.stardust-xr-fusion]
git = "https://github.com/StardustXR/core.git"
# path = "../../core/fusion"
[workspace.dependencies.stardust-xr-molecules]
git = "https://github.com/StardustXR/molecules.git"
# path = "../../molecules"

View File

@@ -9,11 +9,14 @@ use protostar::{
}; };
use stardust_xr_fusion::{ use stardust_xr_fusion::{
client::{Client, ClientState, FrameInfo, RootHandler}, client::{Client, ClientState, FrameInfo, RootHandler},
core::values::Transform, core::values::ResourceID,
drawable::{Alignment, Bounds, MaterialParameter, Model, ResourceID, Text, TextFit, TextStyle}, drawable::{
MaterialParameter, Model, ModelPartAspect, Text, TextBounds, TextFit, TextStyle, XAlign,
YAlign,
},
fields::BoxField, fields::BoxField,
node::NodeType, node::NodeType,
spatial::Spatial, spatial::{Spatial, SpatialAspect, Transform},
}; };
use stardust_xr_molecules::{Grabbable, GrabbableSettings}; use stardust_xr_molecules::{Grabbable, GrabbableSettings};
use std::f32::consts::PI; use std::f32::consts::PI;
@@ -123,12 +126,12 @@ pub struct App {
} }
impl App { impl App {
pub fn create_from_desktop_file( pub fn create_from_desktop_file(
parent: &Spatial, parent: &impl SpatialAspect,
position: impl Into<Vector3<f32>>, position: impl Into<Vector3<f32>>,
desktop_file: DesktopFile, desktop_file: DesktopFile,
) -> Result<Self> { ) -> Result<Self> {
let root = Spatial::create(parent, Transform::from_position(position), false)?; let root = Spatial::create(parent, Transform::from_translation(position), false)?;
let field = BoxField::create(&root, Transform::default(), [APP_SIZE; 3])?; let field = BoxField::create(&root, Transform::none(), [APP_SIZE; 3])?;
let application = Application::create(desktop_file)?; let application = Application::create(desktop_file)?;
let icon = application.icon(128, true); let icon = application.icon(128, true);
let grabbable = Grabbable::create( let grabbable = Grabbable::create(
@@ -154,17 +157,19 @@ impl App {
let label_style = TextStyle { let label_style = TextStyle {
character_height: 0.005, character_height: 0.005,
bounds: Some(Bounds { bounds: Some(TextBounds {
bounds: [0.047013, 0.01].into(), bounds: [0.047013, 0.01].into(),
fit: TextFit::Wrap, fit: TextFit::Wrap,
bounds_align: Alignment::XCenter | Alignment::YCenter, anchor_align_x: XAlign::Center,
anchor_align_y: YAlign::Center,
}), }),
text_align: Alignment::Center.into(), text_align_x: XAlign::Center,
text_align_y: YAlign::Center,
..Default::default() ..Default::default()
}; };
let label = application.name().and_then(|name| { let label = application.name().and_then(|name| {
Text::create( Text::create(
&*icon.model_part("Label").ok()?, &icon.model_part("Label").ok()?,
Transform::none(), Transform::none(),
name, name,
label_style, label_style,
@@ -202,33 +207,26 @@ impl App {
// self.bring_back(); // self.bring_back();
// return; // return;
// } // }
let Ok(distance_future) = self
.grabbable
.content_parent()
.get_position_rotation_scale(&self.root)
else {
return;
};
let application = self.application.clone(); let application = self.application.clone();
let space = self.content_parent().alias(); let space = self.content_parent().alias();
let root = self.root.alias(); let root = self.root.alias();
tokio::task::spawn(async move { tokio::task::spawn(async move {
let Ok((distance, _rotation, _scale)) = distance_future.await else { let Ok(transform) = space.get_transform(&root).await else {
space space
.set_transform(Some(&root), Transform::identity()) .set_relative_transform(&root, Transform::identity())
.unwrap(); .unwrap();
return; return;
}; };
let distance = Vec3::from(distance).length_squared(); let distance = Vec3::from(transform.translation.unwrap()).length_squared();
if distance > ACTIVATION_DISTANCE.powi(2) { if distance > ACTIVATION_DISTANCE.powi(2) {
let _ = application.launch(&space); let _ = application.launch(&space);
} }
space space
.set_transform(Some(&root), Transform::identity()) .set_relative_transform(&root, Transform::identity())
.unwrap(); .unwrap();
}); });
} }

View File

@@ -4,21 +4,15 @@ version = "0.1.0"
edition = "2021" edition = "2021"
[dependencies] [dependencies]
tokio = { version = "1.32.0", features = ["rt", "tokio-macros", "sync"] }
protostar = { path = "../protostar" } protostar = { path = "../protostar" }
color-rs = "0.8.0" color-rs = "0.8.0"
color-eyre = "0.6.2" color-eyre = "0.6.2"
clap = "4.4.6" clap = "4.4.6"
manifest-dir-macros = "0.1.18" manifest-dir-macros = "0.1.18"
glam = "0.24.2" glam = { version = "0.25.0", features = ["mint"] }
mint = "0.5.9" mint = "0.5.9"
tween = "2.0.1" tween = "2.0.1"
tracing-subscriber = "0.3.17" tracing-subscriber = "0.3.17"
tokio = { workspace = true }
[dependencies.stardust-xr-fusion] stardust-xr-fusion = { workspace = true }
git = "https://github.com/StardustXR/core.git" stardust-xr-molecules = { workspace = true }
# path = "../../core/fusion"
[dependencies.stardust-xr-molecules]
git = "https://github.com/StardustXR/molecules.git"
# path = "../../molecules"

View File

@@ -7,11 +7,14 @@ use protostar::{
}; };
use stardust_xr_fusion::{ use stardust_xr_fusion::{
client::FrameInfo, client::FrameInfo,
core::values::Transform, core::values::ResourceID,
drawable::{Alignment, Bounds, MaterialParameter, Model, ResourceID, Text, TextFit, TextStyle}, drawable::{
MaterialParameter, Model, ModelPartAspect, Text, TextBounds, TextFit, TextStyle, XAlign,
YAlign,
},
fields::BoxField, fields::BoxField,
node::NodeType, node::NodeType,
spatial::Spatial, spatial::{Spatial, SpatialAspect, Transform},
}; };
use stardust_xr_molecules::{Grabbable, GrabbableSettings}; use stardust_xr_molecules::{Grabbable, GrabbableSettings};
use std::f32::consts::PI; use std::f32::consts::PI;
@@ -71,12 +74,12 @@ impl App {
desktop_file: DesktopFile, desktop_file: DesktopFile,
) -> Result<Self> { ) -> Result<Self> {
let position = position.into(); let position = position.into();
let field = BoxField::create(parent, Transform::default(), [APP_SIZE; 3])?; let field = BoxField::create(parent, Transform::identity(), [APP_SIZE; 3])?;
let application = Application::create(desktop_file)?; let application = Application::create(desktop_file)?;
let icon = application.icon(128, false); let icon = application.icon(128, false);
let grabbable = Grabbable::create( let grabbable = Grabbable::create(
parent, parent,
Transform::from_position(position), Transform::from_translation(position),
&field, &field,
GrabbableSettings { GrabbableSettings {
max_distance: 0.01, max_distance: 0.01,
@@ -100,18 +103,21 @@ impl App {
let label_style = TextStyle { let label_style = TextStyle {
character_height: APP_SIZE * 2.0, character_height: APP_SIZE * 2.0,
bounds: Some(Bounds { bounds: Some(TextBounds {
bounds: [1.0; 2].into(), bounds: [1.0; 2].into(),
fit: TextFit::Wrap, fit: TextFit::Wrap,
bounds_align: Alignment::XCenter | Alignment::YCenter, anchor_align_x: XAlign::Center,
anchor_align_y: YAlign::Center,
}), }),
text_align: Alignment::Center.into(),
text_align_x: XAlign::Center,
text_align_y: YAlign::Center,
..Default::default() ..Default::default()
}; };
let label = application.name().and_then(|name| { let label = application.name().and_then(|name| {
Text::create( Text::create(
&icon, &icon,
Transform::from_position_rotation( Transform::from_translation_rotation(
[0.0, 0.1, -(APP_SIZE * 4.0)], [0.0, 0.1, -(APP_SIZE * 4.0)],
Quat::from_rotation_x(PI * 0.5), Quat::from_rotation_x(PI * 0.5),
), ),
@@ -159,7 +165,10 @@ impl App {
let scale = grabbable_move.move_by(info.delta); let scale = grabbable_move.move_by(info.delta);
self.grabbable self.grabbable
.content_parent() .content_parent()
.set_position(Some(&self.parent), Vec3::from(self.position) * scale) .set_relative_transform(
&self.parent,
Transform::from_translation(Vec3::from(self.position) * scale),
)
.unwrap(); .unwrap();
} else { } else {
if grabbable_move.final_value() == 0.0001 { if grabbable_move.final_value() == 0.0001 {
@@ -176,7 +185,7 @@ impl App {
let scale = grabbable_shrink.move_by(info.delta); let scale = grabbable_shrink.move_by(info.delta);
self.grabbable self.grabbable
.content_parent() .content_parent()
.set_scale(Some(&self.parent), Vector3::from([scale; 3])) .set_relative_transform(&self.parent, Transform::from_scale([scale; 3]))
.unwrap(); .unwrap();
} else { } else {
self.grabbable self.grabbable
@@ -191,17 +200,19 @@ impl App {
self.grabbable_shrink = None; self.grabbable_shrink = None;
self.grabbable self.grabbable
.content_parent() .content_parent()
.set_position(Some(&self.parent), self.position) .set_relative_transform(
&self.parent,
Transform::from_translation(self.position),
)
.unwrap(); .unwrap();
self.grabbable self.grabbable
.content_parent() .content_parent()
.set_rotation(Some(&self.parent), Quat::default()) .set_relative_transform(&self.parent, Transform::from_rotation(Quat::default()))
.unwrap(); .unwrap();
self.icon self.icon
.set_rotation( .set_local_transform(Transform::from_rotation(
None,
Quat::from_rotation_x(PI / 2.0) * Quat::from_rotation_y(PI), Quat::from_rotation_x(PI / 2.0) * Quat::from_rotation_y(PI),
) ))
.unwrap(); .unwrap();
} }
} else if let Some(grabbable_grow) = &mut self.grabbable_grow { } else if let Some(grabbable_grow) = &mut self.grabbable_grow {
@@ -209,7 +220,7 @@ impl App {
let scale = grabbable_grow.move_by(info.delta); let scale = grabbable_grow.move_by(info.delta);
self.grabbable self.grabbable
.content_parent() .content_parent()
.set_scale(Some(&self.parent), Vector3::from([scale; 3])) .set_relative_transform(&self.parent, Transform::from_scale([scale; 3]))
.unwrap(); .unwrap();
} else { } else {
self.grabbable self.grabbable
@@ -220,32 +231,32 @@ impl App {
} }
} else if self.grabbable.grab_action().actor_stopped() { } else if self.grabbable.grab_action().actor_stopped() {
self.grabbable_shrink = Some(Tweener::quart_in_out(APP_SIZE * 0.5, 0.0001, 0.25)); self.grabbable_shrink = Some(Tweener::quart_in_out(APP_SIZE * 0.5, 0.0001, 0.25));
let Ok(distance_future) = self
.grabbable
.content_parent()
.get_position_rotation_scale(&self.parent)
else {
return;
};
let application = self.application.clone(); let application = self.application.clone();
let space = self.content_parent().alias(); let space = self.content_parent().alias();
let parent = self.parent.alias();
//TODO: split the executable string for the args //TODO: split the executable string for the args
tokio::task::spawn(async move { tokio::task::spawn(async move {
let distance_vector = distance_future.await.ok().unwrap().0; let distance_vector = space
.get_transform(&parent)
.await
.unwrap()
.translation
.unwrap();
let distance = Vec3::from(distance_vector).length_squared(); let distance = Vec3::from(distance_vector).length_squared();
if distance > ACTIVATION_DISTANCE { if distance > ACTIVATION_DISTANCE {
let client = space.node().client().unwrap(); let client = space.node().client().unwrap();
let (_, space_rot, _) = space let space_rot = space
.get_position_rotation_scale(&client.get_root()) .get_transform(client.get_root())
.unwrap()
.await .await
.unwrap()
.rotation
.unwrap(); .unwrap();
let (_, y_rot, _) = Quat::from(space_rot).to_euler(EulerRot::XYZ); let (_, y_rot, _) = Quat::from(space_rot).to_euler(EulerRot::XYZ);
let _ = space.set_transform( let _ = space.set_relative_transform(
Some(client.get_root()), client.get_root(),
Transform::from_rotation_scale(Quat::from_rotation_y(y_rot), [1.0; 3]), Transform::from_rotation_scale(Quat::from_rotation_y(y_rot), [1.0; 3]),
); );
let _ = application.launch(&space); let _ = application.launch(&space);

View File

@@ -10,10 +10,11 @@ use manifest_dir_macros::directory_relative_path;
use protostar::xdg::{get_desktop_files, parse_desktop_file, DesktopFile}; use protostar::xdg::{get_desktop_files, parse_desktop_file, DesktopFile};
use stardust_xr_fusion::{ use stardust_xr_fusion::{
client::{Client, ClientState, FrameInfo, RootHandler}, client::{Client, ClientState, FrameInfo, RootHandler},
core::values::Transform, core::values::ResourceID,
drawable::{MaterialParameter, Model, ResourceID}, drawable::{MaterialParameter, Model, ModelPartAspect},
fields::BoxField, fields::BoxField,
node::NodeError, node::NodeError,
spatial::{SpatialAspect, Transform},
}; };
use stardust_xr_molecules::{touch_plane::TouchPlane, Grabbable, GrabbableSettings, PointerMode}; use stardust_xr_molecules::{touch_plane::TouchPlane, Grabbable, GrabbableSettings, PointerMode};
use std::f32::consts::PI; use std::f32::consts::PI;
@@ -126,10 +127,10 @@ struct Button {
} }
impl Button { impl Button {
fn new(client: &Client) -> Result<Self, NodeError> { fn new(client: &Client) -> Result<Self, NodeError> {
let field = BoxField::create(client.get_root(), Transform::default(), [APP_SIZE; 3])?; let field = BoxField::create(client.get_root(), Transform::identity(), [APP_SIZE; 3])?;
let grabbable = Grabbable::create( let grabbable = Grabbable::create(
client.get_root(), client.get_root(),
Transform::default(), Transform::none(),
&field, &field,
GrabbableSettings { GrabbableSettings {
max_distance: 0.01, max_distance: 0.01,
@@ -141,7 +142,7 @@ impl Button {
field.set_spatial_parent(grabbable.content_parent())?; field.set_spatial_parent(grabbable.content_parent())?;
let touch_plane = TouchPlane::create( let touch_plane = TouchPlane::create(
grabbable.content_parent(), grabbable.content_parent(),
Transform::default(), Transform::identity(),
[(APP_SIZE + PADDING) / 2.0; 2], [(APP_SIZE + PADDING) / 2.0; 2],
(APP_SIZE + PADDING) / 2.0, (APP_SIZE + PADDING) / 2.0,
0.0..1.0, 0.0..1.0,

View File

@@ -23,20 +23,14 @@ resvg = "0.29.0"
rustc-hash = "1.1.0" rustc-hash = "1.1.0"
serde = "1.0.155" serde = "1.0.155"
serde_with = "3.4.0" serde_with = "3.4.0"
tokio = { version = "1.24.1", features = ["full"] }
toml = "0.8.2" toml = "0.8.2"
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"
ustr = "0.10.0" ustr = "0.10.0"
walkdir = "2.3.3" walkdir = "2.3.3"
tokio = { workspace = true }
[dependencies.stardust-xr-fusion] stardust-xr-fusion = { workspace = true }
git = "https://github.com/StardustXR/core.git" stardust-xr-molecules = { workspace = true }
# path = "../../core/fusion"
[dependencies.stardust-xr-molecules]
git = "https://github.com/StardustXR/molecules.git"
# path = "../../molecules"
[dev-dependencies] [dev-dependencies]

View File

@@ -46,11 +46,7 @@ impl Application {
pub fn launch(&self, launch_space: &Spatial) -> Result<(), NodeError> { pub fn launch(&self, launch_space: &Spatial) -> Result<(), NodeError> {
let client = launch_space.node().client()?; let client = launch_space.node().client()?;
let future_startup_token = client.state_token(&ClientState { let launch_space = launch_space.alias();
root: Some(launch_space.alias()),
..Default::default()
})?;
let future_connection_env = client.get_connection_environment()?;
let executable = self let executable = self
.desktop_file .desktop_file
@@ -58,8 +54,22 @@ impl Application {
.clone() .clone()
.ok_or(NodeError::DoesNotExist)?; .ok_or(NodeError::DoesNotExist)?;
tokio::task::spawn(async move { tokio::task::spawn(async move {
let Ok(startup_token) = future_startup_token.await else {return}; let Ok(startup_token) = client
let Ok(connection_env) = future_connection_env.await else {return}; .state_token(&ClientState {
root: Some(launch_space.alias()),
..Default::default()
})
.await
else {
return;
};
let Ok(future_connection_env) = client.get_connection_environment() else {
return;
};
let Ok(connection_env) = future_connection_env.await else {
return;
};
for (k, v) in connection_env.into_iter() { for (k, v) in connection_env.into_iter() {
std::env::set_var(k, v); std::env::set_var(k, v);
} }

View File

@@ -4,7 +4,6 @@ version = "0.1.0"
edition = "2021" edition = "2021"
[dependencies] [dependencies]
tokio = { version = "1.32.0", features = ["rt", "tokio-macros", "sync"] }
protostar = { path = "../protostar" } protostar = { path = "../protostar" }
color-eyre = "0.6.2" color-eyre = "0.6.2"
color-rs = "0.8.0" color-rs = "0.8.0"
@@ -14,11 +13,6 @@ glam = "0.24.2"
mint = "0.5.9" mint = "0.5.9"
tween = "2.0.1" tween = "2.0.1"
tracing-subscriber = "0.3.17" tracing-subscriber = "0.3.17"
tokio = { workspace = true }
[dependencies.stardust-xr-fusion] stardust-xr-fusion = { workspace = true }
git = "https://github.com/StardustXR/core.git" stardust-xr-molecules = { workspace = true }
# path = "../../core/fusion"
[dependencies.stardust-xr-molecules]
git = "https://github.com/StardustXR/molecules.git"
# path = "../../molecules"

View File

@@ -8,11 +8,14 @@ use protostar::{
}; };
use stardust_xr_fusion::{ use stardust_xr_fusion::{
client::{ClientState, FrameInfo, RootHandler}, client::{ClientState, FrameInfo, RootHandler},
core::values::Transform, core::values::ResourceID,
drawable::{Alignment, Bounds, MaterialParameter, Model, ResourceID, Text, TextFit, TextStyle}, drawable::{
MaterialParameter, Model, ModelPartAspect, Text, TextBounds, TextFit, TextStyle, XAlign,
YAlign,
},
fields::BoxField, fields::BoxField,
node::NodeType, node::NodeType,
spatial::Spatial, spatial::{Spatial, SpatialAspect, Transform},
}; };
use stardust_xr_molecules::{Grabbable, GrabbableSettings}; use stardust_xr_molecules::{Grabbable, GrabbableSettings};
use std::f32::consts::PI; use std::f32::consts::PI;
@@ -55,7 +58,7 @@ fn model_from_icon(parent: &Spatial, icon: &Icon) -> Result<Model> {
pub struct Single { pub struct Single {
application: Application, application: Application,
parent: Spatial, root: Spatial,
position: Vector3<f32>, position: Vector3<f32>,
grabbable: Grabbable, grabbable: Grabbable,
_field: BoxField, _field: BoxField,
@@ -69,24 +72,25 @@ pub struct Single {
impl Single { impl Single {
pub fn create_from_desktop_file( pub fn create_from_desktop_file(
parent: &Spatial, parent: &impl SpatialAspect,
position: impl Into<Vector3<f32>>, position: impl Into<Vector3<f32>>,
desktop_file: DesktopFile, desktop_file: DesktopFile,
) -> Result<Self> { ) -> Result<Self> {
let root = Spatial::create(parent, Transform::identity(), false)?;
let position = position.into(); let position = position.into();
let field = BoxField::create(parent, Transform::default(), [MODEL_SCALE * 2.0; 3])?; let field = BoxField::create(&root, Transform::identity(), [MODEL_SCALE * 2.0; 3])?;
let application = Application::create(desktop_file)?; let application = Application::create(desktop_file)?;
let icon = application.icon(128, false); let icon = application.icon(128, false);
let grabbable = Grabbable::create( let grabbable = Grabbable::create(
parent, &root,
Transform::from_position(position), Transform::from_translation(position),
&field, &field,
GrabbableSettings { GrabbableSettings {
max_distance: 0.01, max_distance: 0.01,
..Default::default() ..Default::default()
}, },
)?; )?;
grabbable.content_parent().set_spatial_parent(parent)?; grabbable.content_parent().set_spatial_parent(&root)?;
field.set_spatial_parent(grabbable.content_parent())?; field.set_spatial_parent(grabbable.content_parent())?;
let icon = icon let icon = icon
.map(|i| model_from_icon(grabbable.content_parent(), &i)) .map(|i| model_from_icon(grabbable.content_parent(), &i))
@@ -100,18 +104,20 @@ impl Single {
let label_style = TextStyle { let label_style = TextStyle {
character_height: MODEL_SCALE * 4.0, character_height: MODEL_SCALE * 4.0,
bounds: Some(Bounds { bounds: Some(TextBounds {
bounds: [1.0; 2].into(), bounds: [1.0; 2].into(),
fit: TextFit::Wrap, fit: TextFit::Wrap,
bounds_align: Alignment::XCenter | Alignment::YCenter, anchor_align_x: XAlign::Center,
anchor_align_y: YAlign::Center,
}), }),
text_align: Alignment::Center.into(), text_align_x: XAlign::Center,
text_align_y: YAlign::Center,
..Default::default() ..Default::default()
}; };
let label = application.name().and_then(|name| { let label = application.name().and_then(|name| {
Text::create( Text::create(
&icon, &icon,
Transform::from_position_rotation( Transform::from_translation_rotation(
[0.0, 0.1, -(MODEL_SCALE * 8.0)], [0.0, 0.1, -(MODEL_SCALE * 8.0)],
Quat::from_rotation_x(PI * 0.5), Quat::from_rotation_x(PI * 0.5),
), ),
@@ -121,7 +127,7 @@ impl Single {
.ok() .ok()
}); });
Ok(Single { Ok(Single {
parent: parent.alias(), root,
position, position,
grabbable, grabbable,
_field: field, _field: field,
@@ -147,13 +153,13 @@ impl RootHandler for Single {
let scale = grabbable_move.move_by(info.delta); let scale = grabbable_move.move_by(info.delta);
self.grabbable self.grabbable
.content_parent() .content_parent()
.set_position( .set_relative_transform(
Some(&self.parent), &self.root,
[ Transform::from_translation([
self.position.x * scale, self.position.x * scale,
self.position.y * scale, self.position.y * scale,
self.position.z * scale, self.position.z * scale,
], ]),
) )
.unwrap(); .unwrap();
} else { } else {
@@ -171,12 +177,12 @@ impl RootHandler for Single {
let scale = grabbable_shrink.move_by(info.delta); let scale = grabbable_shrink.move_by(info.delta);
self.grabbable self.grabbable
.content_parent() .content_parent()
.set_scale(Some(&self.parent), Vector3::from([scale; 3])) .set_relative_transform(&self.root, Transform::from_scale([scale; 3]))
.unwrap(); .unwrap();
} else { } else {
self.grabbable self.grabbable
.content_parent() .content_parent()
.set_spatial_parent(&self.parent) .set_spatial_parent(&self.root)
.unwrap(); .unwrap();
if self.currently_shown { if self.currently_shown {
self.grabbable_grow = Some(Tweener::quart_in_out(0.0001, 1.0, 0.25)); self.grabbable_grow = Some(Tweener::quart_in_out(0.0001, 1.0, 0.25));
@@ -186,17 +192,16 @@ impl RootHandler for Single {
self.grabbable_shrink = None; self.grabbable_shrink = None;
self.grabbable self.grabbable
.content_parent() .content_parent()
.set_position(Some(&self.parent), self.position) .set_relative_transform(&self.root, Transform::from_translation(self.position))
.unwrap(); .unwrap();
self.grabbable self.grabbable
.content_parent() .content_parent()
.set_rotation(Some(&self.parent), Quat::default()) .set_relative_transform(&self.root, Transform::from_rotation(Quat::default()))
.unwrap(); .unwrap();
self.icon self.icon
.set_rotation( .set_local_transform(Transform::from_rotation(
None,
Quat::from_rotation_x(PI / 2.0) * Quat::from_rotation_y(PI), Quat::from_rotation_x(PI / 2.0) * Quat::from_rotation_y(PI),
) ))
.unwrap(); .unwrap();
} }
} else if let Some(grabbable_grow) = &mut self.grabbable_grow { } else if let Some(grabbable_grow) = &mut self.grabbable_grow {
@@ -204,31 +209,30 @@ impl RootHandler for Single {
let scale = grabbable_grow.move_by(info.delta); let scale = grabbable_grow.move_by(info.delta);
self.grabbable self.grabbable
.content_parent() .content_parent()
.set_scale(Some(&self.parent), Vector3::from([scale; 3])) .set_relative_transform(&self.root, Transform::from_scale([scale; 3]))
.unwrap(); .unwrap();
} else { } else {
self.grabbable self.grabbable
.content_parent() .content_parent()
.set_spatial_parent(&self.parent) .set_spatial_parent(&self.root)
.unwrap(); .unwrap();
self.grabbable_grow = None; self.grabbable_grow = None;
} }
} else if self.grabbable.grab_action().actor_stopped() { } else if self.grabbable.grab_action().actor_stopped() {
self.grabbable_shrink = Some(Tweener::quart_in_out(MODEL_SCALE, 0.0001, 0.25)); self.grabbable_shrink = Some(Tweener::quart_in_out(MODEL_SCALE, 0.0001, 0.25));
let Ok(distance_future) = self
.grabbable
.content_parent()
.get_position_rotation_scale(&self.parent)
else {
return;
};
let application = self.application.clone(); let application = self.application.clone();
let space = self.content_parent().alias(); let space = self.content_parent().alias();
let root = self.root.alias();
//TODO: split the executable string for the args //TODO: split the executable string for the args
tokio::task::spawn(async move { tokio::task::spawn(async move {
let distance_vector = distance_future.await.ok().unwrap().0; let distance_vector = space
.get_transform(&root)
.await
.unwrap()
.translation
.unwrap();
let distance = Vec3::from(distance_vector).length_squared(); let distance = Vec3::from(distance_vector).length_squared();
if distance > ACTIVATION_DISTANCE { if distance > ACTIVATION_DISTANCE {

View File

@@ -4,7 +4,6 @@ version = "0.1.0"
edition = "2021" edition = "2021"
[dependencies] [dependencies]
tokio = { version = "1.32.0", features = ["rt", "tokio-macros", "sync"] }
protostar = { path = "../protostar" } protostar = { path = "../protostar" }
color-eyre = "0.6.2" color-eyre = "0.6.2"
color-rs = "0.8.0" color-rs = "0.8.0"
@@ -15,11 +14,6 @@ mint = "0.5.9"
tween = "2.0.1" tween = "2.0.1"
tracing-subscriber = "0.3.17" tracing-subscriber = "0.3.17"
walkdir = "2.4.0" walkdir = "2.4.0"
tokio = { workspace = true }
[dependencies.stardust-xr-fusion] stardust-xr-fusion = { workspace = true }
git = "https://github.com/StardustXR/core.git" stardust-xr-molecules = { workspace = true }
# path = "../../core/fusion"
[dependencies.stardust-xr-molecules]
git = "https://github.com/StardustXR/molecules.git"
# path = "../../molecules"

View File

@@ -10,12 +10,14 @@ use protostar::{
}; };
use stardust_xr_fusion::{ use stardust_xr_fusion::{
client::{Client, ClientState, FrameInfo, RootHandler}, client::{Client, ClientState, FrameInfo, RootHandler},
core::values::Transform, core::values::ResourceID,
drawable::{Alignment, Bounds, MaterialParameter, Model, ResourceID, Text, TextFit, TextStyle}, drawable::{
MaterialParameter, Model, ModelPartAspect, Text, TextBounds, TextFit, TextStyle, XAlign,
YAlign,
},
fields::BoxField, fields::BoxField,
node::NodeError, node::{NodeError, NodeType},
node::NodeType, spatial::{Spatial, SpatialAspect, Transform},
spatial::Spatial,
}; };
use stardust_xr_molecules::{touch_plane::TouchPlane, Grabbable, GrabbableSettings}; use stardust_xr_molecules::{touch_plane::TouchPlane, Grabbable, GrabbableSettings};
use std::{f32::consts::PI, path::PathBuf}; use std::{f32::consts::PI, path::PathBuf};
@@ -66,18 +68,18 @@ struct Sirius {
} }
impl Sirius { impl Sirius {
fn new(client: &Client, args: Args) -> Result<Self, NodeError> { fn new(client: &Client, args: Args) -> Result<Self, NodeError> {
let root = Spatial::create(client.get_root(), Transform::default(), false).unwrap(); let root = Spatial::create(client.get_root(), Transform::identity(), false).unwrap();
let field = BoxField::create(&root, Transform::default(), [0.1; 3]).unwrap(); let field = BoxField::create(&root, Transform::identity(), [0.1; 3]).unwrap();
let grabbable = Grabbable::create( let grabbable = Grabbable::create(
&root, &root,
Transform::default(), Transform::identity(),
&field, &field,
GrabbableSettings::default(), GrabbableSettings::default(),
)?; )?;
let touch_plane = TouchPlane::create( let touch_plane = TouchPlane::create(
grabbable.content_parent(), grabbable.content_parent(),
Transform::default(), Transform::identity(),
[0.1; 2], [0.1; 2],
0.03, 0.03,
1.0..0.0, 1.0..0.0,
@@ -107,7 +109,7 @@ impl Sirius {
let model = Model::create( let model = Model::create(
grabbable.content_parent(), grabbable.content_parent(),
Transform::default(), Transform::identity(),
&ResourceID::new_namespaced("protostar", "button"), &ResourceID::new_namespaced("protostar", "button"),
)?; )?;
field.set_spatial_parent(grabbable.content_parent())?; field.set_spatial_parent(grabbable.content_parent())?;
@@ -150,17 +152,20 @@ impl RootHandler for Sirius {
} }
println!("{}", starpos); println!("{}", starpos);
star.content_parent() star.content_parent()
.set_position( .set_relative_transform(
Some(self.grabbable.content_parent()), self.grabbable.content_parent(),
[starpos, 0.1, 0.0], Transform::from_translation([starpos, 0.1, 0.0]),
) )
.ok(); .unwrap();
} }
} }
false => { false => {
for star in &self.clients { for star in &self.clients {
star.content_parent() star.content_parent()
.set_position(Some(self.grabbable.content_parent()), [0.0; 3]) .set_relative_transform(
self.grabbable.content_parent(),
Transform::from_translation([0.0; 3]),
)
.ok(); .ok();
} }
} }
@@ -261,12 +266,12 @@ impl App {
desktop_file: DesktopFile, desktop_file: DesktopFile,
) -> Result<Self> { ) -> Result<Self> {
let position = position.into(); let position = position.into();
let field = BoxField::create(parent, Transform::default(), [APP_SIZE; 3])?; let field = BoxField::create(parent, Transform::identity(), [APP_SIZE; 3])?;
let application = Application::create(desktop_file)?; let application = Application::create(desktop_file)?;
let icon = application.icon(128, false); let icon = application.icon(128, false);
let grabbable = Grabbable::create( let grabbable = Grabbable::create(
parent, parent,
Transform::from_position(position), Transform::from_translation(position),
&field, &field,
GrabbableSettings { GrabbableSettings {
max_distance: 0.01, max_distance: 0.01,
@@ -290,18 +295,21 @@ impl App {
let label_style = TextStyle { let label_style = TextStyle {
character_height: APP_SIZE * 2.0, character_height: APP_SIZE * 2.0,
bounds: Some(Bounds { bounds: Some(TextBounds {
bounds: [1.0; 2].into(), bounds: [1.0; 2].into(),
fit: TextFit::Wrap, fit: TextFit::Wrap,
bounds_align: Alignment::XCenter | Alignment::YCenter, anchor_align_x: XAlign::Center,
anchor_align_y: YAlign::Center,
}), }),
text_align: Alignment::Center.into(),
text_align_x: XAlign::Center,
text_align_y: YAlign::Center,
..Default::default() ..Default::default()
}; };
let label = application.name().and_then(|name| { let label = application.name().and_then(|name| {
Text::create( Text::create(
&icon, &icon,
Transform::from_position_rotation( Transform::from_translation_rotation(
[0.0, 0.1, -(APP_SIZE * 4.0)], [0.0, 0.1, -(APP_SIZE * 4.0)],
Quat::from_rotation_x(PI * 0.5), Quat::from_rotation_x(PI * 0.5),
), ),
@@ -349,7 +357,10 @@ impl App {
let scale = grabbable_move.move_by(info.delta); let scale = grabbable_move.move_by(info.delta);
self.grabbable self.grabbable
.content_parent() .content_parent()
.set_position(Some(&self.parent), Vec3::from(self.position) * scale) .set_relative_transform(
&self.parent,
Transform::from_translation(Vec3::from(self.position) * scale),
)
.unwrap(); .unwrap();
} else { } else {
if grabbable_move.final_value() == 0.0001 { if grabbable_move.final_value() == 0.0001 {
@@ -366,7 +377,7 @@ impl App {
let scale = grabbable_shrink.move_by(info.delta); let scale = grabbable_shrink.move_by(info.delta);
self.grabbable self.grabbable
.content_parent() .content_parent()
.set_scale(Some(&self.parent), Vector3::from([scale; 3])) .set_relative_transform(&self.parent, Transform::from_scale([scale; 3]))
.unwrap(); .unwrap();
} else { } else {
self.grabbable self.grabbable
@@ -381,17 +392,19 @@ impl App {
self.grabbable_shrink = None; self.grabbable_shrink = None;
self.grabbable self.grabbable
.content_parent() .content_parent()
.set_position(Some(&self.parent), self.position) .set_relative_transform(
&self.parent,
Transform::from_translation(self.position),
)
.unwrap(); .unwrap();
self.grabbable self.grabbable
.content_parent() .content_parent()
.set_rotation(Some(&self.parent), Quat::default()) .set_relative_transform(&self.parent, Transform::from_rotation(Quat::default()))
.unwrap(); .unwrap();
self.icon self.icon
.set_rotation( .set_local_transform(Transform::from_rotation(
None,
Quat::from_rotation_x(PI / 2.0) * Quat::from_rotation_y(PI), Quat::from_rotation_x(PI / 2.0) * Quat::from_rotation_y(PI),
) ))
.unwrap(); .unwrap();
} }
} else if let Some(grabbable_grow) = &mut self.grabbable_grow { } else if let Some(grabbable_grow) = &mut self.grabbable_grow {
@@ -399,7 +412,7 @@ impl App {
let scale = grabbable_grow.move_by(info.delta); let scale = grabbable_grow.move_by(info.delta);
self.grabbable self.grabbable
.content_parent() .content_parent()
.set_scale(Some(&self.parent), Vector3::from([scale; 3])) .set_relative_transform(&self.parent, Transform::from_scale([scale; 3]))
.unwrap(); .unwrap();
} else { } else {
self.grabbable self.grabbable
@@ -410,20 +423,19 @@ impl App {
} }
} else if self.grabbable.grab_action().actor_stopped() { } else if self.grabbable.grab_action().actor_stopped() {
self.grabbable_shrink = Some(Tweener::quart_in_out(APP_SIZE * 0.5, 0.0001, 0.25)); self.grabbable_shrink = Some(Tweener::quart_in_out(APP_SIZE * 0.5, 0.0001, 0.25));
let Ok(distance_future) = self
.grabbable
.content_parent()
.get_position_rotation_scale(&self.parent)
else {
return;
};
let application = self.application.clone(); let application = self.application.clone();
let space = self.content_parent().alias(); let space = self.content_parent().alias();
let parent = self.parent.alias();
//TODO: split the executable string for the args //TODO: split the executable string for the args
tokio::task::spawn(async move { tokio::task::spawn(async move {
let distance_vector = distance_future.await.ok().unwrap().0; let distance_vector = space
.get_transform(&parent)
.await
.unwrap()
.translation
.unwrap();
let distance = Vec3::from(distance_vector).length_squared(); let distance = Vec3::from(distance_vector).length_squared();
if distance > ACTIVATION_DISTANCE { if distance > ACTIVATION_DISTANCE {