mirror of
https://github.com/storytold/storyteller-bevy.git
synced 2026-10-18 07:35:19 +00:00
Scene in memory persistance and debug tools (#24)
 Debug tools example --------- Co-authored-by: Danny McGee <dannymcgee@gmail.com>
This commit is contained in:
@@ -3,13 +3,14 @@ use bevy::{
|
||||
prelude::*,
|
||||
render::view::RenderLayers,
|
||||
};
|
||||
use space_editor::space_editor_ui::NotShowCamera;
|
||||
|
||||
use crate::MainCamera;
|
||||
|
||||
use super::GIZMO_RENDER_LAYER;
|
||||
|
||||
#[derive(Component)]
|
||||
pub(super) struct GizmoCamera;
|
||||
pub struct GizmoCamera;
|
||||
|
||||
pub(super) fn spawn_gizmo_camera(
|
||||
mut cmd: Commands,
|
||||
@@ -35,6 +36,22 @@ pub(super) fn spawn_gizmo_camera(
|
||||
},
|
||||
RenderLayers::layer(GIZMO_RENDER_LAYER),
|
||||
Fxaa::default(),
|
||||
NotShowCamera,
|
||||
));
|
||||
});
|
||||
}
|
||||
|
||||
pub(super) fn sync_gizmo_and_main_cameras(
|
||||
q_main_camera: Query<&Camera, (With<MainCamera>, Without<GizmoCamera>)>,
|
||||
mut q_gizmo_camera: Query<&mut Camera, (With<GizmoCamera>, Without<MainCamera>)>,
|
||||
) {
|
||||
let Ok(main_cam) = q_main_camera.get_single() else {
|
||||
return;
|
||||
};
|
||||
|
||||
let Ok(mut gizmo_cam) = q_gizmo_camera.get_single_mut() else {
|
||||
return;
|
||||
};
|
||||
|
||||
gizmo_cam.viewport = main_cam.viewport.clone();
|
||||
}
|
||||
|
||||
@@ -13,7 +13,7 @@ use self::{
|
||||
|
||||
use super::{Selection, TransformMode, TransformType};
|
||||
|
||||
mod camera;
|
||||
pub mod camera;
|
||||
mod combo;
|
||||
mod common;
|
||||
mod resources;
|
||||
@@ -62,6 +62,10 @@ impl Plugin for GizmoPlugin {
|
||||
normalize_gizmo_scale.after(CameraMotionSystem),
|
||||
),
|
||||
);
|
||||
|
||||
//sync camera viewports
|
||||
app.add_systems(Update, camera::sync_gizmo_and_main_cameras);
|
||||
|
||||
app.add_systems(
|
||||
PostUpdate,
|
||||
update_ss_ring_rotation.after(TransformSystem::TransformPropagate),
|
||||
@@ -139,10 +143,10 @@ fn spawn_gizmo(
|
||||
|
||||
fn sync_gizmo_transform(
|
||||
mut cmd: Commands,
|
||||
mut q_gizmo: Query<(&mut Transform, &TransformGizmo)>,
|
||||
mut q_gizmo: Query<(Entity, &mut Transform, &TransformGizmo)>,
|
||||
q_targets: Query<&GlobalTransform>,
|
||||
) {
|
||||
for (mut transform, gizmo) in q_gizmo.iter_mut() {
|
||||
for (ent, mut transform, gizmo) in q_gizmo.iter_mut() {
|
||||
if let Ok(target) = q_targets.get(gizmo.target) {
|
||||
match gizmo.transform_space {
|
||||
super::TransformSpace::Local => {
|
||||
@@ -155,7 +159,7 @@ fn sync_gizmo_transform(
|
||||
}
|
||||
}
|
||||
} else {
|
||||
cmd.entity(gizmo.target).despawn_recursive();
|
||||
cmd.entity(ent).despawn_recursive();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user