From 5c50ac33e32a6b19323d4d0499c79f112aa0f2fe Mon Sep 17 00:00:00 2001 From: hut Date: Mon, 1 Apr 2024 18:06:41 +0200 Subject: [PATCH] move global illumination from world.rs to camera.rs --- src/camera.rs | 19 +++++++++++++++++++ src/world.rs | 18 ------------------ 2 files changed, 19 insertions(+), 18 deletions(-) diff --git a/src/camera.rs b/src/camera.rs index 31fed12..d4b5f89 100644 --- a/src/camera.rs +++ b/src/camera.rs @@ -3,9 +3,11 @@ use bevy::input::mouse::MouseMotion; use bevy::window::PrimaryWindow; use bevy::core_pipeline::bloom::{BloomCompositeMode, BloomSettings}; use bevy::core_pipeline::tonemapping::Tonemapping; +use bevy::pbr::CascadeShadowConfigBuilder; use bevy::transform::TransformSystem; use bevy::math::DVec3; use bevy_xpbd_3d::prelude::*; +use std::f32::consts::PI; use crate::{settings, audio, actor}; pub struct CameraPlugin; @@ -46,6 +48,23 @@ pub fn setup_camera( ..default() }, )); + + // Add Light from the Sun + commands.spawn(DirectionalLightBundle { + directional_light: DirectionalLight { + illuminance: 1000.0, + shadows_enabled: false, + ..default() + }, + transform: Transform::from_rotation(Quat::from_rotation_y(PI/2.0)), + cascade_shadow_config: CascadeShadowConfigBuilder { + first_cascade_far_bound: 7.0, + maximum_distance: 25.0, + ..default() + } + .into(), + ..default() + }); } pub fn sync_camera_to_player( diff --git a/src/world.rs b/src/world.rs index 695cc75..a895f26 100644 --- a/src/world.rs +++ b/src/world.rs @@ -1,6 +1,5 @@ use crate::{actor, nature, settings}; use bevy::prelude::*; -use bevy::pbr::CascadeShadowConfigBuilder; use bevy::render::render_resource::{AsBindGroup, ShaderRef}; use bevy::math::DVec3; use bevy_xpbd_3d::prelude::*; @@ -180,23 +179,6 @@ pub fn setup( Position::from_xyz(0.0, 0.0, 0.0), Rotation::from(Quat::from_rotation_z(1f32.to_radians())), )); - - // Add Light from the Sun - commands.spawn(DirectionalLightBundle { - directional_light: DirectionalLight { - illuminance: 1000.0, - shadows_enabled: false, - ..default() - }, - transform: Transform::from_rotation(Quat::from_rotation_y(PI/2.0)), - cascade_shadow_config: CascadeShadowConfigBuilder { - first_cascade_far_bound: 7.0, - maximum_distance: 25.0, - ..default() - } - .into(), - ..default() - }); } fn handle_cheats(