oxide_engine/light/
components.rs1use glam::Vec3;
4
5use oxide_ecs::Component;
6
7#[derive(Component, Clone, Copy, Debug)]
9pub struct DirectionalLight {
10 pub direction: Vec3,
12 pub color: Vec3,
14 pub intensity: f32,
16}
17
18impl Default for DirectionalLight {
19 fn default() -> Self {
20 Self {
21 direction: Vec3::NEG_Y,
22 color: Vec3::ONE,
23 intensity: 1.0,
24 }
25 }
26}
27
28impl DirectionalLight {
29 pub fn new(direction: Vec3, color: Vec3, intensity: f32) -> Self {
31 Self {
32 direction: direction.normalize(),
33 color,
34 intensity,
35 }
36 }
37}
38
39#[derive(Component, Clone, Copy, Debug)]
41pub struct PointLight {
42 pub position: Vec3,
44 pub color: Vec3,
46 pub intensity: f32,
48 pub radius: f32,
50}
51
52impl Default for PointLight {
53 fn default() -> Self {
54 Self {
55 position: Vec3::ZERO,
56 color: Vec3::ONE,
57 intensity: 1.0,
58 radius: 10.0,
59 }
60 }
61}
62
63impl PointLight {
64 pub fn new(position: Vec3, color: Vec3, intensity: f32, radius: f32) -> Self {
66 Self {
67 position,
68 color,
69 intensity,
70 radius,
71 }
72 }
73}
74
75#[derive(Component, Clone, Copy, Debug)]
78pub struct AmbientLight {
79 pub color: Vec3,
81 pub intensity: f32,
83}
84
85impl Default for AmbientLight {
86 fn default() -> Self {
87 Self {
88 color: Vec3::ONE,
89 intensity: 0.2,
90 }
91 }
92}
93
94impl AmbientLight {
95 pub fn new(color: Vec3, intensity: f32) -> Self {
97 Self { color, intensity }
98 }
99}