camera: tune camera and light
This commit is contained in:
parent
fbb833b6fb
commit
c8391f34f2
|
@ -8,9 +8,12 @@ pub struct PlayerCamera;
|
||||||
#[derive(Component)]
|
#[derive(Component)]
|
||||||
pub struct Light;
|
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) {
|
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);
|
.looking_at(Vec3::ZERO, Vec3::Y);
|
||||||
commands.spawn()
|
commands.spawn()
|
||||||
.insert_bundle(PerspectiveCameraBundle {
|
.insert_bundle(PerspectiveCameraBundle {
|
||||||
|
@ -27,8 +30,8 @@ pub fn setup(mut commands: Commands) {
|
||||||
transform: hilight_transform,
|
transform: hilight_transform,
|
||||||
point_light: PointLight {
|
point_light: PointLight {
|
||||||
range: 2000.0,
|
range: 2000.0,
|
||||||
radius: 2000.0,
|
radius: 200.0,
|
||||||
intensity: 4000.0,
|
intensity: 2000.0,
|
||||||
shadows_enabled: true,
|
shadows_enabled: true,
|
||||||
..Default::default()
|
..Default::default()
|
||||||
},
|
},
|
||||||
|
@ -76,9 +79,9 @@ pub fn track_players(
|
||||||
(max_z? - min_z?) / 4.0
|
(max_z? - min_z?) / 4.0
|
||||||
);
|
);
|
||||||
Some(Vec3::new(
|
Some(Vec3::new(
|
||||||
(max_x? + min_x?) / 2.0 - dist,
|
(min_x? + max_x?) / 2.0 + OFFSET_X,
|
||||||
max_y + dist,
|
max_y + OFFSET_Y,
|
||||||
max_z? + dist
|
(min_z? + max_z?) / 2.0 + OFFSET_Z + dist
|
||||||
))
|
))
|
||||||
}) {
|
}) {
|
||||||
for mut camera_transform in queries.q1().iter_mut() {
|
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| {
|
if let Some(light_pos) = max_y.and_then(|max_y| {
|
||||||
Some(Vec3::new(
|
Some(Vec3::new(
|
||||||
(max_x? + min_x?) / 2.0,
|
(min_x? + max_x?) / 2.0,
|
||||||
max_y + 8.0,
|
max_y + 5.0,
|
||||||
(max_z? + min_z?) / 2.0 + 10.0,
|
max_z? + 5.0
|
||||||
))
|
))
|
||||||
}) {
|
}) {
|
||||||
for ref mut light_transform in queries.q2().iter_mut() {
|
for ref mut light_transform in queries.q2().iter_mut() {
|
||||||
light_transform.translation = light_pos;
|
light_transform.translation = light_pos;
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
println!("No player to target!");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue