camera: tune camera and light

This commit is contained in:
Astro 2022-01-15 02:38:30 +01:00
parent fbb833b6fb
commit c8391f34f2
1 changed files with 12 additions and 11 deletions

View File

@ -8,9 +8,12 @@ pub struct PlayerCamera;
#[derive(Component)]
pub struct Light;
const OFFSET_X: f32 = -5.0;
const OFFSET_Y: f32 = 10.0;
const OFFSET_Z: f32 = 17.32;
pub fn setup(mut commands: Commands) {
let camera_transform = Transform::from_xyz(-10.0, 10.0, 17.32)
let camera_transform = Transform::from_xyz(OFFSET_X, OFFSET_Y, OFFSET_Z)
.looking_at(Vec3::ZERO, Vec3::Y);
commands.spawn()
.insert_bundle(PerspectiveCameraBundle {
@ -27,8 +30,8 @@ pub fn setup(mut commands: Commands) {
transform: hilight_transform,
point_light: PointLight {
range: 2000.0,
radius: 2000.0,
intensity: 4000.0,
radius: 200.0,
intensity: 2000.0,
shadows_enabled: true,
..Default::default()
},
@ -76,9 +79,9 @@ pub fn track_players(
(max_z? - min_z?) / 4.0
);
Some(Vec3::new(
(max_x? + min_x?) / 2.0 - dist,
max_y + dist,
max_z? + dist
(min_x? + max_x?) / 2.0 + OFFSET_X,
max_y + OFFSET_Y,
(min_z? + max_z?) / 2.0 + OFFSET_Z + dist
))
}) {
for mut camera_transform in queries.q1().iter_mut() {
@ -89,16 +92,14 @@ pub fn track_players(
if let Some(light_pos) = max_y.and_then(|max_y| {
Some(Vec3::new(
(max_x? + min_x?) / 2.0,
max_y + 8.0,
(max_z? + min_z?) / 2.0 + 10.0,
(min_x? + max_x?) / 2.0,
max_y + 5.0,
max_z? + 5.0
))
}) {
for ref mut light_transform in queries.q2().iter_mut() {
light_transform.translation = light_pos;
}
} else {
println!("No player to target!");
}
}