fix: respect imperial units in wall panel (#321)

This commit is contained in:
MateoSaettone
2026-06-10 07:48:34 -04:00
committed by GitHub
parent ab3c256804
commit 11135b608b
11 changed files with 283 additions and 123 deletions
+2 -12
View File
@@ -20,6 +20,7 @@ import {
EDITOR_LAYER,
type FencePlanPoint,
formatAngleRadians,
formatLinearMeasurement,
getAngleArcToSegmentReference,
getAngleToSegmentReference,
getSegmentAngleReferenceAtPoint,
@@ -94,17 +95,6 @@ type AngleSource = {
draftVector: FencePlanPoint
}
function formatMeasurement(value: number, unit: 'metric' | 'imperial') {
if (unit === 'imperial') {
const feet = value * 3.280_84
const wholeFeet = Math.floor(feet)
const inches = Math.round((feet - wholeFeet) * 12)
if (inches === 12) return `${wholeFeet + 1}'0"`
return `${wholeFeet}'${inches}"`
}
return `${Number.parseFloat(value.toFixed(2))}m`
}
function clamp(value: number, min: number, max: number) {
return Math.min(max, Math.max(min, value))
}
@@ -365,7 +355,7 @@ function getDraftMeasurementState(
const length = Math.hypot(dx, dz)
if (length < 0.01) return null
return {
lengthLabel: formatMeasurement(length, unit),
lengthLabel: formatLinearMeasurement(length, unit),
lengthPosition: [
(start[0] + end[0]) / 2,
baseY + previewHeight + DRAFT_LABEL_Y_OFFSET,