feat: formatting

This commit is contained in:
Nova
2023-07-19 04:16:32 -07:00
parent f63ca4a25b
commit f15578f7df
2 changed files with 48 additions and 22 deletions

View File

@@ -174,7 +174,10 @@ fn main() {
sk.input_hand_visible(Handed::Right, false);
}
let play_space = sk.world_has_bounds().then(|| PlaySpace::new().ok()).flatten();
let play_space = sk
.world_has_bounds()
.then(|| PlaySpace::new().ok())
.flatten();
let (event_stop_tx, event_stop_rx) = oneshot::channel::<()>();
let (info_sender, info_receiver) = oneshot::channel::<EventLoopInfo>();

View File

@@ -4,47 +4,70 @@ use color_eyre::eyre::Result;
use glam::Mat4;
use mint::Vector2;
use nanoid::nanoid;
use serde::{Serialize, Deserialize};
use serde::{Deserialize, Serialize};
use stereokit::StereoKitMultiThread;
use crate::{nodes::{spatial::Spatial, data::{PulseReceiver, Mask}, Node, fields::{Field, r#box::BoxField}}, core::client::INTERNAL_CLIENT};
use crate::{
core::client::INTERNAL_CLIENT,
nodes::{
data::{Mask, PulseReceiver},
fields::{r#box::BoxField, Field},
spatial::Spatial,
Node,
},
};
#[derive(Debug, Deserialize, Serialize)]
struct PlaySpaceMap {
play_space: (),
size: Vector2<f32>,
play_space: (),
size: Vector2<f32>,
}
impl Default for PlaySpaceMap {
fn default() -> Self {
Self { play_space: (), size: [0.0; 2].into() }
}
fn default() -> Self {
Self {
play_space: (),
size: [0.0; 2].into(),
}
}
}
pub struct PlaySpace {
_node: Arc<Node>,
spatial: Arc<Spatial>,
field: Arc<Field>,
_pulse_rx: Arc<PulseReceiver>,
_node: Arc<Node>,
spatial: Arc<Spatial>,
field: Arc<Field>,
_pulse_rx: Arc<PulseReceiver>,
}
impl PlaySpace {
pub fn new() -> Result<Self> {
let node = Node::create(&INTERNAL_CLIENT, "", &nanoid!(), false).add_to_scenegraph()?;
let spatial = Spatial::add_to(&node, None, Mat4::IDENTITY, false)?;
let field = BoxField::add_to(&node, [0.0;3].into())?;
let field = BoxField::add_to(&node, [0.0; 3].into())?;
let pulse_rx = PulseReceiver::add_to(&node, field.clone(), Mask::from_struct::<PlaySpaceMap>())?;
let pulse_rx =
PulseReceiver::add_to(&node, field.clone(), Mask::from_struct::<PlaySpaceMap>())?;
Ok(PlaySpace {
_node: node,
spatial,
field,
field,
_pulse_rx: pulse_rx,
})
}
pub fn update(&self, sk: &impl StereoKitMultiThread) {
let pose = sk.world_get_bounds_pose();
self.spatial.set_local_transform(Mat4::from_rotation_translation(pose.orientation, pose.position));
let Field::Box(box_field) = self.field.as_ref() else {return};
box_field.set_size([sk.world_get_bounds_size().x, 0.0, sk.world_get_bounds_size().y].into());
}
}
pub fn update(&self, sk: &impl StereoKitMultiThread) {
let pose = sk.world_get_bounds_pose();
self.spatial
.set_local_transform(Mat4::from_rotation_translation(
pose.orientation,
pose.position,
));
let Field::Box(box_field) = self.field.as_ref() else {return};
box_field.set_size(
[
sk.world_get_bounds_size().x,
0.0,
sk.world_get_bounds_size().y,
]
.into(),
);
}
}