@pascal-app/editor 0.7.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 +6 -6
- package/src/components/editor/custom-camera-controls.tsx +2 -1
- package/src/components/editor/editor-layout-v2.tsx +4 -3
- package/src/components/editor/first-person/build-collider-world.ts +5 -7
- package/src/components/editor/first-person/bvh-ecctrl.tsx +119 -54
- package/src/components/editor/first-person-controls.tsx +11 -11
- package/src/components/editor/floating-action-menu.tsx +0 -0
- package/src/components/editor/floorplan-panel.tsx +44 -37
- package/src/components/editor/index.tsx +68 -53
- package/src/components/editor/selection-manager.tsx +2 -2
- package/src/components/editor/snapshot-capture-overlay.tsx +465 -0
- package/src/components/editor/thumbnail-generator.tsx +18 -61
- package/src/components/editor/use-floorplan-background-placement.ts +3 -3
- package/src/components/editor/wall-measurement-label.tsx +0 -0
- package/src/components/editor-2d/renderers/floorplan-draft-layer.tsx +6 -1
- package/src/components/editor-2d/renderers/floorplan-measurements-layer.tsx +6 -1
- package/src/components/editor-2d/renderers/floorplan-stair-layer.tsx +5 -5
- 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/move-ceiling-tool.tsx +9 -2
- package/src/components/tools/fence/curve-fence-tool.tsx +4 -5
- package/src/components/tools/fence/fence-tool.tsx +2 -2
- package/src/components/tools/fence/move-fence-endpoint-tool.tsx +11 -8
- package/src/components/tools/fence/move-fence-tool.tsx +13 -9
- package/src/components/tools/item/move-tool.tsx +3 -6
- package/src/components/tools/item/placement-math.ts +2 -4
- package/src/components/tools/item/placement-strategies.ts +11 -10
- package/src/components/tools/item/use-draft-node.ts +0 -1
- package/src/components/tools/item/use-placement-coordinator.tsx +9 -111
- package/src/components/tools/roof/move-roof-tool.tsx +7 -2
- package/src/components/tools/select/box-select-tool.tsx +12 -17
- package/src/components/tools/shared/segment-angle.ts +1 -1
- package/src/components/tools/tool-manager.tsx +12 -12
- package/src/components/tools/wall/curve-wall-tool.tsx +8 -6
- package/src/components/tools/wall/move-wall-endpoint-tool.tsx +11 -8
- package/src/components/tools/wall/move-wall-tool.tsx +6 -4
- package/src/components/tools/wall/wall-drafting.ts +0 -0
- package/src/components/tools/wall/wall-tool.tsx +3 -3
- package/src/components/tools/zone/zone-tool.tsx +20 -5
- package/src/components/ui/action-menu/camera-actions.tsx +0 -0
- package/src/components/ui/action-menu/control-modes.tsx +7 -1
- package/src/components/ui/action-menu/furnish-tools.tsx +6 -92
- package/src/components/ui/action-menu/index.tsx +35 -86
- package/src/components/ui/action-menu/view-toggles.tsx +19 -31
- package/src/components/ui/command-palette/editor-commands.tsx +6 -4
- package/src/components/ui/command-palette/index.tsx +4 -255
- package/src/components/ui/controls/material-picker.tsx +8 -5
- package/src/components/ui/floating-level-selector.tsx +1 -1
- package/src/components/ui/helpers/helper-manager.tsx +5 -0
- package/src/components/ui/item-catalog/catalog-items.tsx +1742 -315
- package/src/components/ui/item-catalog/item-catalog.tsx +88 -46
- package/src/components/ui/level-duplicate-dialog.tsx +3 -5
- package/src/components/ui/panels/ceiling-panel.tsx +2 -3
- package/src/components/ui/panels/column-panel.tsx +62 -18
- package/src/components/ui/panels/door-panel.tsx +272 -265
- package/src/components/ui/panels/fence-panel.tsx +0 -5
- package/src/components/ui/panels/paint-panel.tsx +66 -41
- package/src/components/ui/panels/panel-manager.tsx +3 -32
- package/src/components/ui/panels/reference-panel.tsx +28 -13
- package/src/components/ui/panels/roof-panel.tsx +52 -2
- package/src/components/ui/panels/roof-segment-panel.tsx +0 -0
- package/src/components/ui/panels/slab-panel.tsx +0 -0
- package/src/components/ui/panels/spawn-panel.tsx +10 -4
- package/src/components/ui/panels/stair-panel.tsx +66 -14
- package/src/components/ui/panels/wall-panel.tsx +97 -1
- package/src/components/ui/panels/window-panel.tsx +13 -5
- 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/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/site-panel/ceiling-tree-node.tsx +0 -0
- package/src/components/ui/sidebar/panels/site-panel/index.tsx +4 -6
- 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 +1 -7
- package/src/components/ui/sidebar/panels/site-panel/tree-node.tsx +3 -1
- package/src/components/ui/sidebar/panels/site-panel/zone-tree-node.tsx +3 -1
- package/src/components/ui/sidebar/panels/zone-panel/index.tsx +1 -1
- 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-save.ts +14 -0
- package/src/hooks/use-keyboard.ts +10 -0
- package/src/index.tsx +8 -1
- package/src/lib/level-duplication.test.ts +0 -2
- package/src/lib/level-duplication.ts +1 -1
- package/src/lib/material-paint.ts +1 -1
- package/src/lib/roof-duplication.ts +1 -1
- package/src/lib/scene-bounds.ts +1 -1
- 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 +2 -2
- package/src/store/use-editor.tsx +27 -59
- 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 -436
|
@@ -1,280 +0,0 @@
|
|
|
1
|
-
'use client'
|
|
2
|
-
|
|
3
|
-
import { Howl } from 'howler'
|
|
4
|
-
import { Disc3, Settings2, SkipBack, SkipForward, Volume2, VolumeX } from 'lucide-react'
|
|
5
|
-
import { AnimatePresence, motion } from 'motion/react'
|
|
6
|
-
import { useCallback, useEffect, useRef, useState } from 'react'
|
|
7
|
-
import { Slider } from '../components/ui/slider'
|
|
8
|
-
import { cn } from '../lib/utils'
|
|
9
|
-
import useAudio from '../store/use-audio'
|
|
10
|
-
|
|
11
|
-
const PLAYLIST = [
|
|
12
|
-
{
|
|
13
|
-
title: 'Ballroom in Miniature',
|
|
14
|
-
file: '/audios/radios/classic/Ballroom in Miniature.mp3',
|
|
15
|
-
},
|
|
16
|
-
{
|
|
17
|
-
title: 'Blueprints in Springtime',
|
|
18
|
-
file: '/audios/radios/classic/Blueprints in Springtime.mp3',
|
|
19
|
-
},
|
|
20
|
-
{
|
|
21
|
-
title: 'Clockwork Tea Party',
|
|
22
|
-
file: '/audios/radios/classic/Clockwork Tea Party.mp3',
|
|
23
|
-
},
|
|
24
|
-
{
|
|
25
|
-
title: 'Clockwork Tea Party (Alternate)',
|
|
26
|
-
file: '/audios/radios/classic/Clockwork Tea Party (Alternate).mp3',
|
|
27
|
-
},
|
|
28
|
-
{
|
|
29
|
-
title: 'Clockwork Teacups',
|
|
30
|
-
file: '/audios/radios/classic/Clockwork Teacups.mp3',
|
|
31
|
-
},
|
|
32
|
-
{
|
|
33
|
-
title: 'Evening in the Parlor',
|
|
34
|
-
file: '/audios/radios/classic/Evening in the Parlor.mp3',
|
|
35
|
-
},
|
|
36
|
-
{
|
|
37
|
-
title: 'Glass Atrium',
|
|
38
|
-
file: '/audios/radios/classic/Glass Atrium.mp3',
|
|
39
|
-
},
|
|
40
|
-
{
|
|
41
|
-
title: 'Moonlight On The Drafting Table',
|
|
42
|
-
file: '/audios/radios/classic/Moonlight On The Drafting Table.mp3',
|
|
43
|
-
},
|
|
44
|
-
{
|
|
45
|
-
title: 'Sunlit Garden Reverie',
|
|
46
|
-
file: '/audios/radios/classic/Sunlit Garden Reverie.mp3',
|
|
47
|
-
},
|
|
48
|
-
{
|
|
49
|
-
title: 'Sunlit Waltz in Pastel Hues',
|
|
50
|
-
file: '/audios/radios/classic/Sunlit Waltz in Pastel Hues.mp3',
|
|
51
|
-
},
|
|
52
|
-
]
|
|
53
|
-
|
|
54
|
-
// Shuffle array helper
|
|
55
|
-
function shuffleArray<T>(array: T[]): T[] {
|
|
56
|
-
const shuffled = [...array]
|
|
57
|
-
for (let i = shuffled.length - 1; i > 0; i--) {
|
|
58
|
-
const j = Math.floor(Math.random() * (i + 1))
|
|
59
|
-
;[shuffled[i], shuffled[j]] = [shuffled[j]!, shuffled[i]!]
|
|
60
|
-
}
|
|
61
|
-
return shuffled
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
export function PascalRadio() {
|
|
65
|
-
const [shuffledPlaylist] = useState(() => shuffleArray(PLAYLIST))
|
|
66
|
-
const [currentTrackIndex, setCurrentTrackIndex] = useState(0)
|
|
67
|
-
const { masterVolume, radioVolume, muted, isRadioPlaying, setRadioPlaying } = useAudio()
|
|
68
|
-
const soundRef = useRef<Howl | null>(null)
|
|
69
|
-
const [isOpen, setIsOpen] = useState(false)
|
|
70
|
-
const containerRef = useRef<HTMLDivElement>(null)
|
|
71
|
-
|
|
72
|
-
const currentTrack = shuffledPlaylist[currentTrackIndex]!
|
|
73
|
-
|
|
74
|
-
// Calculate effective volume (masterVolume * radioVolume, both are 0-100)
|
|
75
|
-
const effectiveVolume = (masterVolume / 100) * (radioVolume / 100)
|
|
76
|
-
|
|
77
|
-
// Keep a ref so the track-init effect can read current volume/muted/isRadioPlaying
|
|
78
|
-
// without those values being part of its dependency array (which would restart the song).
|
|
79
|
-
const effectiveVolumeRef = useRef(effectiveVolume)
|
|
80
|
-
const mutedRef = useRef(muted)
|
|
81
|
-
const isPlayingRef = useRef(isRadioPlaying)
|
|
82
|
-
effectiveVolumeRef.current = effectiveVolume
|
|
83
|
-
mutedRef.current = muted
|
|
84
|
-
isPlayingRef.current = isRadioPlaying
|
|
85
|
-
|
|
86
|
-
const handleNext = useCallback(() => {
|
|
87
|
-
setCurrentTrackIndex((prev) => (prev + 1) % shuffledPlaylist.length)
|
|
88
|
-
}, [shuffledPlaylist.length])
|
|
89
|
-
|
|
90
|
-
const handlePrevious = useCallback(() => {
|
|
91
|
-
setCurrentTrackIndex((prev) => (prev - 1 + shuffledPlaylist.length) % shuffledPlaylist.length)
|
|
92
|
-
}, [shuffledPlaylist.length])
|
|
93
|
-
|
|
94
|
-
// Initialize Howler only when the track changes — not on volume/mute/play-state changes.
|
|
95
|
-
// Volume and mute are handled by the separate effect below.
|
|
96
|
-
useEffect(() => {
|
|
97
|
-
if (soundRef.current) {
|
|
98
|
-
soundRef.current.unload()
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
const wasPlaying = isPlayingRef.current
|
|
102
|
-
|
|
103
|
-
soundRef.current = new Howl({
|
|
104
|
-
src: [currentTrack.file],
|
|
105
|
-
volume: mutedRef.current ? 0 : effectiveVolumeRef.current,
|
|
106
|
-
onend: handleNext,
|
|
107
|
-
})
|
|
108
|
-
|
|
109
|
-
if (wasPlaying && !mutedRef.current) {
|
|
110
|
-
soundRef.current?.play()
|
|
111
|
-
}
|
|
112
|
-
|
|
113
|
-
return () => {
|
|
114
|
-
soundRef.current?.unload()
|
|
115
|
-
}
|
|
116
|
-
}, [handleNext, currentTrack.file])
|
|
117
|
-
|
|
118
|
-
// Update volume when settings change
|
|
119
|
-
useEffect(() => {
|
|
120
|
-
if (soundRef.current) {
|
|
121
|
-
soundRef.current.volume(muted ? 0 : effectiveVolume)
|
|
122
|
-
|
|
123
|
-
// Pause if muted, resume if unmuted and was playing
|
|
124
|
-
if (muted && isRadioPlaying) {
|
|
125
|
-
soundRef.current.pause()
|
|
126
|
-
} else if (!muted && isRadioPlaying && !soundRef.current.playing()) {
|
|
127
|
-
soundRef.current.play()
|
|
128
|
-
} else if (!isRadioPlaying && soundRef.current.playing()) {
|
|
129
|
-
soundRef.current.pause()
|
|
130
|
-
}
|
|
131
|
-
}
|
|
132
|
-
}, [effectiveVolume, muted, isRadioPlaying])
|
|
133
|
-
|
|
134
|
-
const handlePlayPause = () => {
|
|
135
|
-
if (!soundRef.current || muted) return
|
|
136
|
-
|
|
137
|
-
if (isRadioPlaying) {
|
|
138
|
-
soundRef.current.pause()
|
|
139
|
-
} else {
|
|
140
|
-
soundRef.current.play()
|
|
141
|
-
}
|
|
142
|
-
setRadioPlaying(!isRadioPlaying)
|
|
143
|
-
}
|
|
144
|
-
|
|
145
|
-
const handleVolumeChange = (value: number[]) => {
|
|
146
|
-
useAudio.setState({ radioVolume: value[0] })
|
|
147
|
-
}
|
|
148
|
-
|
|
149
|
-
// Handle click outside to close
|
|
150
|
-
useEffect(() => {
|
|
151
|
-
function handleClickOutside(event: MouseEvent) {
|
|
152
|
-
if (containerRef.current && !containerRef.current.contains(event.target as Node)) {
|
|
153
|
-
setIsOpen(false)
|
|
154
|
-
}
|
|
155
|
-
}
|
|
156
|
-
if (isOpen) {
|
|
157
|
-
document.addEventListener('mousedown', handleClickOutside)
|
|
158
|
-
}
|
|
159
|
-
return () => {
|
|
160
|
-
document.removeEventListener('mousedown', handleClickOutside)
|
|
161
|
-
}
|
|
162
|
-
}, [isOpen])
|
|
163
|
-
|
|
164
|
-
return (
|
|
165
|
-
<motion.div
|
|
166
|
-
className={cn(
|
|
167
|
-
'flex flex-col overflow-hidden rounded-lg border border-border bg-background/95 shadow-lg backdrop-blur-md',
|
|
168
|
-
!isOpen && 'cursor-pointer transition-colors hover:bg-accent/90',
|
|
169
|
-
)}
|
|
170
|
-
layout
|
|
171
|
-
onClick={() => {
|
|
172
|
-
if (!isOpen) setIsOpen(true)
|
|
173
|
-
}}
|
|
174
|
-
ref={containerRef}
|
|
175
|
-
transition={{ type: 'spring', bounce: 0.2, duration: 0.6 }}
|
|
176
|
-
>
|
|
177
|
-
<div className="flex items-center justify-between gap-2 px-3 py-2 font-medium text-sm">
|
|
178
|
-
<div className="flex items-center gap-2">
|
|
179
|
-
<Disc3 className={cn('h-4 w-4 shrink-0', isRadioPlaying && 'animate-spin')} />
|
|
180
|
-
<span className="hidden whitespace-nowrap sm:inline">Radio Pascal</span>
|
|
181
|
-
</div>
|
|
182
|
-
<div className="flex items-center gap-2">
|
|
183
|
-
<div
|
|
184
|
-
aria-label={isRadioPlaying ? 'Pause' : 'Play'}
|
|
185
|
-
className="cursor-pointer rounded-sm bg-accent/30 p-1 transition-all hover:bg-accent hover:text-accent-foreground hover:shadow-sm"
|
|
186
|
-
onClick={(e) => {
|
|
187
|
-
e.stopPropagation()
|
|
188
|
-
handlePlayPause()
|
|
189
|
-
}}
|
|
190
|
-
onKeyDown={(e) => {
|
|
191
|
-
if (e.key === 'Enter' || e.key === ' ') {
|
|
192
|
-
e.preventDefault()
|
|
193
|
-
e.stopPropagation()
|
|
194
|
-
handlePlayPause()
|
|
195
|
-
}
|
|
196
|
-
}}
|
|
197
|
-
role="button"
|
|
198
|
-
tabIndex={0}
|
|
199
|
-
>
|
|
200
|
-
{isRadioPlaying ? (
|
|
201
|
-
<Volume2 className="h-3.5 w-3.5" />
|
|
202
|
-
) : (
|
|
203
|
-
<VolumeX className="h-3.5 w-3.5" />
|
|
204
|
-
)}
|
|
205
|
-
</div>
|
|
206
|
-
<button
|
|
207
|
-
aria-label="Radio Settings"
|
|
208
|
-
className={cn(
|
|
209
|
-
'cursor-pointer rounded-sm p-1 transition-all hover:bg-accent hover:text-accent-foreground',
|
|
210
|
-
isOpen && 'bg-accent text-accent-foreground',
|
|
211
|
-
)}
|
|
212
|
-
onClick={(e) => {
|
|
213
|
-
e.stopPropagation()
|
|
214
|
-
setIsOpen(!isOpen)
|
|
215
|
-
}}
|
|
216
|
-
>
|
|
217
|
-
<Settings2 className="h-3.5 w-3.5" />
|
|
218
|
-
</button>
|
|
219
|
-
</div>
|
|
220
|
-
</div>
|
|
221
|
-
|
|
222
|
-
<AnimatePresence>
|
|
223
|
-
{isOpen && (
|
|
224
|
-
<motion.div
|
|
225
|
-
animate={{ opacity: 1, height: 'auto' }}
|
|
226
|
-
exit={{ opacity: 0, height: 0 }}
|
|
227
|
-
initial={{ opacity: 0, height: 0 }}
|
|
228
|
-
transition={{ type: 'spring', bounce: 0.2, duration: 0.6 }}
|
|
229
|
-
>
|
|
230
|
-
<div className="w-[16rem] space-y-3 px-3 pb-3">
|
|
231
|
-
<div className="mb-3 h-px w-full bg-border/50" />
|
|
232
|
-
{/* Current song info with prev/next */}
|
|
233
|
-
<div>
|
|
234
|
-
<p className="mb-2 text-muted-foreground text-xs">Now Playing</p>
|
|
235
|
-
<div className="flex items-center justify-between gap-2">
|
|
236
|
-
<button
|
|
237
|
-
aria-label="Previous"
|
|
238
|
-
className="shrink-0 rounded-full p-1.5 transition-colors hover:bg-accent"
|
|
239
|
-
onClick={handlePrevious}
|
|
240
|
-
>
|
|
241
|
-
<SkipBack className="h-4 w-4" />
|
|
242
|
-
</button>
|
|
243
|
-
<p
|
|
244
|
-
className="flex-1 truncate text-center font-medium text-sm"
|
|
245
|
-
title={currentTrack.title}
|
|
246
|
-
>
|
|
247
|
-
{currentTrack.title}
|
|
248
|
-
</p>
|
|
249
|
-
<button
|
|
250
|
-
aria-label="Next"
|
|
251
|
-
className="shrink-0 rounded-full p-1.5 transition-colors hover:bg-accent"
|
|
252
|
-
onClick={handleNext}
|
|
253
|
-
>
|
|
254
|
-
<SkipForward className="h-4 w-4" />
|
|
255
|
-
</button>
|
|
256
|
-
</div>
|
|
257
|
-
</div>
|
|
258
|
-
|
|
259
|
-
{/* Volume control */}
|
|
260
|
-
<div className="flex items-center gap-2">
|
|
261
|
-
<Volume2 className="h-3.5 w-3.5 shrink-0 text-muted-foreground" />
|
|
262
|
-
<Slider
|
|
263
|
-
aria-label="Radio Volume"
|
|
264
|
-
className="flex-1"
|
|
265
|
-
max={100}
|
|
266
|
-
onValueChange={handleVolumeChange}
|
|
267
|
-
step={1}
|
|
268
|
-
value={[radioVolume]}
|
|
269
|
-
/>
|
|
270
|
-
<span className="w-8 shrink-0 text-right text-muted-foreground text-xs">
|
|
271
|
-
{radioVolume}%
|
|
272
|
-
</span>
|
|
273
|
-
</div>
|
|
274
|
-
</div>
|
|
275
|
-
</motion.div>
|
|
276
|
-
)}
|
|
277
|
-
</AnimatePresence>
|
|
278
|
-
</motion.div>
|
|
279
|
-
)
|
|
280
|
-
}
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
'use client'
|
|
2
|
-
|
|
3
|
-
import { Eye } from 'lucide-react'
|
|
4
|
-
import useEditor from '../store/use-editor'
|
|
5
|
-
|
|
6
|
-
export function PreviewButton() {
|
|
7
|
-
return (
|
|
8
|
-
<button
|
|
9
|
-
className="flex cursor-pointer items-center gap-2 rounded-lg border border-border bg-background/95 px-3 py-2 font-medium text-sm shadow-lg backdrop-blur-md transition-colors hover:bg-accent/90"
|
|
10
|
-
onClick={() => useEditor.getState().setPreviewMode(true)}
|
|
11
|
-
>
|
|
12
|
-
<Eye className="h-4 w-4 shrink-0" />
|
|
13
|
-
<span className="hidden whitespace-nowrap sm:inline">Preview</span>
|
|
14
|
-
</button>
|
|
15
|
-
)
|
|
16
|
-
}
|