constellation center

This commit is contained in:
WanderingPenwing 2024-10-06 18:17:57 +02:00
parent 84f7ed3611
commit f27f783501
3 changed files with 17 additions and 12 deletions

20
Cargo.lock generated
View file

@ -208,6 +208,16 @@ dependencies = [
"libloading 0.7.4", "libloading 0.7.4",
] ]
[[package]]
name = "astraea"
version = "0.1.0"
dependencies = [
"bevy",
"rand",
"serde",
"serde_json",
]
[[package]] [[package]]
name = "async-broadcast" name = "async-broadcast"
version = "0.5.1" version = "0.5.1"
@ -305,16 +315,6 @@ dependencies = [
"bevy_internal", "bevy_internal",
] ]
[[package]]
name = "bevy-test"
version = "0.1.0"
dependencies = [
"bevy",
"rand",
"serde",
"serde_json",
]
[[package]] [[package]]
name = "bevy_a11y" name = "bevy_a11y"
version = "0.14.2" version = "0.14.2"

View file

@ -1,5 +1,5 @@
[package] [package]
name = "bevy-test" name = "astraea"
version = "0.1.0" version = "0.1.0"
edition = "2021" edition = "2021"

View file

@ -362,9 +362,14 @@ fn choose_constellation(
let target_index = rng.next_u32().rem_euclid(4) as usize; let target_index = rng.next_u32().rem_euclid(4) as usize;
let target_constellation = &constellations[target_index]; let target_constellation = &constellations[target_index];
let mut mean_pos = Vec3::ZERO;
for star in target_constellation.stars.clone() {
mean_pos += celestial_to_cartesian(star.rah, star.dec)
}
let target_rotation = Quat::from_rotation_arc( let target_rotation = Quat::from_rotation_arc(
Vec3::Z, Vec3::Z,
-celestial_to_cartesian(target_constellation.rah, target_constellation.dec), -mean_pos*(1.0/target_constellation.stars.len() as f32),
); );
player.target_rotation = Some(target_rotation); player.target_rotation = Some(target_rotation);