|
| 1 | +//! A light in Processing |
| 2 | +//! |
| 3 | +
|
| 4 | +use bevy::prelude::*; |
| 5 | + |
| 6 | +pub struct LightPlugin; |
| 7 | + |
| 8 | +impl Plugin for LightPlugin { |
| 9 | + fn build(&self, _app: &mut App) {} |
| 10 | +} |
| 11 | + |
| 12 | +pub fn create_directional( |
| 13 | + In((px, py, pz, r, g, b, a, illuminance)): In<(f32, f32, f32, f32, f32, f32, f32, f32)>, |
| 14 | + mut commands: Commands, |
| 15 | +) -> Entity { |
| 16 | + commands |
| 17 | + .spawn(( |
| 18 | + DirectionalLight { |
| 19 | + illuminance, |
| 20 | + color: Color::srgba(r, g, b, a), |
| 21 | + ..default() |
| 22 | + }, |
| 23 | + Transform::from_xyz(px, py, pz), |
| 24 | + )) |
| 25 | + .id() |
| 26 | +} |
| 27 | + |
| 28 | +pub fn create_point( |
| 29 | + In((px, py, pz, r, g, b, a, intensity, range, radius)): In<( |
| 30 | + f32, |
| 31 | + f32, |
| 32 | + f32, |
| 33 | + f32, |
| 34 | + f32, |
| 35 | + f32, |
| 36 | + f32, |
| 37 | + f32, |
| 38 | + f32, |
| 39 | + f32, |
| 40 | + )>, |
| 41 | + mut commands: Commands, |
| 42 | +) -> Entity { |
| 43 | + commands |
| 44 | + .spawn(( |
| 45 | + PointLight { |
| 46 | + intensity, |
| 47 | + color: Color::srgba(r, g, b, a), |
| 48 | + range, |
| 49 | + radius, |
| 50 | + ..default() |
| 51 | + }, |
| 52 | + Transform::from_xyz(px, py, pz), |
| 53 | + )) |
| 54 | + .id() |
| 55 | +} |
| 56 | + |
| 57 | +pub fn create_spot( |
| 58 | + In((px, py, pz, r, g, b, a, intensity, range, radius, inner_angle, outer_angle)): In<( |
| 59 | + f32, |
| 60 | + f32, |
| 61 | + f32, |
| 62 | + f32, |
| 63 | + f32, |
| 64 | + f32, |
| 65 | + f32, |
| 66 | + f32, |
| 67 | + f32, |
| 68 | + f32, |
| 69 | + f32, |
| 70 | + f32, |
| 71 | + )>, |
| 72 | + mut commands: Commands, |
| 73 | +) -> Entity { |
| 74 | + commands |
| 75 | + .spawn(( |
| 76 | + SpotLight { |
| 77 | + color: Color::srgba(r, g, b, a), |
| 78 | + intensity, |
| 79 | + range, |
| 80 | + radius, |
| 81 | + inner_angle, |
| 82 | + outer_angle, |
| 83 | + ..default() |
| 84 | + }, |
| 85 | + Transform::from_xyz(px, py, pz), |
| 86 | + )) |
| 87 | + .id() |
| 88 | +} |
0 commit comments