Skip to content

Commit a6663cd

Browse files
authored
Try #2367:
2 parents 00d8d5d + 11328a3 commit a6663cd

File tree

4 files changed

+24
-5
lines changed

4 files changed

+24
-5
lines changed

crates/bevy_pbr/src/entity.rs

+14-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
1-
use crate::{light::PointLight, material::StandardMaterial, render_graph::PBR_PIPELINE_HANDLE};
1+
use crate::{
2+
light::{DirectionalLight, PointLight},
3+
material::StandardMaterial,
4+
render_graph::PBR_PIPELINE_HANDLE,
5+
};
26
use bevy_asset::Handle;
37
use bevy_ecs::bundle::Bundle;
48
use bevy_render::{
@@ -40,10 +44,18 @@ impl Default for PbrBundle {
4044
}
4145
}
4246

43-
/// A component bundle for "light" entities
47+
/// A component bundle for "point light" entities
4448
#[derive(Debug, Bundle, Default)]
4549
pub struct PointLightBundle {
4650
pub point_light: PointLight,
4751
pub transform: Transform,
4852
pub global_transform: GlobalTransform,
4953
}
54+
55+
/// A component bundle for "directional light" entities
56+
#[derive(Debug, Bundle, Default)]
57+
pub struct DirectionalLightBundle {
58+
pub directional_light: DirectionalLight,
59+
pub transform: Transform,
60+
pub global_transform: GlobalTransform,
61+
}

crates/bevy_pbr/src/lib.rs

+1
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ impl Plugin for PbrPlugin {
3232
fn build(&self, app: &mut AppBuilder) {
3333
app.add_asset::<StandardMaterial>()
3434
.register_type::<PointLight>()
35+
.register_type::<DirectionalLight>()
3536
.add_system_to_stage(
3637
CoreStage::PostUpdate,
3738
shader::asset_shader_defs_system::<StandardMaterial>.system(),

crates/bevy_pbr/src/light.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ impl Default for DirectionalLight {
109109
fn default() -> Self {
110110
DirectionalLight {
111111
color: Color::rgb(1.0, 1.0, 1.0),
112-
illuminance: 100000.0,
112+
illuminance: 100_000.0,
113113
direction: Vec3::new(0.0, -1.0, 0.0),
114114
}
115115
}

examples/3d/3d_scene.rs

+8-2
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,14 @@ fn setup(
2828
..Default::default()
2929
});
3030
// light
31-
commands.spawn_bundle(PointLightBundle {
32-
transform: Transform::from_xyz(4.0, 8.0, 4.0),
31+
let transform = Transform::from_xyz(4.0, 8.0, 4.0).looking_at(Vec3::ZERO, Vec3::Y);
32+
let mut directional_light = DirectionalLight::default();
33+
directional_light.illuminance = 10_000.0;
34+
directional_light.set_direction(transform.forward());
35+
36+
commands.spawn_bundle(DirectionalLightBundle {
37+
transform,
38+
directional_light,
3339
..Default::default()
3440
});
3541
// camera

0 commit comments

Comments
 (0)