main
annieversary 2021-10-06 18:27:49 +02:00
parent 03ebb738f3
commit 0474c8c036
3 changed files with 23 additions and 13 deletions

View File

@ -24,7 +24,7 @@ pub fn camera_follow_player(
}; };
for (mut trans, _) in camera.iter_mut() { 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); trans.look_at(player_pos, Vec3::Y);
} }
} }

View File

@ -110,7 +110,7 @@ fn setup(
spawn_player(&mut commands, &mut meshes, &mut materials); spawn_player(&mut commands, &mut meshes, &mut materials);
// light balls // light balls
for i in 1..10 { for i in 2..12 {
spawn_light_ball( spawn_light_ball(
&mut commands, &mut commands,
&light_ball_materials, &light_ball_materials,

View File

@ -25,19 +25,22 @@ pub fn spawn_player(
.insert(Player); .insert(Player);
// light // 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 commands
.spawn() .spawn()
.insert(LightFriends) .insert(LightFriends)
.insert(Transform::default()) .insert(Transform::default())
.insert(GlobalTransform::default()) .insert(GlobalTransform::default())
.with_children(|children| { .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 children
.spawn_bundle(PbrBundle { .spawn_bundle(PbrBundle {
mesh: meshes.add(Mesh::from(shape::Icosphere { mesh: meshes.add(Mesh::from(shape::Icosphere {
@ -51,7 +54,7 @@ pub fn spawn_player(
.insert_bundle(LightBundle { .insert_bundle(LightBundle {
transform: Transform::from_xyz(0.0, 0.0, 0.0), transform: Transform::from_xyz(0.0, 0.0, 0.0),
light: Light { light: Light {
color: Color::rgb(7.52, 5.72, 5.72), color: color.as_rgba() * 10.0,
..Default::default() ..Default::default()
}, },
..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<Time>) { pub fn light_movement(
mut query: Query<(&mut Transform, &PlayerLight)>,
time: Res<Time>,
interpolation: Res<FloatingOrbsInterpolationState>,
) {
let t = time.seconds_since_startup(); let t = time.seconds_since_startup();
// make the friends go further when the button is pressed
let width = 5.0 + interpolation.0 * 7.0;
for (mut trans, light) in query.iter_mut() { for (mut trans, light) in query.iter_mut() {
let i = light.i as f64; let i = light.i as f64;
let i2 = i / 2.0; let i2 = i / 2.0;
trans.translation = Vec3::new( trans.translation = Vec3::new(
5.0 * i2 as f32 * (t * 0.4 * i2 + i).cos() as f32, width * i2 as f32 * (t * 0.4 * i2 + i).cos() as f32,
3.0 * (t * 1.1 * i2 + i).sin() as f32 + 4.0, 3.0 * (t * 1.1 * i2 + i).sin() as f32 + 4.0,
5.0 * (t * 0.4 * i + i).sin() as f32, width * (t * 0.4 * i + i).sin() as f32,
); );
} }
} }