use serde::{Deserialize, Serialize};
#[derive(Default, Debug, Clone, Copy, PartialEq, Serialize, Deserialize)]
pub enum LightType {
#[default]
Directional,
Point,
Spot,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct Light {
pub light_type: LightType,
pub color: nalgebra_glm::Vec3,
pub intensity: f32,
pub range: f32,
pub inner_cone_angle: f32,
pub outer_cone_angle: f32,
pub cast_shadows: bool,
pub shadow_bias: f32,
#[serde(default)]
pub shadow_resolution: u32,
#[serde(default)]
pub shadow_distance: f32,
#[serde(default)]
pub cookie_texture: Option<String>,
}
impl Default for Light {
fn default() -> Self {
Self {
light_type: LightType::default(),
color: nalgebra_glm::Vec3::new(0.0, 0.0, 0.0),
intensity: 0.0,
range: 0.0,
inner_cone_angle: 0.0,
outer_cone_angle: 0.0,
cast_shadows: false,
shadow_bias: 0.0,
shadow_resolution: 0,
shadow_distance: 0.0,
cookie_texture: None,
}
}
}
impl Light {
pub fn with_shadows(mut self, bias: f32) -> Self {
self.cast_shadows = true;
self.shadow_bias = bias;
self
}
}