primase_core/
light_translucency.rs1use crate::{Component, Entity, Geometry, JsonError, World};
3use serde::Serialize;
4
5#[derive(Clone, Copy, Debug, PartialEq, Serialize)]
9pub struct LightTranslucency {
10 pub strength: f32,
11 pub exponent_scale: f32,
12}
13impl Component for LightTranslucency {
14 const NAME: &'static str = "core.light_translucency";
15 const GEOMETRY: Geometry = Geometry::None;
16 fn to_json(&self) -> Result<Option<serde_json::Value>, JsonError> {
17 crate::json::to_value(self).map(Some)
18 }
19 fn verify(&self, _e: Entity, _w: &World) -> Result<(), String> {
20 if !self.strength.is_finite()
21 || self.strength < 0.
22 || !self.exponent_scale.is_finite()
23 || self.exponent_scale <= 0.
24 {
25 return Err(
26 "light translucency requires finite nonnegative strength and positive exponent scale".into(),
27 );
28 }
29 Ok(())
30 }
31}