* 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 * editor: per-door-type floor-plan symbols Render a distinct, static plan symbol for each door type in the registry floor-plan builder (`packages/nodes/src/door/floorplan.ts`), independent of the door's live open/close animation: - single / hinged: fixed 90° swing with a dashed quarter-circle arc - double / french: two mirrored half-width leaves + dashed arcs - folding / bifold: static zigzag accordion (~80% span) on the wall face - sliding: bypass — two overlapping panels on parallel tracks + arrow - pocket: thin white leaf, ~60% closed, sliding into the solid wall - barn: surface-mounted panel parked over the wall, dashed closed-ghost + slide arrow The swing arc is dashed in screen-pixel units (the renderer uses non-scaling-stroke). Symbols are oriented by hingesSide / swingDirection / slideDirection as appropriate. Also includes pre-existing working-tree changes unrelated to the door symbols: group move/rotate transform and box-select tweaks, and a regenerated ifc-converter next-env.d.ts. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> * Fix recessed ceiling fixtures and draw safety * feat(editor): magnetic wall-snap with per-kind beacon (2D + 3D) Snap the wall draft / endpoint-move point onto existing wall geometry — corners, midpoints, wall–wall intersections, and along-wall edges — and show a beacon at the snap point whose glyph encodes what it caught (square = corner, triangle = midpoint, ✕ = intersection, circle = edge). - Pure snap geometry extracted to wall-snap-geometry.ts (unit-tested). - Ephemeral useWallSnapIndicator store drives a 3D pillar+glyph beacon and a 2D SVG glyph beacon, both indigo to match the alignment guides. - Gated by a new persisted "Magnetic snap" toggle in the Display menu (useEditor); honored by draw + commit + endpoint-move in both views. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> * editor: garage and open-doorway floor-plan symbols Extend the per-door-type plan symbols in the registry floor-plan builder (packages/nodes/src/door/floorplan.ts): - open doorway (openingKind === 'opening'): bare gap, no leaf/arc/panel (mirrors the 3D system, which renders only the cutout for openings) - garage sectional: closed leaf + side tracks into the garage + dashed parked ghost at the inner end - garage roll-up: closed leaf + coil barrel (capsule) with a coil hint - garage tilt-up: closed leaf + dashed parked panel + dashed curved up-and-over swing path - gate the swing arc to actual swing doors (hinged/double/french) so other types fall back to the plain footprint Garage mechanisms sit on the interior (door-local -z) side to match the 3D garage builders, independent of swingDirection. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> * arch: enforce layer boundaries — registry dispatch, store relocation, shared helper Three architectural fixes to bring the branch into full compliance: 1. **ceiling-system kind check → CeilingCutCapability** Replace `child.type === 'item'` branch in `ceiling-system` with registry dispatch. Add `CeilingCutCapability` type to `packages/core` registry types, implement `buildCeilingHole` on `itemDefinition`, and rewrite `collectRecessedItemHoles` → `collectCeilingHoles` to dispatch through `nodeRegistry` — viewer never again inspects a node's kind directly. 2. **useAlignmentGuides + useWallSnapIndicator → packages/editor** These stores are editor-only UI (snap beacons, alignment guides). Move them from `packages/core/src/store/` to `packages/editor/src/store/`, re-export from `packages/editor`, and update all 34 consumer files across `packages/editor` and `packages/nodes` to import from `@pascal-app/editor`. 3. **findLevelAncestorId extracted to core** `item-light-system` had a private `resolveNodeLevelId` that duplicated level-ancestor traversal logic. Extract it as `findLevelAncestorId` in `packages/core` (spatial-grid-sync), export it, and replace the local copy. All four packages typecheck cleanly (zero errors). Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> * chore: fix lint, untrack .claude/launch.json Run bun check --write to clear 8 Biome errors (formatting + import order + one unused import). Untrack .claude/launch.json and add it plus .claude/settings.local.json to .gitignore so local IDE/agent configs stop landing in commits. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
106 lines
3.7 KiB
TypeScript
106 lines
3.7 KiB
TypeScript
import { type AlignmentAnchor, resolveAlignment, type WallNode } from '@pascal-app/core'
|
|
import { snapToHalf, useAlignmentGuides } from '@pascal-app/editor'
|
|
|
|
/** Figma-style alignment-snap threshold (meters), matching the move tools. */
|
|
export const WALL_OPENING_ALIGNMENT_THRESHOLD_M = 0.08
|
|
/**
|
|
* A wall opening (door / window) can only slide ALONG its host wall, so it can
|
|
* only satisfy an x- or z-guide when the wall runs along that axis. Below this
|
|
* |component| (≈ wall within 60° of the axis) the along-wall move needed to
|
|
* reach the guide blows up, so we skip it rather than jump the opening across
|
|
* the wall.
|
|
*/
|
|
const MIN_AXIS_COMPONENT = 0.5
|
|
|
|
/**
|
|
* Resolve a wall opening's along-wall position with Figma-style alignment to
|
|
* other objects, publishing the matching guide as a side effect.
|
|
*
|
|
* The probe is the RAW cursor position on the wall (not the 0.5m snap) so
|
|
* off-grid anchors are caught; we then keep only the guide on an axis the wall
|
|
* runs along and map it to the along-wall coordinate that lands the opening on
|
|
* it. Falls back to the half-metre snap when nothing aligns, and clears the
|
|
* guide on bypass / no-match. Returns the localX to use (X-clamped to the wall
|
|
* given `width`). `bypass` (Alt) disables alignment.
|
|
*/
|
|
export function resolveWallSlideAlignment(args: {
|
|
wallNode: WallNode
|
|
rawLocalX: number
|
|
width: number
|
|
candidates: readonly AlignmentAnchor[]
|
|
bypass: boolean
|
|
}): number {
|
|
const { wallNode, rawLocalX, width, candidates, bypass } = args
|
|
const base = snapToHalf(rawLocalX)
|
|
if (bypass || candidates.length === 0) {
|
|
useAlignmentGuides.getState().clear()
|
|
return base
|
|
}
|
|
|
|
const dx = wallNode.end[0] - wallNode.start[0]
|
|
const dz = wallNode.end[1] - wallNode.start[1]
|
|
const wallLength = Math.sqrt(dx * dx + dz * dz)
|
|
if (wallLength < 1e-6) {
|
|
useAlignmentGuides.getState().clear()
|
|
return base
|
|
}
|
|
const cos = dx / wallLength
|
|
const sin = dz / wallLength
|
|
const clampX = (localX: number) => Math.max(width / 2, Math.min(wallLength - width / 2, localX))
|
|
|
|
const probe = resolveAlignment({
|
|
moving: [
|
|
{
|
|
nodeId: '__wall-opening-draft__',
|
|
kind: 'corner',
|
|
x: wallNode.start[0] + rawLocalX * cos,
|
|
z: wallNode.start[1] + rawLocalX * sin,
|
|
},
|
|
],
|
|
candidates,
|
|
threshold: WALL_OPENING_ALIGNMENT_THRESHOLD_M,
|
|
})
|
|
|
|
// Keep only a guide on an axis the wall runs along, mapped to the along-wall
|
|
// position that satisfies it; pick the nearest such.
|
|
let bestLocalX: number | null = null
|
|
let bestDelta = Number.POSITIVE_INFINITY
|
|
for (const guide of probe.guides) {
|
|
const denom = guide.axis === 'x' ? cos : sin
|
|
if (Math.abs(denom) < MIN_AXIS_COMPONENT) continue
|
|
const origin = guide.axis === 'x' ? wallNode.start[0] : wallNode.start[1]
|
|
const targetLocalX = (guide.coord - origin) / denom
|
|
const delta = Math.abs(targetLocalX - rawLocalX)
|
|
if (delta < bestDelta) {
|
|
bestDelta = delta
|
|
bestLocalX = targetLocalX
|
|
}
|
|
}
|
|
if (bestLocalX === null) {
|
|
useAlignmentGuides.getState().clear()
|
|
return base
|
|
}
|
|
|
|
const clampedX = clampX(bestLocalX)
|
|
// Re-resolve from where the opening actually lands (post-clamp) so the
|
|
// published guide connects to the opening, not the raw cursor.
|
|
const published = resolveAlignment({
|
|
moving: [
|
|
{
|
|
nodeId: '__wall-opening-draft__',
|
|
kind: 'corner',
|
|
x: wallNode.start[0] + clampedX * cos,
|
|
z: wallNode.start[1] + clampedX * sin,
|
|
},
|
|
],
|
|
candidates,
|
|
threshold: WALL_OPENING_ALIGNMENT_THRESHOLD_M,
|
|
})
|
|
if (published.guides.length === 0) {
|
|
useAlignmentGuides.getState().clear()
|
|
} else {
|
|
useAlignmentGuides.getState().set(published.guides)
|
|
}
|
|
return clampedX
|
|
}
|