include proton scale

This commit is contained in:
Aevyrie 2023-10-23 12:51:03 -07:00
parent 8118c11980
commit 409f158b0e
2 changed files with 16 additions and 16 deletions

View File

@ -38,16 +38,16 @@ fn setup(
transform: Transform::from_xyz(0.0, 0.0, 8.0) transform: Transform::from_xyz(0.0, 0.0, 8.0)
.looking_at(Vec3::new(0.0, 0.0, 0.0), Vec3::Y), .looking_at(Vec3::new(0.0, 0.0, 0.0), Vec3::Y),
projection: Projection::Perspective(PerspectiveProjection { projection: Projection::Perspective(PerspectiveProjection {
near: 1e-16, near: 1e-18,
..default() ..default()
}), }),
..default() ..default()
}, },
GridCell::<i128>::default(), // All spatial entities need this component GridCell::<i128>::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 CameraController::default() // Built-in camera controller
.with_max_speed(10e35) .with_speed_bounds([10e-18, 10e35])
.with_smoothness(0.95, 0.9) .with_smoothness(0.9, 0.8)
.with_speed(1.0), .with_speed(1.0),
)); ));
@ -67,7 +67,7 @@ fn setup(
}); });
let mut translation = Vec3::ZERO; let mut translation = Vec3::ZERO;
for i in -12..=27 { for i in -16..=27 {
let j = 10_f32.powf(i as f32); let j = 10_f32.powf(i as f32);
translation.x += j; translation.x += j;
commands.spawn(( commands.spawn((
@ -166,19 +166,19 @@ fn ui_text_system(
let (cell, transform) = origin.single(); let (cell, transform) = origin.single();
let translation = transform.translation; 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!( 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 translation.x, translation.y, translation.z
); );
let velocity = camera.single().velocity(); let velocity = camera.single().velocity();
let speed = velocity.0.length() / time.delta_seconds_f64(); let speed = velocity.0.length() / time.delta_seconds_f64();
let camera_text = if speed > 3.0e8 { 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 { } 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() { 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"), (1e-10, "diameter of a carbon atom"),
(4e-11, "diameter of a hydrogen atom"), (4e-11, "diameter of a hydrogen atom"),
(4e-12, "diameter of an electron"), (4e-12, "diameter of an electron"),
(1.9e-15, "diameter of a proton"),
]; ];
let mut min = items[0]; let mut min = items[0];

View File

@ -37,7 +37,7 @@ pub struct CameraController {
pub smoothness: f64, pub smoothness: f64,
/// Rotational smoothness, from `0.0` to `1.0`. /// Rotational smoothness, from `0.0` to `1.0`.
pub rotational_smoothness: f64, pub rotational_smoothness: f64,
/// Maximum possible speed. /// Base speed.
pub speed: f64, pub speed: f64,
/// Minimum and maximum speed. /// Minimum and maximum speed.
pub speed_bounds: [f64; 2], pub speed_bounds: [f64; 2],
@ -56,12 +56,6 @@ impl CameraController {
self 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. /// 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 { pub fn with_slowing(mut self, slow_near_objects: bool) -> Self {
self.slow_near_objects = slow_near_objects; self.slow_near_objects = slow_near_objects;
@ -73,6 +67,11 @@ impl CameraController {
self.speed = speed; self.speed = speed;
self 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. /// Returns the translational and rotational velocity of the camera.
pub fn velocity(&self) -> (DVec3, DQuat) { pub fn velocity(&self) -> (DVec3, DQuat) {