Skip to content

Commit e45da4e

Browse files
committed
examples: Randomize hue of light color in many_lights
For François. <3
1 parent b89c3b2 commit e45da4e

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

examples/stress_tests/many_lights.rs

+3
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ use bevy::{
55
prelude::*,
66
render::{camera::CameraProjection, primitives::Frustum, RenderApp, RenderStage},
77
};
8+
use rand::{thread_rng, Rng};
89

910
fn main() {
1011
App::new()
@@ -55,13 +56,15 @@ fn setup(
5556
// the same number of visible meshes regardless of the viewing angle.
5657
// NOTE: f64 is used to avoid precision issues that produce visual artifacts in the distribution
5758
let golden_ratio = 0.5f64 * (1.0f64 + 5.0f64.sqrt());
59+
let mut rng = thread_rng();
5860
for i in 0..N_LIGHTS {
5961
let spherical_polar_theta_phi = fibonacci_spiral_on_sphere(golden_ratio, i, N_LIGHTS);
6062
let unit_sphere_p = spherical_polar_to_cartesian(spherical_polar_theta_phi);
6163
commands.spawn_bundle(PointLightBundle {
6264
point_light: PointLight {
6365
range: LIGHT_RADIUS,
6466
intensity: LIGHT_INTENSITY,
67+
color: Color::hsl(rng.gen_range(0.0..360.0), 1.0, 0.5),
6568
..default()
6669
},
6770
transform: Transform::from_translation((RADIUS as f64 * unit_sphere_p).as_vec3()),

0 commit comments

Comments
 (0)