summaryrefslogtreecommitdiff
path: root/engine/src/lighting.rs
diff options
context:
space:
mode:
Diffstat (limited to 'engine/src/lighting.rs')
-rw-r--r--engine/src/lighting.rs97
1 files changed, 6 insertions, 91 deletions
diff --git a/engine/src/lighting.rs b/engine/src/lighting.rs
index e285739..c5369db 100644
--- a/engine/src/lighting.rs
+++ b/engine/src/lighting.rs
@@ -6,57 +6,15 @@ use crate::vector::Vec3;
#[derive(Debug, Clone, Component)]
pub struct LightSource
{
- position: Vec3<f32>,
- ambient: Color<f32>,
- diffuse: Color<f32>,
- specular: Color<f32>,
+ pub position: Vec3<f32>,
+ pub ambient: Color<f32>,
+ pub diffuse: Color<f32>,
+ pub specular: Color<f32>,
}
-impl LightSource
+impl Default for LightSource
{
- #[must_use]
- pub fn position(&self) -> &Vec3<f32>
- {
- &self.position
- }
-
- #[must_use]
- pub fn ambient(&self) -> &Color<f32>
- {
- &self.ambient
- }
-
- #[must_use]
- pub fn diffuse(&self) -> &Color<f32>
- {
- &self.diffuse
- }
-
- #[must_use]
- pub fn specular(&self) -> &Color<f32>
- {
- &self.specular
- }
-
- pub fn translate(&mut self, translation: Vec3<f32>)
- {
- self.position += translation;
- }
-}
-
-#[derive(Debug, Clone, Default)]
-pub struct LightSourceBuilder
-{
- position: Vec3<f32>,
- ambient: Color<f32>,
- diffuse: Color<f32>,
- specular: Color<f32>,
-}
-
-impl LightSourceBuilder
-{
- #[must_use]
- pub fn new() -> Self
+ fn default() -> Self
{
Self {
position: Vec3::default(),
@@ -65,47 +23,4 @@ impl LightSourceBuilder
specular: Color { red: 1.0, green: 1.0, blue: 1.0 },
}
}
-
- #[must_use]
- pub fn position(mut self, position: Vec3<f32>) -> Self
- {
- self.position = position;
-
- self
- }
-
- #[must_use]
- pub fn ambient(mut self, ambient: Color<f32>) -> Self
- {
- self.ambient = ambient;
-
- self
- }
-
- #[must_use]
- pub fn diffuse(mut self, diffuse: Color<f32>) -> Self
- {
- self.diffuse = diffuse;
-
- self
- }
-
- #[must_use]
- pub fn specular(mut self, specular: Color<f32>) -> Self
- {
- self.specular = specular;
-
- self
- }
-
- #[must_use]
- pub fn build(&self) -> LightSource
- {
- LightSource {
- position: self.position.clone(),
- ambient: self.ambient.clone(),
- diffuse: self.diffuse.clone(),
- specular: self.specular.clone(),
- }
- }
}