From 409f158b0eff769f354239c16e71de2d9d524c4e Mon Sep 17 00:00:00 2001 From: Aevyrie Date: Mon, 23 Oct 2023 12:51:03 -0700 Subject: [PATCH] include proton scale --- examples/demo.rs | 19 ++++++++++--------- src/camera.rs | 13 ++++++------- 2 files changed, 16 insertions(+), 16 deletions(-) diff --git a/examples/demo.rs b/examples/demo.rs index 443df92..db2e428 100644 --- a/examples/demo.rs +++ b/examples/demo.rs @@ -38,16 +38,16 @@ fn setup( transform: Transform::from_xyz(0.0, 0.0, 8.0) .looking_at(Vec3::new(0.0, 0.0, 0.0), Vec3::Y), projection: Projection::Perspective(PerspectiveProjection { - near: 1e-16, + near: 1e-18, ..default() }), ..default() }, GridCell::::default(), // All spatial entities need this component - FloatingOrigin, // Important: marks this as the entity to use as the floating origin when propagating transforms for rendering. + FloatingOrigin, // Important: marks the floating origin entity for rendering. CameraController::default() // Built-in camera controller - .with_max_speed(10e35) - .with_smoothness(0.95, 0.9) + .with_speed_bounds([10e-18, 10e35]) + .with_smoothness(0.9, 0.8) .with_speed(1.0), )); @@ -67,7 +67,7 @@ fn setup( }); let mut translation = Vec3::ZERO; - for i in -12..=27 { + for i in -16..=27 { let j = 10_f32.powf(i as f32); translation.x += j; commands.spawn(( @@ -166,19 +166,19 @@ fn ui_text_system( let (cell, transform) = origin.single(); let translation = transform.translation; - let grid_text = format!("Origin GridCell: {}x, {}y, {}z", cell.x, cell.y, cell.z); + let grid_text = format!("GridCell: {}x, {}y, {}z", cell.x, cell.y, cell.z); let translation_text = format!( - "Origin Transform: {:>8.2}x, {:>8.2}y, {:>8.2}z", + "Transform: {:>8.2}x, {:>8.2}y, {:>8.2}z", translation.x, translation.y, translation.z ); let velocity = camera.single().velocity(); let speed = velocity.0.length() / time.delta_seconds_f64(); let camera_text = if speed > 3.0e8 { - format!("Camera Speed: {:.0e} * speed of light", speed / 3.0e8) + format!("Speed: {:.0e} * speed of light", speed / 3.0e8) } else { - format!("Camera Speed: {:.2e} m/s", speed) + format!("Speed: {:.2e} m/s", speed) }; let (nearest_text, fact_text) = if let Some(nearest) = camera.single().nearest_object() { @@ -232,6 +232,7 @@ fn closest<'a>(diameter: f32) -> (f32, &'a str) { (1e-10, "diameter of a carbon atom"), (4e-11, "diameter of a hydrogen atom"), (4e-12, "diameter of an electron"), + (1.9e-15, "diameter of a proton"), ]; let mut min = items[0]; diff --git a/src/camera.rs b/src/camera.rs index 47a150c..ff6c648 100644 --- a/src/camera.rs +++ b/src/camera.rs @@ -37,7 +37,7 @@ pub struct CameraController { pub smoothness: f64, /// Rotational smoothness, from `0.0` to `1.0`. pub rotational_smoothness: f64, - /// Maximum possible speed. + /// Base speed. pub speed: f64, /// Minimum and maximum speed. pub speed_bounds: [f64; 2], @@ -56,12 +56,6 @@ impl CameraController { self } - /// Sets the `max_speed` parameter of the controller, and returns the modified result. - pub fn with_max_speed(mut self, max_speed: f64) -> Self { - self.speed = max_speed; - self - } - /// Sets the `slow_near_objects` parameter of the controller, and returns the modified result. pub fn with_slowing(mut self, slow_near_objects: bool) -> Self { self.slow_near_objects = slow_near_objects; @@ -73,6 +67,11 @@ impl CameraController { self.speed = speed; self } + /// Sets the speed of the controller, and returns the modified result. + pub fn with_speed_bounds(mut self, speed_limits: [f64; 2]) -> Self { + self.speed_bounds = speed_limits; + self + } /// Returns the translational and rotational velocity of the camera. pub fn velocity(&self) -> (DVec3, DQuat) {