byte-engine 0.1.0

A composable Rust game engine focused on graphics, input, audio, physics, and retained UI.
use math::Vector3;

use super::super::cct;
use crate::{
	core::{Entity, EntityHandle},
	inspector::Inspectable,
	rendering::lights::{Light, LightClasses},
};

/// The `PointLight` struct provides omnidirectional scene lighting from a local
/// source, such as a light bulb.
#[derive(Debug, Clone, Copy)]
pub struct PointLight {
	pub position: Vector3,
	pub color: Vector3,
}

impl PointLight {
	pub fn new(position: Vector3, cct: f32) -> Self {
		Self {
			position,
			color: cct::rgb_from_temperature(cct),
		}
	}
}

impl Light for PointLight {
	fn class(&self) -> LightClasses {
		LightClasses::Point
	}
}

impl Inspectable for PointLight {
	fn as_string(&self) -> String {
		format!("{:?}", self)
	}
}