mirror of
https://github.com/storytold/storyteller-bevy.git
synced 2026-10-17 00:13:17 +00:00
Fix gizmo depth sorting (#46)
Small patch for the `GizmoMaterial` that fixes depth sorting for non-translucent elements by setting their blend mode to `AlphaMode::Opaque`
This commit is contained in:
@@ -15,7 +15,7 @@ impl From<Color> for GizmoMaterial {
|
||||
fn from(color: Color) -> Self {
|
||||
GizmoMaterial {
|
||||
color,
|
||||
blend_mode: AlphaMode::Blend,
|
||||
blend_mode: AlphaMode::Opaque,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -102,9 +102,13 @@ pub(super) fn init_resources(
|
||||
let rotate_x = ra_mats.add(design_system::Color::RED.into());
|
||||
let rotate_y = ra_mats.add(design_system::Color::GREEN.into());
|
||||
let rotate_z = ra_mats.add(design_system::Color::BLUE.into());
|
||||
let rotate_trackball = ra_mats.add(Color::WHITE.with_a(0.0).into());
|
||||
let rotate_ss = ra_mats.add(Color::WHITE.into());
|
||||
|
||||
let rotate_trackball = ra_mats.add(GizmoMaterial {
|
||||
color: Color::WHITE.with_a(0.0),
|
||||
blend_mode: AlphaMode::Blend,
|
||||
});
|
||||
|
||||
cmd.insert_resource(GizmoMats {
|
||||
translate_x,
|
||||
translate_y,
|
||||
|
||||
@@ -239,11 +239,17 @@ pub(super) fn on_rotate(
|
||||
q_widget: Query<&RotationWidget>,
|
||||
) {
|
||||
// Components from the gizmo root (the entity being transformed)
|
||||
let (mut xform, parent, init_xform, init_point, mut last_point, mut last_rotation) =
|
||||
q_root.single_mut();
|
||||
|
||||
let gizmo_xform = q_gizmo.single();
|
||||
let (cam, cam_xform) = q_camera.single();
|
||||
let Ok((mut xform, parent, init_xform, init_point, mut last_point, mut last_rotation)) =
|
||||
q_root.get_single_mut()
|
||||
else {
|
||||
return;
|
||||
};
|
||||
let Ok(gizmo_xform) = q_gizmo.get_single() else {
|
||||
return;
|
||||
};
|
||||
let Ok((cam, cam_xform)) = q_camera.get_single() else {
|
||||
return;
|
||||
};
|
||||
|
||||
// `Transform::rotate_axis` takes an axis vector relative to the transform's
|
||||
// _parent_. We'll use the gizmo root's parent's global transform (if it
|
||||
|
||||
Reference in New Issue
Block a user