fix(editor): commit ceiling locally in 2D-only view (3D tool can't)

Same fix as slab: ceiling is committed by its 3D registry tool, dead in 2D-only
view. Commit it from the panel on both close paths, gated to viewMode==='2d'.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
Wassim SAMAD
2026-06-25 14:57:24 -04:00
co-authored by Claude Opus 4.8
parent 0e778ab526
commit 6f37783fbd
@@ -6,6 +6,7 @@ import {
type AnyNodeId, type AnyNodeId,
type BuildingNode, type BuildingNode,
type CeilingNode, type CeilingNode,
CeilingNode as CeilingNodeSchema,
type ColumnNode, type ColumnNode,
calculateLevelMiters, calculateLevelMiters,
DEFAULT_ANGLE_STEP, DEFAULT_ANGLE_STEP,
@@ -7607,6 +7608,27 @@ export function FloorplanPanel({
[levelId, setSelection], [levelId, setSelection],
) )
const createCeilingOnCurrentLevel = useCallback(
(points: WallPlanPoint[]) => {
if (!levelId) {
return null
}
const { createNode, nodes } = useScene.getState()
const ceilingCount = Object.values(nodes).filter((node) => node.type === 'ceiling').length
const defaults = useEditor.getState().toolDefaults.ceiling ?? {}
const ceiling = CeilingNodeSchema.parse({
...defaults,
name: `Ceiling ${ceilingCount + 1}`,
polygon: points.map(([x, z]) => [x, z] as [number, number]),
})
createNode(ceiling, levelId)
sfxEmitter.emit('sfx:structure-build')
setSelection({ selectedIds: [ceiling.id] })
return ceiling.id
},
[levelId, setSelection],
)
useEffect(() => { useEffect(() => {
if (!isStairBuildActive) { if (!isStairBuildActive) {
useStairBuildPreview.getState().reset() useStairBuildPreview.getState().reset()
@@ -9176,6 +9198,9 @@ export function FloorplanPanel({
const firstPoint = ceilingDraftPoints[0] const firstPoint = ceilingDraftPoints[0]
if (firstPoint && ceilingDraftPoints.length >= 3 && isPointNearPlanPoint(point, firstPoint)) { if (firstPoint && ceilingDraftPoints.length >= 3 && isPointNearPlanPoint(point, firstPoint)) {
if (useEditor.getState().viewMode === '2d') {
createCeilingOnCurrentLevel(ceilingDraftPoints)
}
clearCeilingPlacementDraft() clearCeilingPlacementDraft()
return return
} }
@@ -9183,7 +9208,7 @@ export function FloorplanPanel({
setCeilingDraftPoints((currentPoints) => [...currentPoints, point]) setCeilingDraftPoints((currentPoints) => [...currentPoints, point])
setCursorPoint(point) setCursorPoint(point)
}, },
[ceilingDraftPoints, clearCeilingPlacementDraft], [ceilingDraftPoints, clearCeilingPlacementDraft, createCeilingOnCurrentLevel],
) )
const handleCeilingPlacementConfirm = useCallback( const handleCeilingPlacementConfirm = useCallback(
(point?: WallPlanPoint) => { (point?: WallPlanPoint) => {
@@ -9206,9 +9231,12 @@ export function FloorplanPanel({
return return
} }
if (useEditor.getState().viewMode === '2d') {
createCeilingOnCurrentLevel(nextPoints)
}
clearCeilingPlacementDraft() clearCeilingPlacementDraft()
}, },
[ceilingDraftPoints, clearCeilingPlacementDraft], [ceilingDraftPoints, clearCeilingPlacementDraft, createCeilingOnCurrentLevel],
) )
const handleZonePlacementPoint = useCallback( const handleZonePlacementPoint = useCallback(
(point: WallPlanPoint) => { (point: WallPlanPoint) => {