Preserve untouched Track Cube rotation angles

This commit is contained in:
dotCooCoo committed 2026-11-27 07:40:43 -08:00
1 parent 37fc94d291
commit cc0b8ad623
4 files changed
+83 -3

No files matched your search

+75 -2
View File
@@ -74,7 +74,8 @@ fn tidy(degrees: f64) -> f64 {
/// The X, Y and Z angles of rotation `m`. Of the two sets of angles that make it, the one nearest
/// `near` (so a turn moves the fields as little as it can); with Y at ±90°, where X and Z turn about
/// the same axis, X keeps its value from `near`.
/// the same axis, X keeps its value from `near`. An unchanged axis keeps its original precision;
/// only an angle that actually turned is tidied to the fields' precision.
fn angles_of(m: M3, near: [f64; 3]) -> [f64; 3] {
let y = (-m[2][0]).clamp(-1.0, 1.0).asin().to_degrees();
let candidates = if m[2][1].hypot(m[2][2]) < 1e-9 {
@@ -87,7 +88,11 @@ fn angles_of(m: M3, near: [f64; 3]) -> [f64; 3] {
[Some([x, y, z]), Some([x + 180.0, 180.0 - y, z + 180.0])]
};
let distance = |a: &[f64; 3]| a.iter().zip(near).map(|(a, b)| tidy(a - b).abs()).sum::<f64>();
candidates.into_iter().flatten().min_by(|a, b| distance(a).total_cmp(&distance(b))).unwrap_or(near).map(tidy)
let chosen = candidates.into_iter().flatten().min_by(|a, b| distance(a).total_cmp(&distance(b))).unwrap_or(near);
std::array::from_fn(|i| {
let delta = (chosen[i] - near[i] + 180.0).rem_euclid(360.0) - 180.0;
if delta.abs() <= 1e-9 { near[i] } else { tidy(chosen[i]) }
})
}
/// Where corner `i` of the cube (bit 0 for +X, bit 1 for +Y, bit 2 for +Z) is drawn.
@@ -392,6 +397,7 @@ impl Component for TrackCube<'_> {
/// The track cube's row on the Rotation page of the 3D (Classic) effects. It reads and writes `rotationX`, `rotationY` and
/// `rotationZ` (a missing one reads the effect's default) and only writes an angle that changes; the dialog's preview applies
/// them and OK records them as one undo step. Its control's events go to the rows, so a drag previews and Escape restores.
/// A screen-plane turn changes Z while retaining the original precision of X and Y.
pub(crate) fn row() -> Param {
Param::custom("__trackCube", tl!("Track cube"), |ui, fields, cx| {
let defaults = vectorcraft_effects::default_params(fields.text("__effect").unwrap_or_default()).unwrap_or(json!({}));
@@ -455,3 +461,70 @@ fn paint_cube(painter: &egui::Painter, s: &RowStyle, rect: Rect, m: M3, active:
#[cfg(test)]
#[path = "tests_track_cube.rs"]
mod tests;
#[cfg(test)]
mod precision_tests {
use super::*;
use crate::VectorcraftApp;
use crate::tests::panel_harness::Panel;
use craft::ui::patterns::form_dialogs::{DialogFields, HostedParamDialog};
use egui::{Key, Modifiers};
use serde_json::Value;
use vectorcraft_effects::CLASSIC_ROTATE;
fn fields(panel: &Panel) -> DialogFields {
panel.app().dialogs().unwrap().with(|host| host.get::<HostedParamDialog>().unwrap().fields().clone())
}
fn stored(panel: &Panel, node: u64) -> Value {
panel.app().session.active().unwrap().doc.node(vectorcraft_doc::NodeId(node)).unwrap().appearance.effects[0].params.clone()
}
#[test]
fn screen_plane_keys_preserve_the_untouched_rotation_axes_through_preview_and_ok() {
let initial = [17.234567, 23.456789, 9.06];
for (key, z) in [(Key::PageDown, 10.06), (Key::PageUp, 8.06)] {
for save in [false, true] {
let mut app = crate::testing::windowed(VectorcraftApp::new(vectorcraft_engine::Session::new(), Default::default()));
app.run("file.new", json!({"width": 200, "height": 200})).unwrap();
let node = app.run("shape.rectangle", json!({"x": 20, "y": 20, "width": 80, "height": 80})).unwrap()["id"].as_u64().unwrap();
app.run("select.set", json!({"ids": [node]})).unwrap();
app.run(
"effect.apply",
json!({"effect": CLASSIC_ROTATE, "ids": [node], "item": null,
"params": {"rotationX": initial[0], "rotationY": initial[1], "rotationZ": initial[2]}}),
)
.unwrap();
let original = app.session.active().unwrap().doc.clone();
let undo = app.session.active().unwrap().history.undo.len();
let mut panel = Panel::new(app, crate::tests::picks::dialogs);
panel.room(egui::vec2(1100.0, 1100.0));
panel.app().run("effect.dialog", json!({"effect": CLASSIC_ROTATE, "index": 0, "item": null})).unwrap();
panel.frame();
panel.frame();
assert!(panel.app().dialogs().unwrap().with(|host| host.get::<HostedParamDialog>().unwrap().is_previewing()));
let read = |value: &DialogFields| ROTATION_KEYS.map(|key| value.number(key).unwrap());
assert_eq!(read(&fields(&panel)), initial, "the real dialog opens on the exact fractional rotations");
panel.click_role("Track cube", Role::SLIDER);
assert_eq!(read(&fields(&panel)), initial, "a click without a drag moves no axis");
panel.key(key, Modifiers::NONE);
let expected = [initial[0], initial[1], z];
assert_eq!(read(&fields(&panel)), expected, "a screen-plane turn changes only Euler Z");
let preview = stored(&panel, node);
assert_eq!(ROTATION_KEYS.map(|key| preview[key].as_f64().unwrap()), expected);
assert_eq!(panel.app().session.active().unwrap().history.undo.len(), undo);
panel.click(if save { "OK" } else { "Cancel" });
panel.frame();
panel.frame();
assert!(!panel.app().dialogs().unwrap().with(|host| host.is_open::<HostedParamDialog>()));
assert_eq!(panel.app().session.active().unwrap().history.undo.len(), undo + usize::from(save));
if save {
let applied = stored(&panel, node);
assert_eq!(ROTATION_KEYS.map(|key| applied[key].as_f64().unwrap()), expected);
panel.app().run("edit.undo", json!({})).unwrap();
}
assert_eq!(panel.app().session.active().unwrap().doc, original);
}
}
}
}
+2
View File
@@ -5959,6 +5959,8 @@ and No Shading and Diffuse Shading as the only surfaces for an object that uses
The defaults and the shading are VectorCraft's own. An unknown parameter (`highlightSize` and `drawHiddenFaces`
included), a number out of range, a flag that is not true or false, a surface other than `none` or `diffuse`, or
another shading color is refused with an error and the document is not changed.
In all three Classic dialogs, the track cube retains untouched rotation components at their original precision;
Page Up and Page Down change Z without rounding fractional X and Y values.
```json
{"name":"run_command","arguments":{"command":"effect.apply","params":{"effect":"threeD.classicRotate","item":null,"params":{"rotationX":0,"rotationY":40,"rotationZ":0,"surface":"diffuse","blendSteps":64}}}}
+3
View File
@@ -372,6 +372,8 @@ presets, drawn at the current X, Y and Z rotation inside a ring
The drag changes the effect's `rotationX`, `rotationY` and `rotationZ` and previews live; X, Y and Z and the
presets follow it (**Custom** off a preset). OK keeps the change as one undo step. The angles stay between -180°
and 180°: of the two sets of angles that give the same turn, the cube writes the one nearest the current values.
Untouched axes retain their original precision; only a changed axis is rounded to the fields' precision. Page Up
and Page Down change Z while preserving fractional X and Y values.
In the 3D and Materials panel, a drag is one undo step when the pointer is released, and the cube is off while the
selected effects hold different rotations. The cube's 0.5° per point of drag, Escape during a drag and its keyboard
steps are VectorCraft's own.
@@ -757,6 +759,7 @@ Release measurements and a repeatable CLI scene are in [3D lighting performance]
| Date | Change |
|---|---|
| 2026-11-27 | Classic track cube screen-plane keyboard turns preserve untouched fractional X/Y angles through preview, OK, Cancel and Undo. |
| 2026-11-13 | Extrude & Bevel cuts its walls into slices only for a twist. A taper alone keeps each wall flat, so it is one face, without the light ticks at the joints between slices or the light line down a wall (#7019). Inflate still slices its sides for a taper. |
| 2026-11-12 | The seams of Extrude & Bevel, Inflate and Rotate under a white light, and of the faces of Extrude & Bevel (Classic), Revolve (Classic) and Rotate (Classic), went from miter to round joins (the seams of Revolve and of colored lights, and 3D (Classic) Wireframe edges, were already round): no thorns on edge-on facets, and facets with no neighbor now have rounded convex corners ([Seams](#seams)). |
| 2026-11-08 | Contours that cross, touch or overlap are merged by vectorcraft-pathops before Extrude & Bevel, Inflate and Rotate build a solid, sharing its limits; others are built as drawn. |
+3 -1
View File
@@ -1,6 +1,6 @@
# UI and interaction parity
> **Last reviewed:** 2026-10-10 · **Last updated:** 2026-11-25 · **Change:** minor (G12: History row menus adapted to shared Craft list/menu controls after rebase (#8845); scores and estimates unchanged; previously: G12/M14: History row context menus, pending-edit snapshot targeting, keyboard access and document-switch dismissal (#8845); scores and estimates unchanged; previously: Pencil Edit Selected Paths follows lifted strokes, carves, loops, closes and redraws compound paths; Layers: a targeted item with an appearance of its own keeps its inner ring visible around a smaller appearance dot, so the target circle's four looks differ, #8711; scores and estimates unchanged; previously: G12: Asset Export tile context menus; scores and estimates unchanged; previously: Properties panel per context (G12): contextual text Quick Actions (Create Outlines, Retype, Find and Replace…); scores and estimates unchanged; previously: Layers: a targeted item with an appearance of its own keeps its inner ring visible around a smaller appearance dot, so the target circle's four looks differ, #8711; scores and estimates unchanged; previously: Trim View hides the ruler guides, guide paths and the grid while it is on and greys out Show/Hide Guides and Show/Hide Grid, #8363; scores and estimates unchanged; previously: Scissors shows the actual proposed cut point while hovering, using its existing snapping and cut target (#8655); scores and estimates unchanged; previously: Graphic Styles panel: right-click item context menu for tiles and rows with Options, Duplicate, Delete, Redefine, Break Link; scores and estimates unchanged; previously: Artboard tool: Shift held once a move or Alt-copy drag is under way keeps it to the level, upright or 45° line, #8580; scores and estimates unchanged; previously: Image Trace Ignore Color keeps the canvas View and stays armed on a missed pixel (#8068); Canvas context menu: a right-click on a path offers Simplify… next to Smooth…, opening the Simplify slider, or the Simplify dialog kept for next time, as Object › Path › Simplify… does, #8344; scores and estimates unchanged; previously: a tool drag held near an edge of the canvas scrolls the view, #8551; scores and estimates unchanged; previously: G12: Place: show progress window with Cancel for slow placed files exceeding 0.4 s, part of #5930; scores and estimates unchanged; previously: All Tools drawer: a tool the toolbar holds is dimmed in the readable dim text colour, not the disabled colour that was unreadable against the panel, and a hovered dimmed row takes the panel's darker fill so it stays readable, #8294; scores and estimates unchanged; previously: : selected guide rows stay highlighted after the pointer leaves (#7344); scores and estimates unchanged; previously: Layersselected Dimension extension-line color and weight in Properties (#7078; four focused UI regressions passed); scores and estimates unchanged; previously: Brush Options Key Color: restore canvas input for the existing one-shot pick, then resume the retained draft and previous tool (#8284; six full-app input regressions passed); scores and estimates unchanged; previously: Ellipse: Up/Down changes Anchors while drawing (#7840); scores and estimates unchanged; previously: Windows/Linux menu access keys and localized cues (#6596); previously: Backquote/~ arrow pattern nudges (#7717); scores and estimates unchanged; previously: Window > Toolbars > Compact Tools offers optional denser main Tools spacing (#7234); default layout, scores and estimates unchanged; previously: Direct Selection: Space during an ordinary path's handle drag repositions its anchor and handles, including a Pen loan (#7237, request 3 only; scores and estimates unchanged); previously: Floating panels keep their window level while focus moves between the app's windows, so a press on one panel's bar no longer hands the keyboard to another, #6986; scores and estimates unchanged; previously minor: Lock Guides: a selection marquee (Selection, Direct Selection, Group Selection, Enclosing Lasso) leaves out paths made into guides inside groups and compound paths too, as clicks do (#3074), so a group is no longer selected by a locked guide in it; an enclosing marquee measures a group without its locked or hidden guides, and Direct Selection takes no anchor or segment of a guide that can't be picked; a guide in a group still moves with its group (#8538); scores and estimates unchanged; previously: Production Preflight: output-aware fonts, text overflow, linked files and effective image resolution, clickable findings and automatic rechecking; scores and estimates unchanged; previously: Layers panel: an Alt-drag copies a row above or below itself, so the top layer dragged up, the bottom layer dragged down and a lone layer are copied, #8237; scores and estimates unchanged; previously: Layers panel: Alt over the list shows the copy cursor while rows or the selected-art square are dragged, #8217; scores andLine truncated
> **Last reviewed:** 2026-10-10 · **Last updated:** 2026-11-27 · **Change:** minor (Classic 3D track cube: preserve untouched fractional rotation axes; scores and estimates unchanged; previously: G12: History row menus adapted to shared Craft list/menu controls after rebase (#8845); scores and estimates unchanged; previously: G12/M14: History row context menus, pending-edit snapshot targeting, keyboard access and document-switch dismissal (#8845); scores and estimates unchanged; previously: Pencil Edit Selected Paths follows lifted strokes, carves, loops, closes and redraws compound paths; Layers: a targeted item with an appearance of its own keeps its inner ring visible around a smaller appearance dot, so the target circle's four looks differ, #8711; scores and estimates unchanged; previously: G12: Asset Export tile context menus; scores and estimates unchanged; previously: Properties panel per context (G12): contextual text Quick Actions (Create Outlines, Retype, Find and Replace…); scores and estimates unchanged; previously: Layers: a targeted item with an appearance of its own keeps its inner ring visible around a smaller appearance dot, so the target circle's four looks differ, #8711; scores and estimates unchanged; previously: Trim View hides the ruler guides, guide paths and the grid while it is on and greys out Show/Hide Guides and Show/Hide Grid, #8363; scores and estimates unchanged; previously: Scissors shows the actual proposed cut point while hovering, using its existing snapping and cut target (#8655); scores and estimates unchanged; previously: Graphic Styles panel: right-click item context menu for tiles and rows with Options, Duplicate, Delete, Redefine, Break Link; scores and estimates unchanged; previously: Artboard tool: Shift held once a move or Alt-copy drag is under way keeps it to the level, upright or 45° line, #8580; scores and estimates unchanged; previously: Image Trace Ignore Color keeps the canvas View and stays armed on a missed pixel (#8068); Canvas context menu: a right-click on a path offers Simplify… next to Smooth…, opening the Simplify slider, or the Simplify dialog kept for next time, as Object › Path › Simplify… does, #8344; scores and estimates unchanged; previously: a tool drag held near an edge of the canvas scrolls the view, #8551; scores and estimates unchanged; previously: G12: Place: show progress window with Cancel for slow placed files exceeding 0.4 s, part of #5930; scores and estimates unchanged; previously: All Tools drawer: a tool the toolbar holds is dimmed in the readable dim text colour, not the disabled colour that was unreadable against the panel, and a hovered dimmed row takes the panel's darker fill so it stays readable, #8294; scores and estimates unchanged; previously: : selected guide rows stay highlighted after the pointer leaves (#7344); scores and estimates unchanged; previously: Layersselected Dimension extension-line color and weight in Properties (#7078; four focused UI regressions passed); scores and estimates unchanged; previously: Brush Options Key Color: restore canvas input for the existing one-shot pick, then resume the retained draft and previous tool (#8284; six full-app input regressions passed); scores and estimates unchanged; previously: Ellipse: Up/Down changes Anchors while drawing (#7840); scores and estimates unchanged; previously: Windows/Linux menu access keys and localized cues (#6596); previously: Backquote/~ arrow pattern nudges (#7717); scores and estimates unchanged; previously: Window > Toolbars > Compact Tools offers optional denser main Tools spacing (#7234); default layout, scores and estimates unchanged; previously: Direct Selection: Space during an ordinary path's handle drag repositions its anchor and handles, including a Pen loan (#7237, request 3 only; scores and estimates unchanged); previously: Floating panels keep their window level while focus moves between the app's windows, so a press on one panel's bar no longer hands the keyboard to another, #6986; scores and estimates unchanged; previously minor: Lock Guides: a selection marquee (Selection, Direct Selection, Group Selection, Enclosing Lasso) leaves out paths made into guides inside groups and compound paths too, as clicks do (#3074), so a group is no longer selected by a locked guide in it; an enclosing marquee measures a group without its locked or hidden guides, and Direct Selection takes no anchor or segment of a guide that can't be picked; a guide in a group still moves with its group (#8538); scores and estimates unchanged; previously: Production Preflight: output-aware fonts, text overflow, linked files and effective image resolution, clickable findings and automatic rechecking; scores and estimates unchanged; previously: Layers panel: an Alt-drag copies a row above or below itself, so the top layer dragged up, the bottom layer dragged down and a lone layer are copied, #8237; scores and estimates unchanged; previously: Layers panLine truncated
>
> Tech Circuit update (2026-11-14): three original procedural brushes; ten built-in brush libraries (G5).
>
@@ -70,6 +70,7 @@ Artboard Options forwards the active Artboard tool's Scale Artwork with Artboard
| Date | Change | Summary |
|---|---|---|
| 2026-11-27 | minor | Classic 3D track cube: screen-plane keyboard turns retain untouched fractional X/Y angles through preview, OK, Cancel and Undo. Scores and estimates unchanged. |
| 2026-11-24 | minor | G12: History row context menus use shared Craft List and Menu controls after rebasing onto the panel migration. App-specific actions retain the chosen snapshot across pending edits and dismiss on document switches; keyboard context requests and focus restoration use the shared runtime. Regression cases retained (#8845); scores and estimates unchanged. |
| 2026-11-21 | minor | G12/M14: History row context menus retain the chosen snapshot while the menu is open and pending edits settle; jumps settle typing before counting undo/redo, and discarded states report that they are unavailable. Shift+F10 opens the focused row menu, Escape restores row focus, and switching documents dismisses the popup. History checklist, area and milestone evidence updated (#8845); scores and estimates unchanged. |
| 2026-11-20 | minor | G12: Asset Export tiles have item context menus for Export, Remove, Rename, Select Artwork on Canvas and collecting selected artwork; right-click selects an unselected tile and preserves an existing multi-selection. Headless regressions: panels::tests_asset_export. Scores and estimates unchanged. |
@@ -643,6 +644,7 @@ before release (#6373). [Paint faces and edges](https://helpx.adobe.com/illustra
| Date | Change | Summary |
|---|---|---|
| 2026-11-27 | minor | Classic 3D track cube preserves untouched rotation precision; scores and estimates unchanged. |
| 2026-11-26 | minor | #8744: native-canvas sampler-owned release/Zoom regression source, retaining ordinary navigation, dock rejection, accepted sampling, document/selection/paint/history controls and no idle replay. Runtime pending; scores, gaps and hours unchanged. |
| 2026-11-24 | minor | G12: History row context menus use shared Craft List and Menu controls after rebasing onto the panel migration. App-specific actions retain the chosen snapshot across pending edits and dismiss on document switches; keyboard context requests and focus restoration use the shared runtime. Regression cases retained (#8845); scores and estimates unchanged. |
| 2026-11-23 | minor | Gradient stop editor: a compact Color-tab menu offers Grayscale Slider, RGB Sliders, HSB Sliders, CMYK Sliders and Web Color Sliders, sharing the Color panel mode and conversion behavior (#7918). Choosing a mode keeps the editor open; Escape closes the menu first. Scores and estimates unchanged. |