Repository navigation
feat(wall): interactive dimension input and continuous chain drafting in 3D and 2D #1207
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
Closed
Changes from all commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
00a424a
feat(wall): interactive dimension input and continuous chain drafting…
saadmooh ef18b2c
feat: generalize numerical dimension drafting to slabs, ceilings, and…
saadmooh d7feecd
feat: show and edit dimension indicators on opening selection
saadmooh 29f509a
fix(drafting): resolve Bugbot review issues on continuous chaining an…
saadmooh 419528a
fix(editor): defer drei Html unmount and avoid unmounting room label …
saadmooh 282d716
feat(wall): collinear wall tracking transit and dimension input refocus
saadmooh 199443e
merge: upstream main into feat/wall-dimension-drafting
saadmooh d345a6d
merge: upstream main into feat/wall-dimension-drafting (clean re-sync)
saadmooh 044b382
fix(drafting): resolve Bugbot review issues on focus TDZ, wall nextSt…
saadmooh 1a9ed75
fix(editor): avoid fence double-click emit and prevent opening commit…
saadmooh 39b11ff
Merge remote-tracking branch 'upstream/main' into feat/wall-dimension…
saadmooh File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,65 @@ | ||
| import { describe, expect, it } from 'bun:test' | ||
| import { parseAngle, parseDimension, pointFromLengthAngle } from './units' | ||
|
|
||
| describe('parseDimension', () => { | ||
| it('parses bare number as meters', () => { | ||
| expect(parseDimension('3.5')).toBe(3.5) | ||
| expect(parseDimension('10')).toBe(10) | ||
| }) | ||
|
|
||
| it('parses meters with "m" suffix', () => { | ||
| expect(parseDimension('3.5m')).toBe(3.5) | ||
| expect(parseDimension('5 M')).toBe(5) | ||
| }) | ||
|
|
||
| it('parses centimeters with "cm" suffix', () => { | ||
| expect(parseDimension('200cm')).toBe(2) | ||
| expect(parseDimension('50 cm')).toBe(0.5) | ||
| }) | ||
|
|
||
| it('parses feet with "ft" suffix', () => { | ||
| expect(parseDimension('10ft')).toBeCloseTo(3.048, 4) | ||
| }) | ||
|
|
||
| it('returns null on invalid string', () => { | ||
| expect(parseDimension('')).toBeNull() | ||
| expect(parseDimension('abc')).toBeNull() | ||
| expect(parseDimension('5xyz')).toBeNull() | ||
| }) | ||
| }) | ||
|
|
||
| describe('parseAngle', () => { | ||
| it('parses plain degrees', () => { | ||
| expect(parseAngle('45')).toBe(45) | ||
| expect(parseAngle('90.5')).toBe(90.5) | ||
| }) | ||
|
|
||
| it('handles ° and deg suffix', () => { | ||
| expect(parseAngle('90°')).toBe(90) | ||
| expect(parseAngle('180deg')).toBe(180) | ||
| }) | ||
|
|
||
| it('normalizes negative and >360 angles', () => { | ||
| expect(parseAngle('-90')).toBe(270) | ||
| expect(parseAngle('450')).toBe(90) | ||
| }) | ||
|
|
||
| it('returns null on invalid string', () => { | ||
| expect(parseAngle('')).toBeNull() | ||
| expect(parseAngle('invalid')).toBeNull() | ||
| }) | ||
| }) | ||
|
|
||
| describe('pointFromLengthAngle', () => { | ||
| it('calculates point east (+X) at 0 deg', () => { | ||
| const pt = pointFromLengthAngle([0, 0], 5, 0) | ||
| expect(pt[0]).toBeCloseTo(5, 4) | ||
| expect(pt[1]).toBeCloseTo(0, 4) | ||
| }) | ||
|
|
||
| it('calculates point south (+Z) at 90 deg', () => { | ||
| const pt = pointFromLengthAngle([0, 0], 5, 90) | ||
| expect(pt[0]).toBeCloseTo(0, 4) | ||
| expect(pt[1]).toBeCloseTo(5, 4) | ||
| }) | ||
| }) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,82 @@ | ||
| /** | ||
| * Unit parsing for dimension input. | ||
| * | ||
| * Parses strings like "3.5m", "12ft", "120cm" into meters. | ||
| * Numbers without a suffix are treated as project units (meters). | ||
| */ | ||
|
|
||
| const UNIT_FACTORS: Record<string, number> = { | ||
| m: 1, | ||
| ft: 0.3048, | ||
| cm: 0.01, | ||
| in: 0.0254, | ||
| mm: 0.001, | ||
| } | ||
|
|
||
| /** | ||
| * Parse a dimension string with optional unit suffix into meters. | ||
| * | ||
| * Supported suffixes: m, ft, cm, in, mm (case-insensitive). | ||
| * A bare number (e.g. "3.5") is treated as meters. | ||
| * | ||
| * @returns The value in meters, or null if parsing fails. | ||
| */ | ||
| export function parseDimension(input: string): number | null { | ||
| const trimmed = input.trim() | ||
| if (!trimmed) return null | ||
|
|
||
| const match = trimmed.match(/^([+-]?\d+(?:\.\d+)?)\s*([a-zA-Z]*)$/) | ||
| if (!match || !match[1]) return null | ||
|
|
||
| const value = parseFloat(match[1]) | ||
| if (Number.isNaN(value)) return null | ||
|
|
||
| const unit = (match[2] ?? '').toLowerCase() | ||
| if (unit === '') return value // no suffix → meters | ||
|
|
||
| const factor = UNIT_FACTORS[unit] | ||
| if (factor === undefined) return null | ||
|
|
||
| return value * factor | ||
| } | ||
|
|
||
| /** | ||
| * Parse an angle string into degrees. | ||
| * | ||
| * Accepts plain numbers (e.g. "45", "90.5"). | ||
| * Trailing "°" or "deg" suffixes are stripped if present. | ||
| * | ||
| * @returns The angle in degrees, or null if parsing fails. | ||
| */ | ||
| export function parseAngle(input: string): number | null { | ||
| const trimmed = input.trim() | ||
| if (!trimmed) return null | ||
|
|
||
| // Strip common degree suffixes | ||
| const cleaned = trimmed.replace(/°|deg$/i, '').trim() | ||
| if (!cleaned) return null | ||
|
|
||
| const value = parseFloat(cleaned) | ||
| if (Number.isNaN(value)) return null | ||
|
|
||
| // Normalize to 0-360 range | ||
| return ((value % 360) + 360) % 360 | ||
| } | ||
|
|
||
| /** | ||
| * Calculate the next point given a start point, length (meters), and angle (degrees). | ||
| * Angle is measured clockwise from the +X axis (east). | ||
| * | ||
| * @returns [x, z] of the calculated point. | ||
| */ | ||
| export function pointFromLengthAngle( | ||
| start: [number, number], | ||
| lengthMeters: number, | ||
| angleDeg: number, | ||
| ): [number, number] { | ||
| const rad = (angleDeg * Math.PI) / 180 | ||
| return [ | ||
| start[0] + Math.cos(rad) * lengthMeters, | ||
| start[1] + Math.sin(rad) * lengthMeters, | ||
| ] | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Dimension parser ignores project units
High Severity
parseDimensionand the copy insidesetValuestreat a bare number as meters and reject architectural feet-inch strings. The editor already hasparseDimensionInput, which honors metric vs imperial. In an imperial project, typing10or12'6"during wall/fence/slab/ceiling drafting produces the wrong length or fails to parse.Additional Locations (2)
packages/editor/src/lib/dimension-draft-store.ts#L93-L109packages/editor/src/lib/floorplan/dimension-drive.ts#L33-L40Reviewed by Cursor Bugbot for commit 199443e. Configure here.