From c793c81ee8435b4501652b3637465251b95391c1 Mon Sep 17 00:00:00 2001 From: Hartmut Seichter Date: Tue, 6 Dec 2022 16:29:41 +0100 Subject: [PATCH] initial setup for rendering into a viewport --- src/offaxis.rs | 2 +- src/screeninfo.rs | 8 +++++--- src/utils.rs | 3 ++- 3 files changed, 8 insertions(+), 5 deletions(-) diff --git a/src/offaxis.rs b/src/offaxis.rs index 0ed0b3d..c50e156 100644 --- a/src/offaxis.rs +++ b/src/offaxis.rs @@ -68,6 +68,6 @@ pub fn offaxis_camera_setup(mut commands: Commands) { VisibleEntities::default(), Camera::default(), Camera3d::default(), - ScreenInfo::default() + ScreenInfo::new("Test") )); } diff --git a/src/screeninfo.rs b/src/screeninfo.rs index 956f750..56b9732 100644 --- a/src/screeninfo.rs +++ b/src/screeninfo.rs @@ -28,9 +28,9 @@ pub struct ScreenInfo { impl ScreenInfo { - fn default() -> Self { + pub fn new(name: &str) -> Self { Self { - name: String::from("main"), + name: name.to_string(), width: 3.08, height: 2.33, center: Vec3 { x: 0.0, y: -1.15, z: -3.08 }, @@ -45,7 +45,7 @@ impl ScreenInfo { } - fn update(&mut self) { + pub fn update(&mut self) -> &mut Self { // compute right as up ^ forward self.horizontal = self.up.cross(self.normal); @@ -55,6 +55,8 @@ impl ScreenInfo { self.bottom = self.center - self.up * (self.height * 0.5); self.left = self.center - self.horizontal * (self.height * 0.5); self.right = self.center + self.horizontal * (self.height * 0.5); + + self } diff --git a/src/utils.rs b/src/utils.rs index 548f31f..fa16c1b 100644 --- a/src/utils.rs +++ b/src/utils.rs @@ -28,6 +28,7 @@ pub fn update_offaxis(mut query : Query<( (*q).far *= 1.0; println!("Update {:?}",q); - println!("Screeninfo {0}",si.name.len()); + + println!("Screeninfo {}",si.name); } } \ No newline at end of file