@@ -9,27 +9,80 @@ impl Plugin for LightPlugin {
99 fn build ( & self , _app : & mut App ) { }
1010}
1111
12- #[ derive( Component ) ]
13- pub struct Light {
14- pub light_type : LightType ,
15- pub pos : Vec3 ,
12+ pub fn create_directional (
13+ In ( ( px, py, pz, r, g, b, a, illuminance) ) : In < ( f32 , f32 , f32 , f32 , f32 , f32 , f32 , f32 ) > ,
14+ mut commands : Commands ,
15+ ) -> Entity {
16+ commands
17+ . spawn ( (
18+ DirectionalLight {
19+ illuminance,
20+ color : Color :: srgba ( r, g, b, a) ,
21+ ..default ( )
22+ } ,
23+ Transform :: from_xyz ( px, py, pz) ,
24+ ) )
25+ . id ( )
1626}
1727
18- #[ derive( Clone , Copy , Debug , PartialEq , Eq ) ]
19- pub enum LightType {
20- Directional ,
21- Point ,
22- Spot ,
28+ pub fn create_point (
29+ In ( ( px, py, pz, r, g, b, a, intensity, range, radius) ) : In < (
30+ f32 ,
31+ f32 ,
32+ f32 ,
33+ f32 ,
34+ f32 ,
35+ f32 ,
36+ f32 ,
37+ f32 ,
38+ f32 ,
39+ f32 ,
40+ ) > ,
41+ mut commands : Commands ,
42+ ) -> Entity {
43+ commands
44+ . spawn ( (
45+ PointLight {
46+ intensity,
47+ color : Color :: srgba ( r, g, b, a) ,
48+ range,
49+ radius,
50+ ..default ( )
51+ } ,
52+ Transform :: from_xyz ( px, py, pz) ,
53+ ) )
54+ . id ( )
2355}
2456
25- pub fn create (
26- In ( ( light_type, x, y, z) ) : In < ( LightType , f32 , f32 , f32 ) > ,
57+ pub fn create_spot (
58+ In ( ( px, py, pz, r, g, b, a, intensity, range, radius, inner_angle, outer_angle) ) : In < (
59+ f32 ,
60+ f32 ,
61+ f32 ,
62+ f32 ,
63+ f32 ,
64+ f32 ,
65+ f32 ,
66+ f32 ,
67+ f32 ,
68+ f32 ,
69+ f32 ,
70+ f32 ,
71+ ) > ,
2772 mut commands : Commands ,
2873) -> Entity {
29- match light_type {
30- LightType :: Directional => commands
31- . spawn ( ( DirectionalLight :: default ( ) , Transform :: from_xyz ( x, y, z) ) )
32- . id ( ) ,
33- _ => commands. spawn ( DirectionalLight :: default ( ) ) . id ( ) ,
34- }
74+ commands
75+ . spawn ( (
76+ SpotLight {
77+ color : Color :: srgba ( r, g, b, a) ,
78+ intensity,
79+ range,
80+ radius,
81+ inner_angle,
82+ outer_angle,
83+ ..default ( )
84+ } ,
85+ Transform :: from_xyz ( px, py, pz) ,
86+ ) )
87+ . id ( )
3588}
0 commit comments