//! The test world: lighting and a physics-collidable arena to explore.

mod level;
mod lighting;

pub use level::spawn_level;
pub use lighting::{
    spawn_sun, sync_project_sun_from_settings, sync_project_sun_illuminance,
    sync_project_sun_visibility, sync_scene_directional_shadow_cascades,
};

use bevy::prelude::*;
use settings::ProjectSettings;

#[unsafe(no_mangle)]
pub fn apply_ambient_light(mut commands: Commands, settings: Res<ProjectSettings>) {
    let rendering = &settings.rendering;
    commands.insert_resource(GlobalAmbientLight {
        color: Color::srgb(
            rendering.ambient_color[0],
            rendering.ambient_color[1],
            rendering.ambient_color[2],
        ),
        brightness: rendering.ambient_brightness,
        ..default()
    });
}
