* Add roof surface placement support for items Items (e.g. solar panels) can now be placed on sloped roof surfaces. The placement system computes euler rotation from the roof surface normal so items sit flush on the slope instead of going inside. - Add roofStrategy to placement-strategies with enter/move/click/leave - Wire roof:enter/move/click/leave events in the placement coordinator - Add calculateRoofRotation in placement-math using surface normals - Support full 3D cursor rotation for sloped surfaces - Items on roofs are parented to the level with world-space rotation Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * fixed conflict * feat(duct): ceiling-snap drawing + connected-joint endpoint move Duct draw tool's ceiling mode now hangs each path point just below the ceiling actually covering it (per-room heights tracked), with a translucent surface highlight and a plumb line to the floor so the in-flight point reads clearly from any angle. Dragging a duct corner that sits on a fitting now carries the fitting's other ducts along (port-connectivity second hop), so the joint moves together instead of tearing apart. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com> * feat(mep): detach + vertical modifiers for duct/pipe joint editing Alt detaches a dragged duct/pipe endpoint or fitting from its connected joint (no elbow re-aim, no connectivity follow); Ctrl/Cmd drives vertical riser movement on the fitting move. Behavioral parity across 2D and 3D. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com> * feat(mep): full DWV pipe parity for joint editing Bring pipe-segment endpoint drags and pipe-fitting moves to parity with duct: free-drag endpoints, Alt-detach, Ctrl/Cmd-vertical riser, elbow re-aim, and connectivity follow. Generalizes the shared elbow-reaim and auto-fitting helpers to dispatch by run kind so 2D and 3D share one path. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com> * feat(mep): wall-style arrow handles for duct fittings + segments Add violet directional arrow affordances to duct-fitting selection (height, move cross, rotate arc) mirroring the duct-segment rig: portaled into the parent frame to stay out of the selection outline, rendered via the shared HandleArrow, and carrying mated-run connectivity through the single-undo dance. The move cross engages press-drag-release (placementDragMode) the same way the floating drag does, so the markup hit-areas go inert and the fitting move tool commits on pointer-up. Also re-export the HandleArrow primitives from @pascal-app/editor and extend the duct-segment side-move/floorplan affordances. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com> * feat(mep): click-to-latch cube handles for duct + fitting editing Replace the hover-reveal / multi-handle selection rigs with a single click-to-latch cube that opens a directional cluster, shared between duct segments and fittings via a new selection-handles module (HandleCube / MoveChevron / RotateArc, all sized to the roof pitch cube). - Duct segment: per-vertex + run-center cubes reveal axis-locked move chevrons (down arrow always shown), plus a roll arc at the run center. - Duct fitting: center cube reveals six ±XYZ move arrows and three per-axis rotation arcs (oriented in place), replacing the old height/move/rotate trio with axis-cycling. - Rotation (fitting arcs + duct roll) snaps to 45° steps; Shift = smooth. - thin chevron profile + press-drag-release commit retained. * fix(mep): orient duct roll arc consistently + drop Ctrl-vertical drag Build a fully-determined basis for the duct roll gizmo so the curved arrow always seats at the top-outer 45° corner regardless of run direction, instead of an arbitrary apex from a single setFromUnitVectors. The selection-rig ±Y arrows now own vertical movement, so the redundant Ctrl-modifier riser drag is removed from the fitting move tool. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com> * feat(mep): run-aligned duct handles, swing snapping, elbow flatten Align the duct run-center cube + horizontal arrows to the run axis (matching the per-vertex handles) while keeping whole-run translate. Endpoint side / up-down swing arrows now follow grid snap points and port-snap onto nearby collars (Shift sweeps smoothly). Relax elbow realign + fitting schemas to flatten to a straight 0° coupling. Surface HVAC-specific hints in the select-mode helper panel for duct / fitting. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com> * feat(mep): per-segment linesets/liquid-lines with joint-follow editing Linesets and liquid lines now commit one independent two-point node per drawn segment instead of folding into a single mitered polyline, so each line selects and deletes on its own. Endpoint caps fill shared-coordinate joints so connected segments still read as continuous pipe. Dragging a shared endpoint carries mated segments along via port connectivity (Alt detaches), so a run still edits as one welded piece. Liquid-line follow mode traces the whole connected lineset run, laying a per-segment parallel line down its full assembled length. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com> * feat(mep): vertical-offset auto-routing on duct center-cube ±Y drag Lifting/lowering a connected run with the run-center cube now keeps each connected end welded to its stationary partner instead of dragging the whole network. Run-to-run ends get the classic S/Z offset (two elbows + plumb riser, partner trimmed back one leg); elbow-connected ends form a clean L — the existing elbow stays put and re-aims its collar vertical, with one new top elbow + riser reconnecting to the lifted endpoint. The offset is ghosted live and minted as a single undo step on release. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com> * Add roof accessory placement guides Measure roof accessory placement against the active roof face using visible surface bounds and preview geometry footprints. Add dormer-local guides and special linear handling for ridge vents and gutters. * Improve duct and placement routing * Fix duct vertical movement routing * Fix duct vertical offsets and roof accessory movement * Add DWV movement parity and line endpoint controls * Fix MEP handle review issues * Fix chimney placement and duct offset cleanup * Use snapped targets for roof accessory commits * fix(nodes): repair MEP movement review issues - auto-fitting: tee branch now follows the drawn lateral angle; update the stale square-tee test + doc comment that contradicted the rewrite - duct-segment: re-enable the vertical auto-offset rewind (the disabled stub left mintedIds empty, so re-dragging a tagged duct stranded old elbows/risers and stacked duplicates); remove the dead stub - duct-segment: strip the stale auto-offset tag on manual corner/roll commits so the horizontal-move path no longer trusts an out-of-date base - chimney: resume history before mutating segment children arrays so a cross-segment move reparents in one tracked transaction (undo stays consistent) - dormer: align schema test with the new windowSill=false default * fix: address mep movement review issues * fix: address follow-up mep review comments * fix: address additional mep review comments --------- Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com> Co-authored-by: pascal-open-bot <open@pascal.app>
148 lines
6.1 KiB
TypeScript
148 lines
6.1 KiB
TypeScript
import {
|
|
type AnyNode,
|
|
type AnyNodeId,
|
|
analyzePortConnectivity,
|
|
type FloorplanAffordance,
|
|
type FloorplanAffordanceSession,
|
|
type PortConnectivity,
|
|
resolveConnectivityUpdates,
|
|
useScene,
|
|
} from '@pascal-app/core'
|
|
import { snapPointToGrid, type WallPlanPoint } from '@pascal-app/editor'
|
|
import {
|
|
detectFittingEndpoint,
|
|
type FittingEndpoint,
|
|
planFittingEndpointReaim,
|
|
} from './fitting-endpoint-reaim'
|
|
|
|
/**
|
|
* Shared "drag a path point" floor-plan affordance for polyline
|
|
* distribution kinds (duct-segment / pipe-segment / lineset). It is the
|
|
* 2D counterpart of their 3D `affordanceTools.selection` handles: one
|
|
* draggable handle per path vertex, moved freely on the plan (XZ) with
|
|
* grid snap (Shift bypasses). The vertex's Y (elevation / slope) is held
|
|
* fixed — plan editing never changes height.
|
|
*
|
|
* Like the 3D handles, dragging a vertex that sits on a fitting carries the
|
|
* joint along (port connectivity): the fitting follows, connected runs stretch
|
|
* along their own axis and translate across it, and that perpendicular slide
|
|
* propagates down the chain. And — duct / pipe only — dragging the free end
|
|
* of a straight run whose other end sits on an elbow re-aims that elbow to
|
|
* follow the drag (bend angle adapts) instead of translating it rigidly. Holding
|
|
* **Alt** detaches: the joint breaks for the drag so the vertex moves on its
|
|
* own (no elbow re-aim, no connectivity follow). Behavioral parity with the
|
|
* 3D selection tool.
|
|
*
|
|
* Wired via `def.floorplanAffordances['move-path-point']`; the floor-plan
|
|
* builders emit `endpoint-handle` primitives carrying `{ pointIndex }` so
|
|
* the dispatcher routes pointer-downs here.
|
|
*/
|
|
export type PathPointPayload = { pointIndex: number }
|
|
|
|
type PathShape = { path: ReadonlyArray<readonly [number, number, number]> }
|
|
|
|
export function createPathPointMoveAffordance<N extends PathShape & { id: AnyNodeId }>(
|
|
kind: string,
|
|
): FloorplanAffordance<N> {
|
|
const inert: FloorplanAffordanceSession = {
|
|
affectedIds: [],
|
|
apply() {},
|
|
canCommit() {
|
|
return false
|
|
},
|
|
}
|
|
return {
|
|
start({ node, payload, nodes }): FloorplanAffordanceSession {
|
|
const { pointIndex } = payload as PathPointPayload
|
|
const initialPath = node.path.map((p) => [...p] as [number, number, number])
|
|
const target = initialPath[pointIndex]
|
|
if (!target) return { ...inert, affectedIds: [node.id] }
|
|
// Hold the dragged vertex's elevation — the plan move only shifts XZ.
|
|
const y = target[1]
|
|
|
|
// Connectivity snapshot: which fittings / runs are mated to this run's
|
|
// endpoints so they follow the drag. Only endpoints (first / last vertex)
|
|
// bear ports; interior vertices have no joint, so skip the analysis.
|
|
const isEndpoint = pointIndex === 0 || pointIndex === initialPath.length - 1
|
|
|
|
// Fitting re-aim (duct / pipe): if this is a straight run whose OTHER
|
|
// end sits on an elbow collar (bend angle adapts) or a duct tee branch
|
|
// collar (branch lean adapts), the fitting swings to follow the drag —
|
|
// the 2D twin of the 3D selection handle's behaviour. Takes precedence
|
|
// over the rigid connectivity follow for this endpoint.
|
|
const fittingEndpoint: FittingEndpoint | null = isEndpoint
|
|
? detectFittingEndpoint(kind, initialPath, pointIndex, nodes)
|
|
: null
|
|
|
|
const connectivity: PortConnectivity | null =
|
|
isEndpoint && !fittingEndpoint
|
|
? analyzePortConnectivity(node as unknown as AnyNode, nodes)
|
|
: null
|
|
|
|
// Report every node the drag may write so the dispatcher snapshots them
|
|
// for the single-undo dance.
|
|
const affectedIds: AnyNodeId[] = [
|
|
node.id,
|
|
...(fittingEndpoint ? [fittingEndpoint.fitting.id as AnyNodeId] : []),
|
|
...(connectivity?.connections.map((c) => c.nodeId) ?? []),
|
|
]
|
|
|
|
const followUpdates = (nextPath: [number, number, number][]) => {
|
|
if (!connectivity) return []
|
|
const preview = {
|
|
...(node as unknown as Record<string, unknown>),
|
|
path: nextPath,
|
|
} as AnyNode
|
|
return resolveConnectivityUpdates(connectivity, preview).filter(
|
|
(u) => useScene.getState().nodes[u.id],
|
|
)
|
|
}
|
|
|
|
return {
|
|
affectedIds,
|
|
apply({ planPoint, modifiers }) {
|
|
// Plan coords map x→world X, y→world Z.
|
|
const raw: WallPlanPoint = [planPoint[0], planPoint[1]]
|
|
const [sx, sz] = modifiers.shiftKey ? raw : snapPointToGrid(raw)
|
|
const dragged: [number, number, number] = [sx, y, sz]
|
|
// Alt = detach: break the joint for this drag — the elbow does NOT
|
|
// re-aim and mated fittings / runs do NOT follow; the vertex moves
|
|
// on its own. Mirrors the 3D selection drag and the wall corner.
|
|
const detached = modifiers.altKey
|
|
// Fitting re-aim: the fitting swings to follow the dragged end and
|
|
// the run rides its re-aimed collar. Out-of-range turns hold the
|
|
// frame.
|
|
if (!detached && fittingEndpoint) {
|
|
const plan = planFittingEndpointReaim(fittingEndpoint, pointIndex, dragged)
|
|
if (!plan) return
|
|
useScene.getState().updateNodes([
|
|
{ id: node.id, data: { path: plan.path } as Partial<unknown> as never },
|
|
{
|
|
id: plan.fittingUpdate.id,
|
|
data: plan.fittingUpdate.data as Partial<unknown> as never,
|
|
},
|
|
])
|
|
return
|
|
}
|
|
const nextPath = initialPath.map((p, i) => (i === pointIndex ? dragged : p))
|
|
useScene.getState().updateNodes([
|
|
{ id: node.id, data: { path: nextPath } as Partial<unknown> as never },
|
|
...(detached ? [] : followUpdates(nextPath)).map((u) => ({
|
|
id: u.id,
|
|
data: u.data as Partial<unknown> as never,
|
|
})),
|
|
])
|
|
},
|
|
canCommit() {
|
|
const final = useScene.getState().nodes[node.id] as N | undefined
|
|
return (
|
|
!!final &&
|
|
(final as unknown as { type: string }).type === kind &&
|
|
final.path.length >= 2
|
|
)
|
|
},
|
|
}
|
|
},
|
|
}
|
|
}
|