arch: enforce layer boundaries — ceiling dispatch, store relocation, shared helper (#382)
* 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>
This commit is contained in:
co-authored by
Claude Opus 4.7
parent
7796837081
commit
ce6f999310
@@ -29,6 +29,32 @@ export function resolveLevelId(node: AnyNode, nodes: Record<string, AnyNode>): s
|
||||
return 'default' // fallback for orphaned items
|
||||
}
|
||||
|
||||
/**
|
||||
* Walks the parent chain of `nodeId` and returns the id of the first ancestor
|
||||
* whose `type` is `'level'`, or `null` when no level ancestor exists (orphaned
|
||||
* node, top-level building node, etc.). Unlike `resolveLevelId`, this variant:
|
||||
*
|
||||
* - accepts a node **id** rather than a resolved node, saving the caller a
|
||||
* `nodes[id]` lookup when only the id is at hand.
|
||||
* - returns `null` instead of the `'default'` fallback, which lets callers
|
||||
* distinguish "genuinely has no level" from "is a level".
|
||||
* - has a loop guard (16 iterations) so a corrupt parent-chain cycle cannot
|
||||
* hang the frame loop.
|
||||
*/
|
||||
export function findLevelAncestorId(
|
||||
nodeId: AnyNodeId,
|
||||
nodes: Record<string, AnyNode>,
|
||||
): string | null {
|
||||
let current: AnyNode | undefined = nodes[nodeId]
|
||||
let guard = 0
|
||||
while (current && guard < 16) {
|
||||
if (current.type === 'level') return current.id
|
||||
current = current.parentId ? nodes[current.parentId] : undefined
|
||||
guard += 1
|
||||
}
|
||||
return null
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the building id that contains the given level, or `null` if
|
||||
* the level is unparented or no enclosing building exists.
|
||||
|
||||
@@ -46,6 +46,7 @@ export {
|
||||
} from './hooks/spatial-grid/floor-placed-elevation'
|
||||
export { pointInPolygon, spatialGridManager } from './hooks/spatial-grid/spatial-grid-manager'
|
||||
export {
|
||||
findLevelAncestorId,
|
||||
initSpatialGridSync,
|
||||
resolveBuildingForLevel,
|
||||
resolveLevelId,
|
||||
@@ -111,7 +112,6 @@ export {
|
||||
resetSceneHistoryPauseDepth,
|
||||
resumeSceneHistory,
|
||||
} from './store/history-control'
|
||||
export { default as useAlignmentGuides } from './store/use-alignment-guides'
|
||||
export {
|
||||
type ControlValue,
|
||||
type DoorAnimationState,
|
||||
|
||||
@@ -982,6 +982,12 @@ export type Capabilities = {
|
||||
*/
|
||||
alignmentFootprint?: AlignmentFootprintConfig
|
||||
roofAccessory?: RoofAccessoryConfig
|
||||
/**
|
||||
* Kind cuts a hole in the ceiling surface it is attached to (e.g. recessed
|
||||
* downlights). The viewer's `CeilingSystem` calls this for each child of a
|
||||
* ceiling to collect extra holes before triangulating. See `CeilingCutCapability`.
|
||||
*/
|
||||
ceilingCut?: CeilingCutCapability
|
||||
paint?: PaintCapability
|
||||
/**
|
||||
* Kind is placed by clicking on a wall (door, window). When set, the
|
||||
@@ -1179,6 +1185,22 @@ export type RoofAccessoryConfig = {
|
||||
buildCut?: (node: AnyNode, hostSegment: AnyNode) => BufferGeometry | null
|
||||
}
|
||||
|
||||
/**
|
||||
* Capability for kinds that cut a hole in their host ceiling when the node is
|
||||
* attached to a ceiling surface (e.g. recessed downlights). The viewer's
|
||||
* `CeilingSystem` queries children of a ceiling for this capability and merges
|
||||
* the returned polygons as extra holes before triangulating, keeping the viewer
|
||||
* free of per-kind branching.
|
||||
*
|
||||
* Returns a rotated-rectangle footprint in ceiling-local [x, z] plan space —
|
||||
* the same coordinate space as `CeilingNode.polygon` and `.holes`. Return
|
||||
* `null` when this particular instance should not cut a hole (e.g. a
|
||||
* non-recessed variant of the same kind).
|
||||
*/
|
||||
export type CeilingCutCapability = {
|
||||
buildCeilingHole: (node: AnyNode) => Array<[number, number]> | null
|
||||
}
|
||||
|
||||
export type CapabilityCtx = { node: AnyNode }
|
||||
|
||||
export type MovableConfig = {
|
||||
|
||||
@@ -98,6 +98,11 @@ const assetSchema = z.object({
|
||||
src: AssetUrl,
|
||||
dimensions: z.tuple([z.number(), z.number(), z.number()]).default([1, 1, 1]), // [w, h, d]
|
||||
attachTo: z.enum(['wall', 'wall-side', 'ceiling']).optional(),
|
||||
// Ceiling fixtures (e.g. recessed downlights) that embed *into* the ceiling
|
||||
// rather than hang below it: the item seats flush with the ceiling plane
|
||||
// (its body rising into the void above) and the ceiling is cut out around
|
||||
// the item's footprint. Ignored unless `attachTo === 'ceiling'`.
|
||||
recessed: z.boolean().optional(),
|
||||
tags: z.array(z.string()).optional(),
|
||||
// Function-axis tag slugs from the taxonomy. Drives the hierarchical
|
||||
// Items-tab browse: a tree node matches when any of its descendant slugs
|
||||
|
||||
@@ -1,21 +0,0 @@
|
||||
// Ephemeral store for Figma-style alignment guides published during a
|
||||
// move / placement drag. The producer (a tool or move overlay) writes
|
||||
// guides on pointermove; the renderer (a 2D / 3D guide layer) subscribes
|
||||
// and draws them. Both sides clear on commit, cancel, and unmount.
|
||||
|
||||
import { create } from 'zustand'
|
||||
import type { AlignmentGuide } from '../services/alignment'
|
||||
|
||||
type AlignmentGuidesState = {
|
||||
guides: AlignmentGuide[]
|
||||
set(guides: AlignmentGuide[]): void
|
||||
clear(): void
|
||||
}
|
||||
|
||||
const useAlignmentGuides = create<AlignmentGuidesState>((set) => ({
|
||||
guides: [],
|
||||
set: (guides) => set({ guides }),
|
||||
clear: () => set({ guides: [] }),
|
||||
}))
|
||||
|
||||
export default useAlignmentGuides
|
||||
Reference in New Issue
Block a user