Finish refactor gizmo

This commit is contained in:
rewin
2024-01-11 22:16:13 +03:00
parent ce36fff9cd
commit 91ab46639a
4 changed files with 15 additions and 11 deletions
+1 -1
View File
@@ -32,7 +32,7 @@ web-sys = { version = "0.3.65", optional = true, features = [
"HtmlElement",
"Window",
] }
space_editor = {git = "https://github.com/rewin123/space_editor", rev = "f039601b6d286a5f9e3b09521623000d5bf3eb84"}
space_editor = {git = "https://github.com/rewin123/space_editor", rev = "c972e586114aabf4e44a8c82d29ad7045dd350d1"}
[features]
wasm = [
+4 -4
View File
@@ -39,7 +39,7 @@ pub(super) fn spawn_combo_translation_rotation_gizmo(
On::<Pointer<Out>>::run(on_gizmo_element_unhover),
On::<Pointer<DragStart>>::run(on_translation_start),
On::<Pointer<Drag>>::run(on_translate),
On::<Pointer<DragEnd>>::target_commands_mut(on_translation_end),
On::<Pointer<DragEnd>>::run(on_translation_end),
));
// Rotate X
@@ -78,7 +78,7 @@ pub(super) fn spawn_combo_translation_rotation_gizmo(
On::<Pointer<Out>>::run(on_gizmo_element_unhover),
On::<Pointer<DragStart>>::run(on_translation_start),
On::<Pointer<Drag>>::run(on_translate),
On::<Pointer<DragEnd>>::target_commands_mut(on_translation_end),
On::<Pointer<DragEnd>>::run(on_translation_end),
));
// Rotate Y
@@ -117,7 +117,7 @@ pub(super) fn spawn_combo_translation_rotation_gizmo(
On::<Pointer<Out>>::run(on_gizmo_element_unhover),
On::<Pointer<DragStart>>::run(on_translation_start),
On::<Pointer<Drag>>::run(on_translate),
On::<Pointer<DragEnd>>::target_commands_mut(on_translation_end),
On::<Pointer<DragEnd>>::run(on_translation_end),
));
// Rotate Z
@@ -156,7 +156,7 @@ pub(super) fn spawn_combo_translation_rotation_gizmo(
On::<Pointer<Out>>::run(on_gizmo_element_unhover),
On::<Pointer<DragStart>>::run(on_translation_start),
On::<Pointer<Drag>>::run(on_translate),
On::<Pointer<DragEnd>>::target_commands_mut(on_translation_end),
On::<Pointer<DragEnd>>::run(on_translation_end),
));
});
}
+7 -4
View File
@@ -36,7 +36,7 @@ pub(super) fn spawn_translation_gizmo(
On::<Pointer<Out>>::run(on_gizmo_element_unhover),
On::<Pointer<DragStart>>::run(on_translation_start),
On::<Pointer<Drag>>::run(on_translate),
On::<Pointer<DragEnd>>::target_commands_mut(on_translation_end),
On::<Pointer<DragEnd>>::run(on_translation_end),
))
.with_children(|cmd| {
use super::{CIRC_45, ROT_X, ROT_Y, ROT_Z};
@@ -215,10 +215,13 @@ pub(super) fn on_translation_start(
}
pub(super) fn on_translation_end(
_: &ListenerInput<Pointer<DragEnd>>,
cmd: &mut EntityCommands<'_, '_, '_>,
_: Listener<Pointer<DragEnd>>,
mut cmd: Commands,
q_initial_transforms: Query<Entity, With<InitialTransform>>,
) {
cmd.remove::<InitialTransform>();
for ent in q_initial_transforms.iter() {
cmd.entity(ent).remove::<InitialTransform>();
}
}
pub(super) fn on_translate(
+3 -2
View File
@@ -13,7 +13,7 @@ use bevy::{
scene::InstanceId,
};
use space_editor::prelude::PrefabMarker;
use space_editor::prelude::{PrefabMarker, space_undo::OneFrameUndoIgnore};
#[cfg(feature = "wasm")]
use wasm_bindgen::prelude::wasm_bindgen;
@@ -208,7 +208,8 @@ fn spawn_next_scene(
SceneRoot,
SceneElement,
SpatialBundle::default(),
PrefabMarker
PrefabMarker,
OneFrameUndoIgnore::default() //To prevert undo try to register add event
))
.id();