diff --git a/crates/bevy_pbr/src/entity.rs b/crates/bevy_pbr/src/entity.rs index 9b1d3c6314743..2c38dd7dd656c 100644 --- a/crates/bevy_pbr/src/entity.rs +++ b/crates/bevy_pbr/src/entity.rs @@ -1,4 +1,8 @@ -use crate::{light::PointLight, material::StandardMaterial, render_graph::PBR_PIPELINE_HANDLE}; +use crate::{ + light::{DirectionalLight, PointLight}, + material::StandardMaterial, + render_graph::PBR_PIPELINE_HANDLE, +}; use bevy_asset::Handle; use bevy_ecs::bundle::Bundle; use bevy_render::{ @@ -40,10 +44,18 @@ impl Default for PbrBundle { } } -/// A component bundle for "light" entities +/// A component bundle for "point light" entities #[derive(Debug, Bundle, Default)] pub struct PointLightBundle { pub point_light: PointLight, pub transform: Transform, pub global_transform: GlobalTransform, } + +/// A component bundle for "directional light" entities +#[derive(Debug, Bundle, Default)] +pub struct DirectionalLightBundle { + pub directional_light: DirectionalLight, + pub transform: Transform, + pub global_transform: GlobalTransform, +} diff --git a/crates/bevy_pbr/src/lib.rs b/crates/bevy_pbr/src/lib.rs index e279fe8b8d90f..8c8af37545b76 100644 --- a/crates/bevy_pbr/src/lib.rs +++ b/crates/bevy_pbr/src/lib.rs @@ -32,6 +32,7 @@ impl Plugin for PbrPlugin { fn build(&self, app: &mut AppBuilder) { app.add_asset::() .register_type::() + .register_type::() .add_system_to_stage( CoreStage::PostUpdate, shader::asset_shader_defs_system::.system(), diff --git a/crates/bevy_pbr/src/light.rs b/crates/bevy_pbr/src/light.rs index 343bb6888f38d..9d4804c8f055f 100644 --- a/crates/bevy_pbr/src/light.rs +++ b/crates/bevy_pbr/src/light.rs @@ -109,7 +109,7 @@ impl Default for DirectionalLight { fn default() -> Self { DirectionalLight { color: Color::rgb(1.0, 1.0, 1.0), - illuminance: 100000.0, + illuminance: 100_000.0, direction: Vec3::new(0.0, -1.0, 0.0), } } diff --git a/examples/3d/3d_scene.rs b/examples/3d/3d_scene.rs index 3aec65a2e82b9..924ccba3c9d81 100644 --- a/examples/3d/3d_scene.rs +++ b/examples/3d/3d_scene.rs @@ -28,8 +28,12 @@ fn setup( ..Default::default() }); // light - commands.spawn_bundle(PointLightBundle { - transform: Transform::from_xyz(4.0, 8.0, 4.0), + let transform = Transform::from_xyz(4.0, 8.0, 4.0).looking_at(Vec3::ZERO, Vec3::Y); + let directional_light = DirectionalLight::new(Color::WHITE, 10_000.0, transform.forward()); + + commands.spawn_bundle(DirectionalLightBundle { + directional_light, + transform, ..Default::default() }); // camera