use bevy::{
color::Color,
ecs::{bundle::Bundle, component::Component},
reflect::Reflect,
render::{
sync_world::SyncToRenderWorld,
view::{self, InheritedVisibility, ViewVisibility, Visibility, VisibilityClass},
},
transform::components::{GlobalTransform, Transform},
};
#[derive(Component, Clone, Reflect)]
#[require(SyncToRenderWorld, Transform, Visibility, VisibilityClass)]
#[component(on_add = view::add_visibility_class::<PointLight2d>)]
pub struct PointLight2d {
pub color: Color,
pub intensity: f32,
pub radius: f32,
pub falloff: f32,
pub cast_shadows: bool,
}
impl Default for PointLight2d {
fn default() -> Self {
Self {
color: Color::WHITE,
intensity: 1.0,
radius: 0.5,
falloff: 0.0,
cast_shadows: false,
}
}
}
#[derive(Bundle, Default)]
#[deprecated(
since = "0.5.0",
note = "Use the `PointLight2d` component instead. Inserting `PointLight2d` will also insert the other components required automatically."
)]
pub struct PointLight2dBundle {
pub point_light: PointLight2d,
pub transform: Transform,
pub global_transform: GlobalTransform,
pub visibility: Visibility,
pub inherited_visibility: InheritedVisibility,
pub view_visibility: ViewVisibility,
}
#[derive(Component, Clone, Reflect)]
pub struct AmbientLight2d {
pub color: Color,
pub brightness: f32,
}
impl Default for AmbientLight2d {
fn default() -> Self {
Self {
color: Color::WHITE,
brightness: 1.0,
}
}
}