feat: add production measurement tools (#505)
* feat: add persistent measurement tools * feat: make measurements associative * fix: finish measurements with Escape * feat: improve measurement snapping guides * feat: clarify measurement axis feedback * feat: smart measure lens, zone reports, and direct measurement editing - Smart measurement lens: registry-owned wall/slab/zone hover reports with a single top-center HUD, click-to-pin, latest-event back pressure, and no scene writes - Conservative derived zone quantities (footprint, perimeter, proven enclosure, gross wall/floor surface, flat-room volume) with the selected-zone blueprint panel - Direct editing of committed measurements via selected-only 2D/3D vertex affordances with midpoint insertion, cancellation, and one-write history - Shared measurement surface-query session; 2D tracing joins the slab/ceiling magnetic pipeline with registered-corner snapping - Angle arcs on the smaller angle, indigo active/black resting hierarchy, screen-sized normal-aligned contact rings Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> * fix: make measurement snapping always magnetic Measurement drafting and committed-edit paths gated wall, semantic, and axis magnetism on isMagneticSnapActive(), which is only true in the 'lines' snapping mode — in the default 'grid' mode corners and wall intersections barely attracted (3D association fell to the 0.012 m verify tolerance, 2D wall radii to the 0.05 m connect stick). Measurement is an analysis tool whose anchors exist to bind real geometry, so its snapping no longer consults the construction snapping-mode chip: 2D/3D drafting and committed vertex edits are always magnetic, Alt is the temporary bypass in both views (releasing the axis pull, wall magnetism, and the 2D projected-geometry pull, and shrinking association to contact tolerance). A discrete 2D wall snap (endpoint / midpoint / crossing) now outranks the locked axis pull, and committed 2D edits route the fallback through the raw pointer so free drags no longer quantize to the construction grid. Volume extrusion height keeps its mode-driven grid quantize. Codex adversarial review confirmed the diagnosis and plumbing; its 2D Alt-depth and grid-quantize findings are applied. New surface-plan-snap tests pin the magnetic override seam. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> * fix(measurement): stabilize area surface intent --------- Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Fable 5
parent
22c9472066
commit
ae87ca5475
@@ -12,6 +12,7 @@ import {
|
||||
roofSegmentResizeAffordance,
|
||||
roofSegmentRotateAffordance,
|
||||
} from './floorplan-affordances'
|
||||
import { matchRoofSegmentMeasurementFeature, roofSegmentMeasurementFeatures } from './measurement'
|
||||
import { roofSegmentParametrics } from './parametrics'
|
||||
import { RoofSegmentNode } from './schema'
|
||||
|
||||
@@ -303,6 +304,17 @@ export const roofSegmentDefinition: NodeDefinition<typeof RoofSegmentNode> = {
|
||||
module: () => import('./renderer'),
|
||||
},
|
||||
floorplan: buildRoofSegmentFloorplan,
|
||||
measurement: {
|
||||
features: (node, ctx) =>
|
||||
roofSegmentMeasurementFeatures(node, ctx.parent?.type === 'roof' ? ctx.parent : null),
|
||||
match: (node, ctx, point, maxDistance) =>
|
||||
matchRoofSegmentMeasurementFeature(
|
||||
node,
|
||||
ctx.parent?.type === 'roof' ? ctx.parent : null,
|
||||
point,
|
||||
maxDistance,
|
||||
),
|
||||
},
|
||||
// Body-move target. The generic Path 2 fallback writes plan coords
|
||||
// directly to `position`, which is wrong here because the segment's
|
||||
// position is roof-local. `roofSegmentMoveTarget` inverts the parent
|
||||
|
||||
@@ -0,0 +1,100 @@
|
||||
import {
|
||||
getRoofSegmentSurfaceY,
|
||||
type MeasurementFeature,
|
||||
type MeasurementFeatureBinding,
|
||||
type RoofNode,
|
||||
type RoofSegmentNode,
|
||||
} from '@pascal-app/core'
|
||||
import { getRoofSegmentPlanLinework, type PlanPt, type PlanSeg } from './floorplan'
|
||||
|
||||
function transformPoint(node: RoofSegmentNode, roof: RoofNode, [x, z]: PlanPt) {
|
||||
const segmentCos = Math.cos(node.rotation)
|
||||
const segmentSin = Math.sin(node.rotation)
|
||||
const segmentX = node.position[0] + x * segmentCos + z * segmentSin
|
||||
const segmentZ = node.position[2] - x * segmentSin + z * segmentCos
|
||||
const roofCos = Math.cos(roof.rotation)
|
||||
const roofSin = Math.sin(roof.rotation)
|
||||
return [
|
||||
roof.position[0] + segmentX * roofCos + segmentZ * roofSin,
|
||||
roof.position[1] + node.position[1] + getRoofSegmentSurfaceY(node, x, z),
|
||||
roof.position[2] - segmentX * roofSin + segmentZ * roofCos,
|
||||
] as [number, number, number]
|
||||
}
|
||||
|
||||
function segmentFeature(
|
||||
node: RoofSegmentNode,
|
||||
roof: RoofNode,
|
||||
id: string,
|
||||
label: string,
|
||||
snapKind: 'ridge' | 'edge',
|
||||
segment: PlanSeg,
|
||||
): MeasurementFeature {
|
||||
return {
|
||||
id,
|
||||
label,
|
||||
snapKind,
|
||||
priority: snapKind === 'ridge' ? 100 : 75,
|
||||
geometry: {
|
||||
kind: 'segment',
|
||||
start: transformPoint(node, roof, segment[0]),
|
||||
end: transformPoint(node, roof, segment[1]),
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
export function roofSegmentMeasurementFeatures(
|
||||
node: RoofSegmentNode,
|
||||
roof: RoofNode | null,
|
||||
): MeasurementFeature[] {
|
||||
if (roof?.type !== 'roof') return []
|
||||
const linework = getRoofSegmentPlanLinework(node)
|
||||
return [
|
||||
...linework.ridges.map((segment, index) =>
|
||||
segmentFeature(node, roof, `roof:ridge:${index}`, 'Roof ridge', 'ridge', segment),
|
||||
),
|
||||
...linework.hips.map((segment, index) =>
|
||||
segmentFeature(node, roof, `roof:hip:${index}`, 'Roof hip', 'edge', segment),
|
||||
),
|
||||
...linework.breaks.map((segment, index) =>
|
||||
segmentFeature(node, roof, `roof:break:${index}`, 'Roof break', 'edge', segment),
|
||||
),
|
||||
]
|
||||
}
|
||||
|
||||
export function matchRoofSegmentMeasurementFeature(
|
||||
node: RoofSegmentNode,
|
||||
roof: RoofNode | null,
|
||||
hit: [number, number, number],
|
||||
maxDistance: number,
|
||||
): MeasurementFeatureBinding | null {
|
||||
let best: MeasurementFeatureBinding | null = null
|
||||
for (const feature of roofSegmentMeasurementFeatures(node, roof)) {
|
||||
if (feature.geometry.kind !== 'segment') continue
|
||||
const { start, end } = feature.geometry
|
||||
const dx = end[0] - start[0]
|
||||
const dy = end[1] - start[1]
|
||||
const dz = end[2] - start[2]
|
||||
const lengthSquared = dx * dx + dy * dy + dz * dz
|
||||
const t =
|
||||
lengthSquared <= 1e-12
|
||||
? 0
|
||||
: Math.max(
|
||||
0,
|
||||
Math.min(
|
||||
1,
|
||||
((hit[0] - start[0]) * dx + (hit[1] - start[1]) * dy + (hit[2] - start[2]) * dz) /
|
||||
lengthSquared,
|
||||
),
|
||||
)
|
||||
const point: [number, number, number] = [
|
||||
start[0] + dx * t,
|
||||
start[1] + dy * t,
|
||||
start[2] + dz * t,
|
||||
]
|
||||
const distance = Math.hypot(hit[0] - point[0], hit[1] - point[1], hit[2] - point[2])
|
||||
if (distance <= maxDistance && (!best || distance < best.distance)) {
|
||||
best = { featureId: feature.id, point, parameters: { t }, distance }
|
||||
}
|
||||
}
|
||||
return best
|
||||
}
|
||||
Reference in New Issue
Block a user