Path: blob/main/crates/bevy_solari/src/realtime/extract.rs
6596 views
use super::{prepare::SolariLightingResources, SolariLighting};1use bevy_camera::Camera;2use bevy_ecs::system::{Commands, ResMut};3use bevy_pbr::deferred::SkipDeferredLighting;4use bevy_render::{sync_world::RenderEntity, MainWorld};56pub fn extract_solari_lighting(mut main_world: ResMut<MainWorld>, mut commands: Commands) {7let mut cameras_3d = main_world.query::<(RenderEntity, &Camera, Option<&mut SolariLighting>)>();89for (entity, camera, solari_lighting) in cameras_3d.iter_mut(&mut main_world) {10let mut entity_commands = commands11.get_entity(entity)12.expect("Camera entity wasn't synced.");13if let Some(mut solari_lighting) = solari_lighting14&& camera.is_active15{16entity_commands.insert((solari_lighting.clone(), SkipDeferredLighting));17solari_lighting.reset = false;18} else {19entity_commands.remove::<(20SolariLighting,21SolariLightingResources,22SkipDeferredLighting,23)>();24}25}26}272829