eulumdat_bevy/photometric/
light.rs1use super::PhotometricData;
7use bevy::prelude::*;
8use std::marker::PhantomData;
9
10#[derive(Component, Clone, Debug)]
27pub struct PhotometricLight<T: PhotometricData> {
28 pub data: T,
30 pub intensity_scale: f32,
32 pub show_solid: bool,
34 pub show_model: bool,
36 pub shadows_enabled: bool,
38}
39
40impl<T: PhotometricData> PhotometricLight<T> {
41 pub fn new(data: T) -> Self {
43 Self {
44 data,
45 intensity_scale: 1.0,
46 show_solid: false,
47 show_model: true,
48 shadows_enabled: false,
49 }
50 }
51
52 pub fn with_intensity_scale(mut self, scale: f32) -> Self {
54 self.intensity_scale = scale;
55 self
56 }
57
58 pub fn with_solid(mut self, show: bool) -> Self {
60 self.show_solid = show;
61 self
62 }
63
64 pub fn with_model(mut self, show: bool) -> Self {
66 self.show_model = show;
67 self
68 }
69
70 pub fn with_shadows(mut self, enabled: bool) -> Self {
72 self.shadows_enabled = enabled;
73 self
74 }
75}
76
77#[derive(Bundle, Clone)]
89pub struct PhotometricLightBundle<T: PhotometricData> {
90 pub light: PhotometricLight<T>,
92 pub transform: Transform,
94 pub global_transform: GlobalTransform,
96}
97
98impl<T: PhotometricData> PhotometricLightBundle<T> {
99 pub fn new(data: T) -> Self {
101 Self {
102 light: PhotometricLight::new(data),
103 transform: Transform::default(),
104 global_transform: GlobalTransform::default(),
105 }
106 }
107
108 pub fn with_transform(mut self, transform: Transform) -> Self {
110 self.transform = transform;
111 self
112 }
113
114 pub fn with_intensity_scale(mut self, scale: f32) -> Self {
116 self.light = self.light.with_intensity_scale(scale);
117 self
118 }
119
120 pub fn with_solid(mut self, show: bool) -> Self {
122 self.light = self.light.with_solid(show);
123 self
124 }
125
126 pub fn with_model(mut self, show: bool) -> Self {
128 self.light = self.light.with_model(show);
129 self
130 }
131
132 pub fn with_shadows(mut self, enabled: bool) -> Self {
134 self.light = self.light.with_shadows(enabled);
135 self
136 }
137}
138
139#[derive(Component)]
143pub struct BevyLightMarker<T: PhotometricData> {
144 pub parent: Entity,
146 _phantom: PhantomData<T>,
147}
148
149impl<T: PhotometricData> BevyLightMarker<T> {
150 pub fn new(parent: Entity) -> Self {
152 Self {
153 parent,
154 _phantom: PhantomData,
155 }
156 }
157}
158
159#[derive(Component)]
161pub struct PhotometricSolid<T: PhotometricData> {
162 pub parent: Entity,
164 _phantom: PhantomData<T>,
165}
166
167impl<T: PhotometricData> PhotometricSolid<T> {
168 pub fn new(parent: Entity) -> Self {
170 Self {
171 parent,
172 _phantom: PhantomData,
173 }
174 }
175}
176
177#[derive(Component)]
179pub struct LuminaireModel<T: PhotometricData> {
180 pub parent: Entity,
182 _phantom: PhantomData<T>,
183}
184
185impl<T: PhotometricData> LuminaireModel<T> {
186 pub fn new(parent: Entity) -> Self {
188 Self {
189 parent,
190 _phantom: PhantomData,
191 }
192 }
193}
194
195#[derive(Resource)]
197pub struct PhotometricPluginState<T: PhotometricData> {
198 _phantom: PhantomData<T>,
199}
200
201impl<T: PhotometricData> Default for PhotometricPluginState<T> {
202 fn default() -> Self {
203 Self {
204 _phantom: PhantomData,
205 }
206 }
207}