From 0474c8c036c040c3ffcb67286db35a129c4f90e8 Mon Sep 17 00:00:00 2001 From: annieversary Date: Wed, 6 Oct 2021 18:27:49 +0200 Subject: [PATCH] color --- src/camera.rs | 2 +- src/main.rs | 2 +- src/player.rs | 32 +++++++++++++++++++++----------- 3 files changed, 23 insertions(+), 13 deletions(-) diff --git a/src/camera.rs b/src/camera.rs index df0e633..d0746f0 100644 --- a/src/camera.rs +++ b/src/camera.rs @@ -24,7 +24,7 @@ pub fn camera_follow_player( }; for (mut trans, _) in camera.iter_mut() { - trans.translation = player_pos + Vec3::new(-50.0, 100.0, 50.0); + trans.translation = player_pos + Vec3::new(-100.0, 200.0, 100.0); trans.look_at(player_pos, Vec3::Y); } } diff --git a/src/main.rs b/src/main.rs index c79b4ba..bb48564 100644 --- a/src/main.rs +++ b/src/main.rs @@ -110,7 +110,7 @@ fn setup( spawn_player(&mut commands, &mut meshes, &mut materials); // light balls - for i in 1..10 { + for i in 2..12 { spawn_light_ball( &mut commands, &light_ball_materials, diff --git a/src/player.rs b/src/player.rs index c28ec63..875cce4 100644 --- a/src/player.rs +++ b/src/player.rs @@ -25,19 +25,22 @@ pub fn spawn_player( .insert(Player); // light - let mut light_material: StandardMaterial = Color::rgb(0.737255, 0.560784, 0.560784).into(); - light_material.metallic = 0.5; - light_material.reflectance = 0.5; - light_material.emissive = Color::rgb(7.52, 5.72, 5.72); - let light_material = materials.add(light_material); - commands .spawn() .insert(LightFriends) .insert(Transform::default()) .insert(GlobalTransform::default()) .with_children(|children| { - for i in 0..6 { + let count = 6; + for i in 0..count { + let color = Color::hsl(360.0 * i as f32 / count as f32, 0.5, 0.5); + + let mut light_material: StandardMaterial = color.into(); + light_material.metallic = 0.5; + light_material.reflectance = 0.5; + light_material.emissive = color.as_rgba() * 10.0; + let light_material = materials.add(light_material); + children .spawn_bundle(PbrBundle { mesh: meshes.add(Mesh::from(shape::Icosphere { @@ -51,7 +54,7 @@ pub fn spawn_player( .insert_bundle(LightBundle { transform: Transform::from_xyz(0.0, 0.0, 0.0), light: Light { - color: Color::rgb(7.52, 5.72, 5.72), + color: color.as_rgba() * 10.0, ..Default::default() }, ..Default::default() @@ -86,15 +89,22 @@ pub fn move_light_friends( } } -pub fn light_movement(mut query: Query<(&mut Transform, &PlayerLight)>, time: Res