* 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>
98 lines
3.2 KiB
TypeScript
98 lines
3.2 KiB
TypeScript
import {
|
|
type NodeDefinition,
|
|
resolveAutoZonePolygon,
|
|
ZoneNode as ZoneNodeSchema,
|
|
} from '@pascal-app/core'
|
|
import { polygonMeasurementFeatures } from '../shared/polygon-measurement'
|
|
import { buildZoneFloorplan } from './floorplan'
|
|
import {
|
|
zoneAddVertexAffordance,
|
|
zoneDeleteVertexAffordance,
|
|
zoneMoveEdgeAffordance,
|
|
zoneMoveVertexAffordance,
|
|
} from './floorplan-affordances'
|
|
import { zoneFloorplanMoveTarget } from './floorplan-move'
|
|
import { zoneParametrics } from './parametrics'
|
|
import { zoneQuickMeasurement } from './quick-measurement'
|
|
import { ZoneNode } from './schema'
|
|
|
|
/**
|
|
* Zone — Stage A. Custom-behavior escape hatch: zone uses TSL shader
|
|
* materials + `<Html>` portals + per-frame uniform poking, so it
|
|
* lives via `def.renderer` + `def.system` (no `def.geometry` possible
|
|
* because zone isn't really a mesh).
|
|
*/
|
|
export const zoneDefinition: NodeDefinition<typeof ZoneNode> = {
|
|
kind: 'zone',
|
|
snapProfile: 'structural',
|
|
schemaVersion: 1,
|
|
schema: ZoneNode,
|
|
category: 'site',
|
|
|
|
defaults: () => {
|
|
const stub = ZoneNodeSchema.parse({ id: 'zone_default' as never, type: 'zone' })
|
|
const { id: _id, type: _type, ...rest } = stub
|
|
return rest
|
|
},
|
|
|
|
capabilities: {
|
|
selectable: { hitVolume: 'bbox' },
|
|
duplicable: true,
|
|
deletable: true,
|
|
// Zones describe regions of a site — they don't translate as
|
|
// reusable presets independent of their site context.
|
|
presettable: false,
|
|
},
|
|
|
|
parametrics: zoneParametrics,
|
|
measurement: {
|
|
features: (node, ctx) =>
|
|
polygonMeasurementFeatures({
|
|
featurePrefix: 'zone',
|
|
height: 0,
|
|
label: 'Zone',
|
|
polygon: resolveAutoZonePolygon(node, ctx.resolve),
|
|
}),
|
|
quickMeasure: (node, ctx) => zoneQuickMeasurement(node, ctx),
|
|
},
|
|
// No dirty consumer rebuilds this kind — see NodeDefinition.dirtyTracking.
|
|
dirtyTracking: false,
|
|
|
|
renderer: {
|
|
kind: 'parametric',
|
|
module: () => import('./renderer'),
|
|
},
|
|
system: {
|
|
module: () => import('./system'),
|
|
priority: 4,
|
|
},
|
|
floorplan: buildZoneFloorplan,
|
|
floorplanDependencies: (node) => (node.autoFromWalls ? node.boundaryWallIds : []),
|
|
// 2D body move — centroid-pivot polygon mover (same as slab / ceiling).
|
|
// Without this, zone fell through to the overlay's generic free-translate
|
|
// path, which committed a `position` field zone has no schema for, so the
|
|
// polygon never actually moved on drop.
|
|
floorplanMoveTarget: zoneFloorplanMoveTarget,
|
|
// Polygon editor when selected — same four operations slabs / ceilings
|
|
// expose. The shared factories key off `node.polygon`, optional
|
|
// `node.holes` (absent on zones). See `floorplan-affordances.ts`.
|
|
floorplanAffordances: {
|
|
'move-vertex': zoneMoveVertexAffordance,
|
|
'add-vertex': zoneAddVertexAffordance,
|
|
'move-edge': zoneMoveEdgeAffordance,
|
|
'delete-vertex': zoneDeleteVertexAffordance,
|
|
},
|
|
|
|
presentation: {
|
|
label: 'Zone',
|
|
description: 'A polygonal site zone (lawn, water, paving) with a TSL gradient material.',
|
|
icon: { kind: 'url', src: '/icons/zone.webp' },
|
|
paletteSection: 'site',
|
|
paletteOrder: 20,
|
|
},
|
|
|
|
mcp: {
|
|
description: 'A polygon-bounded site zone with a typed surface (grass / water / paving / ...).',
|
|
},
|
|
}
|