diff --git a/examples/3d/skybox.rs b/examples/3d/skybox.rs index 518a06cf3c71f..2b320f30a84a3 100644 --- a/examples/3d/skybox.rs +++ b/examples/3d/skybox.rs @@ -80,7 +80,7 @@ fn setup(mut commands: Commands, asset_server: Res) { CameraController::default(), Skybox { image: skybox_handle.clone(), - brightness: 150.0, + brightness: 1000.0, }, )); diff --git a/examples/3d/spotlight.rs b/examples/3d/spotlight.rs index 343fad122e687..324f8be7ed84c 100644 --- a/examples/3d/spotlight.rs +++ b/examples/3d/spotlight.rs @@ -5,6 +5,13 @@ use std::f32::consts::*; use bevy::{pbr::NotShadowCaster, prelude::*}; use rand::{rngs::StdRng, Rng, SeedableRng}; +const INSTRUCTIONS: &str = "\ +Controls +-------- +Horizontal Movement: WASD +Vertical Movement: Space and Shift +Rotate Camera: Left and Right Arrows"; + fn main() { App::new() .insert_resource(AmbientLight { @@ -13,7 +20,7 @@ fn main() { }) .add_plugins(DefaultPlugins) .add_systems(Startup, setup) - .add_systems(Update, (light_sway, movement)) + .add_systems(Update, (light_sway, movement, rotation)) .run(); } @@ -27,30 +34,38 @@ fn setup( mut materials: ResMut>, ) { // ground plane - commands.spawn(PbrBundle { - mesh: meshes.add(Plane3d::default().mesh().size(100.0, 100.0)), - material: materials.add(Color::WHITE), - ..default() - }); + commands.spawn(( + PbrBundle { + mesh: meshes.add(Plane3d::default().mesh().size(100.0, 100.0)), + material: materials.add(Color::WHITE), + ..default() + }, + Movable, + )); // cubes let mut rng = StdRng::seed_from_u64(19878367467713); let cube_mesh = meshes.add(Cuboid::new(0.5, 0.5, 0.5)); let blue = materials.add(Color::rgb_u8(124, 144, 255)); - for _ in 0..40 { - let x = rng.gen_range(-5.0..5.0); - let y = rng.gen_range(0.0..3.0); - let z = rng.gen_range(-5.0..5.0); - commands.spawn(( - PbrBundle { - mesh: cube_mesh.clone(), - material: blue.clone(), - transform: Transform::from_xyz(x, y, z), - ..default() - }, - Movable, - )); - } + + commands.spawn_batch( + std::iter::repeat_with(move || { + let x = rng.gen_range(-5.0..5.0); + let y = rng.gen_range(0.0..3.0); + let z = rng.gen_range(-5.0..5.0); + + ( + PbrBundle { + mesh: cube_mesh.clone(), + material: blue.clone(), + transform: Transform::from_xyz(x, y, z), + ..default() + }, + Movable, + ) + }) + .take(40), + ); let sphere_mesh = meshes.add(Sphere::new(0.05).mesh().uv(32, 18)); let sphere_mesh_direction = meshes.add(Sphere::new(0.1).mesh().uv(32, 18)); @@ -64,6 +79,7 @@ fn setup( emissive: Color::rgba_linear(50.0, 0.0, 0.0, 0.0), ..default() }); + for x in 0..4 { for z in 0..4 { let x = x as f32 - 2.0; @@ -74,7 +90,7 @@ fn setup( transform: Transform::from_xyz(1.0 + x, 2.0, z) .looking_at(Vec3::new(1.0 + x, 0.0, z), Vec3::X), spot_light: SpotLight { - intensity: 4000.0, // lumens + intensity: 40_000.0, // lumens color: Color::WHITE, shadows_enabled: true, inner_angle: PI / 4.0 * 0.85, @@ -111,6 +127,22 @@ fn setup( transform: Transform::from_xyz(-4.0, 5.0, 10.0).looking_at(Vec3::ZERO, Vec3::Y), ..default() }); + + commands.spawn( + TextBundle::from_section( + INSTRUCTIONS, + TextStyle { + font_size: 20.0, + ..default() + }, + ) + .with_style(Style { + position_type: PositionType::Absolute, + top: Val::Px(12.0), + left: Val::Px(12.0), + ..default() + }), + ); } fn light_sway(time: Res