This commit is contained in:
WanderingPenwing 2024-10-05 13:11:11 +02:00
parent c0725dcceb
commit 085318c7c6

View file

@ -53,34 +53,38 @@ fn setup(
let star_size = 0.02; let star_size = 0.02;
let sky_radius = 2.0; let sky_radius = 2.0;
let mesh = meshes.add(Cuboid::new(star_size, star_size, star_size));
let material = materials.add(Color::srgb(1.0, 1.0, 1.0));
for star in stars { for star in stars {
info!("{:?}", star); info!("{:?}", star);
let star_pos = star_position(star) * sky_radius; let star_pos = star_position(star) * sky_radius;
info!("{:?}", star_pos); info!("{:?}", star_pos);
// commands.spawn((
// PbrBundle {//Plane3d::default().mesh().size(1., 1.) commands.spawn((
// mesh: meshes.add(Cuboid::new(star_size, star_size, star_size)), PbrBundle {
// material: materials.add(Color::srgb(1.0, 1.0, 1.0)), mesh: mesh.clone(),
// transform: Transform::from_xyz(star_pos.x, star_pos.y, star_pos.z), material: material.clone(),
// ..default() transform: Transform::from_xyz(star_pos.x, star_pos.y, star_pos.z),
// }, ..default()
// Star, },
// )); Star,
));
} }
commands.spawn(( // commands.spawn((
PbrBundle {//Plane3d::default().mesh().size(1., 1.) // PbrBundle {//Plane3d::default().mesh().size(1., 1.)
mesh: meshes.add(Cuboid::new(star_size, star_size, star_size)), // mesh: meshes.add(Cuboid::new(star_size, star_size, star_size)),
material: materials.add(Color::srgb(1.0, 0.0, 0.0)), // material: materials.add(Color::srgb(1.0, 0.0, 0.0)),
transform: Transform::from_xyz(1.0, 0.0, 0.0), // transform: Transform::from_xyz(1.0, 0.0, 0.0),
..default() // ..default()
}, // },
Star, // Star,
)); // ));
// light // light
commands.spawn(DirectionalLightBundle { commands.spawn(DirectionalLightBundle {
@ -128,13 +132,13 @@ fn star_position(star_data: StarData) -> Vec3 {
+ dec_parts[1].parse::<f64>().unwrap() / 60.0 + dec_parts[1].parse::<f64>().unwrap() / 60.0
+ dec_parts[2].parse::<f64>().unwrap() / 3600.0; + dec_parts[2].parse::<f64>().unwrap() / 3600.0;
let dec_sign : f64 = if text_dec.starts_with('-') { // let dec_sign : f64 = if text_dec.starts_with('-') {
-1.0 // -1.0
} else { // } else {
1.0 // 1.0
}; // };
return celestial_to_cartesian(ra_seconds/3600.0, dec_sign * dec_deg) return celestial_to_cartesian(ra_seconds/3600.0, dec_deg)
} }
fn celestial_to_cartesian(rah: f64, ded: f64) -> Vec3 { fn celestial_to_cartesian(rah: f64, ded: f64) -> Vec3 {