feat: sync surface polygon editing

This commit is contained in:
Aymeric Rabot
2026-06-09 19:54:35 -04:00
parent 92078741cd
commit e81dc63b28
12 changed files with 523 additions and 311 deletions
@@ -1,8 +1,10 @@
import type { CeilingNode } from '@pascal-app/core'
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'
/**
@@ -11,6 +13,35 @@ import {
* optional `holeIndex`. See `slab/floorplan-affordances.ts` for the
* full contract.
*/
export const ceilingMoveVertexAffordance = createPolygonVertexAffordance<CeilingNode>('ceiling')
export const ceilingAddVertexAffordance = createPolygonAddVertexAffordance<CeilingNode>('ceiling')
export const ceilingMoveEdgeAffordance = createPolygonMoveEdgeAffordance<CeilingNode>('ceiling')
const ceilingSnapOptions = {
resolvePlanPoint({
node,
nodes,
rawPoint,
fallbackPoint,
modifiers,
}: PolygonAffordanceSnapContext<CeilingNode>) {
const sceneNodes = nodes as Record<string, AnyNode>
return resolveCeilingPlanPointSnap({
rawPoint,
fallbackPoint,
levelId: resolveLevelId(node, sceneNodes),
excludeId: node.id,
nodes: sceneNodes,
altKey: modifiers.altKey,
}).point
},
}
export const ceilingMoveVertexAffordance = createPolygonVertexAffordance<CeilingNode>(
'ceiling',
ceilingSnapOptions,
)
export const ceilingAddVertexAffordance = createPolygonAddVertexAffordance<CeilingNode>(
'ceiling',
ceilingSnapOptions,
)
export const ceilingMoveEdgeAffordance = createPolygonMoveEdgeAffordance<CeilingNode>(
'ceiling',
ceilingSnapOptions,
)