diff --git a/src/nature.rs b/src/nature.rs index e4af0f5..f8abec7 100644 --- a/src/nature.rs +++ b/src/nature.rs @@ -8,6 +8,7 @@ pub const OXY_M: f32 = OXYGEN_USE_KG_PER_S * 60.0; pub const OXY_H: f32 = OXYGEN_USE_KG_PER_S * 60.0 * 60.0; pub const OXY_D: f32 = OXYGEN_USE_KG_PER_S * 60.0 * 60.0 * 24.0; pub const PARSEC2METER: f64 = 3.0857e16; +pub const DIST_JUPTER_SUN: f64 = 778479.0e6; pub fn star_color_index_to_rgb(color_index: f32) -> (f32, f32, f32) { let temperature = 4600.0 * ((1.0 / (0.92 * color_index + 1.7)) + (1.0 / (0.92 * color_index + 0.62))); diff --git a/src/world.rs b/src/world.rs index 5136637..8e61c1a 100644 --- a/src/world.rs +++ b/src/world.rs @@ -125,19 +125,20 @@ pub fn setup( let mut starcount = 0; for star in stars::STARS { let mag = star.3; + let is_sun = mag < -20.0; if mag > STARS_MAX_MAGNITUDE { continue; } let scale_color = {|color: f32| - if mag < -20.0 { - color * 13.0f32 // Sun + if is_sun { + color * 13.0f32 } else { color * (0.0659663 * mag * mag - 1.09862 * mag + 4.3) } }; let scale_size = {|mag: f32| - if mag < -20.0 { - 40000.0f32 // Sun + if is_sun { + 40000.0f32 } else { 1000.0 * (0.230299 * mag * mag - 3.09013 * mag + 15.1782) } * 100.0 @@ -148,7 +149,12 @@ pub fn setup( unlit: true, ..default() }); - let dist = 1e9; + let mesh_distance = 1e9; + let starchart_distance = if is_sun { + nature::DIST_JUPTER_SUN + } else { + nature::PARSEC2METER * star.5 as f64 + }; let name = if star.6.is_empty() { "Uncharted Star".to_string() } else { @@ -158,15 +164,15 @@ pub fn setup( Star, hud::IsClickable { name: Some(name), - distance: Some(nature::PARSEC2METER * star.5 as f64), + distance: Some(starchart_distance), }, PbrBundle { mesh: sphere_handle.clone(), material: star_color_handle, transform: Transform::from_xyz( - dist * star.0, - dist * star.1, - dist * star.2, + mesh_distance * star.0, + mesh_distance * star.1, + mesh_distance * star.2, ) .with_scale(Vec3::splat(scale_size(mag))), ..default()