mod extract;
mod node;
mod pipeline;
mod plugin;
mod prepare;
pub(super) mod prelude {
pub(super) use super::extract::{
ExtractedAmbientLight2d, ExtractedLight2dMeta, ExtractedPointLight2d,
};
pub(super) use super::node::{Light2dCompositeNode, Light2dNode};
pub(super) use super::pipeline::{Light2dCompositePipeline, Light2dPipeline};
pub(crate) use super::plugin::{Light2dCompositeLabel, Light2dLabel, Light2dPlugin};
pub(super) use super::prepare::Light2dTextures;
pub(crate) use super::{AmbientLight2d, PointLight2d};
}
use bevy::{
camera::{
primitives::Aabb,
visibility::{Visibility, VisibilityClass, add_visibility_class},
},
color::Color,
ecs::component::Component,
math::Vec3A,
reflect::Reflect,
render::sync_world::SyncToRenderWorld,
transform::components::Transform,
};
#[derive(Component, Reflect, Clone, Copy)]
#[require(SyncToRenderWorld)]
pub struct AmbientLight2d {
pub color: Color,
pub intensity: f32,
}
impl Default for AmbientLight2d {
fn default() -> Self {
Self {
color: Color::WHITE,
intensity: 1.,
}
}
}
#[derive(Component, Reflect, Clone, Copy)]
#[require(SyncToRenderWorld, Transform, Visibility, VisibilityClass)]
#[component(on_add = add_visibility_class::<Self>)]
pub struct PointLight2d {
pub color: Color,
pub intensity: f32,
pub inner_radius: f32,
pub outer_radius: f32,
}
impl PointLight2d {
fn aabb(&self) -> Aabb {
Aabb {
center: Vec3A::ZERO,
half_extents: Vec3A::new(self.outer_radius, self.outer_radius, 0.),
}
}
}
impl Default for PointLight2d {
fn default() -> Self {
Self {
color: Color::WHITE,
intensity: 1.,
inner_radius: 0.,
outer_radius: 64.,
}
}
}