correct sun distance display
This commit is contained in:
parent
9f15e78e07
commit
55f0c6c607
|
@ -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_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 OXY_D: f32 = OXYGEN_USE_KG_PER_S * 60.0 * 60.0 * 24.0;
|
||||||
pub const PARSEC2METER: f64 = 3.0857e16;
|
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) {
|
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)));
|
let temperature = 4600.0 * ((1.0 / (0.92 * color_index + 1.7)) + (1.0 / (0.92 * color_index + 0.62)));
|
||||||
|
|
24
src/world.rs
24
src/world.rs
|
@ -125,19 +125,20 @@ pub fn setup(
|
||||||
let mut starcount = 0;
|
let mut starcount = 0;
|
||||||
for star in stars::STARS {
|
for star in stars::STARS {
|
||||||
let mag = star.3;
|
let mag = star.3;
|
||||||
|
let is_sun = mag < -20.0;
|
||||||
if mag > STARS_MAX_MAGNITUDE {
|
if mag > STARS_MAX_MAGNITUDE {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
let scale_color = {|color: f32|
|
let scale_color = {|color: f32|
|
||||||
if mag < -20.0 {
|
if is_sun {
|
||||||
color * 13.0f32 // Sun
|
color * 13.0f32
|
||||||
} else {
|
} else {
|
||||||
color * (0.0659663 * mag * mag - 1.09862 * mag + 4.3)
|
color * (0.0659663 * mag * mag - 1.09862 * mag + 4.3)
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
let scale_size = {|mag: f32|
|
let scale_size = {|mag: f32|
|
||||||
if mag < -20.0 {
|
if is_sun {
|
||||||
40000.0f32 // Sun
|
40000.0f32
|
||||||
} else {
|
} else {
|
||||||
1000.0 * (0.230299 * mag * mag - 3.09013 * mag + 15.1782)
|
1000.0 * (0.230299 * mag * mag - 3.09013 * mag + 15.1782)
|
||||||
} * 100.0
|
} * 100.0
|
||||||
|
@ -148,7 +149,12 @@ pub fn setup(
|
||||||
unlit: true,
|
unlit: true,
|
||||||
..default()
|
..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() {
|
let name = if star.6.is_empty() {
|
||||||
"Uncharted Star".to_string()
|
"Uncharted Star".to_string()
|
||||||
} else {
|
} else {
|
||||||
|
@ -158,15 +164,15 @@ pub fn setup(
|
||||||
Star,
|
Star,
|
||||||
hud::IsClickable {
|
hud::IsClickable {
|
||||||
name: Some(name),
|
name: Some(name),
|
||||||
distance: Some(nature::PARSEC2METER * star.5 as f64),
|
distance: Some(starchart_distance),
|
||||||
},
|
},
|
||||||
PbrBundle {
|
PbrBundle {
|
||||||
mesh: sphere_handle.clone(),
|
mesh: sphere_handle.clone(),
|
||||||
material: star_color_handle,
|
material: star_color_handle,
|
||||||
transform: Transform::from_xyz(
|
transform: Transform::from_xyz(
|
||||||
dist * star.0,
|
mesh_distance * star.0,
|
||||||
dist * star.1,
|
mesh_distance * star.1,
|
||||||
dist * star.2,
|
mesh_distance * star.2,
|
||||||
)
|
)
|
||||||
.with_scale(Vec3::splat(scale_size(mag))),
|
.with_scale(Vec3::splat(scale_size(mag))),
|
||||||
..default()
|
..default()
|
||||||
|
|
Loading…
Reference in a new issue