diff --git a/apps/editor/components/build-tab.tsx b/apps/editor/components/build-tab.tsx
index 545d19b5d7..efd3092f49 100644
--- a/apps/editor/components/build-tab.tsx
+++ b/apps/editor/components/build-tab.tsx
@@ -36,7 +36,6 @@ import {
import {
activateBuildTool,
activateFenceFeaturePlacement,
- activateModularCabinetTool,
activateRoofFeatureTool,
activateRoofType,
activateTerrainSculptMode,
@@ -47,10 +46,10 @@ import {
MEP_ITEMS,
MEP_TOOL_KINDS,
type MepItem,
- MODULAR_CABINET_ICON,
} from '@/lib/build-palette'
import { getActiveRoofFeatureId, ROOF_TYPE_OPTIONS } from '@/lib/build-tab-state'
import { cn } from '@/lib/utils'
+import { KitchenBrowser } from './kitchen-browser'
const subscribeToClientMount = () => () => {}
@@ -61,6 +60,8 @@ const subscribeToClientMount = () => () => {}
*/
export function BuildTab() {
const [mepOpen, setMepOpen] = useState(false)
+ const [kitchenOpen, setKitchenOpen] = useState(false)
+ const [buildSearch, setBuildSearch] = useState('')
const activeTool = useEditor((s) => s.tool)
const selectedId = useViewer((s) => s.selection.selectedIds[0])
const selectedFenceFeature = useScene((s) => {
@@ -118,7 +119,7 @@ export function BuildTab() {
const isMepActive =
(mode === 'build' && !!activeTool && MEP_TOOL_KINDS.has(activeTool)) ||
(mode === 'select' && mepOpen)
- const isKitchenActive = mode === 'build' && activeTool === 'cabinet'
+ const isKitchenActive = kitchenOpen || (mode === 'build' && activeTool === 'cabinet')
const parsedRoofType = RoofTypeSchema.safeParse(roofDefaults?.roofType)
const activeRoofType = parsedRoofType.success ? parsedRoofType.data : 'gable'
@@ -136,6 +137,8 @@ export function BuildTab() {
const handleTypeClick = useCallback(
(type: BuildType) => {
setMepOpen(type.id === 'mep')
+ setKitchenOpen(type.id === 'kitchen')
+ setBuildSearch('')
if (type.id === 'fence' && selectedFence) return
if (type.mode === 'terrain-sculpt') {
activateTerrainSculptMode()
@@ -146,7 +149,7 @@ export function BuildTab() {
ed.setMode('build')
ed.setTool(null)
} else if (type.id === 'kitchen') {
- activateModularCabinetTool()
+ useEditor.getState().setMode('select')
} else if (type.id === 'terrace') {
startTerraceDraft()
} else if (type.kind) {
@@ -193,393 +196,404 @@ export function BuildTab() {
return (
-
- triggerSFX('sfx:menu-hover')}
- onSelect={(variant) => {
- triggerSFX('sfx:menu-click')
- selectWallDrawVariant(variant)
- const editor = useEditor.getState()
- if (!(editor.mode === 'build' && editor.tool === 'wall')) activateBuildTool('wall')
- }}
- />
-
- {typesIn('add').map(renderTile)}
-
-
- {typesIn('outdoor').map(renderTile)}
-
-
- {advancedTypes.map(renderTile)}
-
-
+
+ Search build tools and kitchen items
+
+
setBuildSearch(event.target.value)}
+ className="h-9 w-full shrink-0 rounded-lg border border-border bg-background px-3 text-xs focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring"
+ />
+ {buildSearch.trim() ? (
+ <>
+
+ {buildTypes
+ .filter((type) => type.label.toLowerCase().includes(buildSearch.toLowerCase()))
+ .map(renderTile)}
+
+
+ >
+ ) : (
+ <>
+ {isKitchenActive ? (
+
{
+ setKitchenOpen(false)
+ useEditor.getState().setMode('select')
+ }}
+ >
+ ← All build tools
+
+ ) : (
+
+ triggerSFX('sfx:menu-hover')}
+ onSelect={(variant) => {
+ triggerSFX('sfx:menu-click')
+ selectWallDrawVariant(variant)
+ const editor = useEditor.getState()
+ if (!(editor.mode === 'build' && editor.tool === 'wall'))
+ activateBuildTool('wall')
+ }}
+ />
+
+ {typesIn('add').map(renderTile)}
+
+
+ {typesIn('outdoor').map(renderTile)}
+
+
+ {advancedTypes.map(renderTile)}
+
+
+ )}
- {mode === 'terrain-sculpt' ? (
-
-
-
- ) : mode === 'build' && (activeTool === 'roof' || isRoofFeatureActive) ? (
-
-
-
Roof type
-
- {ROOF_TYPE_OPTIONS.map((roofType) => {
- const active = activeTool === 'roof' && activeRoofType === roofType.value
- return (
-
+
+
+ ) : mode === 'build' && (activeTool === 'roof' || isRoofFeatureActive) ? (
+
+
+
+ Roof type
+
+
+ {ROOF_TYPE_OPTIONS.map((roofType) => {
+ const active = activeTool === 'roof' && activeRoofType === roofType.value
+ return (
+ {
+ triggerSFX('sfx:menu-click')
+ activateRoofType(roofType.value)
+ }}
+ onMouseEnter={() => triggerSFX('sfx:menu-hover')}
+ type="button"
+ >
+ {roofType.label}
+
+ )
+ })}
+
+
+
+
{
+ const editor = useEditor.getState()
+ if (!(editor.mode === 'build' && editor.tool === 'roof'))
+ activateBuildTool('roof')
+ }}
+ />
+ {activeRoofType === 'conical' && (
+
+ Select a curved wall to match its radius and arc.
+
+ )}
+
+ {roofFeatures.length > 0 ? (
+
+
+ Features & extensions
+
+
+
+ {roofFeatures.map((feature) => {
+ const active = mode === 'build' && feature.id === activeRoofFeatureId
+ return (
+
+
+ {
+ triggerSFX('sfx:menu-click')
+ activateRoofFeatureTool(feature)
+ }}
+ onMouseEnter={() => triggerSFX('sfx:menu-hover')}
+ type="button"
+ >
+
+
+
+
+ {feature.label}
+
+
+ )
+ })}
+
+
+
+ ) : null}
+
+ ) : fenceContext ? (
+
+
Fence features
+
+ {(['gate', 'opening'] as const).map((kind) => (
+ {
triggerSFX('sfx:menu-click')
- activateRoofType(roofType.value)
+ activateFenceFeaturePlacement(kind)
}}
onMouseEnter={() => triggerSFX('sfx:menu-hover')}
- type="button"
- >
- {roofType.label}
-
- )
- })}
+ title={kind === 'gate' ? 'Add Gate' : 'Add Open Passage'}
+ />
+ ))}
+
+ {selectedFenceFeature && (
+
+ Match fence style
+
+ useScene.getState().updateNode(selectedFenceFeature.id, {
+ matchFenceStyle: event.currentTarget.checked,
+ })
+ }
+ />
+
+ )}
+ {!!placingFenceFeature && (
+
+
+ Hover a fence to preview. Click to place. Esc cancels. Leave room between
+ openings.
+
+ {typeof fenceDefaults?.featurePlacementFeedback === 'string' && (
+
+ {fenceDefaults.featurePlacementFeedback}
+
+ )}
+
+ Match fence style
+
+ useEditor.getState().setToolDefaults('fence', {
+ ...fenceDefaults,
+ featureMatchStyle: event.currentTarget.checked,
+ })
+ }
+ />
+
+ {fenceDefaults?.featureMatchStyle === false && placingFenceFeature === 'gate' && (
+
+ Gate style
+
+ useEditor.getState().setToolDefaults('fence', {
+ ...fenceDefaults,
+ featureStyle: event.currentTarget.value,
+ })
+ }
+ >
+ Picket
+ Vertical slats
+ Horizontal boards
+ Solid privacy
+ Open rails
+
+
+ )}
+
+ Opening width (m)
+ {
+ const width = event.currentTarget.valueAsNumber
+ if (Number.isFinite(width) && width >= 0.35)
+ useEditor.getState().setToolDefaults('fence', {
+ ...fenceDefaults,
+ featureWidth: Math.min(12, width),
+ })
+ }}
+ />
+
+ {placingFenceFeature === 'gate' && (
+
+ Leaves
+
+ useEditor.getState().setToolDefaults('fence', {
+ ...fenceDefaults,
+ featureLeafType: event.target.value,
+ })
+ }
+ >
+ Single gate
+ Double gate
+
+
+ )}
+
+ )}
+
+ Choose Gate or Open Passage, then click its position on any fence. Find placed gates
+ and openings under their fence in the scene graph.
+
-
-
-
{
- const editor = useEditor.getState()
- if (!(editor.mode === 'build' && editor.tool === 'roof')) activateBuildTool('roof')
- }}
- />
- {activeRoofType === 'conical' && (
-
- Select a curved wall to match its radius and arc.
-
- )}
-
- {roofFeatures.length > 0 ? (
-
-
- Features & extensions
-
+ ) : isKitchenActive ? (
+
+ ) : isMepActive ? (
+
+
MEP
- {roofFeatures.map((feature) => {
- const active = mode === 'build' && feature.id === activeRoofFeatureId
+ {MEP_ITEMS.map((item) => {
+ const active = isMepItemActive(item)
return (
-
+
{
triggerSFX('sfx:menu-click')
- activateRoofFeatureTool(feature)
+ activateBuildTool(item.kind)
}}
onMouseEnter={() => triggerSFX('sfx:menu-hover')}
type="button"
>
- {feature.label}
+ {item.label}
)
})}
-
- ) : null}
-
- ) : fenceContext ? (
-
-
Fence features
-
- {(['gate', 'opening'] as const).map((kind) => (
- {
- triggerSFX('sfx:menu-click')
- activateFenceFeaturePlacement(kind)
- }}
- onMouseEnter={() => triggerSFX('sfx:menu-hover')}
- title={kind === 'gate' ? 'Add Gate' : 'Add Open Passage'}
- />
- ))}
-
- {selectedFenceFeature && (
-
- Match fence style
-
- useScene.getState().updateNode(selectedFenceFeature.id, {
- matchFenceStyle: event.currentTarget.checked,
- })
- }
- />
-
- )}
- {!!placingFenceFeature && (
-
-
- Hover a fence to preview. Click to place. Esc cancels. Leave room between openings.
-
- {typeof fenceDefaults?.featurePlacementFeedback === 'string' && (
-
- {fenceDefaults.featurePlacementFeedback}
-
- )}
-
- Match fence style
-
- useEditor.getState().setToolDefaults('fence', {
- ...fenceDefaults,
- featureMatchStyle: event.currentTarget.checked,
- })
- }
- />
-
- {fenceDefaults?.featureMatchStyle === false && placingFenceFeature === 'gate' && (
-
- Gate style
-
- useEditor.getState().setToolDefaults('fence', {
- ...fenceDefaults,
- featureStyle: event.currentTarget.value,
- })
- }
- >
- Picket
- Vertical slats
- Horizontal boards
- Solid privacy
- Open rails
-
-
- )}
-
- Opening width (m)
- {
- const width = event.currentTarget.valueAsNumber
- if (Number.isFinite(width) && width >= 0.35)
- useEditor.getState().setToolDefaults('fence', {
- ...fenceDefaults,
- featureWidth: Math.min(12, width),
- })
- }}
- />
-
- {placingFenceFeature === 'gate' && (
-
- Leaves
-
- useEditor.getState().setToolDefaults('fence', {
- ...fenceDefaults,
- featureLeafType: event.target.value,
- })
- }
- >
- Single gate
- Double gate
-
-
- )}
-
- )}
-
- Choose Gate or Open Passage, then click its position on any fence. Find placed gates and
- openings under their fence in the scene graph.
-
-
- ) : isKitchenActive ? (
-
-
Kitchen
-
-
-
-
+
+ {(['duct-fitting', 'pipe-fitting'] as const)
+ .filter((kind) => (kind === 'duct-fitting' ? ductContext : pipeContext))
+ .map((kind) => (
+ {
+ if (option.id !== 'fittingType') return undefined
+ if (kind === 'duct-fitting' && value === 'elbow')
+ return '/icons/duct-fitting.webp'
+ return `/icons/fittings/${kind === 'duct-fitting' ? 'duct' : 'pipe'}-${value}.webp`
+ }}
+ kind={kind}
+ onSelect={(option, value) => {
+ if (activeTool !== kind) {
+ const defaults = useEditor.getState().toolDefaults[kind]
+ activateBuildTool(kind)
+ if (defaults) useEditor.getState().setToolDefaults(kind, defaults)
+ }
+ option.set(value)
+ }}
+ />
+ ))}
+
+ {liquidLineContext ? (
+
+ Liquid Line
{
triggerSFX('sfx:menu-click')
- activateModularCabinetTool()
+ toggleFollow()
}}
onMouseEnter={() => triggerSFX('sfx:menu-hover')}
type="button"
>
-
+ Follow lineset
+ {follow ? 'On' : 'Off'}
-
-
- Modular Cabinet
-
-
-
-
-
- ) : isMepActive ? (
-
-
MEP
-
-
- {MEP_ITEMS.map((item) => {
- const active = isMepItemActive(item)
- return (
-
-
- {
- triggerSFX('sfx:menu-click')
- activateBuildTool(item.kind)
- }}
- onMouseEnter={() => triggerSFX('sfx:menu-hover')}
- type="button"
- >
-
-
-
-
- {item.label}
-
-
- )
- })}
-
-
-
- {(['duct-fitting', 'pipe-fitting'] as const)
- .filter((kind) => (kind === 'duct-fitting' ? ductContext : pipeContext))
- .map((kind) => (
-
{
- if (option.id !== 'fittingType') return undefined
- if (kind === 'duct-fitting' && value === 'elbow')
- return '/icons/duct-fitting.webp'
- return `/icons/fittings/${kind === 'duct-fitting' ? 'duct' : 'pipe'}-${value}.webp`
- }}
- kind={kind}
- onSelect={(option, value) => {
- if (activeTool !== kind) {
- const defaults = useEditor.getState().toolDefaults[kind]
- activateBuildTool(kind)
- if (defaults) useEditor.getState().setToolDefaults(kind, defaults)
- }
- option.set(value)
- }}
- />
- ))}
-
- {liquidLineContext ? (
-
- Liquid Line
- {
- triggerSFX('sfx:menu-click')
- toggleFollow()
- }}
- onMouseEnter={() => triggerSFX('sfx:menu-hover')}
- type="button"
- >
- Follow lineset
- {follow ? 'On' : 'Off'}
-
-
- {follow
- ? 'Click a lineset to lay the line beside it.'
- : 'Trace a line alongside an existing lineset (F).'}
-
+
+ {follow
+ ? 'Click a lineset to lay the line beside it.'
+ : 'Trace a line alongside an existing lineset (F).'}
+
+
+ ) : null}
) : null}
-
- ) : null}
+ >
+ )}
)
}
diff --git a/apps/editor/components/kitchen-browser.tsx b/apps/editor/components/kitchen-browser.tsx
new file mode 100644
index 0000000000..d8175f72e1
--- /dev/null
+++ b/apps/editor/components/kitchen-browser.tsx
@@ -0,0 +1,133 @@
+'use client'
+
+import {
+ type AnyNodeId,
+ type CabinetNode,
+ emitter,
+ resolveLevelId,
+ useScene,
+} from '@pascal-app/core'
+import { useCommandPalette, useCommandRegistry, useEditor } from '@pascal-app/editor'
+import {
+ beginKitchenPlacement,
+ findKitchenItems,
+ KITCHEN_ITEMS,
+ KitchenCollection,
+ kitchenPresetForModule,
+} from '@pascal-app/nodes'
+import { useViewer } from '@pascal-app/viewer'
+import { useEffect } from 'react'
+import { useShallow } from 'zustand/react/shallow'
+
+const NO_ITEMS: never[] = []
+
+function focusKitchenItem(id: AnyNodeId) {
+ const nodes = useScene.getState().nodes
+ const node = nodes[id]
+ if (!node) return
+ const levelId = resolveLevelId(node, nodes)
+ const level = levelId ? nodes[levelId as AnyNodeId] : undefined
+ const building = level?.parentId ? nodes[level.parentId as AnyNodeId] : undefined
+ useEditor.getState().setMode('select')
+ useViewer.getState().setSelection({
+ selectedIds: [id],
+ ...(level?.type === 'level' ? { levelId: level.id } : {}),
+ ...(building?.type === 'building' ? { buildingId: building.id } : {}),
+ })
+ emitter.emit('camera-controls:focus', { nodeId: id })
+ emitter.emit('selection:find-node', node)
+}
+
+export function KitchenBrowser({ query = '' }: { query?: string }) {
+ const defaults = useEditor((state) => state.toolDefaults.cabinet)
+ const mode = useEditor((state) => state.mode)
+ // Read the scene only while a query asks for placed items.
+ const matches = useScene(
+ useShallow((state) => (query.trim() ? findKitchenItems(state.nodes, query) : NO_ITEMS)),
+ )
+ const active = KITCHEN_ITEMS.find((item) => item.id === defaults?.kitchenPreset)
+ return (
+
+
+
Add to kitchen
+
+ Choose an item, then click to place it. Appliances include their cabinetry.
+
+
+
+ {query.trim() && (
+
+
Find in this project · {matches.length}
+ {matches.map((node) => (
+
focusKitchenItem(node.id)}
+ className="block w-full rounded-lg border border-border/60 px-3 py-2 text-left text-xs hover:bg-muted focus-visible:ring-2 focus-visible:ring-ring"
+ >
+ {node.name || 'Kitchen cabinet'}
+
+ Select and show in scene
+
+
+ ))}
+ {!matches.length && (
+
No matching kitchen items placed yet.
+ )}
+
+ )}
+
+ )
+}
+
+export function KitchenCommands() {
+ const register = useCommandRegistry((state) => state.register)
+ // Always mounted: the placed items are read only while the palette is open to list them.
+ const paletteOpen = useCommandPalette((state) => state.open)
+ const modules = useScene(
+ useShallow((state) => (paletteOpen ? findKitchenItems(state.nodes, '') : NO_ITEMS)),
+ )
+ useEffect(
+ () =>
+ register(
+ KITCHEN_ITEMS.map((item) => ({
+ id: `kitchen.add.${item.id}`,
+ label: `Add ${item.label}`,
+ group: 'Kitchen · Add',
+ keywords: item.keywords.split(' '),
+ execute: () => beginKitchenPlacement(item.id),
+ })),
+ ),
+ [register],
+ )
+ useEffect(
+ () =>
+ register(
+ modules.map((node) => {
+ const nodes = useScene.getState().nodes
+ const parent = node.parentId ? nodes[node.parentId as AnyNodeId] : undefined
+ const preset =
+ node.type === 'cabinet-module'
+ ? kitchenPresetForModule(
+ node,
+ parent?.type === 'cabinet' ? (parent as CabinetNode) : undefined,
+ )
+ : 'base-door'
+ const item = KITCHEN_ITEMS.find((entry) => entry.id === preset)!
+ return {
+ id: `kitchen.find.${node.id}`,
+ label: `Find ${node.name || item.label}`,
+ group: 'Kitchen · In this project',
+ keywords: item.keywords.split(' '),
+ execute: () => focusKitchenItem(node.id),
+ }
+ }),
+ ),
+ [register, modules],
+ )
+ return null
+}
diff --git a/apps/editor/components/scene-loader.tsx b/apps/editor/components/scene-loader.tsx
index 251c1bb030..9a1263f3ef 100644
--- a/apps/editor/components/scene-loader.tsx
+++ b/apps/editor/components/scene-loader.tsx
@@ -21,6 +21,7 @@ import { type PersistedSceneGraph, sceneGraphSignature } from '@/lib/scene-signa
import { useThumbnailAutosave } from '@/lib/use-thumbnail-autosave'
import { BuildTab } from './build-tab'
import { EditorNavbar } from './editor-navbar'
+import { KitchenCommands } from './kitchen-browser'
import { PaintPanel } from './paint-panel'
import { EditorViewerToolbarLeft, EditorViewerToolbarRight } from './viewer-toolbar'
import { useWebXRFeature, useWebXRInstalled, WebXRFeatureRuntime } from './webxr-feature-gate'
@@ -368,6 +369,7 @@ function SceneEditor({ initialScene, meta: initialMeta }: SceneLoaderProps) {
{saveError}
)}
+