camera: realign

master
Astro 9 months ago
parent 06954b38ea
commit 8f6001d3ec
  1. 15
      src/camera.rs

@ -10,7 +10,7 @@ pub struct Light;
pub fn setup(mut commands: Commands) {
let camera_transform = Transform::from_xyz(-10.0, 10.0, 20.0)
let camera_transform = Transform::from_xyz(-10.0, 10.0, 17.32)
.looking_at(Vec3::ZERO, Vec3::Y);
commands.spawn()
.insert_bundle(PerspectiveCameraBundle {
@ -70,12 +70,16 @@ pub fn track_players(
}
}
if let Some(target) = max_y.and_then(|max_y| {
let dist = 10.0f32.max(
max_x? - min_x?
let dist = 8.0f32.max(
max_x? - min_x? / 2.0
).max(
(max_z? - min_z?) / 2.0
(max_z? - min_z?) / 4.0
);
Some(Vec3::new(min_x? - dist, max_y + dist, max_z? + 2.0 * dist))
Some(Vec3::new(
(max_x? + min_x?) / 2.0 - dist,
max_y + dist,
max_z? + dist
))
}) {
for mut camera_transform in queries.q1().iter_mut() {
let t = &mut camera_transform.translation;
@ -98,4 +102,3 @@ pub fn track_players(
}
}

Loading…
Cancel
Save