@@ 15,6 15,8 @@ bevy_dice = { path = "../bevy_dice" }
avian3d = { version = "0.3", default-features = false }
bevy = { version = "0.16", default-features = false, features = [
"async_executor",
+ "bevy_core_pipeline",
+ "bevy_pbr",
"bevy_render",
"bevy_state",
"bevy_window",
@@ 4,16 4,10 @@
* This file is licensed under MIT, see LICENSE for more information.
*/
-use std::{collections::HashMap, f32::consts::PI};
+use std::collections::HashMap;
use avian3d::prelude::*;
-use bevy::{
- asset::LoadState,
- core_pipeline::bloom::Bloom,
- pbr::{Atmosphere, light_consts::lux::RAW_SUNLIGHT},
- prelude::*,
- render::camera::Exposure,
-};
+use bevy::{asset::LoadState, prelude::*};
use bevy_dice::{DicePlugin, DicePluginConfig, Die, DieVariant, ThrowDie};
use bevy_egui::{EguiContextPass, EguiContexts, EguiPlugin, egui};
use bevy_embedded_assets::EmbeddedAssetPlugin;
@@ 65,7 59,7 @@ fn main() {
app.init_resource::<UIState>()
.add_systems(EguiContextPass, ui);
- app.add_systems(Update, rotate_sun);
+ app.add_systems(Update, rotate_light);
app.add_observer(despawn_dice);
@@ 109,24 103,16 @@ fn setup(
));
commands.spawn((
- DirectionalLight {
+ PointLight {
shadows_enabled: true,
- illuminance: RAW_SUNLIGHT,
..default()
},
- Transform::from_xyz(1.0, 3.0, 0.0).looking_at(Vec3::ZERO, Vec3::Y),
+ Transform::from_xyz(4.0, 8.0, 0.0),
));
commands.spawn((
Camera3d::default(),
- Camera {
- hdr: true,
- ..Default::default()
- },
Transform::from_xyz(-2.5, 4.5, 9.0).looking_at(Vec3::ZERO, Dir3::Y),
- Atmosphere::EARTH,
- Exposure::SUNLIGHT,
- Bloom::NATURAL,
));
commands.insert_resource(DicePluginConfig {
@@ 218,8 204,11 @@ fn despawn_dice(
}
}
-fn rotate_sun(mut q_suns: Query<&mut Transform, With<DirectionalLight>>, r_time: Res<Time>) {
- q_suns
- .iter_mut()
- .for_each(|mut transform| transform.rotate_y(-r_time.delta_secs() * PI / 10.0));
+fn rotate_light(mut q_lights: Query<&mut Transform, With<PointLight>>, r_time: Res<Time>) {
+ q_lights.iter_mut().for_each(|mut transform| {
+ transform.rotate_around(
+ Vec3::new(0.0, 0.0, 0.0),
+ Quat::from_euler(EulerRot::XYZ, 0.0, 0.5 * r_time.delta_secs(), 0.0),
+ )
+ });
}