You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
martian-chess/examples/shadow.rs

30 lines
751 B
Rust

use bevy::prelude::*;
fn main() {
App::new()
.add_plugins(DefaultPlugins)
.add_systems(Startup, init)
.add_systems(Update, add_shadows)
.run();
}
fn init(server: Res<AssetServer>, mut commands: Commands) {
commands.spawn(SceneBundle {
scene: server.load("models/shadow-example.gltf#Scene0"),
..default()
});
}
fn add_shadows(
mut lights: Query<(Entity, &mut PointLight), Added<PointLight>>,
mut commands: Commands,
) {
lights.iter_mut().for_each(|(e, mut l)| {
l.shadows_enabled = true;
let config: bevy::pbr::CascadeShadowConfig =
bevy::pbr::CascadeShadowConfigBuilder { ..default() }.into();
commands.entity(e).insert(config);
});
}