Migrate lights to required components (#15554)

# Objective

Another step in the migration to required components: lights!

Note that this does not include `EnvironmentMapLight` or reflection
probes yet, because their API hasn't been fully chosen yet.

## Solution

As per the [selected
proposals](https://hackmd.io/@bevy/required_components/%2FLLnzwz9XTxiD7i2jiUXkJg):

- Deprecate `PointLightBundle` in favor of the `PointLight` component
- Deprecate `SpotLightBundle` in favor of the `PointLight` component
- Deprecate `DirectionalLightBundle` in favor of the `DirectionalLight`
component

## Testing

I ran some examples with lights.

---

## Migration Guide

`PointLightBundle`, `SpotLightBundle`, and `DirectionalLightBundle` have
been deprecated. Use the `PointLight`, `SpotLight`, and
`DirectionalLight` components instead. Adding them will now insert the
other components required by them automatically.
This commit is contained in:
Joona Aalto 2024-10-01 06:20:43 +03:00 committed by GitHub
parent 383c2e5bd7
commit de888a373d
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
104 changed files with 538 additions and 720 deletions

View file

@ -17,8 +17,7 @@ use bevy_ecs::{
use bevy_hierarchy::{BuildChildren, ChildBuild, WorldChildBuilder}; use bevy_hierarchy::{BuildChildren, ChildBuild, WorldChildBuilder};
use bevy_math::{Affine2, Mat4, Vec3}; use bevy_math::{Affine2, Mat4, Vec3};
use bevy_pbr::{ use bevy_pbr::{
DirectionalLight, DirectionalLightBundle, PbrBundle, PointLight, PointLightBundle, SpotLight, DirectionalLight, PbrBundle, PointLight, SpotLight, StandardMaterial, UvChannel, MAX_JOINTS,
SpotLightBundle, StandardMaterial, UvChannel, MAX_JOINTS,
}; };
use bevy_render::{ use bevy_render::{
alpha::AlphaMode, alpha::AlphaMode,
@ -1523,15 +1522,12 @@ fn load_node(
if let Some(light) = gltf_node.light() { if let Some(light) = gltf_node.light() {
match light.kind() { match light.kind() {
gltf::khr_lights_punctual::Kind::Directional => { gltf::khr_lights_punctual::Kind::Directional => {
let mut entity = parent.spawn(DirectionalLightBundle { let mut entity = parent.spawn(DirectionalLight {
directional_light: DirectionalLight {
color: Color::srgb_from_array(light.color()), color: Color::srgb_from_array(light.color()),
// NOTE: KHR_punctual_lights defines the intensity units for directional // NOTE: KHR_punctual_lights defines the intensity units for directional
// lights in lux (lm/m^2) which is what we need. // lights in lux (lm/m^2) which is what we need.
illuminance: light.intensity(), illuminance: light.intensity(),
..Default::default() ..Default::default()
},
..Default::default()
}); });
if let Some(name) = light.name() { if let Some(name) = light.name() {
entity.insert(Name::new(name.to_string())); entity.insert(Name::new(name.to_string()));
@ -1543,8 +1539,7 @@ fn load_node(
} }
} }
gltf::khr_lights_punctual::Kind::Point => { gltf::khr_lights_punctual::Kind::Point => {
let mut entity = parent.spawn(PointLightBundle { let mut entity = parent.spawn(PointLight {
point_light: PointLight {
color: Color::srgb_from_array(light.color()), color: Color::srgb_from_array(light.color()),
// NOTE: KHR_punctual_lights defines the intensity units for point lights in // NOTE: KHR_punctual_lights defines the intensity units for point lights in
// candela (lm/sr) which is luminous intensity and we need luminous power. // candela (lm/sr) which is luminous intensity and we need luminous power.
@ -1553,8 +1548,6 @@ fn load_node(
range: light.range().unwrap_or(20.0), range: light.range().unwrap_or(20.0),
radius: 0.0, radius: 0.0,
..Default::default() ..Default::default()
},
..Default::default()
}); });
if let Some(name) = light.name() { if let Some(name) = light.name() {
entity.insert(Name::new(name.to_string())); entity.insert(Name::new(name.to_string()));
@ -1569,8 +1562,7 @@ fn load_node(
inner_cone_angle, inner_cone_angle,
outer_cone_angle, outer_cone_angle,
} => { } => {
let mut entity = parent.spawn(SpotLightBundle { let mut entity = parent.spawn(SpotLight {
spot_light: SpotLight {
color: Color::srgb_from_array(light.color()), color: Color::srgb_from_array(light.color()),
// NOTE: KHR_punctual_lights defines the intensity units for spot lights in // NOTE: KHR_punctual_lights defines the intensity units for spot lights in
// candela (lm/sr) which is luminous intensity and we need luminous power. // candela (lm/sr) which is luminous intensity and we need luminous power.
@ -1581,8 +1573,6 @@ fn load_node(
inner_angle: inner_cone_angle, inner_angle: inner_cone_angle,
outer_angle: outer_cone_angle, outer_angle: outer_cone_angle,
..Default::default() ..Default::default()
},
..Default::default()
}); });
if let Some(name) = light.name() { if let Some(name) = light.name() {
entity.insert(Name::new(name.to_string())); entity.insert(Name::new(name.to_string()));

View file

@ -1,3 +1,5 @@
#![expect(deprecated)]
use crate::{ use crate::{
CascadeShadowConfig, Cascades, DirectionalLight, Material, PointLight, SpotLight, CascadeShadowConfig, Cascades, DirectionalLight, Material, PointLight, SpotLight,
StandardMaterial, StandardMaterial,
@ -97,6 +99,10 @@ pub struct CascadesVisibleEntities {
/// A component bundle for [`PointLight`] entities. /// A component bundle for [`PointLight`] entities.
#[derive(Debug, Bundle, Default, Clone)] #[derive(Debug, Bundle, Default, Clone)]
#[deprecated(
since = "0.15.0",
note = "Use the `PointLight` component instead. Inserting it will now also insert the other components required by it automatically."
)]
pub struct PointLightBundle { pub struct PointLightBundle {
pub point_light: PointLight, pub point_light: PointLight,
pub cubemap_visible_entities: CubemapVisibleEntities, pub cubemap_visible_entities: CubemapVisibleEntities,
@ -115,6 +121,10 @@ pub struct PointLightBundle {
/// A component bundle for spot light entities /// A component bundle for spot light entities
#[derive(Debug, Bundle, Default, Clone)] #[derive(Debug, Bundle, Default, Clone)]
#[deprecated(
since = "0.15.0",
note = "Use the `SpotLight` component instead. Inserting it will now also insert the other components required by it automatically."
)]
pub struct SpotLightBundle { pub struct SpotLightBundle {
pub spot_light: SpotLight, pub spot_light: SpotLight,
pub visible_entities: VisibleMeshEntities, pub visible_entities: VisibleMeshEntities,
@ -133,6 +143,10 @@ pub struct SpotLightBundle {
/// A component bundle for [`DirectionalLight`] entities. /// A component bundle for [`DirectionalLight`] entities.
#[derive(Debug, Bundle, Default, Clone)] #[derive(Debug, Bundle, Default, Clone)]
#[deprecated(
since = "0.15.0",
note = "Use the `DirectionalLight` component instead. Inserting it will now also insert the other components required by it automatically."
)]
pub struct DirectionalLightBundle { pub struct DirectionalLightBundle {
pub directional_light: DirectionalLight, pub directional_light: DirectionalLight,
pub frusta: CascadesFrusta, pub frusta: CascadesFrusta,

View file

@ -68,6 +68,7 @@ pub use volumetric_fog::{
/// The PBR prelude. /// The PBR prelude.
/// ///
/// This includes the most common types in this crate, re-exported for your convenience. /// This includes the most common types in this crate, re-exported for your convenience.
#[expect(deprecated)]
pub mod prelude { pub mod prelude {
#[doc(hidden)] #[doc(hidden)]
pub use crate::{ pub use crate::{

View file

@ -1,3 +1,5 @@
use bevy_render::{view::Visibility, world_sync::SyncToRenderWorld};
use super::*; use super::*;
/// A Directional light. /// A Directional light.
@ -37,7 +39,7 @@ use super::*;
/// Shadows are produced via [cascaded shadow maps](https://developer.download.nvidia.com/SDK/10.5/opengl/src/cascaded_shadow_maps/doc/cascaded_shadow_maps.pdf). /// Shadows are produced via [cascaded shadow maps](https://developer.download.nvidia.com/SDK/10.5/opengl/src/cascaded_shadow_maps/doc/cascaded_shadow_maps.pdf).
/// ///
/// To modify the cascade setup, such as the number of cascades or the maximum shadow distance, /// To modify the cascade setup, such as the number of cascades or the maximum shadow distance,
/// change the [`CascadeShadowConfig`] component of the [`DirectionalLightBundle`]. /// change the [`CascadeShadowConfig`] component of the entity with the [`DirectionalLight`].
/// ///
/// To control the resolution of the shadow maps, use the [`DirectionalLightShadowMap`] resource: /// To control the resolution of the shadow maps, use the [`DirectionalLightShadowMap`] resource:
/// ///
@ -49,6 +51,15 @@ use super::*;
/// ``` /// ```
#[derive(Component, Debug, Clone, Reflect)] #[derive(Component, Debug, Clone, Reflect)]
#[reflect(Component, Default, Debug)] #[reflect(Component, Default, Debug)]
#[require(
Cascades,
CascadesFrusta,
CascadeShadowConfig,
CascadesVisibleEntities,
Transform,
Visibility,
SyncToRenderWorld
)]
pub struct DirectionalLight { pub struct DirectionalLight {
/// The color of the light. /// The color of the light.
/// ///

View file

@ -1,3 +1,5 @@
use bevy_render::{view::Visibility, world_sync::SyncToRenderWorld};
use super::*; use super::*;
/// A light that emits light in all directions from a central point. /// A light that emits light in all directions from a central point.
@ -19,6 +21,13 @@ use super::*;
/// Source: [Wikipedia](https://en.wikipedia.org/wiki/Lumen_(unit)#Lighting) /// Source: [Wikipedia](https://en.wikipedia.org/wiki/Lumen_(unit)#Lighting)
#[derive(Component, Debug, Clone, Copy, Reflect)] #[derive(Component, Debug, Clone, Copy, Reflect)]
#[reflect(Component, Default, Debug)] #[reflect(Component, Default, Debug)]
#[require(
CubemapFrusta,
CubemapVisibleEntities,
Transform,
Visibility,
SyncToRenderWorld
)]
pub struct PointLight { pub struct PointLight {
/// The color of this light source. /// The color of this light source.
pub color: Color, pub color: Color,

View file

@ -1,3 +1,5 @@
use bevy_render::{view::Visibility, world_sync::SyncToRenderWorld};
use super::*; use super::*;
/// A light that emits light in a given direction from a central point. /// A light that emits light in a given direction from a central point.
@ -7,6 +9,7 @@ use super::*;
/// the transform, and can be specified with [`Transform::looking_at`](Transform::looking_at). /// the transform, and can be specified with [`Transform::looking_at`](Transform::looking_at).
#[derive(Component, Debug, Clone, Copy, Reflect)] #[derive(Component, Debug, Clone, Copy, Reflect)]
#[reflect(Component, Default, Debug)] #[reflect(Component, Default, Debug)]
#[require(Frustum, VisibleMeshEntities, Transform, Visibility, SyncToRenderWorld)]
pub struct SpotLight { pub struct SpotLight {
/// The color of the light. /// The color of the light.
/// ///

View file

@ -30,14 +30,13 @@ fn setup(
..default() ..default()
}); });
// light // light
commands.spawn(PointLightBundle { commands.spawn((
point_light: PointLight { PointLight {
shadows_enabled: true, shadows_enabled: true,
..default() ..default()
}, },
transform: Transform::from_xyz(4.0, 8.0, 4.0), Transform::from_xyz(4.0, 8.0, 4.0),
..default() ));
});
// camera // camera
commands.spawn(Camera3dBundle { commands.spawn(Camera3dBundle {
transform: Transform::from_xyz(-2.5, 4.5, 9.0).looking_at(Vec3::ZERO, Vec3::Y), transform: Transform::from_xyz(-2.5, 4.5, 9.0).looking_at(Vec3::ZERO, Vec3::Y),

View file

@ -116,17 +116,16 @@ fn setup(
)); ));
} }
commands.spawn(PointLightBundle { commands.spawn((
point_light: PointLight { PointLight {
shadows_enabled: true, shadows_enabled: true,
intensity: 10_000_000., intensity: 10_000_000.,
range: 100.0, range: 100.0,
shadow_depth_bias: 0.2, shadow_depth_bias: 0.2,
..default() ..default()
}, },
transform: Transform::from_xyz(8.0, 16.0, 8.0), Transform::from_xyz(8.0, 16.0, 8.0),
..default() ));
});
// ground plane // ground plane
commands.spawn(PbrBundle { commands.spawn(PbrBundle {

View file

@ -66,10 +66,10 @@ fn setup(
)); ));
// light // light
commands.spawn(DirectionalLightBundle { commands.spawn((
transform: Transform::from_translation(Vec3::ONE).looking_at(Vec3::ZERO, Vec3::Y), DirectionalLight::default(),
..default() Transform::from_translation(Vec3::ONE).looking_at(Vec3::ZERO, Vec3::Y),
}); ));
// camera // camera
commands.spawn(Camera3dBundle { commands.spawn(Camera3dBundle {

View file

@ -252,25 +252,19 @@ fn add_skybox_and_environment_map(
/// Spawns a rotating directional light. /// Spawns a rotating directional light.
fn spawn_directional_light(commands: &mut Commands) { fn spawn_directional_light(commands: &mut Commands) {
commands.spawn(DirectionalLightBundle { commands.spawn(DirectionalLight {
directional_light: DirectionalLight {
color: WHITE.into(), color: WHITE.into(),
illuminance: 3000.0, illuminance: 3000.0,
..default() ..default()
},
..default()
}); });
} }
/// Spawns a rotating point light. /// Spawns a rotating point light.
fn spawn_point_light(commands: &mut Commands) { fn spawn_point_light(commands: &mut Commands) {
commands.spawn(PointLightBundle { commands.spawn(PointLight {
point_light: PointLight {
color: WHITE.into(), color: WHITE.into(),
intensity: 200000.0, intensity: 200000.0,
..default() ..default()
},
..default()
}); });
} }

View file

@ -281,26 +281,20 @@ fn setup(
}); });
// Light // Light
commands.spawn(DirectionalLightBundle { commands.spawn((
directional_light: DirectionalLight { DirectionalLight {
illuminance: light_consts::lux::FULL_DAYLIGHT, illuminance: light_consts::lux::FULL_DAYLIGHT,
shadows_enabled: true, shadows_enabled: true,
..default() ..default()
}, },
transform: Transform::from_rotation(Quat::from_euler( Transform::from_rotation(Quat::from_euler(EulerRot::ZYX, 0.0, PI * -0.15, PI * -0.15)),
EulerRot::ZYX, CascadeShadowConfigBuilder {
0.0,
PI * -0.15,
PI * -0.15,
)),
cascade_shadow_config: CascadeShadowConfigBuilder {
maximum_distance: 3.0, maximum_distance: 3.0,
first_cascade_far_bound: 0.9, first_cascade_far_bound: 0.9,
..default() ..default()
} }
.into(), .build(),
..default() ));
});
// Camera // Camera
commands.spawn(( commands.spawn((

View file

@ -58,17 +58,15 @@ fn setup_terrain_scene(
.build(); .build();
// Sun // Sun
commands.spawn(DirectionalLightBundle { commands.spawn((
directional_light: DirectionalLight { DirectionalLight {
color: Color::srgb(0.98, 0.95, 0.82), color: Color::srgb(0.98, 0.95, 0.82),
shadows_enabled: true, shadows_enabled: true,
..default() ..default()
}, },
transform: Transform::from_xyz(0.0, 0.0, 0.0) Transform::from_xyz(0.0, 0.0, 0.0).looking_at(Vec3::new(-0.15, -0.05, 0.25), Vec3::Y),
.looking_at(Vec3::new(-0.15, -0.05, 0.25), Vec3::Y),
cascade_shadow_config, cascade_shadow_config,
..default() ));
});
// Terrain // Terrain
commands.spawn(SceneBundle { commands.spawn(SceneBundle {

View file

@ -110,14 +110,13 @@ fn setup(
brightness: 0.0, brightness: 0.0,
}); });
commands.spawn(PointLightBundle { commands.spawn((
point_light: PointLight { PointLight {
intensity: 2000.0, intensity: 2000.0,
..default() ..default()
}, },
transform: Transform::from_xyz(0.0, 0.0, 0.0), Transform::from_xyz(0.0, 0.0, 0.0),
..default() ));
});
commands.spawn(ImageBundle { commands.spawn(ImageBundle {
image: UiImage { image: UiImage {

View file

@ -167,10 +167,7 @@ fn setup(
} }
// Light // Light
commands.spawn(PointLightBundle { commands.spawn((PointLight::default(), Transform::from_xyz(4.0, 8.0, 4.0)));
transform: Transform::from_xyz(4.0, 8.0, 4.0),
..default()
});
// Camera // Camera
commands.spawn(Camera3dBundle { commands.spawn(Camera3dBundle {

View file

@ -188,21 +188,19 @@ fn spawn_scratched_gold_ball(
/// Spawns a light. /// Spawns a light.
fn spawn_light(commands: &mut Commands) { fn spawn_light(commands: &mut Commands) {
// Add the cascades objects used by the `DirectionalLightBundle`, since the commands.spawn((
// user can toggle between a point light and a directional light. PointLight {
commands
.spawn(PointLightBundle {
point_light: PointLight {
color: WHITE.into(), color: WHITE.into(),
intensity: 100000.0, intensity: 100000.0,
..default() ..default()
}, },
..default() // Add the cascades objects used by the `DirectionalLight`, since the
}) // user can toggle between a point light and a directional light.
.insert(CascadesFrusta::default()) CascadesFrusta::default(),
.insert(Cascades::default()) Cascades::default(),
.insert(CascadeShadowConfig::default()) CascadeShadowConfig::default(),
.insert(CascadesVisibleEntities::default()); CascadesVisibleEntities::default(),
));
} }
/// Spawns a camera with associated skybox and environment map. /// Spawns a camera with associated skybox and environment map.

View file

@ -398,26 +398,20 @@ fn add_basic_scene(commands: &mut Commands, asset_server: &AssetServer) {
}); });
// Spawn the light. // Spawn the light.
commands.spawn(DirectionalLightBundle { commands.spawn((
directional_light: DirectionalLight { DirectionalLight {
illuminance: 15000.0, illuminance: 15000.0,
shadows_enabled: true, shadows_enabled: true,
..default() ..default()
}, },
transform: Transform::from_rotation(Quat::from_euler( Transform::from_rotation(Quat::from_euler(EulerRot::ZYX, 0.0, PI * -0.15, PI * -0.15)),
EulerRot::ZYX, CascadeShadowConfigBuilder {
0.0,
PI * -0.15,
PI * -0.15,
)),
cascade_shadow_config: CascadeShadowConfigBuilder {
maximum_distance: 3.0, maximum_distance: 3.0,
first_cascade_far_bound: 0.9, first_cascade_far_bound: 0.9,
..default() ..default()
} }
.into(), .build(),
..default() ));
});
} }
impl Display for SelectedGlobalColorGradingOption { impl Display for SelectedGlobalColorGradingOption {

View file

@ -66,21 +66,20 @@ fn setup(
Fxaa::default(), Fxaa::default(),
)); ));
commands.spawn(DirectionalLightBundle { commands.spawn((
directional_light: DirectionalLight { DirectionalLight {
illuminance: 15_000., illuminance: 15_000.,
shadows_enabled: true, shadows_enabled: true,
..default() ..default()
}, },
cascade_shadow_config: CascadeShadowConfigBuilder { CascadeShadowConfigBuilder {
num_cascades: 3, num_cascades: 3,
maximum_distance: 10.0, maximum_distance: 10.0,
..default() ..default()
} }
.into(), .build(),
transform: Transform::from_rotation(Quat::from_euler(EulerRot::ZYX, 0.0, 0.0, -FRAC_PI_4)), Transform::from_rotation(Quat::from_euler(EulerRot::ZYX, 0.0, 0.0, -FRAC_PI_4)),
..default() ));
});
// FlightHelmet // FlightHelmet
let helmet_scene = asset_server let helmet_scene = asset_server
@ -139,17 +138,16 @@ fn setup(
NotShadowCaster, NotShadowCaster,
)); ));
// Light // Light
commands.spawn(PointLightBundle { commands.spawn((
point_light: PointLight { PointLight {
intensity: 800.0, intensity: 800.0,
radius: 0.125, radius: 0.125,
shadows_enabled: true, shadows_enabled: true,
color: sphere_color, color: sphere_color,
..default() ..default()
}, },
transform: sphere_pos, sphere_pos,
..default() ));
});
// Spheres // Spheres
for i in 0..6 { for i in 0..6 {

View file

@ -113,14 +113,13 @@ fn setup_pyramid_scene(
}); });
// light // light
commands.spawn(PointLightBundle { commands.spawn((
transform: Transform::from_xyz(0.0, 1.0, 0.0), PointLight {
point_light: PointLight {
shadows_enabled: true, shadows_enabled: true,
..default() ..default()
}, },
..default() Transform::from_xyz(0.0, 1.0, 0.0),
}); ));
} }
fn setup_instructions(mut commands: Commands) { fn setup_instructions(mut commands: Commands) {

View file

@ -49,18 +49,16 @@ fn setup(mut commands: Commands, asset_server: Res<AssetServer>) {
.insert(SyncToRenderWorld); .insert(SyncToRenderWorld);
// Spawn a bright directional light that illuminates the fog well. // Spawn a bright directional light that illuminates the fog well.
commands commands.spawn((
.spawn(DirectionalLightBundle { Transform::from_xyz(1.0, 1.0, -0.3).looking_at(vec3(0.0, 0.5, 0.0), Vec3::Y),
transform: Transform::from_xyz(1.0, 1.0, -0.3).looking_at(vec3(0.0, 0.5, 0.0), Vec3::Y), DirectionalLight {
directional_light: DirectionalLight {
shadows_enabled: true, shadows_enabled: true,
illuminance: 32000.0, illuminance: 32000.0,
..default() ..default()
}, },
..default()
})
// Make sure to add this for the light to interact with the fog. // Make sure to add this for the light to interact with the fog.
.insert(VolumetricLight); VolumetricLight,
));
// Spawn a camera. // Spawn a camera.
commands commands

View file

@ -60,10 +60,7 @@ fn setup(
}); });
// Light up the scene. // Light up the scene.
commands.spawn(PointLightBundle { commands.spawn((PointLight::default(), camera_and_light_transform));
transform: camera_and_light_transform,
..default()
});
// Text to describe the controls. // Text to describe the controls.
commands.spawn( commands.spawn(

View file

@ -260,15 +260,14 @@ fn spawn_irradiance_volume(commands: &mut Commands, assets: &ExampleAssets) {
} }
fn spawn_light(commands: &mut Commands) { fn spawn_light(commands: &mut Commands) {
commands.spawn(PointLightBundle { commands.spawn((
point_light: PointLight { PointLight {
intensity: 250000.0, intensity: 250000.0,
shadows_enabled: true, shadows_enabled: true,
..default() ..default()
}, },
transform: Transform::from_xyz(4.0762, 5.9039, 1.0055), Transform::from_xyz(4.0762, 5.9039, 1.0055),
..default() ));
});
} }
fn spawn_sphere(commands: &mut Commands, assets: &ExampleAssets) { fn spawn_sphere(commands: &mut Commands, assets: &ExampleAssets) {

View file

@ -130,17 +130,15 @@ fn setup(
// red point light // red point light
commands commands
.spawn(PointLightBundle { .spawn((
// transform: Transform::from_xyz(5.0, 8.0, 2.0), PointLight {
transform: Transform::from_xyz(1.0, 2.0, 0.0),
point_light: PointLight {
intensity: 100_000.0, intensity: 100_000.0,
color: RED.into(), color: RED.into(),
shadows_enabled: true, shadows_enabled: true,
..default() ..default()
}, },
..default() Transform::from_xyz(1.0, 2.0, 0.0),
}) ))
.with_children(|builder| { .with_children(|builder| {
builder.spawn(PbrBundle { builder.spawn(PbrBundle {
mesh: meshes.add(Sphere::new(0.1).mesh().uv(32, 18)), mesh: meshes.add(Sphere::new(0.1).mesh().uv(32, 18)),
@ -155,10 +153,8 @@ fn setup(
// green spot light // green spot light
commands commands
.spawn(SpotLightBundle { .spawn((
transform: Transform::from_xyz(-1.0, 2.0, 0.0) SpotLight {
.looking_at(Vec3::new(-1.0, 0.0, 0.0), Vec3::Z),
spot_light: SpotLight {
intensity: 100_000.0, intensity: 100_000.0,
color: LIME.into(), color: LIME.into(),
shadows_enabled: true, shadows_enabled: true,
@ -166,8 +162,8 @@ fn setup(
outer_angle: 0.8, outer_angle: 0.8,
..default() ..default()
}, },
..default() Transform::from_xyz(-1.0, 2.0, 0.0).looking_at(Vec3::new(-1.0, 0.0, 0.0), Vec3::Z),
}) ))
.with_children(|builder| { .with_children(|builder| {
builder.spawn(PbrBundle { builder.spawn(PbrBundle {
transform: Transform::from_rotation(Quat::from_rotation_x(PI / 2.0)), transform: Transform::from_rotation(Quat::from_rotation_x(PI / 2.0)),
@ -183,17 +179,15 @@ fn setup(
// blue point light // blue point light
commands commands
.spawn(PointLightBundle { .spawn((
// transform: Transform::from_xyz(5.0, 8.0, 2.0), PointLight {
transform: Transform::from_xyz(0.0, 4.0, 0.0),
point_light: PointLight {
intensity: 100_000.0, intensity: 100_000.0,
color: BLUE.into(), color: BLUE.into(),
shadows_enabled: true, shadows_enabled: true,
..default() ..default()
}, },
..default() Transform::from_xyz(0.0, 4.0, 0.0),
}) ))
.with_children(|builder| { .with_children(|builder| {
builder.spawn(PbrBundle { builder.spawn(PbrBundle {
mesh: meshes.add(Sphere::new(0.1).mesh().uv(32, 18)), mesh: meshes.add(Sphere::new(0.1).mesh().uv(32, 18)),
@ -207,13 +201,13 @@ fn setup(
}); });
// directional 'sun' light // directional 'sun' light
commands.spawn(DirectionalLightBundle { commands.spawn((
directional_light: DirectionalLight { DirectionalLight {
illuminance: light_consts::lux::OVERCAST_DAY, illuminance: light_consts::lux::OVERCAST_DAY,
shadows_enabled: true, shadows_enabled: true,
..default() ..default()
}, },
transform: Transform { Transform {
translation: Vec3::new(0.0, 2.0, 0.0), translation: Vec3::new(0.0, 2.0, 0.0),
rotation: Quat::from_rotation_x(-PI / 4.), rotation: Quat::from_rotation_x(-PI / 4.),
..default() ..default()
@ -221,14 +215,13 @@ fn setup(
// The default cascade config is designed to handle large scenes. // The default cascade config is designed to handle large scenes.
// As this example has a much smaller world, we can tighten the shadow // As this example has a much smaller world, we can tighten the shadow
// bounds for better visual quality. // bounds for better visual quality.
cascade_shadow_config: CascadeShadowConfigBuilder { CascadeShadowConfigBuilder {
first_cascade_far_bound: 4.0, first_cascade_far_bound: 4.0,
maximum_distance: 10.0, maximum_distance: 10.0,
..default() ..default()
} }
.into(), .build(),
..default() ));
});
// example instructions // example instructions
let style = TextStyle::default(); let style = TextStyle::default();

View file

@ -30,8 +30,8 @@ fn setup(mut commands: Commands, asset_server: Res<AssetServer>) {
}, },
)); ));
commands.spawn(DirectionalLightBundle { commands.spawn((
directional_light: DirectionalLight { DirectionalLight {
shadows_enabled: true, shadows_enabled: true,
..default() ..default()
}, },
@ -39,14 +39,13 @@ fn setup(mut commands: Commands, asset_server: Res<AssetServer>) {
// cascade bounds than the default for better quality. // cascade bounds than the default for better quality.
// We also adjusted the shadow map to be larger since we're // We also adjusted the shadow map to be larger since we're
// only using a single cascade. // only using a single cascade.
cascade_shadow_config: CascadeShadowConfigBuilder { CascadeShadowConfigBuilder {
num_cascades: 1, num_cascades: 1,
maximum_distance: 1.6, maximum_distance: 1.6,
..default() ..default()
} }
.into(), .build(),
..default() ));
});
commands.spawn(SceneBundle { commands.spawn(SceneBundle {
scene: asset_server scene: asset_server
.load(GltfAssetLabel::Scene(0).from_asset("models/FlightHelmet/FlightHelmet.gltf")), .load(GltfAssetLabel::Scene(0).from_asset("models/FlightHelmet/FlightHelmet.gltf")),

View file

@ -22,12 +22,9 @@ fn setup(mut commands: Commands, asset_server: Res<AssetServer>) {
..default() ..default()
}); });
commands.spawn(DirectionalLightBundle { commands.spawn(DirectionalLight {
directional_light: DirectionalLight {
shadows_enabled: true, shadows_enabled: true,
..default() ..default()
},
..default()
}); });
// a barebones scene containing one of each gltf_extra type // a barebones scene containing one of each gltf_extra type

View file

@ -64,26 +64,20 @@ fn setup(
CameraController::default(), CameraController::default(),
)); ));
commands.spawn(DirectionalLightBundle { commands.spawn((
directional_light: DirectionalLight { DirectionalLight {
illuminance: light_consts::lux::FULL_DAYLIGHT, illuminance: light_consts::lux::FULL_DAYLIGHT,
shadows_enabled: true, shadows_enabled: true,
..default() ..default()
}, },
cascade_shadow_config: CascadeShadowConfigBuilder { CascadeShadowConfigBuilder {
num_cascades: 1, num_cascades: 1,
maximum_distance: 15.0, maximum_distance: 15.0,
..default() ..default()
} }
.build(), .build(),
transform: Transform::from_rotation(Quat::from_euler( Transform::from_rotation(Quat::from_euler(EulerRot::ZYX, 0.0, PI * -0.15, PI * -0.15)),
EulerRot::ZYX, ));
0.0,
PI * -0.15,
PI * -0.15,
)),
..default()
});
// A custom file format storing a [`bevy_render::mesh::Mesh`] // A custom file format storing a [`bevy_render::mesh::Mesh`]
// that has been converted to a [`bevy_pbr::meshlet::MeshletMesh`] // that has been converted to a [`bevy_pbr::meshlet::MeshletMesh`]

View file

@ -67,15 +67,14 @@ fn setup_scene(
brightness: 300.0, brightness: 300.0,
}); });
commands.insert_resource(CameraMode::Chase); commands.insert_resource(CameraMode::Chase);
commands.spawn(DirectionalLightBundle { commands.spawn((
directional_light: DirectionalLight { DirectionalLight {
illuminance: 3_000.0, illuminance: 3_000.0,
shadows_enabled: true, shadows_enabled: true,
..default() ..default()
}, },
transform: Transform::default().looking_to(Vec3::new(-1.0, -0.7, -1.0), Vec3::X), Transform::default().looking_to(Vec3::new(-1.0, -0.7, -1.0), Vec3::X),
..default() ));
});
// Sky // Sky
commands.spawn(PbrBundle { commands.spawn(PbrBundle {
mesh: meshes.add(Sphere::default()), mesh: meshes.add(Sphere::default()),

View file

@ -59,8 +59,5 @@ fn setup(
..default() ..default()
}); });
// light // light
commands.spawn(PointLightBundle { commands.spawn((PointLight::default(), Transform::from_xyz(3.0, 8.0, 5.0)));
transform: Transform::from_xyz(3.0, 8.0, 5.0),
..default()
});
} }

View file

@ -221,14 +221,13 @@ fn setup(
// light // light
commands commands
.spawn(PointLightBundle { .spawn((
transform: Transform::from_xyz(2.0, 1.0, -1.1), PointLight {
point_light: PointLight {
shadows_enabled: true, shadows_enabled: true,
..default() ..default()
}, },
..default() Transform::from_xyz(2.0, 1.0, -1.1),
}) ))
.with_children(|commands| { .with_children(|commands| {
// represent the light source as a sphere // represent the light source as a sphere
let mesh = meshes.add(Sphere::new(0.05).mesh().ico(3).unwrap()); let mesh = meshes.add(Sphere::new(0.05).mesh().ico(3).unwrap());

View file

@ -55,10 +55,7 @@ fn setup(
}); });
}); });
// light // light
commands.spawn(PointLightBundle { commands.spawn((PointLight::default(), Transform::from_xyz(4.0, 5.0, -4.0)));
transform: Transform::from_xyz(4.0, 5.0, -4.0),
..default()
});
// camera // camera
commands.spawn(Camera3dBundle { commands.spawn(Camera3dBundle {
transform: Transform::from_xyz(5.0, 10.0, 10.0).looking_at(Vec3::ZERO, Vec3::Y), transform: Transform::from_xyz(5.0, 10.0, 10.0).looking_at(Vec3::ZERO, Vec3::Y),

View file

@ -51,14 +51,13 @@ fn setup(
..default() ..default()
}); });
commands.spawn(DirectionalLightBundle { commands.spawn((
transform: Transform::from_xyz(50.0, 50.0, 50.0).looking_at(Vec3::ZERO, Vec3::Y), DirectionalLight {
directional_light: DirectionalLight {
illuminance: 1_500., illuminance: 1_500.,
..default() ..default()
}, },
..default() Transform::from_xyz(50.0, 50.0, 50.0).looking_at(Vec3::ZERO, Vec3::Y),
}); ));
// labels // labels
commands.spawn( commands.spawn(

View file

@ -185,17 +185,16 @@ fn spawn_light(commands: &mut Commands, app_status: &AppStatus) {
// light depending on the settings, we add the union of the components // light depending on the settings, we add the union of the components
// necessary for this light to behave as all three of those. // necessary for this light to behave as all three of those.
commands commands
.spawn(DirectionalLightBundle { .spawn((
directional_light: create_directional_light(app_status), create_directional_light(app_status),
transform: Transform::from_rotation(Quat::from_array([ Transform::from_rotation(Quat::from_array([
0.6539259, 0.6539259,
-0.34646285, -0.34646285,
0.36505926, 0.36505926,
-0.5648683, -0.5648683,
])) ]))
.with_translation(vec3(57.693, 34.334, -6.422)), .with_translation(vec3(57.693, 34.334, -6.422)),
..default() ))
})
// These two are needed for point lights. // These two are needed for point lights.
.insert(CubemapVisibleEntities::default()) .insert(CubemapVisibleEntities::default())
.insert(CubemapFrusta::default()) .insert(CubemapFrusta::default())

View file

@ -110,26 +110,20 @@ fn spawn_scene(commands: &mut Commands, asset_server: &AssetServer) {
}); });
// Spawn the light. // Spawn the light.
commands.spawn(DirectionalLightBundle { commands.spawn((
directional_light: DirectionalLight { DirectionalLight {
illuminance: 15000.0, illuminance: 15000.0,
shadows_enabled: true, shadows_enabled: true,
..default() ..default()
}, },
transform: Transform::from_rotation(Quat::from_euler( Transform::from_rotation(Quat::from_euler(EulerRot::ZYX, 0.0, PI * -0.15, PI * -0.15)),
EulerRot::ZYX, CascadeShadowConfigBuilder {
0.0,
PI * -0.15,
PI * -0.15,
)),
cascade_shadow_config: CascadeShadowConfigBuilder {
maximum_distance: 3.0, maximum_distance: 3.0,
first_cascade_far_bound: 0.9, first_cascade_far_bound: 0.9,
..default() ..default()
} }
.into(), .build(),
..default() ));
});
} }
/// Spawns the help text at the bottom of the screen. /// Spawns the help text at the bottom of the screen.

View file

@ -67,8 +67,8 @@ fn setup(mut commands: Commands, asset_server: Res<AssetServer>) {
}, },
)); ));
commands.spawn(DirectionalLightBundle { commands.spawn((
directional_light: DirectionalLight { DirectionalLight {
shadows_enabled: true, shadows_enabled: true,
..default() ..default()
}, },
@ -76,14 +76,13 @@ fn setup(mut commands: Commands, asset_server: Res<AssetServer>) {
// cascade bounds than the default for better quality. // cascade bounds than the default for better quality.
// We also adjusted the shadow map to be larger since we're // We also adjusted the shadow map to be larger since we're
// only using a single cascade. // only using a single cascade.
cascade_shadow_config: CascadeShadowConfigBuilder { CascadeShadowConfigBuilder {
num_cascades: 1, num_cascades: 1,
maximum_distance: 1.6, maximum_distance: 1.6,
..default() ..default()
} }
.into(), .build(),
..default() ));
});
commands.spawn(SceneBundle { commands.spawn(SceneBundle {
scene: asset_server scene: asset_server
.load(GltfAssetLabel::Scene(0).from_asset("models/GltfPrimitives/gltf_primitives.glb")), .load(GltfAssetLabel::Scene(0).from_asset("models/GltfPrimitives/gltf_primitives.glb")),

View file

@ -81,10 +81,8 @@ fn setup(
// Setting the layer to RenderLayers::layer(0) would cause the main view to be lit, but the rendered-to-texture cube to be unlit. // Setting the layer to RenderLayers::layer(0) would cause the main view to be lit, but the rendered-to-texture cube to be unlit.
// Setting the layer to RenderLayers::layer(1) would cause the rendered-to-texture cube to be lit, but the main view to be unlit. // Setting the layer to RenderLayers::layer(1) would cause the rendered-to-texture cube to be lit, but the main view to be unlit.
commands.spawn(( commands.spawn((
PointLightBundle { PointLight::default(),
transform: Transform::from_translation(Vec3::new(0.0, 0.0, 10.0)), Transform::from_translation(Vec3::new(0.0, 0.0, 10.0)),
..default()
},
RenderLayers::layer(0).with(1), RenderLayers::layer(0).with(1),
)); ));

View file

@ -84,13 +84,10 @@ fn spawn_sphere(
/// Spawns a light. /// Spawns a light.
fn spawn_light(commands: &mut Commands) { fn spawn_light(commands: &mut Commands) {
commands.spawn(PointLightBundle { commands.spawn(PointLight {
point_light: PointLight {
color: WHITE.into(), color: WHITE.into(),
intensity: 100000.0, intensity: 100000.0,
..default() ..default()
},
..default()
}); });
} }

View file

@ -70,15 +70,11 @@ fn setup(
// Spawn a directional light shining at the camera with the VolumetricLight component. // Spawn a directional light shining at the camera with the VolumetricLight component.
commands.spawn(( commands.spawn((
DirectionalLightBundle { DirectionalLight {
transform: Transform::from_xyz(-5.0, 5.0, -7.0)
.looking_at(Vec3::new(0.0, 0.0, 0.0), Vec3::Y),
directional_light: DirectionalLight {
shadows_enabled: true, shadows_enabled: true,
..default() ..default()
}, },
..default() Transform::from_xyz(-5.0, 5.0, -7.0).looking_at(Vec3::new(0.0, 0.0, 0.0), Vec3::Y),
},
VolumetricLight, VolumetricLight,
)); ));

View file

@ -54,8 +54,7 @@ fn setup(
Lights, Lights,
)) ))
.with_children(|builder| { .with_children(|builder| {
builder.spawn(PointLightBundle { builder.spawn(PointLight {
point_light: PointLight {
intensity: 0.0, intensity: 0.0,
range: spawn_plane_depth, range: spawn_plane_depth,
color: Color::WHITE, color: Color::WHITE,
@ -63,17 +62,12 @@ fn setup(
shadow_normal_bias: 0.0, shadow_normal_bias: 0.0,
shadows_enabled: true, shadows_enabled: true,
..default() ..default()
},
..default()
}); });
builder.spawn(DirectionalLightBundle { builder.spawn(DirectionalLight {
directional_light: DirectionalLight {
shadow_depth_bias: 0.0, shadow_depth_bias: 0.0,
shadow_normal_bias: 0.0, shadow_normal_bias: 0.0,
shadows_enabled: true, shadows_enabled: true,
..default() ..default()
},
..default()
}); });
}); });

View file

@ -79,38 +79,31 @@ fn setup(
println!("Using DirectionalLight"); println!("Using DirectionalLight");
commands.spawn(PointLightBundle { commands.spawn((
transform: Transform::from_xyz(5.0, 5.0, 0.0), PointLight {
point_light: PointLight {
intensity: 0.0, intensity: 0.0,
range: spawn_plane_depth, range: spawn_plane_depth,
color: Color::WHITE, color: Color::WHITE,
shadows_enabled: true, shadows_enabled: true,
..default() ..default()
}, },
..default() Transform::from_xyz(5.0, 5.0, 0.0),
}); ));
commands.spawn(DirectionalLightBundle { commands.spawn((
directional_light: DirectionalLight { DirectionalLight {
illuminance: light_consts::lux::OVERCAST_DAY, illuminance: light_consts::lux::OVERCAST_DAY,
shadows_enabled: true, shadows_enabled: true,
..default() ..default()
}, },
transform: Transform::from_rotation(Quat::from_euler( Transform::from_rotation(Quat::from_euler(EulerRot::ZYX, 0.0, PI / 2., -PI / 4.)),
EulerRot::ZYX, CascadeShadowConfigBuilder {
0.0,
PI / 2.,
-PI / 4.,
)),
cascade_shadow_config: CascadeShadowConfigBuilder {
first_cascade_far_bound: 7.0, first_cascade_far_bound: 7.0,
maximum_distance: 25.0, maximum_distance: 25.0,
..default() ..default()
} }
.into(), .build(),
..default() ));
});
// camera // camera
commands.spawn(Camera3dBundle { commands.spawn(Camera3dBundle {

View file

@ -60,15 +60,13 @@ struct Cubemap {
fn setup(mut commands: Commands, asset_server: Res<AssetServer>) { fn setup(mut commands: Commands, asset_server: Res<AssetServer>) {
// directional 'sun' light // directional 'sun' light
commands.spawn(DirectionalLightBundle { commands.spawn((
directional_light: DirectionalLight { DirectionalLight {
illuminance: 32000.0, illuminance: 32000.0,
..default() ..default()
}, },
transform: Transform::from_xyz(0.0, 2.0, 0.0) Transform::from_xyz(0.0, 2.0, 0.0).with_rotation(Quat::from_rotation_x(-PI / 4.)),
.with_rotation(Quat::from_rotation_x(-PI / 4.)), ));
..default()
});
let skybox_handle = asset_server.load(CUBEMAPS[0].0); let skybox_handle = asset_server.load(CUBEMAPS[0].0);
// camera // camera

View file

@ -59,15 +59,10 @@ fn setup(
.with_scale(Vec3::splat(radius)), .with_scale(Vec3::splat(radius)),
..default() ..default()
}) })
.with_children(|children| { .with_child(PointLight {
children.spawn(PointLightBundle {
point_light: PointLight {
radius, radius,
color: Color::srgb(0.2, 0.2, 1.0), color: Color::srgb(0.2, 0.2, 1.0),
..default() ..default()
},
..default()
});
}); });
} }
} }

View file

@ -34,13 +34,13 @@ fn setup(
}); });
// Light // Light
commands.spawn(DirectionalLightBundle { commands.spawn((
transform: Transform::from_rotation(Quat::from_euler(EulerRot::ZYX, 0.0, 1.0, -PI / 4.)), Transform::from_rotation(Quat::from_euler(EulerRot::ZYX, 0.0, 1.0, -PI / 4.)),
directional_light: DirectionalLight { DirectionalLight {
shadows_enabled: true, shadows_enabled: true,
..default() ..default()
}, },
cascade_shadow_config: CascadeShadowConfigBuilder { CascadeShadowConfigBuilder {
num_cascades: if cfg!(all( num_cascades: if cfg!(all(
feature = "webgl2", feature = "webgl2",
target_arch = "wasm32", target_arch = "wasm32",
@ -55,9 +55,8 @@ fn setup(
maximum_distance: 280.0, maximum_distance: 280.0,
..default() ..default()
} }
.into(), .build(),
..default() ));
});
// Cameras and their dedicated UI // Cameras and their dedicated UI
for (index, (camera_name, camera_pos)) in [ for (index, (camera_name, camera_pos)) in [

View file

@ -95,10 +95,8 @@ fn setup(
let z = z as f32 - 2.0; let z = z as f32 - 2.0;
// red spot_light // red spot_light
commands commands
.spawn(SpotLightBundle { .spawn((
transform: Transform::from_xyz(1.0 + x, 2.0, z) SpotLight {
.looking_at(Vec3::new(1.0 + x, 0.0, z), Vec3::X),
spot_light: SpotLight {
intensity: 40_000.0, // lumens intensity: 40_000.0, // lumens
color: Color::WHITE, color: Color::WHITE,
shadows_enabled: true, shadows_enabled: true,
@ -106,8 +104,9 @@ fn setup(
outer_angle: PI / 4.0, outer_angle: PI / 4.0,
..default() ..default()
}, },
..default() Transform::from_xyz(1.0 + x, 2.0, z)
}) .looking_at(Vec3::new(1.0 + x, 0.0, z), Vec3::X),
))
.with_children(|builder| { .with_children(|builder| {
builder.spawn(PbrBundle { builder.spawn(PbrBundle {
mesh: sphere_mesh.clone(), mesh: sphere_mesh.clone(),

View file

@ -80,19 +80,13 @@ fn setup(
SphereMarker, SphereMarker,
)); ));
commands.spawn(DirectionalLightBundle { commands.spawn((
directional_light: DirectionalLight { DirectionalLight {
shadows_enabled: true, shadows_enabled: true,
..default() ..default()
}, },
transform: Transform::from_rotation(Quat::from_euler( Transform::from_rotation(Quat::from_euler(EulerRot::ZYX, 0.0, PI * -0.15, PI * -0.15)),
EulerRot::ZYX, ));
0.0,
PI * -0.15,
PI * -0.15,
)),
..default()
});
commands.spawn( commands.spawn(
TextBundle::from_section("", TextStyle::default()).with_style(Style { TextBundle::from_section("", TextStyle::default()).with_style(Style {

View file

@ -118,26 +118,18 @@ fn setup_basic_scene(mut commands: Commands, asset_server: Res<AssetServer>) {
// light // light
commands.spawn(( commands.spawn((
DirectionalLightBundle { DirectionalLight {
directional_light: DirectionalLight {
illuminance: 15_000., illuminance: 15_000.,
shadows_enabled: true, shadows_enabled: true,
..default() ..default()
}, },
transform: Transform::from_rotation(Quat::from_euler( Transform::from_rotation(Quat::from_euler(EulerRot::ZYX, 0.0, PI * -0.15, PI * -0.15)),
EulerRot::ZYX, CascadeShadowConfigBuilder {
0.0,
PI * -0.15,
PI * -0.15,
)),
cascade_shadow_config: CascadeShadowConfigBuilder {
maximum_distance: 3.0, maximum_distance: 3.0,
first_cascade_far_bound: 0.9, first_cascade_far_bound: 0.9,
..default() ..default()
} }
.into(), .build(),
..default()
},
SceneNumber(1), SceneNumber(1),
)); ));
} }

View file

@ -318,9 +318,8 @@ fn setup(
// Candle Light // Candle Light
commands.spawn(( commands.spawn((
PointLightBundle { Transform::from_xyz(-1.0, 1.7, 0.0),
transform: Transform::from_xyz(-1.0, 1.7, 0.0), PointLight {
point_light: PointLight {
color: Color::from( color: Color::from(
LinearRgba::from(ANTIQUE_WHITE).mix(&LinearRgba::from(ORANGE_RED), 0.2), LinearRgba::from(ANTIQUE_WHITE).mix(&LinearRgba::from(ORANGE_RED), 0.2),
), ),
@ -330,8 +329,6 @@ fn setup(
shadows_enabled: true, shadows_enabled: true,
..default() ..default()
}, },
..default()
},
Flicker, Flicker,
)); ));

View file

@ -87,14 +87,13 @@ fn setup(
}); });
// Light // Light
commands.spawn(PointLightBundle { commands.spawn((
point_light: PointLight { PointLight {
shadows_enabled: true, shadows_enabled: true,
..default() ..default()
}, },
transform: Transform::from_xyz(4.0, 8.0, 4.0), Transform::from_xyz(4.0, 8.0, 4.0),
..default() ));
});
// Camera // Camera
commands.spawn(Camera3dBundle { commands.spawn(Camera3dBundle {

View file

@ -31,14 +31,13 @@ fn setup(
}); });
// Light // Light
commands.spawn(PointLightBundle { commands.spawn((
point_light: PointLight { PointLight {
shadows_enabled: true, shadows_enabled: true,
..default() ..default()
}, },
transform: Transform::from_xyz(4.0, 8.0, 4.0), Transform::from_xyz(4.0, 8.0, 4.0),
..default() ));
});
// Camera // Camera
commands.spawn(Camera3dBundle { commands.spawn(Camera3dBundle {

View file

@ -16,14 +16,13 @@ fn main() {
struct MovedScene; struct MovedScene;
fn setup(mut commands: Commands, asset_server: Res<AssetServer>) { fn setup(mut commands: Commands, asset_server: Res<AssetServer>) {
commands.spawn(DirectionalLightBundle { commands.spawn((
transform: Transform::from_xyz(4.0, 25.0, 8.0).looking_at(Vec3::ZERO, Vec3::Y), Transform::from_xyz(4.0, 25.0, 8.0).looking_at(Vec3::ZERO, Vec3::Y),
directional_light: DirectionalLight { DirectionalLight {
shadows_enabled: true, shadows_enabled: true,
..default() ..default()
}, },
..default() ));
});
commands.spawn(( commands.spawn((
Camera3dBundle { Camera3dBundle {
transform: Transform::from_xyz(-0.5, 0.9, 1.5) transform: Transform::from_xyz(-0.5, 0.9, 1.5)

View file

@ -44,14 +44,13 @@ fn setup(
}); });
// Light // Light
commands.spawn(PointLightBundle { commands.spawn((
point_light: PointLight { PointLight {
shadows_enabled: true, shadows_enabled: true,
..default() ..default()
}, },
transform: Transform::from_xyz(4.0, 5.0, 4.0).looking_at(Vec3::ZERO, Vec3::Y), Transform::from_xyz(4.0, 5.0, 4.0).looking_at(Vec3::ZERO, Vec3::Y),
..default() ));
});
// Camera // Camera
commands.spawn(Camera3dBundle { commands.spawn(Camera3dBundle {

View file

@ -121,26 +121,20 @@ fn setup(
.insert(MainModel::LowPoly); .insert(MainModel::LowPoly);
// Spawn a light. // Spawn a light.
commands.spawn(DirectionalLightBundle { commands.spawn((
directional_light: DirectionalLight { DirectionalLight {
illuminance: FULL_DAYLIGHT, illuminance: FULL_DAYLIGHT,
shadows_enabled: true, shadows_enabled: true,
..default() ..default()
}, },
transform: Transform::from_rotation(Quat::from_euler( Transform::from_rotation(Quat::from_euler(EulerRot::ZYX, 0.0, PI * -0.15, PI * -0.15)),
EulerRot::ZYX, CascadeShadowConfigBuilder {
0.0,
PI * -0.15,
PI * -0.15,
)),
cascade_shadow_config: CascadeShadowConfigBuilder {
maximum_distance: 30.0, maximum_distance: 30.0,
first_cascade_far_bound: 0.9, first_cascade_far_bound: 0.9,
..default() ..default()
} }
.into(), .build(),
..default() ));
});
// Spawn a camera. // Spawn a camera.
commands commands

View file

@ -90,32 +90,27 @@ fn setup(mut commands: Commands, asset_server: Res<AssetServer>, app_settings: R
}); });
// Add the point light // Add the point light
commands commands.spawn((
.spawn(( Transform::from_xyz(-0.4, 1.9, 1.0),
PointLightBundle { PointLight {
point_light: PointLight {
shadows_enabled: true, shadows_enabled: true,
range: 150.0, range: 150.0,
color: RED.into(), color: RED.into(),
intensity: 1000.0, intensity: 1000.0,
..default() ..default()
}, },
transform: Transform::from_xyz(-0.4, 1.9, 1.0), VolumetricLight,
..default()
},
MoveBackAndForthHorizontally { MoveBackAndForthHorizontally {
min_x: -1.93, min_x: -1.93,
max_x: -0.4, max_x: -0.4,
speed: -0.2, speed: -0.2,
}, },
)) ));
.insert(VolumetricLight);
// Add the spot light // Add the spot light
commands commands.spawn((
.spawn(SpotLightBundle { Transform::from_xyz(-1.8, 3.9, -2.7).looking_at(Vec3::ZERO, Vec3::Y),
transform: Transform::from_xyz(-1.8, 3.9, -2.7).looking_at(Vec3::ZERO, Vec3::Y), SpotLight {
spot_light: SpotLight {
intensity: 5000.0, // lumens intensity: 5000.0, // lumens
color: Color::WHITE, color: Color::WHITE,
shadows_enabled: true, shadows_enabled: true,
@ -123,9 +118,8 @@ fn setup(mut commands: Commands, asset_server: Res<AssetServer>, app_settings: R
outer_angle: 0.94, outer_angle: 0.94,
..default() ..default()
}, },
..default() VolumetricLight,
}) ));
.insert(VolumetricLight);
// Add the fog volume. // Add the fog volume.
commands.spawn(FogVolumeBundle { commands.spawn(FogVolumeBundle {

View file

@ -100,10 +100,7 @@ fn setup(
)); ));
// light // light
commands.spawn(PointLightBundle { commands.spawn((PointLight::default(), Transform::from_xyz(2.0, 4.0, 2.0)));
transform: Transform::from_xyz(2.0, 4.0, 2.0),
..default()
});
// camera // camera
commands.spawn(Camera3dBundle { commands.spawn(Camera3dBundle {

View file

@ -66,20 +66,19 @@ fn setup(
}); });
// Light // Light
commands.spawn(DirectionalLightBundle { commands.spawn((
transform: Transform::from_rotation(Quat::from_euler(EulerRot::ZYX, 0.0, 1.0, -PI / 4.)), Transform::from_rotation(Quat::from_euler(EulerRot::ZYX, 0.0, 1.0, -PI / 4.)),
directional_light: DirectionalLight { DirectionalLight {
shadows_enabled: true, shadows_enabled: true,
..default() ..default()
}, },
cascade_shadow_config: CascadeShadowConfigBuilder { CascadeShadowConfigBuilder {
first_cascade_far_bound: 200.0, first_cascade_far_bound: 200.0,
maximum_distance: 400.0, maximum_distance: 400.0,
..default() ..default()
} }
.into(), .build(),
..default() ));
});
// Fox // Fox
commands.spawn(SceneBundle { commands.spawn(SceneBundle {

View file

@ -32,14 +32,13 @@ fn setup(
}); });
// Light // Light
commands.spawn(PointLightBundle { commands.spawn((
point_light: PointLight { PointLight {
intensity: 500_000.0, intensity: 500_000.0,
..default() ..default()
}, },
transform: Transform::from_xyz(0.0, 2.5, 0.0), Transform::from_xyz(0.0, 2.5, 0.0),
..default() ));
});
// Let's use the `Name` component to target entities. We can use anything we // Let's use the `Name` component to target entities. We can use anything we
// like, but names are convenient. // like, but names are convenient.

View file

@ -223,15 +223,14 @@ fn setup_scene(
..default() ..default()
}); });
commands.spawn(PointLightBundle { commands.spawn((
point_light: PointLight { PointLight {
intensity: 10_000_000.0, intensity: 10_000_000.0,
shadows_enabled: true, shadows_enabled: true,
..default() ..default()
}, },
transform: Transform::from_xyz(-4.0, 8.0, 13.0), Transform::from_xyz(-4.0, 8.0, 13.0),
..default() ));
});
commands.spawn(SceneBundle { commands.spawn(SceneBundle {
scene: asset_server.load(GltfAssetLabel::Scene(0).from_asset("models/animated/Fox.glb")), scene: asset_server.load(GltfAssetLabel::Scene(0).from_asset("models/animated/Fox.glb")),

View file

@ -108,15 +108,14 @@ fn setup_scene(
}); });
// Spawn the light. // Spawn the light.
commands.spawn(PointLightBundle { commands.spawn((
point_light: PointLight { PointLight {
intensity: 10_000_000.0, intensity: 10_000_000.0,
shadows_enabled: true, shadows_enabled: true,
..default() ..default()
}, },
transform: Transform::from_xyz(-4.0, 8.0, 13.0), Transform::from_xyz(-4.0, 8.0, 13.0),
..default() ));
});
// Spawn the fox. // Spawn the fox.
commands.spawn(SceneBundle { commands.spawn(SceneBundle {

View file

@ -48,16 +48,15 @@ fn setup(
)); ));
// Some light to see something // Some light to see something
commands.spawn(PointLightBundle { commands.spawn((
point_light: PointLight { PointLight {
shadows_enabled: true, shadows_enabled: true,
intensity: 10_000_000., intensity: 10_000_000.,
range: 100.0, range: 100.0,
..default() ..default()
}, },
transform: Transform::from_xyz(8., 16., 8.), Transform::from_xyz(8., 16., 8.),
..default() ));
});
// ground plane // ground plane
commands.spawn(PbrBundle { commands.spawn(PbrBundle {

View file

@ -51,10 +51,10 @@ fn setup(asset_server: Res<AssetServer>, mut commands: Commands) {
.load(GltfAssetLabel::Scene(0).from_asset("models/animated/MorphStressTest.gltf")), .load(GltfAssetLabel::Scene(0).from_asset("models/animated/MorphStressTest.gltf")),
..default() ..default()
}); });
commands.spawn(DirectionalLightBundle { commands.spawn((
transform: Transform::from_rotation(Quat::from_rotation_z(PI / 2.0)), DirectionalLight::default(),
..default() Transform::from_rotation(Quat::from_rotation_z(PI / 2.0)),
}); ));
commands.spawn(Camera3dBundle { commands.spawn(Camera3dBundle {
transform: Transform::from_xyz(3.0, 2.1, 10.2).looking_at(Vec3::ZERO, Vec3::Y), transform: Transform::from_xyz(3.0, 2.1, 10.2).looking_at(Vec3::ZERO, Vec3::Y),
..default() ..default()

View file

@ -174,14 +174,13 @@ fn setup(
..default() ..default()
}); });
// light // light
commands.spawn(PointLightBundle { commands.spawn((
point_light: PointLight { PointLight {
shadows_enabled: true, shadows_enabled: true,
..default() ..default()
}, },
transform: Transform::from_xyz(4.0, 8.0, 4.0), Transform::from_xyz(4.0, 8.0, 4.0),
..default() ));
});
commands.spawn(Camera3dBundle { commands.spawn(Camera3dBundle {
transform: Transform::from_xyz(-2.5, 4.5, 9.0).looking_at(Vec3::ZERO, Vec3::Y), transform: Transform::from_xyz(-2.5, 4.5, 9.0).looking_at(Vec3::ZERO, Vec3::Y),

View file

@ -126,10 +126,8 @@ fn setup(
commands.spawn(( commands.spawn((
Name::new("Point Light"), Name::new("Point Light"),
PointLightBundle { PointLight::default(),
transform: Transform::from_xyz(4.0, 5.0, 4.0), Transform::from_xyz(4.0, 5.0, 4.0),
..default()
},
)); ));
commands.spawn(( commands.spawn((

View file

@ -94,10 +94,7 @@ fn setup(
..default() ..default()
}); });
// light // light
commands.spawn(PointLightBundle { commands.spawn((PointLight::default(), Transform::from_xyz(4.0, 5.0, 4.0)));
transform: Transform::from_xyz(4.0, 5.0, 4.0),
..default()
});
// camera // camera
commands.spawn(Camera3dBundle { commands.spawn(Camera3dBundle {
transform: Transform::from_xyz(0.0, 3.0, 10.0).looking_at(Vec3::ZERO, Vec3::Y), transform: Transform::from_xyz(0.0, 3.0, 10.0).looking_at(Vec3::ZERO, Vec3::Y),

View file

@ -28,11 +28,10 @@ fn setup(mut commands: Commands, asset_server: Res<AssetServer>) {
..default() ..default()
}); });
// light // light
commands.spawn(DirectionalLightBundle { commands.spawn((
directional_light: DirectionalLight::default(), DirectionalLight::default(),
transform: Transform::from_xyz(4.0, 5.0, 4.0).looking_at(Vec3::ZERO, Vec3::Y), Transform::from_xyz(4.0, 5.0, 4.0).looking_at(Vec3::ZERO, Vec3::Y),
..default() ));
});
// camera // camera
commands.spawn(Camera3dBundle { commands.spawn(Camera3dBundle {
transform: Transform::from_xyz(2.0, 2.0, 6.0).looking_at(Vec3::ZERO, Vec3::Y), transform: Transform::from_xyz(2.0, 2.0, 6.0).looking_at(Vec3::ZERO, Vec3::Y),

View file

@ -214,14 +214,13 @@ fn setup_scene(
}); });
// Light // Light
commands.spawn(DirectionalLightBundle { commands.spawn((
transform: Transform::from_rotation(Quat::from_euler(EulerRot::ZYX, 0.0, 1.0, -PI / 4.)), DirectionalLight {
directional_light: DirectionalLight {
shadows_enabled: true, shadows_enabled: true,
..default() ..default()
}, },
..default() Transform::from_rotation(Quat::from_euler(EulerRot::ZYX, 0.0, 1.0, -PI / 4.)),
}); ));
// Plane // Plane
commands.spawn(( commands.spawn((

View file

@ -83,14 +83,13 @@ fn setup(
}); });
// light // light
commands.spawn(PointLightBundle { commands.spawn((
point_light: PointLight { PointLight {
shadows_enabled: true, shadows_enabled: true,
..default() ..default()
}, },
transform: Transform::from_xyz(4.0, 8.0, 4.0), Transform::from_xyz(4.0, 8.0, 4.0),
..default() ));
});
// camera // camera
commands.spawn(Camera3dBundle { commands.spawn(Camera3dBundle {
transform: Transform::from_xyz(0.0, 1.5, 4.0).looking_at(Vec3::ZERO, Vec3::Y), transform: Transform::from_xyz(0.0, 1.5, 4.0).looking_at(Vec3::ZERO, Vec3::Y),

View file

@ -128,10 +128,7 @@ fn setup_env(mut commands: Commands) {
}; };
// lights // lights
commands.spawn(PointLightBundle { commands.spawn((PointLight::default(), Transform::from_xyz(4.0, 12.0, 15.0)));
transform: Transform::from_xyz(4.0, 12.0, 15.0),
..default()
});
// camera // camera
commands.spawn(Camera3dBundle { commands.spawn(Camera3dBundle {

View file

@ -59,10 +59,10 @@ fn setup(
}); });
// light // light
commands.spawn(DirectionalLightBundle { commands.spawn((
transform: Transform::from_xyz(4.0, 8.0, 4.0).looking_at(Vec3::ZERO, Vec3::Y), DirectionalLight::default(),
..default() Transform::from_xyz(4.0, 8.0, 4.0).looking_at(Vec3::ZERO, Vec3::Y),
}); ));
// example instructions // example instructions
commands.spawn( commands.spawn(

View file

@ -82,10 +82,8 @@ fn setup(
commands.spawn(( commands.spawn((
Name::new("Light"), Name::new("Light"),
PointLightBundle { PointLight::default(),
transform: Transform::from_xyz(3.0, 8.0, 5.0), Transform::from_xyz(3.0, 8.0, 5.0),
..default()
},
)); ));
} }

View file

@ -196,15 +196,12 @@ fn spawn_world_model(
fn spawn_lights(mut commands: Commands) { fn spawn_lights(mut commands: Commands) {
commands.spawn(( commands.spawn((
PointLightBundle { PointLight {
point_light: PointLight {
color: Color::from(tailwind::ROSE_300), color: Color::from(tailwind::ROSE_300),
shadows_enabled: true, shadows_enabled: true,
..default() ..default()
}, },
transform: Transform::from_xyz(-2.0, 4.0, -0.75), Transform::from_xyz(-2.0, 4.0, -0.75),
..default()
},
// The light source illuminates both the world model and the view model. // The light source illuminates both the world model and the view model.
RenderLayers::from_layers(&[DEFAULT_RENDER_LAYER, VIEW_MODEL_RENDER_LAYER]), RenderLayers::from_layers(&[DEFAULT_RENDER_LAYER, VIEW_MODEL_RENDER_LAYER]),
)); ));

View file

@ -93,10 +93,8 @@ fn setup(
commands.spawn(( commands.spawn((
Name::new("Light"), Name::new("Light"),
PointLightBundle { PointLight::default(),
transform: Transform::from_xyz(3.0, 8.0, 5.0), Transform::from_xyz(3.0, 8.0, 5.0),
..default()
},
)); ));
} }

View file

@ -109,16 +109,11 @@ fn generate_bodies(
}, },
Star, Star,
)) ))
.with_children(|p| { .with_child(PointLight {
p.spawn(PointLightBundle {
point_light: PointLight {
color: Color::WHITE, color: Color::WHITE,
range: 100.0, range: 100.0,
radius: star_radius, radius: star_radius,
..default() ..default()
},
..default()
});
}); });
commands.spawn(Camera3dBundle { commands.spawn(Camera3dBundle {
transform: Transform::from_xyz(0.0, 10.5, -30.0).looking_at(Vec3::ZERO, Vec3::Y), transform: Transform::from_xyz(0.0, 10.5, -30.0).looking_at(Vec3::ZERO, Vec3::Y),

View file

@ -121,16 +121,15 @@ fn setup(mut commands: Commands, asset_server: Res<AssetServer>, mut game: ResMu
game.player.j = BOARD_SIZE_J / 2; game.player.j = BOARD_SIZE_J / 2;
game.player.move_cooldown = Timer::from_seconds(0.3, TimerMode::Once); game.player.move_cooldown = Timer::from_seconds(0.3, TimerMode::Once);
commands.spawn(PointLightBundle { commands.spawn((
transform: Transform::from_xyz(4.0, 10.0, 4.0), PointLight {
point_light: PointLight {
intensity: 2_000_000.0, intensity: 2_000_000.0,
shadows_enabled: true, shadows_enabled: true,
range: 30.0, range: 30.0,
..default() ..default()
}, },
..default() Transform::from_xyz(4.0, 10.0, 4.0),
}); ));
// spawn the game board // spawn the game board
let cell_scene = let cell_scene =
@ -355,18 +354,15 @@ fn spawn_bonus(
scene: game.bonus.handle.clone(), scene: game.bonus.handle.clone(),
..default() ..default()
}) })
.with_children(|children| { .with_child((
children.spawn(PointLightBundle { PointLight {
point_light: PointLight {
color: Color::srgb(1.0, 1.0, 0.0), color: Color::srgb(1.0, 1.0, 0.0),
intensity: 500_000.0, intensity: 500_000.0,
range: 10.0, range: 10.0,
..default() ..default()
}, },
transform: Transform::from_xyz(0.0, 2.0, 0.0), Transform::from_xyz(0.0, 2.0, 0.0),
..default() ))
});
})
.id(), .id(),
); );
} }

View file

@ -164,14 +164,11 @@ fn load_level_1(
// Spawn the light. // Spawn the light.
commands.spawn(( commands.spawn((
DirectionalLightBundle { DirectionalLight {
transform: Transform::from_xyz(3.0, 3.0, 2.0).looking_at(Vec3::ZERO, Vec3::Y),
directional_light: DirectionalLight {
shadows_enabled: true, shadows_enabled: true,
..default() ..default()
}, },
..default() Transform::from_xyz(3.0, 3.0, 2.0).looking_at(Vec3::ZERO, Vec3::Y),
},
LevelComponents, LevelComponents,
)); ));
} }
@ -207,14 +204,11 @@ fn load_level_2(
// Spawn the light. // Spawn the light.
commands.spawn(( commands.spawn((
DirectionalLightBundle { DirectionalLight {
transform: Transform::from_xyz(3.0, 3.0, 2.0).looking_at(Vec3::ZERO, Vec3::Y),
directional_light: DirectionalLight {
shadows_enabled: true, shadows_enabled: true,
..default() ..default()
}, },
..default() Transform::from_xyz(3.0, 3.0, 2.0).looking_at(Vec3::ZERO, Vec3::Y),
},
LevelComponents, LevelComponents,
)); ));
} }

View file

@ -46,14 +46,13 @@ fn setup(
..default() ..default()
}); });
// light // light
commands.spawn(PointLightBundle { commands.spawn((
point_light: PointLight { PointLight {
shadows_enabled: true, shadows_enabled: true,
..default() ..default()
}, },
transform: Transform::from_xyz(4.0, 8.0, 4.0), Transform::from_xyz(4.0, 8.0, 4.0),
..default() ));
});
// example instructions // example instructions
commands.spawn( commands.spawn(

View file

@ -47,14 +47,13 @@ fn setup(
let mut rng = ChaCha8Rng::seed_from_u64(19878367467713); let mut rng = ChaCha8Rng::seed_from_u64(19878367467713);
// Lights... // Lights...
commands.spawn(PointLightBundle { commands.spawn((
point_light: PointLight { PointLight {
shadows_enabled: true, shadows_enabled: true,
..default() ..default()
}, },
transform: Transform::from_xyz(2., 6., 0.), Transform::from_xyz(2., 6., 0.),
..default() ));
});
// Camera... // Camera...
commands.spawn(Camera3dBundle { commands.spawn(Camera3dBundle {

View file

@ -65,18 +65,17 @@ fn setup(
// Lights. // Lights.
{ {
commands.spawn(PointLightBundle { commands.spawn((
point_light: PointLight { PointLight {
shadows_enabled: true, shadows_enabled: true,
range: 2.0, range: 2.0,
color: DARK_CYAN.into(), color: DARK_CYAN.into(),
..default() ..default()
}, },
transform: Transform::from_xyz(0.0, 1.5, 0.0), Transform::from_xyz(0.0, 1.5, 0.0),
..default() ));
}); commands.spawn((
commands.spawn(SpotLightBundle { SpotLight {
spot_light: SpotLight {
shadows_enabled: true, shadows_enabled: true,
range: 3.5, range: 3.5,
color: PURPLE.into(), color: PURPLE.into(),
@ -84,19 +83,17 @@ fn setup(
inner_angle: PI / 4.0 * 0.8, inner_angle: PI / 4.0 * 0.8,
..default() ..default()
}, },
transform: Transform::from_xyz(4.0, 2.0, 0.0).looking_at(Vec3::X * 1.5, Vec3::Y), Transform::from_xyz(4.0, 2.0, 0.0).looking_at(Vec3::X * 1.5, Vec3::Y),
..default() ));
}); commands.spawn((
commands.spawn(DirectionalLightBundle { DirectionalLight {
directional_light: DirectionalLight {
color: GOLD.into(), color: GOLD.into(),
illuminance: DirectionalLight::default().illuminance * 0.05, illuminance: DirectionalLight::default().illuminance * 0.05,
shadows_enabled: true, shadows_enabled: true,
..default() ..default()
}, },
transform: Transform::from_xyz(-4.0, 2.0, 0.0).looking_at(Vec3::NEG_X * 1.5, Vec3::Y), Transform::from_xyz(-4.0, 2.0, 0.0).looking_at(Vec3::NEG_X * 1.5, Vec3::Y),
..default() ));
});
} }
// Camera. // Camera.

View file

@ -155,17 +155,16 @@ fn setup(
)); ));
// Point light for 3D // Point light for 3D
commands.spawn(PointLightBundle { commands.spawn((
point_light: PointLight { PointLight {
shadows_enabled: true, shadows_enabled: true,
intensity: 10_000_000., intensity: 10_000_000.,
range: 100.0, range: 100.0,
shadow_depth_bias: 0.2, shadow_depth_bias: 0.2,
..default() ..default()
}, },
transform: Transform::from_xyz(8.0, 12.0, 1.0), Transform::from_xyz(8.0, 12.0, 1.0),
..default() ));
});
// Example instructions // Example instructions
commands.spawn( commands.spawn(

View file

@ -82,14 +82,13 @@ fn setup(
}); });
// A light: // A light:
commands.spawn(PointLightBundle { commands.spawn((
point_light: PointLight { PointLight {
shadows_enabled: true, shadows_enabled: true,
..default() ..default()
}, },
transform: Transform::from_xyz(4.0, 8.0, 4.0), Transform::from_xyz(4.0, 8.0, 4.0),
..default() ));
});
// A camera: // A camera:
commands.spawn(Camera3dBundle { commands.spawn(Camera3dBundle {

View file

@ -318,15 +318,14 @@ fn setup_ambient_light(mut ambient_light: ResMut<AmbientLight>) {
} }
fn setup_lights(mut commands: Commands) { fn setup_lights(mut commands: Commands) {
commands.spawn(PointLightBundle { commands.spawn((
point_light: PointLight { PointLight {
intensity: 5000.0, intensity: 5000.0,
..default() ..default()
}, },
transform: Transform::from_translation(Vec3::new(-LEFT_RIGHT_OFFSET_3D, 2.0, 0.0)) Transform::from_translation(Vec3::new(-LEFT_RIGHT_OFFSET_3D, 2.0, 0.0))
.looking_at(Vec3::new(-LEFT_RIGHT_OFFSET_3D, 0.0, 0.0), Vec3::Y), .looking_at(Vec3::new(-LEFT_RIGHT_OFFSET_3D, 0.0, 0.0), Vec3::Y),
..default() ));
});
} }
/// Marker component for header text /// Marker component for header text

View file

@ -314,8 +314,7 @@ fn setup(
// Lights which work as the bulk lighting of the fireflies: // Lights which work as the bulk lighting of the fireflies:
commands.spawn(( commands.spawn((
PointLightBundle { PointLight {
point_light: PointLight {
range: 4.0, range: 4.0,
radius: 0.6, radius: 0.6,
intensity: 1.0, intensity: 1.0,
@ -323,24 +322,21 @@ fn setup(
color: Color::LinearRgba(INSIDE_POINT_COLOR), color: Color::LinearRgba(INSIDE_POINT_COLOR),
..default() ..default()
}, },
transform: Transform::from_translation(*translation), Transform::from_translation(*translation),
..default()
},
FireflyLights, FireflyLights,
)); ));
} }
// Global light: // Global light:
commands.spawn(PointLightBundle { commands.spawn((
point_light: PointLight { PointLight {
color: SKY_COLOR, color: SKY_COLOR,
intensity: 2_000.0, intensity: 2_000.0,
shadows_enabled: false, shadows_enabled: false,
..default() ..default()
}, },
transform: Transform::from_xyz(4.0, 8.0, 4.0), Transform::from_xyz(4.0, 8.0, 4.0),
..default() ));
});
// A camera: // A camera:
commands.spawn(( commands.spawn((

View file

@ -88,9 +88,8 @@ fn setup_scene(
..default() ..default()
}); });
// light // light
commands.spawn(PointLightBundle { commands.spawn((
transform: Transform::from_xyz(4.0, 8.0, 4.0), PointLight {
point_light: PointLight {
intensity: 1_000_000.0, intensity: 1_000_000.0,
// Shadows makes some Android devices segfault, this is under investigation // Shadows makes some Android devices segfault, this is under investigation
// https://github.com/bevyengine/bevy/issues/8214 // https://github.com/bevyengine/bevy/issues/8214
@ -98,8 +97,8 @@ fn setup_scene(
shadows_enabled: true, shadows_enabled: true,
..default() ..default()
}, },
..default() Transform::from_xyz(4.0, 8.0, 4.0),
}); ));
// camera // camera
commands.spawn(Camera3dBundle { commands.spawn(Camera3dBundle {
transform: Transform::from_xyz(-2.0, 2.5, 5.0).looking_at(Vec3::ZERO, Vec3::Y), transform: Transform::from_xyz(-2.0, 2.5, 5.0).looking_at(Vec3::ZERO, Vec3::Y),

View file

@ -74,15 +74,14 @@ fn setup(
)); ));
// A light: // A light:
commands.spawn(PointLightBundle { commands.spawn((
point_light: PointLight { PointLight {
intensity: 15_000_000.0, intensity: 15_000_000.0,
shadows_enabled: true, shadows_enabled: true,
..default() ..default()
}, },
transform: Transform::from_xyz(4.0, 8.0, 4.0), Transform::from_xyz(4.0, 8.0, 4.0),
..default() ));
});
// A camera: // A camera:
commands.spawn(Camera3dBundle { commands.spawn(Camera3dBundle {

View file

@ -74,14 +74,13 @@ fn setup(
println!("{click:?}"); println!("{click:?}");
}); });
// light // light
commands.spawn(PointLightBundle { commands.spawn((
point_light: PointLight { PointLight {
shadows_enabled: true, shadows_enabled: true,
..default() ..default()
}, },
transform: Transform::from_xyz(4.0, 8.0, 4.0), Transform::from_xyz(4.0, 8.0, 4.0),
..default() ));
});
// camera // camera
commands.spawn(Camera3dBundle { commands.spawn(Camera3dBundle {
transform: Transform::from_xyz(-2.5, 4.5, 9.0).looking_at(Vec3::ZERO, Vec3::Y), transform: Transform::from_xyz(-2.5, 4.5, 9.0).looking_at(Vec3::ZERO, Vec3::Y),

View file

@ -41,14 +41,13 @@ fn setup(
)); ));
// light // light
commands.spawn(PointLightBundle { commands.spawn((
point_light: PointLight { PointLight {
shadows_enabled: true, shadows_enabled: true,
..default() ..default()
}, },
transform: Transform::from_xyz(4.0, 8.0, 4.0), Transform::from_xyz(4.0, 8.0, 4.0),
..default() ));
});
// camera // camera
commands.spawn(Camera3dBundle { commands.spawn(Camera3dBundle {

View file

@ -36,10 +36,10 @@ fn setup(mut commands: Commands, asset_server: Res<AssetServer>) {
}); });
// light // light
commands.spawn(DirectionalLightBundle { commands.spawn((
transform: Transform::from_xyz(3.0, 2.0, 1.0).looking_at(Vec3::ZERO, Vec3::Y), DirectionalLight::default(),
..Default::default() Transform::from_xyz(3.0, 2.0, 1.0).looking_at(Vec3::ZERO, Vec3::Y),
}); ));
// camera // camera
commands.spawn(Camera3dBundle { commands.spawn(Camera3dBundle {

View file

@ -22,14 +22,13 @@ fn setup(
..default() ..default()
}); });
// light // light
commands.spawn(PointLightBundle { commands.spawn((
point_light: PointLight { PointLight {
shadows_enabled: true, shadows_enabled: true,
..default() ..default()
}, },
transform: Transform::from_xyz(0.0, 16.0, 8.0), Transform::from_xyz(0.0, 16.0, 8.0),
..default() ));
});
let mesh = meshes.add(Cuboid::from_size(Vec3::splat(0.5))); let mesh = meshes.add(Cuboid::from_size(Vec3::splat(0.5)));
// This example uses the StandardMaterial but it can work with most custom material too // This example uses the StandardMaterial but it can work with most custom material too

View file

@ -342,12 +342,9 @@ fn setup(
Rotates, Rotates,
)); ));
// light // light
commands.spawn(DirectionalLightBundle { commands.spawn(DirectionalLight {
directional_light: DirectionalLight {
illuminance: 1_000., illuminance: 1_000.,
..default() ..default()
},
..default()
}); });
} }

View file

@ -49,10 +49,8 @@ fn setup(
// light // light
commands.spawn(( commands.spawn((
DirectionalLightBundle { DirectionalLight::default(),
transform: Transform::from_xyz(1.0, 1.0, 1.0).looking_at(Vec3::ZERO, Vec3::Y), Transform::from_xyz(1.0, 1.0, 1.0).looking_at(Vec3::ZERO, Vec3::Y),
..default()
},
Rotate, Rotate,
)); ));

View file

@ -32,10 +32,7 @@ fn setup(
material: standard_materials.add(Color::srgb(0.3, 0.5, 0.3)), material: standard_materials.add(Color::srgb(0.3, 0.5, 0.3)),
..default() ..default()
}); });
commands.spawn(PointLightBundle { commands.spawn((PointLight::default(), Transform::from_xyz(4.0, 8.0, 4.0)));
transform: Transform::from_xyz(4.0, 8.0, 4.0),
..default()
});
commands.spawn(MaterialMeshBundle { commands.spawn(MaterialMeshBundle {
mesh: meshes.add(Cuboid::default()), mesh: meshes.add(Cuboid::default()),

View file

@ -127,14 +127,13 @@ fn setup(
}); });
// light // light
commands.spawn(PointLightBundle { commands.spawn((
point_light: PointLight { PointLight {
shadows_enabled: true, shadows_enabled: true,
..default() ..default()
}, },
transform: Transform::from_xyz(4.0, 8.0, 4.0), Transform::from_xyz(4.0, 8.0, 4.0),
..default() ));
});
let style = TextStyle::default(); let style = TextStyle::default();

View file

@ -255,14 +255,13 @@ fn setup(
} }
} }
commands.spawn(DirectionalLightBundle { commands.spawn((
directional_light: DirectionalLight { DirectionalLight {
shadows_enabled: args.shadows, shadows_enabled: args.shadows,
..default() ..default()
}, },
transform: Transform::IDENTITY.looking_at(Vec3::new(0.0, -1.0, -1.0), Vec3::Y), Transform::IDENTITY.looking_at(Vec3::new(0.0, -1.0, -1.0), Vec3::Y),
..default() ));
});
} }
fn init_textures(args: &Args, images: &mut Assets<Image>) -> Vec<Handle<Image>> { fn init_textures(args: &Args, images: &mut Assets<Image>) -> Vec<Handle<Image>> {

View file

@ -208,20 +208,19 @@ fn setup(
}); });
// Light // Light
commands.spawn(DirectionalLightBundle { commands.spawn((
transform: Transform::from_rotation(Quat::from_euler(EulerRot::ZYX, 0.0, 1.0, -PI / 4.)), Transform::from_rotation(Quat::from_euler(EulerRot::ZYX, 0.0, 1.0, -PI / 4.)),
directional_light: DirectionalLight { DirectionalLight {
shadows_enabled: true, shadows_enabled: true,
..default() ..default()
}, },
cascade_shadow_config: CascadeShadowConfigBuilder { CascadeShadowConfigBuilder {
first_cascade_far_bound: 0.9 * radius, first_cascade_far_bound: 0.9 * radius,
maximum_distance: 2.8 * radius, maximum_distance: 2.8 * radius,
..default() ..default()
} }
.into(), .build(),
..default() ));
});
println!("Animation controls:"); println!("Animation controls:");
println!(" - spacebar: play / pause"); println!(" - spacebar: play / pause");

View file

@ -78,16 +78,15 @@ fn setup(
let spherical_polar_theta_phi = fibonacci_spiral_on_sphere(golden_ratio, i, N_LIGHTS); let spherical_polar_theta_phi = fibonacci_spiral_on_sphere(golden_ratio, i, N_LIGHTS);
let unit_sphere_p = spherical_polar_to_cartesian(spherical_polar_theta_phi); let unit_sphere_p = spherical_polar_to_cartesian(spherical_polar_theta_phi);
PointLightBundle { (
point_light: PointLight { PointLight {
range: LIGHT_RADIUS, range: LIGHT_RADIUS,
intensity: LIGHT_INTENSITY, intensity: LIGHT_INTENSITY,
color: Color::hsl(rng.gen_range(0.0..360.0), 1.0, 0.5), color: Color::hsl(rng.gen_range(0.0..360.0), 1.0, 0.5),
..default() ..default()
}, },
transform: Transform::from_translation((RADIUS as f64 * unit_sphere_p).as_vec3()), Transform::from_translation((RADIUS as f64 * unit_sphere_p).as_vec3()),
..default() )
}
})); }));
// camera // camera

View file

@ -153,10 +153,10 @@ fn setup_scene_after_load(
// Spawn a default light if the scene does not have one // Spawn a default light if the scene does not have one
if !scene_handle.has_light { if !scene_handle.has_light {
info!("Spawning a directional light"); info!("Spawning a directional light");
commands.spawn(DirectionalLightBundle { commands.spawn((
transform: Transform::from_xyz(1.0, 1.0, 0.0).looking_at(Vec3::ZERO, Vec3::Y), DirectionalLight::default(),
..default() Transform::from_xyz(1.0, 1.0, 0.0).looking_at(Vec3::ZERO, Vec3::Y),
}); ));
scene_handle.has_light = true; scene_handle.has_light = true;
} }

View file

@ -41,10 +41,10 @@ fn setup(
}); });
// Add a light source so we can see clearly. // Add a light source so we can see clearly.
commands.spawn(DirectionalLightBundle { commands.spawn((
transform: Transform::from_xyz(3.0, 3.0, 3.0).looking_at(Vec3::ZERO, Vec3::Y), DirectionalLight::default(),
..default() Transform::from_xyz(3.0, 3.0, 3.0).looking_at(Vec3::ZERO, Vec3::Y),
}); ));
} }
// This system will rotate any entity in the scene with a Rotatable component around its y-axis. // This system will rotate any entity in the scene with a Rotatable component around its y-axis.

View file

@ -67,14 +67,13 @@ fn setup(
}); });
// A light source // A light source
commands.spawn(PointLightBundle { commands.spawn((
point_light: PointLight { PointLight {
shadows_enabled: true, shadows_enabled: true,
..default() ..default()
}, },
transform: Transform::from_xyz(4.0, 7.0, -4.0), Transform::from_xyz(4.0, 7.0, -4.0),
..default() ));
});
// Initialize random axes // Initialize random axes
let first = seeded_rng.gen(); let first = seeded_rng.gen();

View file

@ -57,10 +57,10 @@ fn setup(
}); });
// Add a light source for better 3d visibility. // Add a light source for better 3d visibility.
commands.spawn(DirectionalLightBundle { commands.spawn((
transform: Transform::from_xyz(3.0, 3.0, 3.0).looking_at(Vec3::ZERO, Vec3::Y), DirectionalLight::default(),
..default() Transform::from_xyz(3.0, 3.0, 3.0).looking_at(Vec3::ZERO, Vec3::Y),
}); ));
} }
// This system will check if a scaled entity went above or below the entities scaling bounds // This system will check if a scaled entity went above or below the entities scaling bounds

View file

@ -86,10 +86,10 @@ fn setup(
}); });
// Add a light source for better 3d visibility. // Add a light source for better 3d visibility.
commands.spawn(DirectionalLightBundle { commands.spawn((
transform: Transform::from_xyz(3.0, 3.0, 3.0).looking_at(Vec3::ZERO, Vec3::Y), DirectionalLight::default(),
..default() Transform::from_xyz(3.0, 3.0, 3.0).looking_at(Vec3::ZERO, Vec3::Y),
}); ));
} }
// This system will move the cube forward. // This system will move the cube forward.

View file

@ -55,10 +55,10 @@ fn setup(
}); });
// Add a light source for better 3d visibility. // Add a light source for better 3d visibility.
commands.spawn(DirectionalLightBundle { commands.spawn((
transform: Transform::from_xyz(3.0, 3.0, 3.0).looking_at(Vec3::ZERO, Vec3::Y), DirectionalLight::default(),
..default() Transform::from_xyz(3.0, 3.0, 3.0).looking_at(Vec3::ZERO, Vec3::Y),
}); ));
} }
// This system will move all Movable entities with a Transform // This system will move all Movable entities with a Transform

View file

@ -51,7 +51,7 @@ fn setup(
let image_handle = images.add(image); let image_handle = images.add(image);
// Light // Light
commands.spawn(DirectionalLightBundle::default()); commands.spawn(DirectionalLight::default());
let texture_camera = commands let texture_camera = commands
.spawn(Camera2dBundle { .spawn(Camera2dBundle {

View file

@ -179,10 +179,10 @@ pub(crate) mod test_setup {
Rotator, Rotator,
)); ));
commands.spawn(DirectionalLightBundle { commands.spawn((
transform: Transform::from_xyz(1.0, 1.0, 1.0).looking_at(Vec3::ZERO, Vec3::Y), DirectionalLight::default(),
..default() Transform::from_xyz(1.0, 1.0, 1.0).looking_at(Vec3::ZERO, Vec3::Y),
}); ));
commands.spawn(Camera3dBundle { commands.spawn(Camera3dBundle {
transform: Transform::from_xyz(-2.0, 2.0, 2.0).looking_at(Vec3::ZERO, Vec3::Y), transform: Transform::from_xyz(-2.0, 2.0, 2.0).looking_at(Vec3::ZERO, Vec3::Y),
..default() ..default()

Some files were not shown because too many files have changed in this diff Show more