54 lines
1.4 KiB
Rust
54 lines
1.4 KiB
Rust
//! Lighting and ground plane setup
|
|
|
|
use bevy::prelude::*;
|
|
|
|
pub struct RenderingPlugin;
|
|
|
|
impl Plugin for RenderingPlugin {
|
|
fn build(&self, app: &mut App) {
|
|
app.add_systems(Startup, setup_lighting_and_ground);
|
|
}
|
|
}
|
|
|
|
/// Set up lighting and ground plane
|
|
///
|
|
/// Creates a directional light (sun), ambient light, and a green ground plane.
|
|
/// Camera setup is handled separately in the camera module.
|
|
fn setup_lighting_and_ground(
|
|
mut commands: Commands,
|
|
mut meshes: ResMut<Assets<Mesh>>,
|
|
mut materials: ResMut<Assets<StandardMaterial>>,
|
|
) {
|
|
info!("Setting up lighting and ground plane");
|
|
|
|
// Directional light (sun)
|
|
commands.spawn((
|
|
DirectionalLight {
|
|
illuminance: 10000.0,
|
|
shadows_enabled: true,
|
|
..default()
|
|
},
|
|
Transform::from_xyz(4.0, 8.0, 4.0).looking_at(Vec3::ZERO, Vec3::Y),
|
|
));
|
|
|
|
// Ambient light
|
|
commands.insert_resource(AmbientLight {
|
|
color: Color::WHITE,
|
|
brightness: 150.0,
|
|
affects_lightmapped_meshes: false,
|
|
});
|
|
|
|
// Ground plane
|
|
commands.spawn((
|
|
Mesh3d(meshes.add(Plane3d::default().mesh().size(20.0, 20.0))),
|
|
MeshMaterial3d(materials.add(StandardMaterial {
|
|
base_color: Color::srgb(0.3, 0.5, 0.3),
|
|
perceptual_roughness: 0.9,
|
|
..default()
|
|
})),
|
|
Transform::from_xyz(0.0, 0.0, 0.0),
|
|
));
|
|
|
|
info!("Lighting and ground setup complete");
|
|
}
|