@pascal-app/editor 0.6.0 → 0.8.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +13 -9
- package/src/components/editor/bottom-sheet.tsx +149 -0
- package/src/components/editor/custom-camera-controls.tsx +74 -5
- package/src/components/editor/editor-layout-mobile.tsx +264 -0
- package/src/components/editor/editor-layout-v2.tsx +24 -3
- package/src/components/editor/first-person/build-collider-world.ts +363 -0
- package/src/components/editor/first-person/bvh-ecctrl.tsx +860 -0
- package/src/components/editor/first-person-controls.tsx +496 -143
- package/src/components/editor/floating-action-menu.tsx +32 -55
- package/src/components/editor/floorplan-background-selection.ts +113 -0
- package/src/components/editor/floorplan-panel.tsx +9861 -3297
- package/src/components/editor/index.tsx +295 -32
- package/src/components/editor/selection-manager.tsx +575 -13
- package/src/components/editor/snapshot-capture-overlay.tsx +465 -0
- package/src/components/editor/thumbnail-generator.tsx +56 -68
- package/src/components/editor/use-floorplan-background-placement.ts +257 -0
- package/src/components/editor/use-floorplan-hit-testing.ts +171 -0
- package/src/components/editor/use-floorplan-scene-data.ts +189 -0
- package/src/components/editor/wall-measurement-label.tsx +267 -36
- package/src/components/editor-2d/floorplan-action-menu-layer.tsx +95 -0
- package/src/components/editor-2d/floorplan-cursor-indicator-overlay.tsx +160 -0
- package/src/components/editor-2d/floorplan-hotkey-handlers.tsx +92 -0
- package/src/components/editor-2d/renderers/floorplan-draft-layer.tsx +124 -0
- package/src/components/editor-2d/renderers/floorplan-marquee-layer.tsx +58 -0
- package/src/components/editor-2d/renderers/floorplan-measurements-layer.tsx +202 -0
- package/src/components/editor-2d/renderers/floorplan-roof-layer.tsx +113 -0
- package/src/components/editor-2d/renderers/floorplan-stair-layer.tsx +474 -0
- package/src/components/editor-2d/svg-paths.ts +119 -0
- package/src/components/systems/ceiling/ceiling-selection-affordance-system.tsx +10 -12
- package/src/components/systems/roof/roof-edit-system.tsx +1 -1
- package/src/components/systems/stair/stair-edit-system.tsx +1 -1
- package/src/components/systems/zone/zone-label-editor-system.tsx +0 -0
- package/src/components/systems/zone/zone-system.tsx +0 -0
- package/src/components/tools/ceiling/ceiling-boundary-editor.tsx +1 -0
- package/src/components/tools/ceiling/ceiling-hole-editor.tsx +1 -0
- package/src/components/tools/ceiling/ceiling-tool.tsx +5 -5
- package/src/components/tools/ceiling/move-ceiling-tool.tsx +9 -2
- package/src/components/tools/column/column-tool.tsx +97 -0
- package/src/components/tools/column/move-column-tool.tsx +105 -0
- package/src/components/tools/door/door-tool.tsx +7 -0
- package/src/components/tools/door/move-door-tool.tsx +28 -8
- package/src/components/tools/fence/curve-fence-tool.tsx +4 -5
- package/src/components/tools/fence/fence-drafting.ts +10 -3
- package/src/components/tools/fence/fence-tool.tsx +160 -4
- package/src/components/tools/fence/move-fence-endpoint-tool.tsx +139 -25
- package/src/components/tools/fence/move-fence-tool.tsx +111 -40
- package/src/components/tools/item/move-tool.tsx +7 -1
- package/src/components/tools/item/placement-math.ts +32 -5
- package/src/components/tools/item/placement-strategies.ts +110 -31
- package/src/components/tools/item/placement-types.ts +7 -0
- package/src/components/tools/item/use-draft-node.ts +1 -0
- package/src/components/tools/item/use-placement-coordinator.tsx +558 -52
- package/src/components/tools/roof/move-roof-tool.tsx +29 -17
- package/src/components/tools/select/box-select-tool.tsx +12 -17
- package/src/components/tools/shared/polygon-editor.tsx +153 -28
- package/src/components/tools/shared/segment-angle.ts +156 -0
- package/src/components/tools/slab/slab-boundary-editor.tsx +1 -0
- package/src/components/tools/slab/slab-hole-editor.tsx +1 -0
- package/src/components/tools/spawn/move-spawn-tool.tsx +101 -0
- package/src/components/tools/spawn/spawn-tool.tsx +130 -0
- package/src/components/tools/tool-manager.tsx +20 -5
- package/src/components/tools/wall/curve-wall-tool.tsx +8 -6
- package/src/components/tools/wall/move-wall-endpoint-tool.tsx +131 -27
- package/src/components/tools/wall/move-wall-tool.tsx +6 -4
- package/src/components/tools/wall/wall-drafting.ts +18 -9
- package/src/components/tools/wall/wall-tool.tsx +136 -4
- package/src/components/tools/window/move-window-tool.tsx +18 -0
- package/src/components/tools/window/window-tool.tsx +5 -0
- package/src/components/tools/zone/zone-tool.tsx +20 -5
- package/src/components/ui/action-menu/camera-actions.tsx +37 -33
- package/src/components/ui/action-menu/control-modes.tsx +34 -1
- package/src/components/ui/action-menu/furnish-tools.tsx +6 -92
- package/src/components/ui/action-menu/index.tsx +98 -59
- package/src/components/ui/action-menu/structure-tools.tsx +2 -0
- package/src/components/ui/action-menu/view-toggles.tsx +418 -41
- package/src/components/ui/command-palette/editor-commands.tsx +24 -5
- package/src/components/ui/command-palette/index.tsx +4 -255
- package/src/components/ui/controls/material-picker.tsx +154 -164
- package/src/components/ui/controls/slider-control.tsx +66 -18
- package/src/components/ui/floating-level-selector.tsx +286 -55
- package/src/components/ui/helpers/helper-manager.tsx +10 -0
- package/src/components/ui/item-catalog/catalog-items.tsx +2563 -1239
- package/src/components/ui/item-catalog/item-catalog.tsx +96 -187
- package/src/components/ui/level-duplicate-dialog.tsx +113 -0
- package/src/components/ui/panels/ceiling-panel.tsx +3 -28
- package/src/components/ui/panels/column-panel.tsx +759 -0
- package/src/components/ui/panels/door-panel.tsx +989 -290
- package/src/components/ui/panels/fence-panel.tsx +2 -49
- package/src/components/ui/panels/mobile-panel-sheet.tsx +108 -0
- package/src/components/ui/panels/mobile-selection-bar.tsx +100 -0
- package/src/components/ui/panels/node-display.ts +39 -0
- package/src/components/ui/panels/paint-panel.tsx +163 -0
- package/src/components/ui/panels/panel-manager.tsx +208 -28
- package/src/components/ui/panels/panel-wrapper.tsx +48 -39
- package/src/components/ui/panels/reference-panel.tsx +253 -5
- package/src/components/ui/panels/roof-panel.tsx +13 -64
- package/src/components/ui/panels/roof-segment-panel.tsx +0 -25
- package/src/components/ui/panels/slab-panel.tsx +4 -30
- package/src/components/ui/panels/spawn-panel.tsx +161 -0
- package/src/components/ui/panels/stair-panel.tsx +20 -74
- package/src/components/ui/panels/stair-segment-panel.tsx +0 -25
- package/src/components/ui/panels/wall-panel.tsx +10 -8
- package/src/components/ui/panels/window-panel.tsx +668 -139
- package/src/components/ui/primitives/number-input.tsx +1 -1
- package/src/components/ui/primitives/sidebar.tsx +0 -0
- package/src/components/ui/sidebar/app-sidebar.tsx +0 -0
- package/src/components/ui/sidebar/icon-rail.tsx +0 -0
- package/src/components/ui/sidebar/mobile-tab-bar.tsx +46 -0
- package/src/components/ui/sidebar/panels/items-panel/index.tsx +330 -0
- package/src/components/ui/sidebar/panels/settings-panel/index.tsx +0 -0
- package/src/components/ui/sidebar/panels/settings-panel/keyboard-shortcuts-dialog.tsx +2 -2
- package/src/components/ui/sidebar/panels/site-panel/building-tree-node.tsx +2 -2
- package/src/components/ui/sidebar/panels/site-panel/ceiling-tree-node.tsx +0 -0
- package/src/components/ui/sidebar/panels/site-panel/column-tree-node.tsx +77 -0
- package/src/components/ui/sidebar/panels/site-panel/index.tsx +105 -22
- package/src/components/ui/sidebar/panels/site-panel/level-tree-node.tsx +2 -2
- package/src/components/ui/sidebar/panels/site-panel/slab-tree-node.tsx +0 -0
- package/src/components/ui/sidebar/panels/site-panel/spawn-tree-node.tsx +76 -0
- package/src/components/ui/sidebar/panels/site-panel/tree-node.tsx +11 -3
- package/src/components/ui/sidebar/panels/site-panel/zone-tree-node.tsx +10 -5
- package/src/components/ui/sidebar/panels/zone-panel/index.tsx +1 -1
- package/src/components/ui/sidebar/tab-bar.tsx +3 -0
- package/src/components/ui/slider.tsx +1 -1
- package/src/components/viewer-overlay.tsx +0 -0
- package/src/components/viewer-zone-system.tsx +0 -0
- package/src/hooks/use-auto-frame.ts +45 -0
- package/src/hooks/use-auto-save.ts +14 -0
- package/src/hooks/use-keyboard.ts +74 -7
- package/src/hooks/use-mobile.ts +12 -12
- package/src/index.tsx +8 -1
- package/src/lib/door-interaction.ts +88 -0
- package/src/lib/floorplan/geometry.ts +263 -0
- package/src/lib/floorplan/index.ts +38 -0
- package/src/lib/floorplan/items.ts +179 -0
- package/src/lib/floorplan/selection-tool.ts +231 -0
- package/src/lib/floorplan/stairs.ts +478 -0
- package/src/lib/floorplan/types.ts +57 -0
- package/src/lib/floorplan/walls.ts +23 -0
- package/src/lib/guide-events.ts +10 -0
- package/src/lib/level-duplication.test.ts +70 -0
- package/src/lib/level-duplication.ts +153 -0
- package/src/lib/local-guide-image.ts +42 -0
- package/src/lib/material-paint.ts +284 -0
- package/src/lib/roof-duplication.ts +214 -0
- package/src/lib/scene-bounds.test.ts +183 -0
- package/src/lib/scene-bounds.ts +169 -0
- package/src/lib/scene.ts +0 -0
- package/src/lib/sfx-bus.ts +2 -0
- package/src/lib/sfx-player.ts +5 -5
- package/src/lib/stair-duplication.ts +126 -0
- package/src/lib/window-interaction.ts +86 -0
- package/src/store/use-editor.tsx +186 -62
- package/tsconfig.json +2 -1
- package/src/components/feedback-dialog.tsx +0 -265
- package/src/components/pascal-radio.tsx +0 -280
- package/src/components/preview-button.tsx +0 -16
- package/src/components/ui/viewer-toolbar.tsx +0 -395
|
@@ -11,9 +11,11 @@ import {
|
|
|
11
11
|
normalizeWallCurveOffset,
|
|
12
12
|
useScene,
|
|
13
13
|
} from '@pascal-app/core'
|
|
14
|
+
|
|
14
15
|
import { useViewer } from '@pascal-app/viewer'
|
|
15
16
|
import { Move, Spline } from 'lucide-react'
|
|
16
17
|
import { useCallback } from 'react'
|
|
18
|
+
|
|
17
19
|
import { sfxEmitter } from '../../../lib/sfx-bus'
|
|
18
20
|
import useEditor from '../../../store/use-editor'
|
|
19
21
|
import { ActionButton, ActionGroup } from '../controls/action-button'
|
|
@@ -83,34 +85,6 @@ export function FencePanel() {
|
|
|
83
85
|
setSelection({ selectedIds: [] })
|
|
84
86
|
}, [setSelection])
|
|
85
87
|
|
|
86
|
-
const handleMove = useCallback(() => {
|
|
87
|
-
if (!node) return
|
|
88
|
-
sfxEmitter.emit('sfx:item-pick')
|
|
89
|
-
setMovingNode(node)
|
|
90
|
-
setSelection({ selectedIds: [] })
|
|
91
|
-
}, [node, setMovingNode, setSelection])
|
|
92
|
-
|
|
93
|
-
const handleCurve = useCallback(() => {
|
|
94
|
-
if (!node) return
|
|
95
|
-
sfxEmitter.emit('sfx:item-pick')
|
|
96
|
-
setCurvingFence(node)
|
|
97
|
-
setSelection({ selectedIds: [] })
|
|
98
|
-
}, [node, setCurvingFence, setSelection])
|
|
99
|
-
|
|
100
|
-
const handleMaterialPresetChange = useCallback(
|
|
101
|
-
(materialPreset: string) => {
|
|
102
|
-
handleUpdate({ materialPreset, material: undefined })
|
|
103
|
-
},
|
|
104
|
-
[handleUpdate],
|
|
105
|
-
)
|
|
106
|
-
|
|
107
|
-
const handleCustomMaterialChange = useCallback(
|
|
108
|
-
(material: MaterialSchema) => {
|
|
109
|
-
handleUpdate({ material, materialPreset: undefined })
|
|
110
|
-
},
|
|
111
|
-
[handleUpdate],
|
|
112
|
-
)
|
|
113
|
-
|
|
114
88
|
if (!(node && node.type === 'fence' && selectedId && selectedCount === 1)) return null
|
|
115
89
|
|
|
116
90
|
const length = getWallCurveLength(node)
|
|
@@ -243,27 +217,6 @@ export function FencePanel() {
|
|
|
243
217
|
value={node.edgeInset}
|
|
244
218
|
/>
|
|
245
219
|
</PanelSection>
|
|
246
|
-
|
|
247
|
-
<PanelSection title="Material">
|
|
248
|
-
<MaterialPicker
|
|
249
|
-
nodeType="fence"
|
|
250
|
-
onChange={handleCustomMaterialChange}
|
|
251
|
-
onSelectMaterialPreset={handleMaterialPresetChange}
|
|
252
|
-
selectedMaterialPreset={node.materialPreset}
|
|
253
|
-
value={node.material}
|
|
254
|
-
/>
|
|
255
|
-
</PanelSection>
|
|
256
|
-
|
|
257
|
-
<PanelSection title="Actions">
|
|
258
|
-
<ActionGroup>
|
|
259
|
-
<ActionButton icon={<Move className="h-3.5 w-3.5" />} label="Move" onClick={handleMove} />
|
|
260
|
-
<ActionButton
|
|
261
|
-
icon={<Spline className="h-3.5 w-3.5" />}
|
|
262
|
-
label="Curve"
|
|
263
|
-
onClick={handleCurve}
|
|
264
|
-
/>
|
|
265
|
-
</ActionGroup>
|
|
266
|
-
</PanelSection>
|
|
267
220
|
</PanelWrapper>
|
|
268
221
|
)
|
|
269
222
|
}
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
'use client'
|
|
2
|
+
|
|
3
|
+
import { X } from 'lucide-react'
|
|
4
|
+
import { AnimatePresence, motion } from 'motion/react'
|
|
5
|
+
import Image from 'next/image'
|
|
6
|
+
import { type ReactNode, useEffect, useState } from 'react'
|
|
7
|
+
import { createPortal } from 'react-dom'
|
|
8
|
+
import useEditor from '../../../store/use-editor'
|
|
9
|
+
|
|
10
|
+
interface MobilePanelSheetProps {
|
|
11
|
+
open: boolean
|
|
12
|
+
onClose: () => void
|
|
13
|
+
icon?: string
|
|
14
|
+
title: string
|
|
15
|
+
children: ReactNode
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
const HEIGHT_VH = 50
|
|
19
|
+
const DRAG_CLOSE_THRESHOLD_PX = 120
|
|
20
|
+
|
|
21
|
+
export function MobilePanelSheet({ open, onClose, icon, title, children }: MobilePanelSheetProps) {
|
|
22
|
+
const [mounted, setMounted] = useState(false)
|
|
23
|
+
const setMobilePanelSheetHeight = useEditor((s) => s.setMobilePanelSheetHeight)
|
|
24
|
+
|
|
25
|
+
useEffect(() => {
|
|
26
|
+
setMounted(true)
|
|
27
|
+
}, [])
|
|
28
|
+
|
|
29
|
+
// Publish the sheet's pixel height to the shared store so the mobile layout
|
|
30
|
+
// can shrink the viewer container and preview edits live. 0 means closed.
|
|
31
|
+
// Tracks visualViewport so the value follows the on-screen keyboard on iOS.
|
|
32
|
+
useEffect(() => {
|
|
33
|
+
if (!open) {
|
|
34
|
+
setMobilePanelSheetHeight(0)
|
|
35
|
+
return
|
|
36
|
+
}
|
|
37
|
+
const compute = () => {
|
|
38
|
+
const vh = window.visualViewport?.height ?? window.innerHeight
|
|
39
|
+
setMobilePanelSheetHeight(Math.round((vh * HEIGHT_VH) / 100))
|
|
40
|
+
}
|
|
41
|
+
compute()
|
|
42
|
+
const vv = window.visualViewport
|
|
43
|
+
vv?.addEventListener('resize', compute)
|
|
44
|
+
window.addEventListener('resize', compute)
|
|
45
|
+
return () => {
|
|
46
|
+
vv?.removeEventListener('resize', compute)
|
|
47
|
+
window.removeEventListener('resize', compute)
|
|
48
|
+
setMobilePanelSheetHeight(0)
|
|
49
|
+
}
|
|
50
|
+
}, [open, setMobilePanelSheetHeight])
|
|
51
|
+
|
|
52
|
+
if (!mounted) return null
|
|
53
|
+
|
|
54
|
+
return createPortal(
|
|
55
|
+
<AnimatePresence>
|
|
56
|
+
{open && (
|
|
57
|
+
<motion.div
|
|
58
|
+
animate={{ y: 0 }}
|
|
59
|
+
className="dark fixed right-0 bottom-0 left-0 z-[60] flex flex-col overflow-hidden rounded-t-2xl bg-sidebar text-sidebar-foreground shadow-[0_-8px_24px_rgba(0,0,0,0.24)]"
|
|
60
|
+
drag="y"
|
|
61
|
+
dragConstraints={{ top: 0, bottom: 0 }}
|
|
62
|
+
dragElastic={{ top: 0, bottom: 0.4 }}
|
|
63
|
+
exit={{ y: '100%' }}
|
|
64
|
+
initial={{ y: '100%' }}
|
|
65
|
+
onDragEnd={(_, info) => {
|
|
66
|
+
if (info.offset.y > DRAG_CLOSE_THRESHOLD_PX) onClose()
|
|
67
|
+
}}
|
|
68
|
+
style={{ height: `${HEIGHT_VH}dvh` }}
|
|
69
|
+
transition={{ type: 'spring', stiffness: 320, damping: 32, mass: 0.8 }}
|
|
70
|
+
>
|
|
71
|
+
<div className="flex h-6 shrink-0 cursor-grab touch-none items-center justify-center active:cursor-grabbing">
|
|
72
|
+
<div className="h-1 w-10 rounded-full bg-muted-foreground/40" />
|
|
73
|
+
</div>
|
|
74
|
+
|
|
75
|
+
<div className="flex shrink-0 items-center justify-between border-border/50 border-b px-3 pt-1 pb-3">
|
|
76
|
+
<div className="flex min-w-0 items-center gap-2">
|
|
77
|
+
{icon && (
|
|
78
|
+
<Image
|
|
79
|
+
alt=""
|
|
80
|
+
className="shrink-0 object-contain"
|
|
81
|
+
height={18}
|
|
82
|
+
src={icon}
|
|
83
|
+
width={18}
|
|
84
|
+
/>
|
|
85
|
+
)}
|
|
86
|
+
<h2 className="truncate font-semibold text-foreground text-sm tracking-tight">
|
|
87
|
+
{title}
|
|
88
|
+
</h2>
|
|
89
|
+
</div>
|
|
90
|
+
<button
|
|
91
|
+
aria-label="Close"
|
|
92
|
+
className="flex h-8 w-8 items-center justify-center rounded-md bg-[#2C2C2E] text-muted-foreground transition-colors hover:bg-[#3e3e3e] hover:text-foreground"
|
|
93
|
+
onClick={onClose}
|
|
94
|
+
type="button"
|
|
95
|
+
>
|
|
96
|
+
<X className="h-4 w-4" />
|
|
97
|
+
</button>
|
|
98
|
+
</div>
|
|
99
|
+
|
|
100
|
+
<div className="no-scrollbar flex min-h-0 flex-1 flex-col overflow-y-auto">
|
|
101
|
+
{children}
|
|
102
|
+
</div>
|
|
103
|
+
</motion.div>
|
|
104
|
+
)}
|
|
105
|
+
</AnimatePresence>,
|
|
106
|
+
document.body,
|
|
107
|
+
)
|
|
108
|
+
}
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
'use client'
|
|
2
|
+
|
|
3
|
+
import type { AnyNode } from '@pascal-app/core'
|
|
4
|
+
import { Copy, Move, SlidersHorizontal, Trash2 } from 'lucide-react'
|
|
5
|
+
import Image from 'next/image'
|
|
6
|
+
import type { MouseEventHandler } from 'react'
|
|
7
|
+
import { cn } from '../../../lib/utils'
|
|
8
|
+
import { getNodeDisplay } from './node-display'
|
|
9
|
+
|
|
10
|
+
interface MobileSelectionBarProps {
|
|
11
|
+
node: AnyNode
|
|
12
|
+
onMove: () => void
|
|
13
|
+
onDuplicate: () => void
|
|
14
|
+
onDelete: () => void
|
|
15
|
+
onEdit: () => void
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
const ACTION_BTN =
|
|
19
|
+
'flex h-9 w-9 items-center justify-center rounded-lg text-muted-foreground transition-colors hover:bg-white/8 hover:text-foreground'
|
|
20
|
+
|
|
21
|
+
export function MobileSelectionBar({
|
|
22
|
+
node,
|
|
23
|
+
onMove,
|
|
24
|
+
onDuplicate,
|
|
25
|
+
onDelete,
|
|
26
|
+
onEdit,
|
|
27
|
+
}: MobileSelectionBarProps) {
|
|
28
|
+
const { icon, label } = getNodeDisplay(node)
|
|
29
|
+
|
|
30
|
+
const stop: MouseEventHandler<HTMLButtonElement> = (e) => e.stopPropagation()
|
|
31
|
+
|
|
32
|
+
return (
|
|
33
|
+
<div className="pointer-events-auto absolute right-3 bottom-6 left-3 z-50 flex h-12 items-stretch gap-1 rounded-2xl border border-border/50 bg-background/95 px-2 shadow-2xl backdrop-blur-xl">
|
|
34
|
+
<button
|
|
35
|
+
aria-label={`Edit ${label}`}
|
|
36
|
+
className={cn(
|
|
37
|
+
'flex min-w-0 flex-1 items-center gap-2 rounded-lg px-2 text-left transition-colors hover:bg-white/8',
|
|
38
|
+
)}
|
|
39
|
+
onClick={onEdit}
|
|
40
|
+
type="button"
|
|
41
|
+
>
|
|
42
|
+
<Image
|
|
43
|
+
alt=""
|
|
44
|
+
className="shrink-0 rounded object-contain"
|
|
45
|
+
height={20}
|
|
46
|
+
src={icon}
|
|
47
|
+
width={20}
|
|
48
|
+
/>
|
|
49
|
+
<span className="truncate font-medium text-foreground text-sm">{label}</span>
|
|
50
|
+
</button>
|
|
51
|
+
|
|
52
|
+
<div className="flex items-center gap-0.5 border-border/40 border-l pl-1">
|
|
53
|
+
<button
|
|
54
|
+
aria-label="Move"
|
|
55
|
+
className={ACTION_BTN}
|
|
56
|
+
onClick={(e) => {
|
|
57
|
+
stop(e)
|
|
58
|
+
onMove()
|
|
59
|
+
}}
|
|
60
|
+
type="button"
|
|
61
|
+
>
|
|
62
|
+
<Move className="h-4 w-4" />
|
|
63
|
+
</button>
|
|
64
|
+
<button
|
|
65
|
+
aria-label="Duplicate"
|
|
66
|
+
className={ACTION_BTN}
|
|
67
|
+
onClick={(e) => {
|
|
68
|
+
stop(e)
|
|
69
|
+
onDuplicate()
|
|
70
|
+
}}
|
|
71
|
+
type="button"
|
|
72
|
+
>
|
|
73
|
+
<Copy className="h-4 w-4" />
|
|
74
|
+
</button>
|
|
75
|
+
<button
|
|
76
|
+
aria-label="Delete"
|
|
77
|
+
className={cn(ACTION_BTN, 'hover:bg-red-500/15 hover:text-red-400')}
|
|
78
|
+
onClick={(e) => {
|
|
79
|
+
stop(e)
|
|
80
|
+
onDelete()
|
|
81
|
+
}}
|
|
82
|
+
type="button"
|
|
83
|
+
>
|
|
84
|
+
<Trash2 className="h-4 w-4" />
|
|
85
|
+
</button>
|
|
86
|
+
<button
|
|
87
|
+
aria-label="Edit properties"
|
|
88
|
+
className={ACTION_BTN}
|
|
89
|
+
onClick={(e) => {
|
|
90
|
+
stop(e)
|
|
91
|
+
onEdit()
|
|
92
|
+
}}
|
|
93
|
+
type="button"
|
|
94
|
+
>
|
|
95
|
+
<SlidersHorizontal className="h-4 w-4" />
|
|
96
|
+
</button>
|
|
97
|
+
</div>
|
|
98
|
+
</div>
|
|
99
|
+
)
|
|
100
|
+
}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import type { AnyNode } from '@pascal-app/core'
|
|
2
|
+
|
|
3
|
+
export type NodeDisplay = {
|
|
4
|
+
icon: string
|
|
5
|
+
label: string
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
const TYPE_DEFAULTS: Record<string, NodeDisplay> = {
|
|
9
|
+
item: { icon: '/icons/furniture.png', label: 'Item' },
|
|
10
|
+
wall: { icon: '/icons/wall.png', label: 'Wall' },
|
|
11
|
+
door: { icon: '/icons/door.png', label: 'Door' },
|
|
12
|
+
window: { icon: '/icons/window.png', label: 'Window' },
|
|
13
|
+
slab: { icon: '/icons/floor.png', label: 'Slab' },
|
|
14
|
+
ceiling: { icon: '/icons/ceiling.png', label: 'Ceiling' },
|
|
15
|
+
column: { icon: '/icons/column.png', label: 'Column' },
|
|
16
|
+
fence: { icon: '/icons/fence.png', label: 'Fence' },
|
|
17
|
+
roof: { icon: '/icons/roof.png', label: 'Roof' },
|
|
18
|
+
'roof-segment': { icon: '/icons/roof.png', label: 'Roof segment' },
|
|
19
|
+
stair: { icon: '/icons/stair.png', label: 'Stair' },
|
|
20
|
+
'stair-segment': { icon: '/icons/stair.png', label: 'Stair segment' },
|
|
21
|
+
scan: { icon: '/icons/mesh.png', label: '3D Scan' },
|
|
22
|
+
guide: { icon: '/icons/floorplan.png', label: 'Guide image' },
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export function getNodeDisplay(node: AnyNode | null | undefined): NodeDisplay {
|
|
26
|
+
if (!node) return { icon: '/icons/select.png', label: 'Selection' }
|
|
27
|
+
const fallback = TYPE_DEFAULTS[node.type] ?? { icon: '/icons/select.png', label: node.type }
|
|
28
|
+
// Item nodes carry an asset with its own thumbnail/name
|
|
29
|
+
if (node.type === 'item') {
|
|
30
|
+
return {
|
|
31
|
+
icon: node.asset?.thumbnail || fallback.icon,
|
|
32
|
+
label: node.name || node.asset?.name || fallback.label,
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
return {
|
|
36
|
+
icon: fallback.icon,
|
|
37
|
+
label: node.name || fallback.label,
|
|
38
|
+
}
|
|
39
|
+
}
|
|
@@ -0,0 +1,163 @@
|
|
|
1
|
+
'use client'
|
|
2
|
+
|
|
3
|
+
import useEditor from '../../../store/use-editor'
|
|
4
|
+
import { PanelSection } from '../controls/panel-section'
|
|
5
|
+
import { Input } from '../primitives/input'
|
|
6
|
+
import { PanelWrapper } from './panel-wrapper'
|
|
7
|
+
|
|
8
|
+
function buildDefaultCustomMaterial() {
|
|
9
|
+
return {
|
|
10
|
+
preset: 'custom' as const,
|
|
11
|
+
properties: {
|
|
12
|
+
color: '#ffffff',
|
|
13
|
+
roughness: 0.5,
|
|
14
|
+
metalness: 0,
|
|
15
|
+
opacity: 1,
|
|
16
|
+
transparent: false,
|
|
17
|
+
side: 'front' as const,
|
|
18
|
+
},
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export function PaintPanel() {
|
|
23
|
+
const activePaintMaterial = useEditor((state) => state.activePaintMaterial)
|
|
24
|
+
const activePaintTarget = useEditor((state) => state.activePaintTarget)
|
|
25
|
+
const setActivePaintMaterial = useEditor((state) => state.setActivePaintMaterial)
|
|
26
|
+
const setPaintPanelOpen = useEditor((state) => state.setPaintPanelOpen)
|
|
27
|
+
|
|
28
|
+
const customMaterial =
|
|
29
|
+
activePaintMaterial?.material?.properties && !activePaintMaterial.materialPreset
|
|
30
|
+
? activePaintMaterial.material
|
|
31
|
+
: null
|
|
32
|
+
|
|
33
|
+
if (!customMaterial) return null
|
|
34
|
+
|
|
35
|
+
const currentProps = customMaterial.properties ?? buildDefaultCustomMaterial().properties
|
|
36
|
+
|
|
37
|
+
const updateCustomMaterial = (
|
|
38
|
+
updates: Partial<typeof currentProps>,
|
|
39
|
+
nextTransparent = currentProps.transparent,
|
|
40
|
+
) => {
|
|
41
|
+
setActivePaintMaterial({
|
|
42
|
+
material: {
|
|
43
|
+
preset: 'custom',
|
|
44
|
+
properties: {
|
|
45
|
+
...currentProps,
|
|
46
|
+
...updates,
|
|
47
|
+
transparent: nextTransparent,
|
|
48
|
+
},
|
|
49
|
+
},
|
|
50
|
+
sourceTarget: activePaintMaterial?.sourceTarget ?? activePaintTarget,
|
|
51
|
+
})
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
return (
|
|
55
|
+
<PanelWrapper onClose={() => setPaintPanelOpen(false)} title="Material" width={320}>
|
|
56
|
+
<PanelSection title="Custom Material">
|
|
57
|
+
<div className="space-y-3">
|
|
58
|
+
<div className="space-y-2">
|
|
59
|
+
<label className="block font-medium text-muted-foreground text-xs uppercase tracking-[0.12em]">
|
|
60
|
+
Color
|
|
61
|
+
</label>
|
|
62
|
+
<div className="flex items-center gap-2">
|
|
63
|
+
<input
|
|
64
|
+
className="h-10 w-14 cursor-pointer rounded-md border border-input bg-transparent"
|
|
65
|
+
onChange={(e) => updateCustomMaterial({ color: e.target.value })}
|
|
66
|
+
type="color"
|
|
67
|
+
value={currentProps.color}
|
|
68
|
+
/>
|
|
69
|
+
<Input
|
|
70
|
+
onChange={(e) => updateCustomMaterial({ color: e.target.value })}
|
|
71
|
+
value={currentProps.color}
|
|
72
|
+
/>
|
|
73
|
+
</div>
|
|
74
|
+
</div>
|
|
75
|
+
|
|
76
|
+
<div className="space-y-2">
|
|
77
|
+
<div className="flex items-center justify-between">
|
|
78
|
+
<label className="font-medium text-muted-foreground text-xs uppercase tracking-[0.12em]">
|
|
79
|
+
Roughness
|
|
80
|
+
</label>
|
|
81
|
+
<span className="font-mono text-muted-foreground text-xs">
|
|
82
|
+
{currentProps.roughness.toFixed(2)}
|
|
83
|
+
</span>
|
|
84
|
+
</div>
|
|
85
|
+
<input
|
|
86
|
+
className="h-2 w-full cursor-pointer appearance-none rounded-full bg-accent"
|
|
87
|
+
max={1}
|
|
88
|
+
min={0}
|
|
89
|
+
onChange={(e) =>
|
|
90
|
+
updateCustomMaterial({ roughness: Number.parseFloat(e.target.value) })
|
|
91
|
+
}
|
|
92
|
+
step={0.01}
|
|
93
|
+
type="range"
|
|
94
|
+
value={currentProps.roughness}
|
|
95
|
+
/>
|
|
96
|
+
</div>
|
|
97
|
+
|
|
98
|
+
<div className="space-y-2">
|
|
99
|
+
<div className="flex items-center justify-between">
|
|
100
|
+
<label className="font-medium text-muted-foreground text-xs uppercase tracking-[0.12em]">
|
|
101
|
+
Metalness
|
|
102
|
+
</label>
|
|
103
|
+
<span className="font-mono text-muted-foreground text-xs">
|
|
104
|
+
{currentProps.metalness.toFixed(2)}
|
|
105
|
+
</span>
|
|
106
|
+
</div>
|
|
107
|
+
<input
|
|
108
|
+
className="h-2 w-full cursor-pointer appearance-none rounded-full bg-accent"
|
|
109
|
+
max={1}
|
|
110
|
+
min={0}
|
|
111
|
+
onChange={(e) =>
|
|
112
|
+
updateCustomMaterial({ metalness: Number.parseFloat(e.target.value) })
|
|
113
|
+
}
|
|
114
|
+
step={0.01}
|
|
115
|
+
type="range"
|
|
116
|
+
value={currentProps.metalness}
|
|
117
|
+
/>
|
|
118
|
+
</div>
|
|
119
|
+
|
|
120
|
+
<div className="space-y-2">
|
|
121
|
+
<div className="flex items-center justify-between">
|
|
122
|
+
<label className="font-medium text-muted-foreground text-xs uppercase tracking-[0.12em]">
|
|
123
|
+
Opacity
|
|
124
|
+
</label>
|
|
125
|
+
<span className="font-mono text-muted-foreground text-xs">
|
|
126
|
+
{currentProps.opacity.toFixed(2)}
|
|
127
|
+
</span>
|
|
128
|
+
</div>
|
|
129
|
+
<input
|
|
130
|
+
className="h-2 w-full cursor-pointer appearance-none rounded-full bg-accent"
|
|
131
|
+
max={1}
|
|
132
|
+
min={0}
|
|
133
|
+
onChange={(e) => {
|
|
134
|
+
const opacity = Number.parseFloat(e.target.value)
|
|
135
|
+
updateCustomMaterial({ opacity }, opacity < 1 || currentProps.transparent)
|
|
136
|
+
}}
|
|
137
|
+
step={0.01}
|
|
138
|
+
type="range"
|
|
139
|
+
value={currentProps.opacity}
|
|
140
|
+
/>
|
|
141
|
+
</div>
|
|
142
|
+
|
|
143
|
+
<div className="space-y-2">
|
|
144
|
+
<label className="block font-medium text-muted-foreground text-xs uppercase tracking-[0.12em]">
|
|
145
|
+
Side
|
|
146
|
+
</label>
|
|
147
|
+
<select
|
|
148
|
+
className="h-9 w-full rounded-md border border-input bg-transparent px-3 text-sm shadow-xs outline-none transition-[color,box-shadow] focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 dark:bg-input/30"
|
|
149
|
+
onChange={(e) =>
|
|
150
|
+
updateCustomMaterial({ side: e.target.value as 'front' | 'back' | 'double' })
|
|
151
|
+
}
|
|
152
|
+
value={currentProps.side}
|
|
153
|
+
>
|
|
154
|
+
<option value="front">Front</option>
|
|
155
|
+
<option value="back">Back</option>
|
|
156
|
+
<option value="double">Double</option>
|
|
157
|
+
</select>
|
|
158
|
+
</div>
|
|
159
|
+
</div>
|
|
160
|
+
</PanelSection>
|
|
161
|
+
</PanelWrapper>
|
|
162
|
+
)
|
|
163
|
+
}
|