pub struct Light { /* private fields */ }Expand description
A light source contributing illumination to a shaded point.
The fields have meanings that depend on LightType:
- For
LightType::Directional,positionis unused anddirectionis the unit vector pointing from the surface toward the light. - For
LightType::Point,positionis the world position of the light anddirectionis unused. - For
LightType::Spot, bothpositionanddirectionare meaningful andspot_coscarriescos(half_angle)of the spotlight cone.
Implementations§
Source§impl Light
Implements factory constructors and shading for Light, Material,
and LightingUniforms.
impl Light
Implements factory constructors and shading for Light, Material,
and LightingUniforms.
Sourcepub fn new_directional(direction: Vector3D, color: Vector3D) -> Light
pub fn new_directional(direction: Vector3D, color: Vector3D) -> Light
Creates a new directional light pointing in direction with color.
The direction is normalized internally; intensity defaults to 1.0.
Falloff and spot half-angle are unused for directional lights.
§Arguments
Vector3D- The unit direction toward the light source.Vector3D- The RGB intensity multiplier.
§Returns
Light- The new directional light.
Sourcepub fn new_point(position: Vector3D, color: Vector3D, intensity: f64) -> Light
pub fn new_point(position: Vector3D, color: Vector3D, intensity: f64) -> Light
Creates a new point light at position with color and intensity.
Falloff defaults to 1.0 (inverse-square). The direction field is
unused for point lights and is set to the zero vector.
§Arguments
Vector3D- The world-space position of the light.Vector3D- The RGB intensity multiplier.f64- The intensity scalar.
§Returns
Light- The new point light.
Sourcepub fn new_spot(
position: Vector3D,
direction: Vector3D,
color: Vector3D,
intensity: f64,
half_angle_rad: f64,
) -> Light
pub fn new_spot( position: Vector3D, direction: Vector3D, color: Vector3D, intensity: f64, half_angle_rad: f64, ) -> Light
Creates a new spotlight at position shining in direction.
The cone is defined by half_angle_rad; the cosine of that angle
is stored for fast cone-test comparisons during shading.
§Arguments
Vector3D- The world-space position of the light.Vector3D- The unit direction the cone opens along.Vector3D- The RGB intensity multiplier.f64- The intensity scalar.f64- The half-angle of the cone in radians.
§Returns
Light- The new spotlight.
Source§impl Light
impl Light
pub fn get_kind(&self) -> LightType
pub fn get_mut_kind(&mut self) -> &mut LightType
pub fn set_kind(&mut self, val: LightType) -> &mut Self
pub fn get_position(&self) -> Vector3D
pub fn get_mut_position(&mut self) -> &mut Vector3D
pub fn set_position(&mut self, val: Vector3D) -> &mut Self
pub fn get_direction(&self) -> Vector3D
pub fn get_mut_direction(&mut self) -> &mut Vector3D
pub fn set_direction(&mut self, val: Vector3D) -> &mut Self
pub fn get_color(&self) -> Vector3D
pub fn get_mut_color(&mut self) -> &mut Vector3D
pub fn set_color(&mut self, val: Vector3D) -> &mut Self
pub fn get_intensity(&self) -> f64
pub fn get_mut_intensity(&mut self) -> &mut f64
pub fn set_intensity(&mut self, val: f64) -> &mut Self
pub fn get_falloff(&self) -> f64
pub fn get_mut_falloff(&mut self) -> &mut f64
pub fn set_falloff(&mut self, val: f64) -> &mut Self
pub fn get_spot_cos(&self) -> f64
pub fn get_mut_spot_cos(&mut self) -> &mut f64
pub fn set_spot_cos(&mut self, val: f64) -> &mut Self
Trait Implementations§
impl StructuralPartialEq for Light
Auto Trait Implementations§
impl Freeze for Light
impl RefUnwindSafe for Light
impl Send for Light
impl Sync for Light
impl Unpin for Light
impl UnsafeUnpin for Light
impl UnwindSafe for Light
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more