Skip to main content

he3d_core/
light.rs

1use he3d_math::Vec3;
2
3use crate::Rgb;
4
5/// A directional light: a parallel light ray direction plus color/strength.
6/// 方向光:一条平行光线方向加上颜色/强度。
7#[derive(Clone, Copy, PartialEq, Debug)]
8pub struct DirectionalLight {
9   /// Ray direction (not a position); will be normalized by the renderer.
10   /// 光线方向(不是位置);渲染器会将其归一化。
11   pub direction: Vec3,
12   /// Light color and strength.
13   /// 光的颜色和强度。
14   pub color: Rgb,
15   /// Base brightness added to every lit surface.
16   /// 添加到每个被照亮表面的基础亮度。
17   pub ambient: f32,
18}
19
20impl Default for DirectionalLight {
21   fn default() -> Self {
22      Self {
23         direction: Vec3::new(0.0, -1.0, 1.0),
24         color: Rgb::WHITE,
25         ambient: 0.15,
26      }
27   }
28}