diff --git a/crates/bevy_gltf/src/loader.rs b/crates/bevy_gltf/src/loader.rs index 0148651f88025..4aebd12a86a00 100644 --- a/crates/bevy_gltf/src/loader.rs +++ b/crates/bevy_gltf/src/loader.rs @@ -17,8 +17,7 @@ use bevy_ecs::{ use bevy_hierarchy::{BuildChildren, ChildBuild, WorldChildBuilder}; use bevy_math::{Affine2, Mat4, Vec3}; use bevy_pbr::{ - DirectionalLight, DirectionalLightBundle, PbrBundle, PointLight, PointLightBundle, SpotLight, - SpotLightBundle, StandardMaterial, UvChannel, MAX_JOINTS, + DirectionalLight, PbrBundle, PointLight, SpotLight, StandardMaterial, UvChannel, MAX_JOINTS, }; use bevy_render::{ alpha::AlphaMode, @@ -1523,14 +1522,11 @@ fn load_node( if let Some(light) = gltf_node.light() { match light.kind() { gltf::khr_lights_punctual::Kind::Directional => { - let mut entity = parent.spawn(DirectionalLightBundle { - directional_light: DirectionalLight { - color: Color::srgb_from_array(light.color()), - // NOTE: KHR_punctual_lights defines the intensity units for directional - // lights in lux (lm/m^2) which is what we need. - illuminance: light.intensity(), - ..Default::default() - }, + let mut entity = parent.spawn(DirectionalLight { + color: Color::srgb_from_array(light.color()), + // NOTE: KHR_punctual_lights defines the intensity units for directional + // lights in lux (lm/m^2) which is what we need. + illuminance: light.intensity(), ..Default::default() }); if let Some(name) = light.name() { @@ -1543,17 +1539,14 @@ fn load_node( } } gltf::khr_lights_punctual::Kind::Point => { - let mut entity = parent.spawn(PointLightBundle { - point_light: PointLight { - color: Color::srgb_from_array(light.color()), - // NOTE: KHR_punctual_lights defines the intensity units for point lights in - // candela (lm/sr) which is luminous intensity and we need luminous power. - // For a point light, luminous power = 4 * pi * luminous intensity - intensity: light.intensity() * core::f32::consts::PI * 4.0, - range: light.range().unwrap_or(20.0), - radius: 0.0, - ..Default::default() - }, + let mut entity = parent.spawn(PointLight { + color: Color::srgb_from_array(light.color()), + // NOTE: KHR_punctual_lights defines the intensity units for point lights in + // candela (lm/sr) which is luminous intensity and we need luminous power. + // For a point light, luminous power = 4 * pi * luminous intensity + intensity: light.intensity() * core::f32::consts::PI * 4.0, + range: light.range().unwrap_or(20.0), + radius: 0.0, ..Default::default() }); if let Some(name) = light.name() { @@ -1569,19 +1562,16 @@ fn load_node( inner_cone_angle, outer_cone_angle, } => { - let mut entity = parent.spawn(SpotLightBundle { - spot_light: SpotLight { - color: Color::srgb_from_array(light.color()), - // NOTE: KHR_punctual_lights defines the intensity units for spot lights in - // candela (lm/sr) which is luminous intensity and we need luminous power. - // For a spot light, we map luminous power = 4 * pi * luminous intensity - intensity: light.intensity() * core::f32::consts::PI * 4.0, - range: light.range().unwrap_or(20.0), - radius: light.range().unwrap_or(0.0), - inner_angle: inner_cone_angle, - outer_angle: outer_cone_angle, - ..Default::default() - }, + let mut entity = parent.spawn(SpotLight { + color: Color::srgb_from_array(light.color()), + // NOTE: KHR_punctual_lights defines the intensity units for spot lights in + // candela (lm/sr) which is luminous intensity and we need luminous power. + // For a spot light, we map luminous power = 4 * pi * luminous intensity + intensity: light.intensity() * core::f32::consts::PI * 4.0, + range: light.range().unwrap_or(20.0), + radius: light.range().unwrap_or(0.0), + inner_angle: inner_cone_angle, + outer_angle: outer_cone_angle, ..Default::default() }); if let Some(name) = light.name() { diff --git a/crates/bevy_pbr/src/bundle.rs b/crates/bevy_pbr/src/bundle.rs index d5ffebf981f43..71f732752546f 100644 --- a/crates/bevy_pbr/src/bundle.rs +++ b/crates/bevy_pbr/src/bundle.rs @@ -1,3 +1,5 @@ +#![expect(deprecated)] + use crate::{ CascadeShadowConfig, Cascades, DirectionalLight, Material, PointLight, SpotLight, StandardMaterial, @@ -97,6 +99,10 @@ pub struct CascadesVisibleEntities { /// A component bundle for [`PointLight`] entities. #[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 point_light: PointLight, pub cubemap_visible_entities: CubemapVisibleEntities, @@ -115,6 +121,10 @@ pub struct PointLightBundle { /// A component bundle for spot light entities #[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 spot_light: SpotLight, pub visible_entities: VisibleMeshEntities, @@ -133,6 +143,10 @@ pub struct SpotLightBundle { /// A component bundle for [`DirectionalLight`] entities. #[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 directional_light: DirectionalLight, pub frusta: CascadesFrusta, diff --git a/crates/bevy_pbr/src/lib.rs b/crates/bevy_pbr/src/lib.rs index c48601b889da3..1b446b57a645b 100644 --- a/crates/bevy_pbr/src/lib.rs +++ b/crates/bevy_pbr/src/lib.rs @@ -68,6 +68,7 @@ pub use volumetric_fog::{ /// The PBR prelude. /// /// This includes the most common types in this crate, re-exported for your convenience. +#[expect(deprecated)] pub mod prelude { #[doc(hidden)] pub use crate::{ diff --git a/crates/bevy_pbr/src/light/directional_light.rs b/crates/bevy_pbr/src/light/directional_light.rs index 89bc3d28468c7..1c53e924b2edb 100644 --- a/crates/bevy_pbr/src/light/directional_light.rs +++ b/crates/bevy_pbr/src/light/directional_light.rs @@ -1,3 +1,5 @@ +use bevy_render::{view::Visibility, world_sync::SyncToRenderWorld}; + use super::*; /// A Directional light. @@ -36,8 +38,8 @@ 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). /// -/// To modify the cascade set up, such as the number of cascades or the maximum shadow distance, -/// change the [`CascadeShadowConfig`] component of the [`DirectionalLightBundle`]. +/// To modify the cascade setup, such as the number of cascades or the maximum shadow distance, +/// change the [`CascadeShadowConfig`] component of the entity with the [`DirectionalLight`]. /// /// To control the resolution of the shadow maps, use the [`DirectionalLightShadowMap`] resource: /// @@ -49,6 +51,15 @@ use super::*; /// ``` #[derive(Component, Debug, Clone, Reflect)] #[reflect(Component, Default, Debug)] +#[require( + Cascades, + CascadesFrusta, + CascadeShadowConfig, + CascadesVisibleEntities, + Transform, + Visibility, + SyncToRenderWorld +)] pub struct DirectionalLight { /// The color of the light. /// diff --git a/crates/bevy_pbr/src/light/point_light.rs b/crates/bevy_pbr/src/light/point_light.rs index b4db7ce4f45f7..8b351985a0aa7 100644 --- a/crates/bevy_pbr/src/light/point_light.rs +++ b/crates/bevy_pbr/src/light/point_light.rs @@ -1,3 +1,5 @@ +use bevy_render::{view::Visibility, world_sync::SyncToRenderWorld}; + use super::*; /// 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) #[derive(Component, Debug, Clone, Copy, Reflect)] #[reflect(Component, Default, Debug)] +#[require( + CubemapFrusta, + CubemapVisibleEntities, + Transform, + Visibility, + SyncToRenderWorld +)] pub struct PointLight { /// The color of this light source. pub color: Color, diff --git a/crates/bevy_pbr/src/light/spot_light.rs b/crates/bevy_pbr/src/light/spot_light.rs index b8d98c7b338ef..b8345e13e00aa 100644 --- a/crates/bevy_pbr/src/light/spot_light.rs +++ b/crates/bevy_pbr/src/light/spot_light.rs @@ -1,3 +1,5 @@ +use bevy_render::{view::Visibility, world_sync::SyncToRenderWorld}; + use super::*; /// 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). #[derive(Component, Debug, Clone, Copy, Reflect)] #[reflect(Component, Default, Debug)] +#[require(Frustum, VisibleMeshEntities, Transform, Visibility, SyncToRenderWorld)] pub struct SpotLight { /// The color of the light. /// diff --git a/examples/3d/3d_scene.rs b/examples/3d/3d_scene.rs index 9b57373ec7936..07d369f17a503 100644 --- a/examples/3d/3d_scene.rs +++ b/examples/3d/3d_scene.rs @@ -30,14 +30,13 @@ fn setup( ..default() }); // light - commands.spawn(PointLightBundle { - point_light: PointLight { + commands.spawn(( + PointLight { shadows_enabled: true, ..default() }, - transform: Transform::from_xyz(4.0, 8.0, 4.0), - ..default() - }); + Transform::from_xyz(4.0, 8.0, 4.0), + )); // camera commands.spawn(Camera3dBundle { transform: Transform::from_xyz(-2.5, 4.5, 9.0).looking_at(Vec3::ZERO, Vec3::Y), diff --git a/examples/3d/3d_shapes.rs b/examples/3d/3d_shapes.rs index 6abac8371a287..c2365e31dbc71 100644 --- a/examples/3d/3d_shapes.rs +++ b/examples/3d/3d_shapes.rs @@ -116,17 +116,16 @@ fn setup( )); } - commands.spawn(PointLightBundle { - point_light: PointLight { + commands.spawn(( + PointLight { shadows_enabled: true, intensity: 10_000_000., range: 100.0, shadow_depth_bias: 0.2, ..default() }, - transform: Transform::from_xyz(8.0, 16.0, 8.0), - ..default() - }); + Transform::from_xyz(8.0, 16.0, 8.0), + )); // ground plane commands.spawn(PbrBundle { diff --git a/examples/3d/3d_viewport_to_world.rs b/examples/3d/3d_viewport_to_world.rs index 569a10a003e05..704352b87701c 100644 --- a/examples/3d/3d_viewport_to_world.rs +++ b/examples/3d/3d_viewport_to_world.rs @@ -66,10 +66,10 @@ fn setup( )); // light - commands.spawn(DirectionalLightBundle { - transform: Transform::from_translation(Vec3::ONE).looking_at(Vec3::ZERO, Vec3::Y), - ..default() - }); + commands.spawn(( + DirectionalLight::default(), + Transform::from_translation(Vec3::ONE).looking_at(Vec3::ZERO, Vec3::Y), + )); // camera commands.spawn(Camera3dBundle { diff --git a/examples/3d/anisotropy.rs b/examples/3d/anisotropy.rs index 40529d1445764..7ba789d0f35e4 100644 --- a/examples/3d/anisotropy.rs +++ b/examples/3d/anisotropy.rs @@ -252,24 +252,18 @@ fn add_skybox_and_environment_map( /// Spawns a rotating directional light. fn spawn_directional_light(commands: &mut Commands) { - commands.spawn(DirectionalLightBundle { - directional_light: DirectionalLight { - color: WHITE.into(), - illuminance: 3000.0, - ..default() - }, + commands.spawn(DirectionalLight { + color: WHITE.into(), + illuminance: 3000.0, ..default() }); } /// Spawns a rotating point light. fn spawn_point_light(commands: &mut Commands) { - commands.spawn(PointLightBundle { - point_light: PointLight { - color: WHITE.into(), - intensity: 200000.0, - ..default() - }, + commands.spawn(PointLight { + color: WHITE.into(), + intensity: 200000.0, ..default() }); } diff --git a/examples/3d/anti_aliasing.rs b/examples/3d/anti_aliasing.rs index 69bafcb30a7e1..6602c91c1e417 100644 --- a/examples/3d/anti_aliasing.rs +++ b/examples/3d/anti_aliasing.rs @@ -281,26 +281,20 @@ fn setup( }); // Light - commands.spawn(DirectionalLightBundle { - directional_light: DirectionalLight { + commands.spawn(( + DirectionalLight { illuminance: light_consts::lux::FULL_DAYLIGHT, shadows_enabled: true, ..default() }, - transform: Transform::from_rotation(Quat::from_euler( - EulerRot::ZYX, - 0.0, - PI * -0.15, - PI * -0.15, - )), - cascade_shadow_config: CascadeShadowConfigBuilder { + Transform::from_rotation(Quat::from_euler(EulerRot::ZYX, 0.0, PI * -0.15, PI * -0.15)), + CascadeShadowConfigBuilder { maximum_distance: 3.0, first_cascade_far_bound: 0.9, ..default() } - .into(), - ..default() - }); + .build(), + )); // Camera commands.spawn(( diff --git a/examples/3d/atmospheric_fog.rs b/examples/3d/atmospheric_fog.rs index 3cd5fda8885ec..6501c61b23883 100644 --- a/examples/3d/atmospheric_fog.rs +++ b/examples/3d/atmospheric_fog.rs @@ -58,17 +58,15 @@ fn setup_terrain_scene( .build(); // Sun - commands.spawn(DirectionalLightBundle { - directional_light: DirectionalLight { + commands.spawn(( + DirectionalLight { color: Color::srgb(0.98, 0.95, 0.82), shadows_enabled: true, ..default() }, - transform: Transform::from_xyz(0.0, 0.0, 0.0) - .looking_at(Vec3::new(-0.15, -0.05, 0.25), Vec3::Y), + Transform::from_xyz(0.0, 0.0, 0.0).looking_at(Vec3::new(-0.15, -0.05, 0.25), Vec3::Y), cascade_shadow_config, - ..default() - }); + )); // Terrain commands.spawn(SceneBundle { diff --git a/examples/3d/auto_exposure.rs b/examples/3d/auto_exposure.rs index 4956cf477f5f4..8bb7cca635683 100644 --- a/examples/3d/auto_exposure.rs +++ b/examples/3d/auto_exposure.rs @@ -110,14 +110,13 @@ fn setup( brightness: 0.0, }); - commands.spawn(PointLightBundle { - point_light: PointLight { + commands.spawn(( + PointLight { intensity: 2000.0, ..default() }, - transform: Transform::from_xyz(0.0, 0.0, 0.0), - ..default() - }); + Transform::from_xyz(0.0, 0.0, 0.0), + )); commands.spawn(ImageBundle { image: UiImage { diff --git a/examples/3d/blend_modes.rs b/examples/3d/blend_modes.rs index 521494446c6e7..faacf07871e4d 100644 --- a/examples/3d/blend_modes.rs +++ b/examples/3d/blend_modes.rs @@ -167,10 +167,7 @@ fn setup( } // Light - commands.spawn(PointLightBundle { - transform: Transform::from_xyz(4.0, 8.0, 4.0), - ..default() - }); + commands.spawn((PointLight::default(), Transform::from_xyz(4.0, 8.0, 4.0))); // Camera commands.spawn(Camera3dBundle { diff --git a/examples/3d/clearcoat.rs b/examples/3d/clearcoat.rs index 4604f35b6d6de..d30963356e183 100644 --- a/examples/3d/clearcoat.rs +++ b/examples/3d/clearcoat.rs @@ -188,21 +188,19 @@ fn spawn_scratched_gold_ball( /// Spawns a light. fn spawn_light(commands: &mut Commands) { - // Add the cascades objects used by the `DirectionalLightBundle`, since the - // user can toggle between a point light and a directional light. - commands - .spawn(PointLightBundle { - point_light: PointLight { - color: WHITE.into(), - intensity: 100000.0, - ..default() - }, + commands.spawn(( + PointLight { + color: WHITE.into(), + intensity: 100000.0, ..default() - }) - .insert(CascadesFrusta::default()) - .insert(Cascades::default()) - .insert(CascadeShadowConfig::default()) - .insert(CascadesVisibleEntities::default()); + }, + // Add the cascades objects used by the `DirectionalLight`, since the + // user can toggle between a point light and a directional light. + CascadesFrusta::default(), + Cascades::default(), + CascadeShadowConfig::default(), + CascadesVisibleEntities::default(), + )); } /// Spawns a camera with associated skybox and environment map. diff --git a/examples/3d/color_grading.rs b/examples/3d/color_grading.rs index 1e8d8b5267e99..cb16ad5a7bdd2 100644 --- a/examples/3d/color_grading.rs +++ b/examples/3d/color_grading.rs @@ -398,26 +398,20 @@ fn add_basic_scene(commands: &mut Commands, asset_server: &AssetServer) { }); // Spawn the light. - commands.spawn(DirectionalLightBundle { - directional_light: DirectionalLight { + commands.spawn(( + DirectionalLight { illuminance: 15000.0, shadows_enabled: true, ..default() }, - transform: Transform::from_rotation(Quat::from_euler( - EulerRot::ZYX, - 0.0, - PI * -0.15, - PI * -0.15, - )), - cascade_shadow_config: CascadeShadowConfigBuilder { + Transform::from_rotation(Quat::from_euler(EulerRot::ZYX, 0.0, PI * -0.15, PI * -0.15)), + CascadeShadowConfigBuilder { maximum_distance: 3.0, first_cascade_far_bound: 0.9, ..default() } - .into(), - ..default() - }); + .build(), + )); } impl Display for SelectedGlobalColorGradingOption { diff --git a/examples/3d/deferred_rendering.rs b/examples/3d/deferred_rendering.rs index faa302625ab4f..b5b573bc21e59 100644 --- a/examples/3d/deferred_rendering.rs +++ b/examples/3d/deferred_rendering.rs @@ -66,21 +66,20 @@ fn setup( Fxaa::default(), )); - commands.spawn(DirectionalLightBundle { - directional_light: DirectionalLight { + commands.spawn(( + DirectionalLight { illuminance: 15_000., shadows_enabled: true, ..default() }, - cascade_shadow_config: CascadeShadowConfigBuilder { + CascadeShadowConfigBuilder { num_cascades: 3, maximum_distance: 10.0, ..default() } - .into(), - transform: Transform::from_rotation(Quat::from_euler(EulerRot::ZYX, 0.0, 0.0, -FRAC_PI_4)), - ..default() - }); + .build(), + Transform::from_rotation(Quat::from_euler(EulerRot::ZYX, 0.0, 0.0, -FRAC_PI_4)), + )); // FlightHelmet let helmet_scene = asset_server @@ -139,17 +138,16 @@ fn setup( NotShadowCaster, )); // Light - commands.spawn(PointLightBundle { - point_light: PointLight { + commands.spawn(( + PointLight { intensity: 800.0, radius: 0.125, shadows_enabled: true, color: sphere_color, ..default() }, - transform: sphere_pos, - ..default() - }); + sphere_pos, + )); // Spheres for i in 0..6 { diff --git a/examples/3d/fog.rs b/examples/3d/fog.rs index d235c1ea2b54f..ffb6c85526064 100644 --- a/examples/3d/fog.rs +++ b/examples/3d/fog.rs @@ -113,14 +113,13 @@ fn setup_pyramid_scene( }); // light - commands.spawn(PointLightBundle { - transform: Transform::from_xyz(0.0, 1.0, 0.0), - point_light: PointLight { + commands.spawn(( + PointLight { shadows_enabled: true, ..default() }, - ..default() - }); + Transform::from_xyz(0.0, 1.0, 0.0), + )); } fn setup_instructions(mut commands: Commands) { diff --git a/examples/3d/fog_volumes.rs b/examples/3d/fog_volumes.rs index 8ebc9233322dd..c161240b3de67 100644 --- a/examples/3d/fog_volumes.rs +++ b/examples/3d/fog_volumes.rs @@ -49,18 +49,16 @@ fn setup(mut commands: Commands, asset_server: Res) { .insert(SyncToRenderWorld); // Spawn a bright directional light that illuminates the fog well. - commands - .spawn(DirectionalLightBundle { - transform: Transform::from_xyz(1.0, 1.0, -0.3).looking_at(vec3(0.0, 0.5, 0.0), Vec3::Y), - directional_light: DirectionalLight { - shadows_enabled: true, - illuminance: 32000.0, - ..default() - }, + commands.spawn(( + Transform::from_xyz(1.0, 1.0, -0.3).looking_at(vec3(0.0, 0.5, 0.0), Vec3::Y), + DirectionalLight { + shadows_enabled: true, + illuminance: 32000.0, ..default() - }) + }, // Make sure to add this for the light to interact with the fog. - .insert(VolumetricLight); + VolumetricLight, + )); // Spawn a camera. commands diff --git a/examples/3d/generate_custom_mesh.rs b/examples/3d/generate_custom_mesh.rs index 4209c12152c22..4492f5bf51da2 100644 --- a/examples/3d/generate_custom_mesh.rs +++ b/examples/3d/generate_custom_mesh.rs @@ -60,10 +60,7 @@ fn setup( }); // Light up the scene. - commands.spawn(PointLightBundle { - transform: camera_and_light_transform, - ..default() - }); + commands.spawn((PointLight::default(), camera_and_light_transform)); // Text to describe the controls. commands.spawn( diff --git a/examples/3d/irradiance_volumes.rs b/examples/3d/irradiance_volumes.rs index 69e8dddfd0650..30b2c8a72063f 100644 --- a/examples/3d/irradiance_volumes.rs +++ b/examples/3d/irradiance_volumes.rs @@ -260,15 +260,14 @@ fn spawn_irradiance_volume(commands: &mut Commands, assets: &ExampleAssets) { } fn spawn_light(commands: &mut Commands) { - commands.spawn(PointLightBundle { - point_light: PointLight { + commands.spawn(( + PointLight { intensity: 250000.0, shadows_enabled: true, ..default() }, - transform: Transform::from_xyz(4.0762, 5.9039, 1.0055), - ..default() - }); + Transform::from_xyz(4.0762, 5.9039, 1.0055), + )); } fn spawn_sphere(commands: &mut Commands, assets: &ExampleAssets) { diff --git a/examples/3d/lighting.rs b/examples/3d/lighting.rs index 4fec6372a69d0..ac548f00ae28c 100644 --- a/examples/3d/lighting.rs +++ b/examples/3d/lighting.rs @@ -130,17 +130,15 @@ fn setup( // red point light commands - .spawn(PointLightBundle { - // transform: Transform::from_xyz(5.0, 8.0, 2.0), - transform: Transform::from_xyz(1.0, 2.0, 0.0), - point_light: PointLight { + .spawn(( + PointLight { intensity: 100_000.0, color: RED.into(), shadows_enabled: true, ..default() }, - ..default() - }) + Transform::from_xyz(1.0, 2.0, 0.0), + )) .with_children(|builder| { builder.spawn(PbrBundle { mesh: meshes.add(Sphere::new(0.1).mesh().uv(32, 18)), @@ -155,10 +153,8 @@ fn setup( // green spot light commands - .spawn(SpotLightBundle { - transform: Transform::from_xyz(-1.0, 2.0, 0.0) - .looking_at(Vec3::new(-1.0, 0.0, 0.0), Vec3::Z), - spot_light: SpotLight { + .spawn(( + SpotLight { intensity: 100_000.0, color: LIME.into(), shadows_enabled: true, @@ -166,8 +162,8 @@ fn setup( outer_angle: 0.8, ..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| { builder.spawn(PbrBundle { transform: Transform::from_rotation(Quat::from_rotation_x(PI / 2.0)), @@ -183,17 +179,15 @@ fn setup( // blue point light commands - .spawn(PointLightBundle { - // transform: Transform::from_xyz(5.0, 8.0, 2.0), - transform: Transform::from_xyz(0.0, 4.0, 0.0), - point_light: PointLight { + .spawn(( + PointLight { intensity: 100_000.0, color: BLUE.into(), shadows_enabled: true, ..default() }, - ..default() - }) + Transform::from_xyz(0.0, 4.0, 0.0), + )) .with_children(|builder| { builder.spawn(PbrBundle { mesh: meshes.add(Sphere::new(0.1).mesh().uv(32, 18)), @@ -207,13 +201,13 @@ fn setup( }); // directional 'sun' light - commands.spawn(DirectionalLightBundle { - directional_light: DirectionalLight { + commands.spawn(( + DirectionalLight { illuminance: light_consts::lux::OVERCAST_DAY, shadows_enabled: true, ..default() }, - transform: Transform { + Transform { translation: Vec3::new(0.0, 2.0, 0.0), rotation: Quat::from_rotation_x(-PI / 4.), ..default() @@ -221,14 +215,13 @@ fn setup( // The default cascade config is designed to handle large scenes. // As this example has a much smaller world, we can tighten the shadow // bounds for better visual quality. - cascade_shadow_config: CascadeShadowConfigBuilder { + CascadeShadowConfigBuilder { first_cascade_far_bound: 4.0, maximum_distance: 10.0, ..default() } - .into(), - ..default() - }); + .build(), + )); // example instructions let style = TextStyle::default(); diff --git a/examples/3d/load_gltf.rs b/examples/3d/load_gltf.rs index b8579c76faea7..5b87b3cd1af75 100644 --- a/examples/3d/load_gltf.rs +++ b/examples/3d/load_gltf.rs @@ -30,8 +30,8 @@ fn setup(mut commands: Commands, asset_server: Res) { }, )); - commands.spawn(DirectionalLightBundle { - directional_light: DirectionalLight { + commands.spawn(( + DirectionalLight { shadows_enabled: true, ..default() }, @@ -39,14 +39,13 @@ fn setup(mut commands: Commands, asset_server: Res) { // cascade bounds than the default for better quality. // We also adjusted the shadow map to be larger since we're // only using a single cascade. - cascade_shadow_config: CascadeShadowConfigBuilder { + CascadeShadowConfigBuilder { num_cascades: 1, maximum_distance: 1.6, ..default() } - .into(), - ..default() - }); + .build(), + )); commands.spawn(SceneBundle { scene: asset_server .load(GltfAssetLabel::Scene(0).from_asset("models/FlightHelmet/FlightHelmet.gltf")), diff --git a/examples/3d/load_gltf_extras.rs b/examples/3d/load_gltf_extras.rs index 64ea8ec4093c5..7291a31927194 100644 --- a/examples/3d/load_gltf_extras.rs +++ b/examples/3d/load_gltf_extras.rs @@ -22,11 +22,8 @@ fn setup(mut commands: Commands, asset_server: Res) { ..default() }); - commands.spawn(DirectionalLightBundle { - directional_light: DirectionalLight { - shadows_enabled: true, - ..default() - }, + commands.spawn(DirectionalLight { + shadows_enabled: true, ..default() }); diff --git a/examples/3d/meshlet.rs b/examples/3d/meshlet.rs index a5eca1ad703fd..86d3029ec81d4 100644 --- a/examples/3d/meshlet.rs +++ b/examples/3d/meshlet.rs @@ -64,26 +64,20 @@ fn setup( CameraController::default(), )); - commands.spawn(DirectionalLightBundle { - directional_light: DirectionalLight { + commands.spawn(( + DirectionalLight { illuminance: light_consts::lux::FULL_DAYLIGHT, shadows_enabled: true, ..default() }, - cascade_shadow_config: CascadeShadowConfigBuilder { + CascadeShadowConfigBuilder { num_cascades: 1, maximum_distance: 15.0, ..default() } .build(), - transform: Transform::from_rotation(Quat::from_euler( - EulerRot::ZYX, - 0.0, - PI * -0.15, - PI * -0.15, - )), - ..default() - }); + Transform::from_rotation(Quat::from_euler(EulerRot::ZYX, 0.0, PI * -0.15, PI * -0.15)), + )); // A custom file format storing a [`bevy_render::mesh::Mesh`] // that has been converted to a [`bevy_pbr::meshlet::MeshletMesh`] diff --git a/examples/3d/motion_blur.rs b/examples/3d/motion_blur.rs index 3bd782ddb09dc..5c5c23861b5e0 100644 --- a/examples/3d/motion_blur.rs +++ b/examples/3d/motion_blur.rs @@ -67,15 +67,14 @@ fn setup_scene( brightness: 300.0, }); commands.insert_resource(CameraMode::Chase); - commands.spawn(DirectionalLightBundle { - directional_light: DirectionalLight { + commands.spawn(( + DirectionalLight { illuminance: 3_000.0, shadows_enabled: true, ..default() }, - transform: Transform::default().looking_to(Vec3::new(-1.0, -0.7, -1.0), Vec3::X), - ..default() - }); + Transform::default().looking_to(Vec3::new(-1.0, -0.7, -1.0), Vec3::X), + )); // Sky commands.spawn(PbrBundle { mesh: meshes.add(Sphere::default()), diff --git a/examples/3d/orthographic.rs b/examples/3d/orthographic.rs index f257ab35f8e67..c5d7d5619504e 100644 --- a/examples/3d/orthographic.rs +++ b/examples/3d/orthographic.rs @@ -59,8 +59,5 @@ fn setup( ..default() }); // light - commands.spawn(PointLightBundle { - transform: Transform::from_xyz(3.0, 8.0, 5.0), - ..default() - }); + commands.spawn((PointLight::default(), Transform::from_xyz(3.0, 8.0, 5.0))); } diff --git a/examples/3d/parallax_mapping.rs b/examples/3d/parallax_mapping.rs index f999c33670522..265b8ce0f4d05 100644 --- a/examples/3d/parallax_mapping.rs +++ b/examples/3d/parallax_mapping.rs @@ -221,14 +221,13 @@ fn setup( // light commands - .spawn(PointLightBundle { - transform: Transform::from_xyz(2.0, 1.0, -1.1), - point_light: PointLight { + .spawn(( + PointLight { shadows_enabled: true, ..default() }, - ..default() - }) + Transform::from_xyz(2.0, 1.0, -1.1), + )) .with_children(|commands| { // represent the light source as a sphere let mesh = meshes.add(Sphere::new(0.05).mesh().ico(3).unwrap()); diff --git a/examples/3d/parenting.rs b/examples/3d/parenting.rs index 9a42ffb59fe08..a4b9a261c9644 100644 --- a/examples/3d/parenting.rs +++ b/examples/3d/parenting.rs @@ -55,10 +55,7 @@ fn setup( }); }); // light - commands.spawn(PointLightBundle { - transform: Transform::from_xyz(4.0, 5.0, -4.0), - ..default() - }); + commands.spawn((PointLight::default(), Transform::from_xyz(4.0, 5.0, -4.0))); // camera commands.spawn(Camera3dBundle { transform: Transform::from_xyz(5.0, 10.0, 10.0).looking_at(Vec3::ZERO, Vec3::Y), diff --git a/examples/3d/pbr.rs b/examples/3d/pbr.rs index ec5c0a492222d..3efc55e681dae 100644 --- a/examples/3d/pbr.rs +++ b/examples/3d/pbr.rs @@ -51,14 +51,13 @@ fn setup( ..default() }); - commands.spawn(DirectionalLightBundle { - transform: Transform::from_xyz(50.0, 50.0, 50.0).looking_at(Vec3::ZERO, Vec3::Y), - directional_light: DirectionalLight { + commands.spawn(( + DirectionalLight { illuminance: 1_500., ..default() }, - ..default() - }); + Transform::from_xyz(50.0, 50.0, 50.0).looking_at(Vec3::ZERO, Vec3::Y), + )); // labels commands.spawn( diff --git a/examples/3d/pcss.rs b/examples/3d/pcss.rs index f99cb465163dc..3c073461f25aa 100644 --- a/examples/3d/pcss.rs +++ b/examples/3d/pcss.rs @@ -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 // necessary for this light to behave as all three of those. commands - .spawn(DirectionalLightBundle { - directional_light: create_directional_light(app_status), - transform: Transform::from_rotation(Quat::from_array([ + .spawn(( + create_directional_light(app_status), + Transform::from_rotation(Quat::from_array([ 0.6539259, -0.34646285, 0.36505926, -0.5648683, ])) .with_translation(vec3(57.693, 34.334, -6.422)), - ..default() - }) + )) // These two are needed for point lights. .insert(CubemapVisibleEntities::default()) .insert(CubemapFrusta::default()) diff --git a/examples/3d/post_processing.rs b/examples/3d/post_processing.rs index 9712fef500731..3472f0294fcfa 100644 --- a/examples/3d/post_processing.rs +++ b/examples/3d/post_processing.rs @@ -110,26 +110,20 @@ fn spawn_scene(commands: &mut Commands, asset_server: &AssetServer) { }); // Spawn the light. - commands.spawn(DirectionalLightBundle { - directional_light: DirectionalLight { + commands.spawn(( + DirectionalLight { illuminance: 15000.0, shadows_enabled: true, ..default() }, - transform: Transform::from_rotation(Quat::from_euler( - EulerRot::ZYX, - 0.0, - PI * -0.15, - PI * -0.15, - )), - cascade_shadow_config: CascadeShadowConfigBuilder { + Transform::from_rotation(Quat::from_euler(EulerRot::ZYX, 0.0, PI * -0.15, PI * -0.15)), + CascadeShadowConfigBuilder { maximum_distance: 3.0, first_cascade_far_bound: 0.9, ..default() } - .into(), - ..default() - }); + .build(), + )); } /// Spawns the help text at the bottom of the screen. diff --git a/examples/3d/query_gltf_primitives.rs b/examples/3d/query_gltf_primitives.rs index f89c090e54f80..725c4321b84e3 100644 --- a/examples/3d/query_gltf_primitives.rs +++ b/examples/3d/query_gltf_primitives.rs @@ -67,8 +67,8 @@ fn setup(mut commands: Commands, asset_server: Res) { }, )); - commands.spawn(DirectionalLightBundle { - directional_light: DirectionalLight { + commands.spawn(( + DirectionalLight { shadows_enabled: true, ..default() }, @@ -76,14 +76,13 @@ fn setup(mut commands: Commands, asset_server: Res) { // cascade bounds than the default for better quality. // We also adjusted the shadow map to be larger since we're // only using a single cascade. - cascade_shadow_config: CascadeShadowConfigBuilder { + CascadeShadowConfigBuilder { num_cascades: 1, maximum_distance: 1.6, ..default() } - .into(), - ..default() - }); + .build(), + )); commands.spawn(SceneBundle { scene: asset_server .load(GltfAssetLabel::Scene(0).from_asset("models/GltfPrimitives/gltf_primitives.glb")), diff --git a/examples/3d/render_to_texture.rs b/examples/3d/render_to_texture.rs index d601e58473790..c8f165e05514e 100644 --- a/examples/3d/render_to_texture.rs +++ b/examples/3d/render_to_texture.rs @@ -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(1) would cause the rendered-to-texture cube to be lit, but the main view to be unlit. commands.spawn(( - PointLightBundle { - transform: Transform::from_translation(Vec3::new(0.0, 0.0, 10.0)), - ..default() - }, + PointLight::default(), + Transform::from_translation(Vec3::new(0.0, 0.0, 10.0)), RenderLayers::layer(0).with(1), )); diff --git a/examples/3d/rotate_environment_map.rs b/examples/3d/rotate_environment_map.rs index dd128959299cd..114097c3a5c87 100644 --- a/examples/3d/rotate_environment_map.rs +++ b/examples/3d/rotate_environment_map.rs @@ -84,12 +84,9 @@ fn spawn_sphere( /// Spawns a light. fn spawn_light(commands: &mut Commands) { - commands.spawn(PointLightBundle { - point_light: PointLight { - color: WHITE.into(), - intensity: 100000.0, - ..default() - }, + commands.spawn(PointLight { + color: WHITE.into(), + intensity: 100000.0, ..default() }); } diff --git a/examples/3d/scrolling_fog.rs b/examples/3d/scrolling_fog.rs index 837d4a5bca876..00ced30c06e48 100644 --- a/examples/3d/scrolling_fog.rs +++ b/examples/3d/scrolling_fog.rs @@ -70,15 +70,11 @@ fn setup( // Spawn a directional light shining at the camera with the VolumetricLight component. commands.spawn(( - DirectionalLightBundle { - 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, - ..default() - }, + DirectionalLight { + shadows_enabled: true, ..default() }, + Transform::from_xyz(-5.0, 5.0, -7.0).looking_at(Vec3::new(0.0, 0.0, 0.0), Vec3::Y), VolumetricLight, )); diff --git a/examples/3d/shadow_biases.rs b/examples/3d/shadow_biases.rs index ffcc1e70e6585..f39e5dde09f9b 100644 --- a/examples/3d/shadow_biases.rs +++ b/examples/3d/shadow_biases.rs @@ -54,25 +54,19 @@ fn setup( Lights, )) .with_children(|builder| { - builder.spawn(PointLightBundle { - point_light: PointLight { - intensity: 0.0, - range: spawn_plane_depth, - color: Color::WHITE, - shadow_depth_bias: 0.0, - shadow_normal_bias: 0.0, - shadows_enabled: true, - ..default() - }, + builder.spawn(PointLight { + intensity: 0.0, + range: spawn_plane_depth, + color: Color::WHITE, + shadow_depth_bias: 0.0, + shadow_normal_bias: 0.0, + shadows_enabled: true, ..default() }); - builder.spawn(DirectionalLightBundle { - directional_light: DirectionalLight { - shadow_depth_bias: 0.0, - shadow_normal_bias: 0.0, - shadows_enabled: true, - ..default() - }, + builder.spawn(DirectionalLight { + shadow_depth_bias: 0.0, + shadow_normal_bias: 0.0, + shadows_enabled: true, ..default() }); }); diff --git a/examples/3d/shadow_caster_receiver.rs b/examples/3d/shadow_caster_receiver.rs index f19adf15e001e..532bc3d0e22e8 100644 --- a/examples/3d/shadow_caster_receiver.rs +++ b/examples/3d/shadow_caster_receiver.rs @@ -79,38 +79,31 @@ fn setup( println!("Using DirectionalLight"); - commands.spawn(PointLightBundle { - transform: Transform::from_xyz(5.0, 5.0, 0.0), - point_light: PointLight { + commands.spawn(( + PointLight { intensity: 0.0, range: spawn_plane_depth, color: Color::WHITE, shadows_enabled: true, ..default() }, - ..default() - }); + Transform::from_xyz(5.0, 5.0, 0.0), + )); - commands.spawn(DirectionalLightBundle { - directional_light: DirectionalLight { + commands.spawn(( + DirectionalLight { illuminance: light_consts::lux::OVERCAST_DAY, shadows_enabled: true, ..default() }, - transform: Transform::from_rotation(Quat::from_euler( - EulerRot::ZYX, - 0.0, - PI / 2., - -PI / 4., - )), - cascade_shadow_config: CascadeShadowConfigBuilder { + Transform::from_rotation(Quat::from_euler(EulerRot::ZYX, 0.0, PI / 2., -PI / 4.)), + CascadeShadowConfigBuilder { first_cascade_far_bound: 7.0, maximum_distance: 25.0, ..default() } - .into(), - ..default() - }); + .build(), + )); // camera commands.spawn(Camera3dBundle { diff --git a/examples/3d/skybox.rs b/examples/3d/skybox.rs index 12b22ae2e853d..e499c809a55cf 100644 --- a/examples/3d/skybox.rs +++ b/examples/3d/skybox.rs @@ -60,15 +60,13 @@ struct Cubemap { fn setup(mut commands: Commands, asset_server: Res) { // directional 'sun' light - commands.spawn(DirectionalLightBundle { - directional_light: DirectionalLight { + commands.spawn(( + DirectionalLight { illuminance: 32000.0, ..default() }, - transform: Transform::from_xyz(0.0, 2.0, 0.0) - .with_rotation(Quat::from_rotation_x(-PI / 4.)), - ..default() - }); + Transform::from_xyz(0.0, 2.0, 0.0).with_rotation(Quat::from_rotation_x(-PI / 4.)), + )); let skybox_handle = asset_server.load(CUBEMAPS[0].0); // camera diff --git a/examples/3d/spherical_area_lights.rs b/examples/3d/spherical_area_lights.rs index e8e5725fecee0..5afad99117d66 100644 --- a/examples/3d/spherical_area_lights.rs +++ b/examples/3d/spherical_area_lights.rs @@ -59,15 +59,10 @@ fn setup( .with_scale(Vec3::splat(radius)), ..default() }) - .with_children(|children| { - children.spawn(PointLightBundle { - point_light: PointLight { - radius, - color: Color::srgb(0.2, 0.2, 1.0), - ..default() - }, - ..default() - }); + .with_child(PointLight { + radius, + color: Color::srgb(0.2, 0.2, 1.0), + ..default() }); } } diff --git a/examples/3d/split_screen.rs b/examples/3d/split_screen.rs index f24f119231849..8e6205ec8d2aa 100644 --- a/examples/3d/split_screen.rs +++ b/examples/3d/split_screen.rs @@ -34,13 +34,13 @@ fn setup( }); // Light - commands.spawn(DirectionalLightBundle { - transform: Transform::from_rotation(Quat::from_euler(EulerRot::ZYX, 0.0, 1.0, -PI / 4.)), - directional_light: DirectionalLight { + commands.spawn(( + Transform::from_rotation(Quat::from_euler(EulerRot::ZYX, 0.0, 1.0, -PI / 4.)), + DirectionalLight { shadows_enabled: true, ..default() }, - cascade_shadow_config: CascadeShadowConfigBuilder { + CascadeShadowConfigBuilder { num_cascades: if cfg!(all( feature = "webgl2", target_arch = "wasm32", @@ -55,9 +55,8 @@ fn setup( maximum_distance: 280.0, ..default() } - .into(), - ..default() - }); + .build(), + )); // Cameras and their dedicated UI for (index, (camera_name, camera_pos)) in [ diff --git a/examples/3d/spotlight.rs b/examples/3d/spotlight.rs index 6c61fd508f289..9c1a675dd3ca9 100644 --- a/examples/3d/spotlight.rs +++ b/examples/3d/spotlight.rs @@ -95,10 +95,8 @@ fn setup( let z = z as f32 - 2.0; // red spot_light commands - .spawn(SpotLightBundle { - 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 { + .spawn(( + SpotLight { intensity: 40_000.0, // lumens color: Color::WHITE, shadows_enabled: true, @@ -106,8 +104,9 @@ fn setup( outer_angle: PI / 4.0, ..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| { builder.spawn(PbrBundle { mesh: sphere_mesh.clone(), diff --git a/examples/3d/ssao.rs b/examples/3d/ssao.rs index 39c53f8dd13c8..3c9890af39c5d 100644 --- a/examples/3d/ssao.rs +++ b/examples/3d/ssao.rs @@ -80,19 +80,13 @@ fn setup( SphereMarker, )); - commands.spawn(DirectionalLightBundle { - directional_light: DirectionalLight { + commands.spawn(( + DirectionalLight { shadows_enabled: true, ..default() }, - transform: Transform::from_rotation(Quat::from_euler( - EulerRot::ZYX, - 0.0, - PI * -0.15, - PI * -0.15, - )), - ..default() - }); + Transform::from_rotation(Quat::from_euler(EulerRot::ZYX, 0.0, PI * -0.15, PI * -0.15)), + )); commands.spawn( TextBundle::from_section("", TextStyle::default()).with_style(Style { diff --git a/examples/3d/tonemapping.rs b/examples/3d/tonemapping.rs index 58c2a76caba71..bd47f13cf873c 100644 --- a/examples/3d/tonemapping.rs +++ b/examples/3d/tonemapping.rs @@ -118,26 +118,18 @@ fn setup_basic_scene(mut commands: Commands, asset_server: Res) { // light commands.spawn(( - DirectionalLightBundle { - directional_light: DirectionalLight { - illuminance: 15_000., - shadows_enabled: true, - ..default() - }, - transform: Transform::from_rotation(Quat::from_euler( - EulerRot::ZYX, - 0.0, - PI * -0.15, - PI * -0.15, - )), - cascade_shadow_config: CascadeShadowConfigBuilder { - maximum_distance: 3.0, - first_cascade_far_bound: 0.9, - ..default() - } - .into(), + DirectionalLight { + illuminance: 15_000., + shadows_enabled: true, ..default() }, + Transform::from_rotation(Quat::from_euler(EulerRot::ZYX, 0.0, PI * -0.15, PI * -0.15)), + CascadeShadowConfigBuilder { + maximum_distance: 3.0, + first_cascade_far_bound: 0.9, + ..default() + } + .build(), SceneNumber(1), )); } diff --git a/examples/3d/transmission.rs b/examples/3d/transmission.rs index 0e17e273049c8..cfff56dee224a 100644 --- a/examples/3d/transmission.rs +++ b/examples/3d/transmission.rs @@ -318,18 +318,15 @@ fn setup( // Candle Light commands.spawn(( - PointLightBundle { - transform: Transform::from_xyz(-1.0, 1.7, 0.0), - point_light: PointLight { - color: Color::from( - LinearRgba::from(ANTIQUE_WHITE).mix(&LinearRgba::from(ORANGE_RED), 0.2), - ), - intensity: 4_000.0, - radius: 0.2, - range: 5.0, - shadows_enabled: true, - ..default() - }, + Transform::from_xyz(-1.0, 1.7, 0.0), + PointLight { + color: Color::from( + LinearRgba::from(ANTIQUE_WHITE).mix(&LinearRgba::from(ORANGE_RED), 0.2), + ), + intensity: 4_000.0, + radius: 0.2, + range: 5.0, + shadows_enabled: true, ..default() }, Flicker, diff --git a/examples/3d/transparency_3d.rs b/examples/3d/transparency_3d.rs index 5db6d7b693a1e..acf98c3b09a62 100644 --- a/examples/3d/transparency_3d.rs +++ b/examples/3d/transparency_3d.rs @@ -87,14 +87,13 @@ fn setup( }); // Light - commands.spawn(PointLightBundle { - point_light: PointLight { + commands.spawn(( + PointLight { shadows_enabled: true, ..default() }, - transform: Transform::from_xyz(4.0, 8.0, 4.0), - ..default() - }); + Transform::from_xyz(4.0, 8.0, 4.0), + )); // Camera commands.spawn(Camera3dBundle { diff --git a/examples/3d/two_passes.rs b/examples/3d/two_passes.rs index 48cfb472a9779..8f56096e7c39e 100644 --- a/examples/3d/two_passes.rs +++ b/examples/3d/two_passes.rs @@ -31,14 +31,13 @@ fn setup( }); // Light - commands.spawn(PointLightBundle { - point_light: PointLight { + commands.spawn(( + PointLight { shadows_enabled: true, ..default() }, - transform: Transform::from_xyz(4.0, 8.0, 4.0), - ..default() - }); + Transform::from_xyz(4.0, 8.0, 4.0), + )); // Camera commands.spawn(Camera3dBundle { diff --git a/examples/3d/update_gltf_scene.rs b/examples/3d/update_gltf_scene.rs index e0d0dfa7c8f17..c7bda9db8b917 100644 --- a/examples/3d/update_gltf_scene.rs +++ b/examples/3d/update_gltf_scene.rs @@ -16,14 +16,13 @@ fn main() { struct MovedScene; fn setup(mut commands: Commands, asset_server: Res) { - commands.spawn(DirectionalLightBundle { - transform: Transform::from_xyz(4.0, 25.0, 8.0).looking_at(Vec3::ZERO, Vec3::Y), - directional_light: DirectionalLight { + commands.spawn(( + Transform::from_xyz(4.0, 25.0, 8.0).looking_at(Vec3::ZERO, Vec3::Y), + DirectionalLight { shadows_enabled: true, ..default() }, - ..default() - }); + )); commands.spawn(( Camera3dBundle { transform: Transform::from_xyz(-0.5, 0.9, 1.5) diff --git a/examples/3d/vertex_colors.rs b/examples/3d/vertex_colors.rs index 628d9023ff198..3fa068ecf34bd 100644 --- a/examples/3d/vertex_colors.rs +++ b/examples/3d/vertex_colors.rs @@ -44,14 +44,13 @@ fn setup( }); // Light - commands.spawn(PointLightBundle { - point_light: PointLight { + commands.spawn(( + PointLight { shadows_enabled: true, ..default() }, - transform: Transform::from_xyz(4.0, 5.0, 4.0).looking_at(Vec3::ZERO, Vec3::Y), - ..default() - }); + Transform::from_xyz(4.0, 5.0, 4.0).looking_at(Vec3::ZERO, Vec3::Y), + )); // Camera commands.spawn(Camera3dBundle { diff --git a/examples/3d/visibility_range.rs b/examples/3d/visibility_range.rs index 8d7245a613ce5..02ccc7ef5d102 100644 --- a/examples/3d/visibility_range.rs +++ b/examples/3d/visibility_range.rs @@ -121,26 +121,20 @@ fn setup( .insert(MainModel::LowPoly); // Spawn a light. - commands.spawn(DirectionalLightBundle { - directional_light: DirectionalLight { + commands.spawn(( + DirectionalLight { illuminance: FULL_DAYLIGHT, shadows_enabled: true, ..default() }, - transform: Transform::from_rotation(Quat::from_euler( - EulerRot::ZYX, - 0.0, - PI * -0.15, - PI * -0.15, - )), - cascade_shadow_config: CascadeShadowConfigBuilder { + Transform::from_rotation(Quat::from_euler(EulerRot::ZYX, 0.0, PI * -0.15, PI * -0.15)), + CascadeShadowConfigBuilder { maximum_distance: 30.0, first_cascade_far_bound: 0.9, ..default() } - .into(), - ..default() - }); + .build(), + )); // Spawn a camera. commands diff --git a/examples/3d/volumetric_fog.rs b/examples/3d/volumetric_fog.rs index 5cbf60de074c2..3f49e23477fdd 100644 --- a/examples/3d/volumetric_fog.rs +++ b/examples/3d/volumetric_fog.rs @@ -90,42 +90,36 @@ fn setup(mut commands: Commands, asset_server: Res, app_settings: R }); // Add the point light - commands - .spawn(( - PointLightBundle { - point_light: PointLight { - shadows_enabled: true, - range: 150.0, - color: RED.into(), - intensity: 1000.0, - ..default() - }, - transform: Transform::from_xyz(-0.4, 1.9, 1.0), - ..default() - }, - MoveBackAndForthHorizontally { - min_x: -1.93, - max_x: -0.4, - speed: -0.2, - }, - )) - .insert(VolumetricLight); + commands.spawn(( + Transform::from_xyz(-0.4, 1.9, 1.0), + PointLight { + shadows_enabled: true, + range: 150.0, + color: RED.into(), + intensity: 1000.0, + ..default() + }, + VolumetricLight, + MoveBackAndForthHorizontally { + min_x: -1.93, + max_x: -0.4, + speed: -0.2, + }, + )); // Add the spot light - commands - .spawn(SpotLightBundle { - transform: Transform::from_xyz(-1.8, 3.9, -2.7).looking_at(Vec3::ZERO, Vec3::Y), - spot_light: SpotLight { - intensity: 5000.0, // lumens - color: Color::WHITE, - shadows_enabled: true, - inner_angle: 0.76, - outer_angle: 0.94, - ..default() - }, + commands.spawn(( + Transform::from_xyz(-1.8, 3.9, -2.7).looking_at(Vec3::ZERO, Vec3::Y), + SpotLight { + intensity: 5000.0, // lumens + color: Color::WHITE, + shadows_enabled: true, + inner_angle: 0.76, + outer_angle: 0.94, ..default() - }) - .insert(VolumetricLight); + }, + VolumetricLight, + )); // Add the fog volume. commands.spawn(FogVolumeBundle { diff --git a/examples/3d/wireframe.rs b/examples/3d/wireframe.rs index ca3f48cc1de59..1ea7f6f4079e7 100644 --- a/examples/3d/wireframe.rs +++ b/examples/3d/wireframe.rs @@ -100,10 +100,7 @@ fn setup( )); // light - commands.spawn(PointLightBundle { - transform: Transform::from_xyz(2.0, 4.0, 2.0), - ..default() - }); + commands.spawn((PointLight::default(), Transform::from_xyz(2.0, 4.0, 2.0))); // camera commands.spawn(Camera3dBundle { diff --git a/examples/animation/animated_fox.rs b/examples/animation/animated_fox.rs index f10e2b66ee1f3..6b9271cad810a 100644 --- a/examples/animation/animated_fox.rs +++ b/examples/animation/animated_fox.rs @@ -66,20 +66,19 @@ fn setup( }); // Light - commands.spawn(DirectionalLightBundle { - transform: Transform::from_rotation(Quat::from_euler(EulerRot::ZYX, 0.0, 1.0, -PI / 4.)), - directional_light: DirectionalLight { + commands.spawn(( + Transform::from_rotation(Quat::from_euler(EulerRot::ZYX, 0.0, 1.0, -PI / 4.)), + DirectionalLight { shadows_enabled: true, ..default() }, - cascade_shadow_config: CascadeShadowConfigBuilder { + CascadeShadowConfigBuilder { first_cascade_far_bound: 200.0, maximum_distance: 400.0, ..default() } - .into(), - ..default() - }); + .build(), + )); // Fox commands.spawn(SceneBundle { diff --git a/examples/animation/animated_transform.rs b/examples/animation/animated_transform.rs index 14c0c9fce5ded..5e3438f7b6b38 100644 --- a/examples/animation/animated_transform.rs +++ b/examples/animation/animated_transform.rs @@ -32,14 +32,13 @@ fn setup( }); // Light - commands.spawn(PointLightBundle { - point_light: PointLight { + commands.spawn(( + PointLight { intensity: 500_000.0, ..default() }, - transform: Transform::from_xyz(0.0, 2.5, 0.0), - ..default() - }); + Transform::from_xyz(0.0, 2.5, 0.0), + )); // Let's use the `Name` component to target entities. We can use anything we // like, but names are convenient. diff --git a/examples/animation/animation_graph.rs b/examples/animation/animation_graph.rs index 94b9a2e52295e..906896b3c8cc9 100644 --- a/examples/animation/animation_graph.rs +++ b/examples/animation/animation_graph.rs @@ -223,15 +223,14 @@ fn setup_scene( ..default() }); - commands.spawn(PointLightBundle { - point_light: PointLight { + commands.spawn(( + PointLight { intensity: 10_000_000.0, shadows_enabled: true, ..default() }, - transform: Transform::from_xyz(-4.0, 8.0, 13.0), - ..default() - }); + Transform::from_xyz(-4.0, 8.0, 13.0), + )); commands.spawn(SceneBundle { scene: asset_server.load(GltfAssetLabel::Scene(0).from_asset("models/animated/Fox.glb")), diff --git a/examples/animation/animation_masks.rs b/examples/animation/animation_masks.rs index b5ca888edd30c..6e3f55a0141f2 100644 --- a/examples/animation/animation_masks.rs +++ b/examples/animation/animation_masks.rs @@ -108,15 +108,14 @@ fn setup_scene( }); // Spawn the light. - commands.spawn(PointLightBundle { - point_light: PointLight { + commands.spawn(( + PointLight { intensity: 10_000_000.0, shadows_enabled: true, ..default() }, - transform: Transform::from_xyz(-4.0, 8.0, 13.0), - ..default() - }); + Transform::from_xyz(-4.0, 8.0, 13.0), + )); // Spawn the fox. commands.spawn(SceneBundle { diff --git a/examples/animation/cubic_curve.rs b/examples/animation/cubic_curve.rs index b3ec6600c573a..b569cae5601db 100644 --- a/examples/animation/cubic_curve.rs +++ b/examples/animation/cubic_curve.rs @@ -48,16 +48,15 @@ fn setup( )); // Some light to see something - commands.spawn(PointLightBundle { - point_light: PointLight { + commands.spawn(( + PointLight { shadows_enabled: true, intensity: 10_000_000., range: 100.0, ..default() }, - transform: Transform::from_xyz(8., 16., 8.), - ..default() - }); + Transform::from_xyz(8., 16., 8.), + )); // ground plane commands.spawn(PbrBundle { diff --git a/examples/animation/morph_targets.rs b/examples/animation/morph_targets.rs index 2885b0355786e..001bfa1fda18f 100644 --- a/examples/animation/morph_targets.rs +++ b/examples/animation/morph_targets.rs @@ -51,10 +51,10 @@ fn setup(asset_server: Res, mut commands: Commands) { .load(GltfAssetLabel::Scene(0).from_asset("models/animated/MorphStressTest.gltf")), ..default() }); - commands.spawn(DirectionalLightBundle { - transform: Transform::from_rotation(Quat::from_rotation_z(PI / 2.0)), - ..default() - }); + commands.spawn(( + DirectionalLight::default(), + Transform::from_rotation(Quat::from_rotation_z(PI / 2.0)), + )); commands.spawn(Camera3dBundle { transform: Transform::from_xyz(3.0, 2.1, 10.2).looking_at(Vec3::ZERO, Vec3::Y), ..default() diff --git a/examples/app/headless_renderer.rs b/examples/app/headless_renderer.rs index 4e7c7a7f3f1dc..ff0b7d09d420c 100644 --- a/examples/app/headless_renderer.rs +++ b/examples/app/headless_renderer.rs @@ -174,14 +174,13 @@ fn setup( ..default() }); // light - commands.spawn(PointLightBundle { - point_light: PointLight { + commands.spawn(( + PointLight { shadows_enabled: true, ..default() }, - transform: Transform::from_xyz(4.0, 8.0, 4.0), - ..default() - }); + Transform::from_xyz(4.0, 8.0, 4.0), + )); commands.spawn(Camera3dBundle { transform: Transform::from_xyz(-2.5, 4.5, 9.0).looking_at(Vec3::ZERO, Vec3::Y), diff --git a/examples/asset/alter_mesh.rs b/examples/asset/alter_mesh.rs index 92e13efdf71fe..81dcd693e0d7b 100644 --- a/examples/asset/alter_mesh.rs +++ b/examples/asset/alter_mesh.rs @@ -126,10 +126,8 @@ fn setup( commands.spawn(( Name::new("Point Light"), - PointLightBundle { - transform: Transform::from_xyz(4.0, 5.0, 4.0), - ..default() - }, + PointLight::default(), + Transform::from_xyz(4.0, 5.0, 4.0), )); commands.spawn(( diff --git a/examples/asset/asset_loading.rs b/examples/asset/asset_loading.rs index 761b58a9ffcc5..0a6c0d33291ef 100644 --- a/examples/asset/asset_loading.rs +++ b/examples/asset/asset_loading.rs @@ -94,10 +94,7 @@ fn setup( ..default() }); // light - commands.spawn(PointLightBundle { - transform: Transform::from_xyz(4.0, 5.0, 4.0), - ..default() - }); + commands.spawn((PointLight::default(), Transform::from_xyz(4.0, 5.0, 4.0))); // camera commands.spawn(Camera3dBundle { transform: Transform::from_xyz(0.0, 3.0, 10.0).looking_at(Vec3::ZERO, Vec3::Y), diff --git a/examples/asset/hot_asset_reloading.rs b/examples/asset/hot_asset_reloading.rs index 317277ac6efb2..4e012a76c5e9e 100644 --- a/examples/asset/hot_asset_reloading.rs +++ b/examples/asset/hot_asset_reloading.rs @@ -28,11 +28,10 @@ fn setup(mut commands: Commands, asset_server: Res) { ..default() }); // light - commands.spawn(DirectionalLightBundle { - directional_light: DirectionalLight::default(), - transform: Transform::from_xyz(4.0, 5.0, 4.0).looking_at(Vec3::ZERO, Vec3::Y), - ..default() - }); + commands.spawn(( + DirectionalLight::default(), + Transform::from_xyz(4.0, 5.0, 4.0).looking_at(Vec3::ZERO, Vec3::Y), + )); // camera commands.spawn(Camera3dBundle { transform: Transform::from_xyz(2.0, 2.0, 6.0).looking_at(Vec3::ZERO, Vec3::Y), diff --git a/examples/asset/multi_asset_sync.rs b/examples/asset/multi_asset_sync.rs index f74de5f7474a7..7fe701b7c0084 100644 --- a/examples/asset/multi_asset_sync.rs +++ b/examples/asset/multi_asset_sync.rs @@ -214,14 +214,13 @@ fn setup_scene( }); // Light - commands.spawn(DirectionalLightBundle { - transform: Transform::from_rotation(Quat::from_euler(EulerRot::ZYX, 0.0, 1.0, -PI / 4.)), - directional_light: DirectionalLight { + commands.spawn(( + DirectionalLight { shadows_enabled: true, ..default() }, - ..default() - }); + Transform::from_rotation(Quat::from_euler(EulerRot::ZYX, 0.0, 1.0, -PI / 4.)), + )); // Plane commands.spawn(( diff --git a/examples/asset/repeated_texture.rs b/examples/asset/repeated_texture.rs index a2458238ba2c9..e78aa48a47a61 100644 --- a/examples/asset/repeated_texture.rs +++ b/examples/asset/repeated_texture.rs @@ -83,14 +83,13 @@ fn setup( }); // light - commands.spawn(PointLightBundle { - point_light: PointLight { + commands.spawn(( + PointLight { shadows_enabled: true, ..default() }, - transform: Transform::from_xyz(4.0, 8.0, 4.0), - ..default() - }); + Transform::from_xyz(4.0, 8.0, 4.0), + )); // camera commands.spawn(Camera3dBundle { transform: Transform::from_xyz(0.0, 1.5, 4.0).looking_at(Vec3::ZERO, Vec3::Y), diff --git a/examples/async_tasks/async_compute.rs b/examples/async_tasks/async_compute.rs index 2ac4149478eea..cffe28143a51c 100644 --- a/examples/async_tasks/async_compute.rs +++ b/examples/async_tasks/async_compute.rs @@ -128,10 +128,7 @@ fn setup_env(mut commands: Commands) { }; // lights - commands.spawn(PointLightBundle { - transform: Transform::from_xyz(4.0, 12.0, 15.0), - ..default() - }); + commands.spawn((PointLight::default(), Transform::from_xyz(4.0, 12.0, 15.0))); // camera commands.spawn(Camera3dBundle { diff --git a/examples/audio/spatial_audio_3d.rs b/examples/audio/spatial_audio_3d.rs index b279e329bcdb8..b2ac095cdb876 100644 --- a/examples/audio/spatial_audio_3d.rs +++ b/examples/audio/spatial_audio_3d.rs @@ -59,10 +59,10 @@ fn setup( }); // light - commands.spawn(DirectionalLightBundle { - transform: Transform::from_xyz(4.0, 8.0, 4.0).looking_at(Vec3::ZERO, Vec3::Y), - ..default() - }); + commands.spawn(( + DirectionalLight::default(), + Transform::from_xyz(4.0, 8.0, 4.0).looking_at(Vec3::ZERO, Vec3::Y), + )); // example instructions commands.spawn( diff --git a/examples/camera/camera_orbit.rs b/examples/camera/camera_orbit.rs index 366bf8be44606..fe76124d61265 100644 --- a/examples/camera/camera_orbit.rs +++ b/examples/camera/camera_orbit.rs @@ -82,10 +82,8 @@ fn setup( commands.spawn(( Name::new("Light"), - PointLightBundle { - transform: Transform::from_xyz(3.0, 8.0, 5.0), - ..default() - }, + PointLight::default(), + Transform::from_xyz(3.0, 8.0, 5.0), )); } diff --git a/examples/camera/first_person_view_model.rs b/examples/camera/first_person_view_model.rs index 79bec51eed2b8..9be69f9847f8e 100644 --- a/examples/camera/first_person_view_model.rs +++ b/examples/camera/first_person_view_model.rs @@ -196,15 +196,12 @@ fn spawn_world_model( fn spawn_lights(mut commands: Commands) { commands.spawn(( - PointLightBundle { - point_light: PointLight { - color: Color::from(tailwind::ROSE_300), - shadows_enabled: true, - ..default() - }, - transform: Transform::from_xyz(-2.0, 4.0, -0.75), + PointLight { + color: Color::from(tailwind::ROSE_300), + shadows_enabled: true, ..default() }, + Transform::from_xyz(-2.0, 4.0, -0.75), // The light source illuminates both the world model and the view model. RenderLayers::from_layers(&[DEFAULT_RENDER_LAYER, VIEW_MODEL_RENDER_LAYER]), )); diff --git a/examples/camera/projection_zoom.rs b/examples/camera/projection_zoom.rs index 108567ab55d58..9ff452b94e723 100644 --- a/examples/camera/projection_zoom.rs +++ b/examples/camera/projection_zoom.rs @@ -93,10 +93,8 @@ fn setup( commands.spawn(( Name::new("Light"), - PointLightBundle { - transform: Transform::from_xyz(3.0, 8.0, 5.0), - ..default() - }, + PointLight::default(), + Transform::from_xyz(3.0, 8.0, 5.0), )); } diff --git a/examples/ecs/iter_combinations.rs b/examples/ecs/iter_combinations.rs index d71635248e11e..25c90998447a0 100644 --- a/examples/ecs/iter_combinations.rs +++ b/examples/ecs/iter_combinations.rs @@ -109,16 +109,11 @@ fn generate_bodies( }, Star, )) - .with_children(|p| { - p.spawn(PointLightBundle { - point_light: PointLight { - color: Color::WHITE, - range: 100.0, - radius: star_radius, - ..default() - }, - ..default() - }); + .with_child(PointLight { + color: Color::WHITE, + range: 100.0, + radius: star_radius, + ..default() }); commands.spawn(Camera3dBundle { transform: Transform::from_xyz(0.0, 10.5, -30.0).looking_at(Vec3::ZERO, Vec3::Y), diff --git a/examples/games/alien_cake_addict.rs b/examples/games/alien_cake_addict.rs index 7dd04f755526b..3fcddf9289b97 100644 --- a/examples/games/alien_cake_addict.rs +++ b/examples/games/alien_cake_addict.rs @@ -121,16 +121,15 @@ fn setup(mut commands: Commands, asset_server: Res, mut game: ResMu game.player.j = BOARD_SIZE_J / 2; game.player.move_cooldown = Timer::from_seconds(0.3, TimerMode::Once); - commands.spawn(PointLightBundle { - transform: Transform::from_xyz(4.0, 10.0, 4.0), - point_light: PointLight { + commands.spawn(( + PointLight { intensity: 2_000_000.0, shadows_enabled: true, range: 30.0, ..default() }, - ..default() - }); + Transform::from_xyz(4.0, 10.0, 4.0), + )); // spawn the game board let cell_scene = @@ -355,18 +354,15 @@ fn spawn_bonus( scene: game.bonus.handle.clone(), ..default() }) - .with_children(|children| { - children.spawn(PointLightBundle { - point_light: PointLight { - color: Color::srgb(1.0, 1.0, 0.0), - intensity: 500_000.0, - range: 10.0, - ..default() - }, - transform: Transform::from_xyz(0.0, 2.0, 0.0), + .with_child(( + PointLight { + color: Color::srgb(1.0, 1.0, 0.0), + intensity: 500_000.0, + range: 10.0, ..default() - }); - }) + }, + Transform::from_xyz(0.0, 2.0, 0.0), + )) .id(), ); } diff --git a/examples/games/loading_screen.rs b/examples/games/loading_screen.rs index 763bc1886054c..48d15e01a5d08 100644 --- a/examples/games/loading_screen.rs +++ b/examples/games/loading_screen.rs @@ -164,14 +164,11 @@ fn load_level_1( // Spawn the light. commands.spawn(( - DirectionalLightBundle { - transform: Transform::from_xyz(3.0, 3.0, 2.0).looking_at(Vec3::ZERO, Vec3::Y), - directional_light: DirectionalLight { - shadows_enabled: true, - ..default() - }, + DirectionalLight { + shadows_enabled: true, ..default() }, + Transform::from_xyz(3.0, 3.0, 2.0).looking_at(Vec3::ZERO, Vec3::Y), LevelComponents, )); } @@ -207,14 +204,11 @@ fn load_level_2( // Spawn the light. commands.spawn(( - DirectionalLightBundle { - transform: Transform::from_xyz(3.0, 3.0, 2.0).looking_at(Vec3::ZERO, Vec3::Y), - directional_light: DirectionalLight { - shadows_enabled: true, - ..default() - }, + DirectionalLight { + shadows_enabled: true, ..default() }, + Transform::from_xyz(3.0, 3.0, 2.0).looking_at(Vec3::ZERO, Vec3::Y), LevelComponents, )); } diff --git a/examples/gizmos/3d_gizmos.rs b/examples/gizmos/3d_gizmos.rs index b6160ef76458e..bfb201a64c39c 100644 --- a/examples/gizmos/3d_gizmos.rs +++ b/examples/gizmos/3d_gizmos.rs @@ -46,14 +46,13 @@ fn setup( ..default() }); // light - commands.spawn(PointLightBundle { - point_light: PointLight { + commands.spawn(( + PointLight { shadows_enabled: true, ..default() }, - transform: Transform::from_xyz(4.0, 8.0, 4.0), - ..default() - }); + Transform::from_xyz(4.0, 8.0, 4.0), + )); // example instructions commands.spawn( diff --git a/examples/gizmos/axes.rs b/examples/gizmos/axes.rs index 69c546df8963a..16c36afd2c545 100644 --- a/examples/gizmos/axes.rs +++ b/examples/gizmos/axes.rs @@ -47,14 +47,13 @@ fn setup( let mut rng = ChaCha8Rng::seed_from_u64(19878367467713); // Lights... - commands.spawn(PointLightBundle { - point_light: PointLight { + commands.spawn(( + PointLight { shadows_enabled: true, ..default() }, - transform: Transform::from_xyz(2., 6., 0.), - ..default() - }); + Transform::from_xyz(2., 6., 0.), + )); // Camera... commands.spawn(Camera3dBundle { diff --git a/examples/gizmos/light_gizmos.rs b/examples/gizmos/light_gizmos.rs index 8f5f5c8121543..9c2930ba4e4d6 100644 --- a/examples/gizmos/light_gizmos.rs +++ b/examples/gizmos/light_gizmos.rs @@ -65,18 +65,17 @@ fn setup( // Lights. { - commands.spawn(PointLightBundle { - point_light: PointLight { + commands.spawn(( + PointLight { shadows_enabled: true, range: 2.0, color: DARK_CYAN.into(), ..default() }, - transform: Transform::from_xyz(0.0, 1.5, 0.0), - ..default() - }); - commands.spawn(SpotLightBundle { - spot_light: SpotLight { + Transform::from_xyz(0.0, 1.5, 0.0), + )); + commands.spawn(( + SpotLight { shadows_enabled: true, range: 3.5, color: PURPLE.into(), @@ -84,19 +83,17 @@ fn setup( inner_angle: PI / 4.0 * 0.8, ..default() }, - transform: Transform::from_xyz(4.0, 2.0, 0.0).looking_at(Vec3::X * 1.5, Vec3::Y), - ..default() - }); - commands.spawn(DirectionalLightBundle { - directional_light: DirectionalLight { + Transform::from_xyz(4.0, 2.0, 0.0).looking_at(Vec3::X * 1.5, Vec3::Y), + )); + commands.spawn(( + DirectionalLight { color: GOLD.into(), illuminance: DirectionalLight::default().illuminance * 0.05, shadows_enabled: true, ..default() }, - transform: Transform::from_xyz(-4.0, 2.0, 0.0).looking_at(Vec3::NEG_X * 1.5, Vec3::Y), - ..default() - }); + Transform::from_xyz(-4.0, 2.0, 0.0).looking_at(Vec3::NEG_X * 1.5, Vec3::Y), + )); } // Camera. diff --git a/examples/math/custom_primitives.rs b/examples/math/custom_primitives.rs index fae0739254300..68638d1ffa765 100644 --- a/examples/math/custom_primitives.rs +++ b/examples/math/custom_primitives.rs @@ -155,17 +155,16 @@ fn setup( )); // Point light for 3D - commands.spawn(PointLightBundle { - point_light: PointLight { + commands.spawn(( + PointLight { shadows_enabled: true, intensity: 10_000_000., range: 100.0, shadow_depth_bias: 0.2, ..default() }, - transform: Transform::from_xyz(8.0, 12.0, 1.0), - ..default() - }); + Transform::from_xyz(8.0, 12.0, 1.0), + )); // Example instructions commands.spawn( diff --git a/examples/math/random_sampling.rs b/examples/math/random_sampling.rs index 55d509a095bbc..a6c831dcb33a9 100644 --- a/examples/math/random_sampling.rs +++ b/examples/math/random_sampling.rs @@ -82,14 +82,13 @@ fn setup( }); // A light: - commands.spawn(PointLightBundle { - point_light: PointLight { + commands.spawn(( + PointLight { shadows_enabled: true, ..default() }, - transform: Transform::from_xyz(4.0, 8.0, 4.0), - ..default() - }); + Transform::from_xyz(4.0, 8.0, 4.0), + )); // A camera: commands.spawn(Camera3dBundle { diff --git a/examples/math/render_primitives.rs b/examples/math/render_primitives.rs index 5d68a8badc20c..453d2d9425f93 100644 --- a/examples/math/render_primitives.rs +++ b/examples/math/render_primitives.rs @@ -318,15 +318,14 @@ fn setup_ambient_light(mut ambient_light: ResMut) { } fn setup_lights(mut commands: Commands) { - commands.spawn(PointLightBundle { - point_light: PointLight { + commands.spawn(( + PointLight { intensity: 5000.0, ..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), - ..default() - }); + )); } /// Marker component for header text diff --git a/examples/math/sampling_primitives.rs b/examples/math/sampling_primitives.rs index 38112989ea5a9..8e272a414ce79 100644 --- a/examples/math/sampling_primitives.rs +++ b/examples/math/sampling_primitives.rs @@ -314,33 +314,29 @@ fn setup( // Lights which work as the bulk lighting of the fireflies: commands.spawn(( - PointLightBundle { - point_light: PointLight { - range: 4.0, - radius: 0.6, - intensity: 1.0, - shadows_enabled: false, - color: Color::LinearRgba(INSIDE_POINT_COLOR), - ..default() - }, - transform: Transform::from_translation(*translation), + PointLight { + range: 4.0, + radius: 0.6, + intensity: 1.0, + shadows_enabled: false, + color: Color::LinearRgba(INSIDE_POINT_COLOR), ..default() }, + Transform::from_translation(*translation), FireflyLights, )); } // Global light: - commands.spawn(PointLightBundle { - point_light: PointLight { + commands.spawn(( + PointLight { color: SKY_COLOR, intensity: 2_000.0, shadows_enabled: false, ..default() }, - transform: Transform::from_xyz(4.0, 8.0, 4.0), - ..default() - }); + Transform::from_xyz(4.0, 8.0, 4.0), + )); // A camera: commands.spawn(( diff --git a/examples/mobile/src/lib.rs b/examples/mobile/src/lib.rs index 54f561871fd79..ba46048336ec5 100644 --- a/examples/mobile/src/lib.rs +++ b/examples/mobile/src/lib.rs @@ -88,9 +88,8 @@ fn setup_scene( ..default() }); // light - commands.spawn(PointLightBundle { - transform: Transform::from_xyz(4.0, 8.0, 4.0), - point_light: PointLight { + commands.spawn(( + PointLight { intensity: 1_000_000.0, // Shadows makes some Android devices segfault, this is under investigation // https://github.com/bevyengine/bevy/issues/8214 @@ -98,8 +97,8 @@ fn setup_scene( shadows_enabled: true, ..default() }, - ..default() - }); + Transform::from_xyz(4.0, 8.0, 4.0), + )); // camera commands.spawn(Camera3dBundle { transform: Transform::from_xyz(-2.0, 2.5, 5.0).looking_at(Vec3::ZERO, Vec3::Y), diff --git a/examples/movement/smooth_follow.rs b/examples/movement/smooth_follow.rs index 6a9fb01878228..cca16c02edd17 100644 --- a/examples/movement/smooth_follow.rs +++ b/examples/movement/smooth_follow.rs @@ -74,15 +74,14 @@ fn setup( )); // A light: - commands.spawn(PointLightBundle { - point_light: PointLight { + commands.spawn(( + PointLight { intensity: 15_000_000.0, shadows_enabled: true, ..default() }, - transform: Transform::from_xyz(4.0, 8.0, 4.0), - ..default() - }); + Transform::from_xyz(4.0, 8.0, 4.0), + )); // A camera: commands.spawn(Camera3dBundle { diff --git a/examples/picking/simple_picking.rs b/examples/picking/simple_picking.rs index 50276f0902e13..4c287cd7971f6 100644 --- a/examples/picking/simple_picking.rs +++ b/examples/picking/simple_picking.rs @@ -74,14 +74,13 @@ fn setup( println!("{click:?}"); }); // light - commands.spawn(PointLightBundle { - point_light: PointLight { + commands.spawn(( + PointLight { shadows_enabled: true, ..default() }, - transform: Transform::from_xyz(4.0, 8.0, 4.0), - ..default() - }); + Transform::from_xyz(4.0, 8.0, 4.0), + )); // camera commands.spawn(Camera3dBundle { transform: Transform::from_xyz(-2.5, 4.5, 9.0).looking_at(Vec3::ZERO, Vec3::Y), diff --git a/examples/remote/server.rs b/examples/remote/server.rs index bab8cacf4cd2d..d5b5e5e19eb86 100644 --- a/examples/remote/server.rs +++ b/examples/remote/server.rs @@ -41,14 +41,13 @@ fn setup( )); // light - commands.spawn(PointLightBundle { - point_light: PointLight { + commands.spawn(( + PointLight { shadows_enabled: true, ..default() }, - transform: Transform::from_xyz(4.0, 8.0, 4.0), - ..default() - }); + Transform::from_xyz(4.0, 8.0, 4.0), + )); // camera commands.spawn(Camera3dBundle { diff --git a/examples/shader/array_texture.rs b/examples/shader/array_texture.rs index 1cd366b092bf3..b247f7842cc55 100644 --- a/examples/shader/array_texture.rs +++ b/examples/shader/array_texture.rs @@ -36,10 +36,10 @@ fn setup(mut commands: Commands, asset_server: Res) { }); // light - commands.spawn(DirectionalLightBundle { - transform: Transform::from_xyz(3.0, 2.0, 1.0).looking_at(Vec3::ZERO, Vec3::Y), - ..Default::default() - }); + commands.spawn(( + DirectionalLight::default(), + Transform::from_xyz(3.0, 2.0, 1.0).looking_at(Vec3::ZERO, Vec3::Y), + )); // camera commands.spawn(Camera3dBundle { diff --git a/examples/shader/automatic_instancing.rs b/examples/shader/automatic_instancing.rs index 1417d55bc4f2d..c45973c938de2 100644 --- a/examples/shader/automatic_instancing.rs +++ b/examples/shader/automatic_instancing.rs @@ -22,14 +22,13 @@ fn setup( ..default() }); // light - commands.spawn(PointLightBundle { - point_light: PointLight { + commands.spawn(( + PointLight { shadows_enabled: true, ..default() }, - transform: Transform::from_xyz(0.0, 16.0, 8.0), - ..default() - }); + Transform::from_xyz(0.0, 16.0, 8.0), + )); 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 diff --git a/examples/shader/custom_post_processing.rs b/examples/shader/custom_post_processing.rs index 96d56259d5374..2fbccc3172329 100644 --- a/examples/shader/custom_post_processing.rs +++ b/examples/shader/custom_post_processing.rs @@ -342,11 +342,8 @@ fn setup( Rotates, )); // light - commands.spawn(DirectionalLightBundle { - directional_light: DirectionalLight { - illuminance: 1_000., - ..default() - }, + commands.spawn(DirectionalLight { + illuminance: 1_000., ..default() }); } diff --git a/examples/shader/extended_material.rs b/examples/shader/extended_material.rs index 427dca5f4cca1..92f7cedeabccc 100644 --- a/examples/shader/extended_material.rs +++ b/examples/shader/extended_material.rs @@ -49,10 +49,8 @@ fn setup( // light commands.spawn(( - DirectionalLightBundle { - transform: Transform::from_xyz(1.0, 1.0, 1.0).looking_at(Vec3::ZERO, Vec3::Y), - ..default() - }, + DirectionalLight::default(), + Transform::from_xyz(1.0, 1.0, 1.0).looking_at(Vec3::ZERO, Vec3::Y), Rotate, )); diff --git a/examples/shader/shader_material_screenspace_texture.rs b/examples/shader/shader_material_screenspace_texture.rs index 0c4614a02ef8d..dfec6c020999f 100644 --- a/examples/shader/shader_material_screenspace_texture.rs +++ b/examples/shader/shader_material_screenspace_texture.rs @@ -32,10 +32,7 @@ fn setup( material: standard_materials.add(Color::srgb(0.3, 0.5, 0.3)), ..default() }); - commands.spawn(PointLightBundle { - transform: Transform::from_xyz(4.0, 8.0, 4.0), - ..default() - }); + commands.spawn((PointLight::default(), Transform::from_xyz(4.0, 8.0, 4.0))); commands.spawn(MaterialMeshBundle { mesh: meshes.add(Cuboid::default()), diff --git a/examples/shader/shader_prepass.rs b/examples/shader/shader_prepass.rs index 7d8be5200b565..c114b9b667019 100644 --- a/examples/shader/shader_prepass.rs +++ b/examples/shader/shader_prepass.rs @@ -127,14 +127,13 @@ fn setup( }); // light - commands.spawn(PointLightBundle { - point_light: PointLight { + commands.spawn(( + PointLight { shadows_enabled: true, ..default() }, - transform: Transform::from_xyz(4.0, 8.0, 4.0), - ..default() - }); + Transform::from_xyz(4.0, 8.0, 4.0), + )); let style = TextStyle::default(); diff --git a/examples/stress_tests/many_cubes.rs b/examples/stress_tests/many_cubes.rs index 7daa219d14583..e854279d15ed4 100644 --- a/examples/stress_tests/many_cubes.rs +++ b/examples/stress_tests/many_cubes.rs @@ -255,14 +255,13 @@ fn setup( } } - commands.spawn(DirectionalLightBundle { - directional_light: DirectionalLight { + commands.spawn(( + DirectionalLight { shadows_enabled: args.shadows, ..default() }, - transform: Transform::IDENTITY.looking_at(Vec3::new(0.0, -1.0, -1.0), Vec3::Y), - ..default() - }); + Transform::IDENTITY.looking_at(Vec3::new(0.0, -1.0, -1.0), Vec3::Y), + )); } fn init_textures(args: &Args, images: &mut Assets) -> Vec> { diff --git a/examples/stress_tests/many_foxes.rs b/examples/stress_tests/many_foxes.rs index ccd3c1c8c9a9e..0fce083abc0a0 100644 --- a/examples/stress_tests/many_foxes.rs +++ b/examples/stress_tests/many_foxes.rs @@ -208,20 +208,19 @@ fn setup( }); // Light - commands.spawn(DirectionalLightBundle { - transform: Transform::from_rotation(Quat::from_euler(EulerRot::ZYX, 0.0, 1.0, -PI / 4.)), - directional_light: DirectionalLight { + commands.spawn(( + Transform::from_rotation(Quat::from_euler(EulerRot::ZYX, 0.0, 1.0, -PI / 4.)), + DirectionalLight { shadows_enabled: true, ..default() }, - cascade_shadow_config: CascadeShadowConfigBuilder { + CascadeShadowConfigBuilder { first_cascade_far_bound: 0.9 * radius, maximum_distance: 2.8 * radius, ..default() } - .into(), - ..default() - }); + .build(), + )); println!("Animation controls:"); println!(" - spacebar: play / pause"); diff --git a/examples/stress_tests/many_lights.rs b/examples/stress_tests/many_lights.rs index c1cc1edc0a03c..f75f59e37c282 100644 --- a/examples/stress_tests/many_lights.rs +++ b/examples/stress_tests/many_lights.rs @@ -78,16 +78,15 @@ fn setup( 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); - PointLightBundle { - point_light: PointLight { + ( + PointLight { range: LIGHT_RADIUS, intensity: LIGHT_INTENSITY, color: Color::hsl(rng.gen_range(0.0..360.0), 1.0, 0.5), ..default() }, - transform: Transform::from_translation((RADIUS as f64 * unit_sphere_p).as_vec3()), - ..default() - } + Transform::from_translation((RADIUS as f64 * unit_sphere_p).as_vec3()), + ) })); // camera diff --git a/examples/tools/scene_viewer/main.rs b/examples/tools/scene_viewer/main.rs index 2d7dc074dbf04..2c29c4aa0b2fc 100644 --- a/examples/tools/scene_viewer/main.rs +++ b/examples/tools/scene_viewer/main.rs @@ -153,10 +153,10 @@ fn setup_scene_after_load( // Spawn a default light if the scene does not have one if !scene_handle.has_light { info!("Spawning a directional light"); - commands.spawn(DirectionalLightBundle { - transform: Transform::from_xyz(1.0, 1.0, 0.0).looking_at(Vec3::ZERO, Vec3::Y), - ..default() - }); + commands.spawn(( + DirectionalLight::default(), + Transform::from_xyz(1.0, 1.0, 0.0).looking_at(Vec3::ZERO, Vec3::Y), + )); scene_handle.has_light = true; } diff --git a/examples/transforms/3d_rotation.rs b/examples/transforms/3d_rotation.rs index c98ffa42ead92..d84e05f9cef8d 100644 --- a/examples/transforms/3d_rotation.rs +++ b/examples/transforms/3d_rotation.rs @@ -41,10 +41,10 @@ fn setup( }); // Add a light source so we can see clearly. - commands.spawn(DirectionalLightBundle { - transform: Transform::from_xyz(3.0, 3.0, 3.0).looking_at(Vec3::ZERO, Vec3::Y), - ..default() - }); + commands.spawn(( + DirectionalLight::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. diff --git a/examples/transforms/align.rs b/examples/transforms/align.rs index 4e9c9f50a5275..c1c483df6a146 100644 --- a/examples/transforms/align.rs +++ b/examples/transforms/align.rs @@ -67,14 +67,13 @@ fn setup( }); // A light source - commands.spawn(PointLightBundle { - point_light: PointLight { + commands.spawn(( + PointLight { shadows_enabled: true, ..default() }, - transform: Transform::from_xyz(4.0, 7.0, -4.0), - ..default() - }); + Transform::from_xyz(4.0, 7.0, -4.0), + )); // Initialize random axes let first = seeded_rng.gen(); diff --git a/examples/transforms/scale.rs b/examples/transforms/scale.rs index 7284e5f7ea035..a38aad53547a9 100644 --- a/examples/transforms/scale.rs +++ b/examples/transforms/scale.rs @@ -57,10 +57,10 @@ fn setup( }); // Add a light source for better 3d visibility. - commands.spawn(DirectionalLightBundle { - transform: Transform::from_xyz(3.0, 3.0, 3.0).looking_at(Vec3::ZERO, Vec3::Y), - ..default() - }); + commands.spawn(( + DirectionalLight::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 diff --git a/examples/transforms/transform.rs b/examples/transforms/transform.rs index 14f732fecb665..a2cea7e36aee3 100644 --- a/examples/transforms/transform.rs +++ b/examples/transforms/transform.rs @@ -86,10 +86,10 @@ fn setup( }); // Add a light source for better 3d visibility. - commands.spawn(DirectionalLightBundle { - transform: Transform::from_xyz(3.0, 3.0, 3.0).looking_at(Vec3::ZERO, Vec3::Y), - ..default() - }); + commands.spawn(( + DirectionalLight::default(), + Transform::from_xyz(3.0, 3.0, 3.0).looking_at(Vec3::ZERO, Vec3::Y), + )); } // This system will move the cube forward. diff --git a/examples/transforms/translation.rs b/examples/transforms/translation.rs index 8e339349d7cda..a2c9a876d75ab 100644 --- a/examples/transforms/translation.rs +++ b/examples/transforms/translation.rs @@ -55,10 +55,10 @@ fn setup( }); // Add a light source for better 3d visibility. - commands.spawn(DirectionalLightBundle { - transform: Transform::from_xyz(3.0, 3.0, 3.0).looking_at(Vec3::ZERO, Vec3::Y), - ..default() - }); + commands.spawn(( + DirectionalLight::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 diff --git a/examples/ui/render_ui_to_texture.rs b/examples/ui/render_ui_to_texture.rs index 8e9305231e3df..2a34e6b6b7da4 100644 --- a/examples/ui/render_ui_to_texture.rs +++ b/examples/ui/render_ui_to_texture.rs @@ -51,7 +51,7 @@ fn setup( let image_handle = images.add(image); // Light - commands.spawn(DirectionalLightBundle::default()); + commands.spawn(DirectionalLight::default()); let texture_camera = commands .spawn(Camera2dBundle { diff --git a/examples/window/low_power.rs b/examples/window/low_power.rs index 4a612922a17d7..44b60d49a115b 100644 --- a/examples/window/low_power.rs +++ b/examples/window/low_power.rs @@ -179,10 +179,10 @@ pub(crate) mod test_setup { Rotator, )); - commands.spawn(DirectionalLightBundle { - transform: Transform::from_xyz(1.0, 1.0, 1.0).looking_at(Vec3::ZERO, Vec3::Y), - ..default() - }); + commands.spawn(( + DirectionalLight::default(), + Transform::from_xyz(1.0, 1.0, 1.0).looking_at(Vec3::ZERO, Vec3::Y), + )); commands.spawn(Camera3dBundle { transform: Transform::from_xyz(-2.0, 2.0, 2.0).looking_at(Vec3::ZERO, Vec3::Y), ..default() diff --git a/examples/window/multiple_windows.rs b/examples/window/multiple_windows.rs index 18d17084d3253..40b120570f8d8 100644 --- a/examples/window/multiple_windows.rs +++ b/examples/window/multiple_windows.rs @@ -17,10 +17,10 @@ fn setup_scene(mut commands: Commands, asset_server: Res) { ..default() }); // light - commands.spawn(DirectionalLightBundle { - transform: Transform::from_xyz(3.0, 3.0, 3.0).looking_at(Vec3::ZERO, Vec3::Y), - ..default() - }); + commands.spawn(( + DirectionalLight::default(), + Transform::from_xyz(3.0, 3.0, 3.0).looking_at(Vec3::ZERO, Vec3::Y), + )); let first_window_camera = commands .spawn(Camera3dBundle { diff --git a/examples/window/screenshot.rs b/examples/window/screenshot.rs index c8dc4d0011fe0..3c4e00e83f811 100644 --- a/examples/window/screenshot.rs +++ b/examples/window/screenshot.rs @@ -72,14 +72,13 @@ fn setup( ..default() }); // light - commands.spawn(PointLightBundle { - point_light: PointLight { + commands.spawn(( + PointLight { shadows_enabled: true, ..default() }, - transform: Transform::from_xyz(4.0, 8.0, 4.0), - ..default() - }); + Transform::from_xyz(4.0, 8.0, 4.0), + )); // camera commands.spawn(Camera3dBundle { transform: Transform::from_xyz(-2.0, 2.5, 5.0).looking_at(Vec3::ZERO, Vec3::Y), diff --git a/tests/window/minimising.rs b/tests/window/minimising.rs index 12d0826573eed..4517d6cf4d979 100644 --- a/tests/window/minimising.rs +++ b/tests/window/minimising.rs @@ -47,14 +47,13 @@ fn setup_3d( ..default() }); // light - commands.spawn(PointLightBundle { - point_light: PointLight { + commands.spawn(( + PointLight { shadows_enabled: true, ..default() }, - transform: Transform::from_xyz(4.0, 8.0, 4.0), - ..default() - }); + Transform::from_xyz(4.0, 8.0, 4.0), + )); // camera commands.spawn(Camera3dBundle { transform: Transform::from_xyz(-2.0, 2.5, 5.0).looking_at(Vec3::ZERO, Vec3::Y), diff --git a/tests/window/resizing.rs b/tests/window/resizing.rs index 3cb6d4913a294..df4b1f78f56b2 100644 --- a/tests/window/resizing.rs +++ b/tests/window/resizing.rs @@ -123,14 +123,13 @@ fn setup_3d( ..default() }); // light - commands.spawn(PointLightBundle { - point_light: PointLight { + commands.spawn(( + PointLight { shadows_enabled: true, ..default() }, - transform: Transform::from_xyz(4.0, 8.0, 4.0), - ..default() - }); + Transform::from_xyz(4.0, 8.0, 4.0), + )); // camera commands.spawn(Camera3dBundle { transform: Transform::from_xyz(-2.0, 2.5, 5.0).looking_at(Vec3::ZERO, Vec3::Y),