import { type AnyNode, type CeilingNode, resolveLevelId } from '@pascal-app/core' import { resolveCeilingPlanPointSnap } from '@pascal-app/editor' import { createPolygonAddVertexAffordance, createPolygonMoveEdgeAffordance, createPolygonVertexAffordance, type PolygonAffordanceSnapContext, } from '../shared/polygon-vertex-affordance' /** * 2D drag affordances for ceiling. Same three operations as slab * (`move-vertex`, `add-vertex`, `move-edge`), each accepting an * optional `holeIndex`. See `slab/floorplan-affordances.ts` for the * full contract. */ const ceilingSnapOptions = { resolvePlanPoint({ node, nodes, rawPoint, fallbackPoint, modifiers, }: PolygonAffordanceSnapContext) { const sceneNodes = nodes as Record return resolveCeilingPlanPointSnap({ rawPoint, fallbackPoint, levelId: resolveLevelId(node, sceneNodes), excludeId: node.id, nodes: sceneNodes, altKey: modifiers.altKey, shiftKey: modifiers.shiftKey, }).point }, } export const ceilingMoveVertexAffordance = createPolygonVertexAffordance( 'ceiling', ceilingSnapOptions, ) export const ceilingAddVertexAffordance = createPolygonAddVertexAffordance( 'ceiling', ceilingSnapOptions, ) export const ceilingMoveEdgeAffordance = createPolygonMoveEdgeAffordance( 'ceiling', ceilingSnapOptions, )