Skip to content

nodes(item): edit physical width, height, and depth directly in ItemPanel - #1308

Open
kruschdev wants to merge 4 commits into
pascalorg:mainfrom
kruschdev:feat/item-panel-editable-dimensions
Open

kruschdev wants to merge 4 commits into
pascalorg:mainfrom
kruschdev:feat/item-panel-editable-dimensions

Conversation

@kruschdev

@kruschdev kruschdev commented Nov 23, 2026 •

Copy link
Copy Markdown

What does this PR do?

Fixes #1307

Previously, the Dimensions readout under Scale in the shared item panel (packages/nodes/src/item/panel.tsx) was read-only, so resizing an item to an exact physical measurement required computing scale factors by hand.

I replaced the read-only Info row with an editable Dimensions section in the shared ItemPanel so both hosted and standalone editors support direct physical dimension entry:

  • Scale math and guards (packages/nodes/src/item/dimensions.ts): Added computeScaleForDimension and editableDimensionAxes. Editing axis i sets scale[i] = requested / asset.dimensions[i] (clamped at >= 0.01, preserving mirrored signs). When the aspect-ratio lock is on, all three axes scale by the same factor so the item keeps its aspect ratio (uniform items set all three axes to requested / asset.dimensions[i]); when off, only the edited axis changes. Missing, zero, negative, or non-finite asset.dimensions are guarded and fall back to the existing Scale controls.
  • Unit-aware inputs and single-step Undo (packages/nodes/src/item/panel.tsx): Added Width, Height, and Depth SliderControl rows (unit="m", precision={2}, step={0.01}) with a Lock Aspect Ratio toggle synced with the panel's uniform-scale state. Direct typed edits (respecting metric/imperial settings and unit suffixes such as 1 m, 90 cm, 36 in) and slider drags each record a single undo step via useScene.temporal, skip no-op writes, and cancel cleanly on Escape.
  • i18n catalogs: Extracted and compiled node.item.panel.width, node.item.panel.height, node.item.panel.depth, and node.item.panel.lockAspectRatio across en, es, fr, ja, and zh-CN (bun run i18n:check passes with 0 missing strings).
  • Tests (packages/nodes/src/item/panel.test.tsx): Added unit tests covering unlocked and aspect-locked scale math, mirrored signs, minimum scale clamping, missing/zero/partial-zero dimension guards, unit-aware ItemPanel controls, single-step Undo on typed edits and drags, no-op write suppression, and drag cancel rollback.

How to test

  1. Run bunx biome check packages/nodes/src/item/dimensions.ts packages/nodes/src/item/panel.tsx packages/nodes/src/item/panel.test.tsx.
  2. Run bun test packages/nodes/src/item/panel.test.tsx (7 pass, 0 fail).
  3. Run bun run i18n:check and bunx turbo run check-types --filter=@pascal-app/nodes --filter=@pascal-app/editor.
  4. Open an editor project, select a furniture item, type 1 m into Width with Lock Aspect Ratio on (confirming 3D, 2D plan, and Scale all update proportionally), press Ctrl+Z / Cmd+Z (restores in one step), then toggle Lock Aspect Ratio off and edit Width independently.

Screenshots / screen recording

Split 2D/3D view: typing 1 m into Width (parsed in imperial mode to 3.28 ft, XYZ scale: 0.50), pressing Ctrl+Z to undo in one step, then toggling Lock Aspect Ratio off and typing 1.2 m (X scale: 0.60, Y/Z scale: 1.00):

Editable item dimensions with aspect-ratio lock and single-step Undo

Checklist

  • I've tested this locally with bun dev
  • My code follows the existing code style (run bun check to verify)
  • I've updated relevant documentation (if applicable)
  • This PR targets the main branch

Note

Medium Risk
Touches scene scale updates and undo/temporal pause/resume semantics in a shared control used beyond the item panel, though changes are guarded and heavily tested.

Overview
Replaces the item panel’s read-only dimension readout with an editable Dimensions section: unit-aware Width / Height / Depth sliders (meters, with locale/unit parsing) when asset.dimensions are valid, plus a Lock Aspect Ratio toggle tied to the existing uniform-scale behavior. Scale updates go through new dimensions.ts helpers (computeScaleForDimension, editableDimensionAxes) with guards for missing/zero axes, mirroring, minimum scale, and uniform vs per-axis edits.

SliderControl is extended with optional onDragStart, dirty-input tracking so click-and-blur without typing does not commit, and stricter wheel/arrow/drag behavior when scene undo tracking is paused—supporting single-step undo for drags, no-op suppression, and cancel rollback from the panel’s dimension drag state.

Adds i18n strings and broad panel.test.tsx coverage for the math and inspector/undo behavior; assets without usable dimensions still use the Scale section only.

Reviewed by Cursor Bugbot for commit 4345aed. Bugbot is set up for automated code reviews on this repo. Configure here.

@kruschdev
kruschdev force-pushed the feat/item-panel-editable-dimensions branch from 4079063 to 5aa3f84 Compare November 25, 2026 22:38

@cursor cursor Bot left a comment •

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Stale Bugbot comment from a previous run.

Comment thread packages/nodes/src/item/panel.tsx Resolved

@cursor cursor Bot left a comment •

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Stale Bugbot comment from a previous run.

Comment thread packages/nodes/src/item/panel.tsx Resolved

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes using high effort and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit 81bf49d. Configure here.

Comment thread packages/nodes/src/item/panel.tsx Resolved

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Item panel: edit physical width / height / depth directly

1 participant