fix camera + light

master
Astro 9 months ago
parent 3226bbc411
commit 7f39a45b92
  1. 17
      src/camera.rs

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

Loading…
Cancel
Save