Fix #64: one 3D compass in the viewer

Two implementations of Show 3D Reference Axes had landed (M13.5 and M14.5) and both drew,
offset by a few pixels: lines, and arrows. Keep the arrowed one (perspective-correct, shown
while a 3D layer is active) and test that only one is drawn.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
bflatasticandClaude Opus 5.5 committed 2026-10-05 23:48:41 +07:00
1 parent 0dcbe325ab
commit 77c056a8db
2 files changed
+2 -17

No files matched your search

-17
View File
@@ -653,23 +653,6 @@ pub fn show(app: &mut EffectcraftApp, ui: &mut egui::Ui, rect: Rect) {
}
app.auto.add("viewer.regionOfInterest", r, "Region of interest");
}
// 3D Reference Axes (grid and guide options): the world axes as seen by the view's camera.
if app.session.prefs.three_d.show_reference_axes && comp.layers.iter().any(|l| l.is_3d()) {
let cam = cam_state(&ectx);
let o = pos2(area.min.x + 40.0, area.max.y - 40.0);
for (axis, col, name) in [
(effectcraft_engine::geom::vec3(1.0, 0.0, 0.0), Color32::from_rgb(0xe0, 0x40, 0x40), "X"),
(effectcraft_engine::geom::vec3(0.0, 1.0, 0.0), Color32::from_rgb(0x50, 0xd0, 0x50), "Y"),
(effectcraft_engine::geom::vec3(0.0, 0.0, 1.0), Color32::from_rgb(0x50, 0x80, 0xf0), "Z"),
] {
let v = cam.view.apply_vec(axis);
let tip = o + vec2(v.x as f32, v.y as f32) * 26.0;
painter.line_segment([o, tip], Stroke::new(2.0, col));
painter.text(tip + (tip - o).normalized() * 7.0, Align2::CENTER_CENTER, name, Tokens::ui(10.0), col);
}
app.auto.add("viewer.referenceAxes", Rect::from_center_size(o, vec2(64.0, 64.0)), "3D Reference Axes");
}
// Overlays + interaction.
let selected = app.session.state.selected_layers.clone();
let mut handle_hits: Vec<(LayerId, usize, Pos2)> = Vec::new();
+2
View File
@@ -391,6 +391,8 @@ fn reference_axes_toggle_from_the_grid_menu() {
h.state_mut().session.execute("layer.setSwitch", json!({"layers": [box_id.0], "switch": "threeD", "value": true})).unwrap();
h.run_steps(3);
assert!(h.state().auto.find("viewer.referenceAxes").is_some(), "on by default (Settings ▸ 3D)");
// Issue #64: one compass, not two.
assert_eq!(h.state().auto.query("viewer.referenceAxes").len(), 1);
let g = rect(&h, "viewer.grid").center();
click(&mut h, g);
h.run_steps(2);