fix camera + light

This commit is contained in:
Astro 2022-01-15 20:13:08 +01:00
parent 3226bbc411
commit 7f39a45b92
1 changed files with 8 additions and 9 deletions

View File

@ -72,22 +72,21 @@ pub fn track_players(
max_z = Some(t.z); max_z = Some(t.z);
} }
} }
if let Some(target) = max_y.and_then(|max_y| { let target = max_y.and_then(|max_y| {
let dist = 8.0f32.max( let dist = 8.0f32.max(
max_x? - min_x? / 2.0 (max_x? - min_x?) / 2.0
).max( ).max(
(max_z? - min_z?) / 4.0 (max_z? - min_z?) / 4.0
); );
Some(Vec3::new( Some(Vec3::new(
(min_x? + max_x?) / 2.0 + OFFSET_X, (min_x? + max_x?) / 2.0 + OFFSET_X - dist / 2.0,
max_y + OFFSET_Y, max_y + OFFSET_Y,
(min_z? + max_z?) / 2.0 + OFFSET_Z + dist max_z? + OFFSET_Z + dist,
)) ))
}) { }).unwrap_or_else(|| Vec3::new(OFFSET_X, OFFSET_Y, OFFSET_Z));
for mut camera_transform in queries.q1().iter_mut() { for mut camera_transform in queries.q1().iter_mut() {
let t = &mut camera_transform.translation; let t = &mut camera_transform.translation;
*t = *t + time.delta_seconds() * (target - *t) / 2.0; *t = *t + time.delta_seconds() * (target - *t) / 2.0;
}
} }
if let Some(light_pos) = max_y.and_then(|max_y| { if let Some(light_pos) = max_y.and_then(|max_y| {