Skip to content

Commit f45af33

Browse files
committed
All lights working in lights example
1 parent 030516b commit f45af33

File tree

1 file changed

+40
-11
lines changed

1 file changed

+40
-11
lines changed

examples/lights.rs

Lines changed: 40 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -31,18 +31,47 @@ fn sketch() -> error::Result<()> {
3131

3232
// We will only declare lights in `setup`
3333
// rather than calling some sort of `light()` method inside of `draw`
34-
let _dir_light = light_create_directional(
34+
let dir_light = light_create_directional(
3535
graphics,
3636
0.0,
3737
0.0,
3838
0.0,
39-
bevy::color::Color::srgb(1.0, 0.0, 0.0),
39+
bevy::color::Color::srgb(0.35, 0.25, 0.5),
4040
1000.0,
4141
)?;
42+
transform_set_position(dir_light, 10.0, 10.0, 0.0)?;
43+
44+
let point_light = light_create_point(
45+
graphics,
46+
100.0,
47+
100.0,
48+
10.0,
49+
bevy::color::Color::srgb(1.0, 0.5, 0.25),
50+
1_000_000.0,
51+
20.0,
52+
0.0,
53+
)?;
54+
transform_set_position(point_light, 10.0, 10.0, 0.0)?;
55+
transform_look_at(point_light, 0.0, 0.0, 0.0)?;
56+
57+
let spot_light = light_create_spot(
58+
graphics,
59+
-15.0,
60+
-15.0,
61+
0.0,
62+
bevy::color::Color::srgb(0.25, 0.5, 0.88),
63+
1_000_000.0,
64+
25.0,
65+
0.6,
66+
0.8,
67+
core::f32::consts::FRAC_PI_4,
68+
)?;
69+
transform_set_position(spot_light, 5.0, 7.5, 10.0)?;
70+
transform_look_at(spot_light, 0.0, 0.0, 0.0)?;
4271

4372
graphics_mode_3d(graphics)?;
44-
graphics_camera_position(graphics, 100.0, 100.0, 300.0)?;
45-
graphics_camera_look_at(graphics, 0.0, 0.0, 0.0)?;
73+
transform_set_position(graphics, 100.0, 100.0, 300.0)?;
74+
transform_look_at(graphics, 0.0, 0.0, 0.0)?;
4675

4776
let mut angle = 0.0;
4877

@@ -54,15 +83,15 @@ fn sketch() -> error::Result<()> {
5483
DrawCommand::BackgroundColor(bevy::color::Color::srgb(0.18, 0.20, 0.15)),
5584
)?;
5685

57-
graphics_record_command(graphics, DrawCommand::PushMatrix)?;
58-
graphics_record_command(graphics, DrawCommand::Translate { x: 25.0, y: 25.0 })?;
59-
graphics_record_command(graphics, DrawCommand::Rotate { angle })?;
60-
graphics_record_command(graphics, DrawCommand::Geometry(box_geo))?;
61-
graphics_record_command(graphics, DrawCommand::PopMatrix)?;
86+
// graphics_record_command(graphics, DrawCommand::PushMatrix)?;
87+
// graphics_record_command(graphics, DrawCommand::Translate { x: 0.0, y: 0.0 })?;
88+
// graphics_record_command(graphics, DrawCommand::Rotate { angle })?;
89+
// graphics_record_command(graphics, DrawCommand::Geometry(box_geo))?;
90+
// graphics_record_command(graphics, DrawCommand::PopMatrix)?;
6291

6392
graphics_record_command(graphics, DrawCommand::PushMatrix)?;
64-
graphics_record_command(graphics, DrawCommand::Translate { x: -25.0, y: 20.0 })?;
65-
graphics_record_command(graphics, DrawCommand::Scale { x: 1.5, y: 2.0 })?;
93+
graphics_record_command(graphics, DrawCommand::Translate { x: 0.0, y: 0.0 })?;
94+
// graphics_record_command(graphics, DrawCommand::Scale { x: 5.0, y: 5.0 })?;
6695
graphics_record_command(graphics, DrawCommand::Rotate { angle })?;
6796
graphics_record_command(graphics, DrawCommand::Geometry(box_geo))?;
6897
graphics_record_command(graphics, DrawCommand::PopMatrix)?;

0 commit comments

Comments
 (0)