@pascal-app/editor 1.0.1 → 1.0.3

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.
Files changed (111) hide show
  1. package/package.json +10 -5
  2. package/src/components/editor/custom-camera-controls.tsx +22 -74
  3. package/src/components/editor/editor-layout-mobile.tsx +1 -0
  4. package/src/components/editor/floorplan-panel.tsx +210 -163
  5. package/src/components/editor/grid.tsx +31 -7
  6. package/src/components/editor/group-actions.ts +5 -9
  7. package/src/components/editor/group-floating-action-menu.tsx +19 -9
  8. package/src/components/editor/group-move-3d.ts +4 -6
  9. package/src/components/editor/group-rotate-handle.tsx +81 -35
  10. package/src/components/editor/group-selection-box-3d.tsx +25 -17
  11. package/src/components/editor/group-transform-shared.test.ts +126 -1
  12. package/src/components/editor/group-transform-shared.ts +79 -73
  13. package/src/components/editor/handles/handle-arrow.tsx +72 -2
  14. package/src/components/editor/handles/use-handle-drag.ts +75 -6
  15. package/src/components/editor/index.tsx +24 -9
  16. package/src/components/editor/node-action-menu.tsx +2 -0
  17. package/src/components/editor/node-arrow-handles.tsx +141 -7
  18. package/src/components/editor/registry-action-contributions.tsx +53 -0
  19. package/src/components/editor/wall-move-side-handles.tsx +71 -21
  20. package/src/components/editor/wall-opening-highlights.tsx +2 -3
  21. package/src/components/editor-2d/floorplan-group-move.tsx +17 -24
  22. package/src/components/editor-2d/floorplan-registered-tool-layer.tsx +33 -12
  23. package/src/components/editor-2d/floorplan-registry-move-overlay.tsx +154 -49
  24. package/src/components/editor-2d/renderers/floorplan-draft-wall-measurement.tsx +166 -0
  25. package/src/components/editor-2d/renderers/floorplan-registry-layer.test.ts +49 -0
  26. package/src/components/editor-2d/renderers/floorplan-registry-layer.tsx +67 -21
  27. package/src/components/systems/zone/zone-system.tsx +8 -4
  28. package/src/components/tools/__fixtures__/hosting.ts +10 -0
  29. package/src/components/tools/item/item-surface-placement.test.ts +3 -9
  30. package/src/components/tools/item/item-surface-strategy-resolver.test.ts +3 -9
  31. package/src/components/tools/item/placement-strategies.ts +55 -43
  32. package/src/components/tools/item/shelf-surface-strategy-resolver.test.ts +3 -3
  33. package/src/components/tools/item/use-draft-node.ts +41 -2
  34. package/src/components/tools/item/use-placement-coordinator.tsx +166 -73
  35. package/src/components/tools/registry/item-surface-move.test.ts +10 -2
  36. package/src/components/tools/registry/item-surface-move.ts +46 -24
  37. package/src/components/tools/registry/item-surface-resolver.test.ts +2 -2
  38. package/src/components/tools/registry/move-registry-node-tool.tsx +23 -9
  39. package/src/components/tools/shared/affordance-dispatch.test.ts +24 -0
  40. package/src/components/tools/shared/affordance-dispatch.ts +13 -0
  41. package/src/components/tools/shared/draft-measurement-label.tsx +38 -0
  42. package/src/components/tools/shared/pointer-support-cap.test.ts +27 -0
  43. package/src/components/tools/shared/pointer-support-cap.ts +17 -5
  44. package/src/components/tools/shared/surface-rejection.test.tsx +5 -4
  45. package/src/components/tools/shared/surface-rejection.tsx +14 -0
  46. package/src/components/tools/tool-manager.tsx +36 -3
  47. package/src/components/ui/controls/material-paint-panel.tsx +6 -67
  48. package/src/components/ui/controls/material-picker.tsx +5 -67
  49. package/src/components/ui/controls/slider-control.tsx +76 -31
  50. package/src/components/ui/helpers/helper-manager.tsx +24 -6
  51. package/src/components/ui/helpers/registered-tool-helper.tsx +2 -32
  52. package/src/components/ui/item-catalog/item-catalog.tsx +5 -30
  53. package/src/components/ui/panels/multi-height-mode.tsx +27 -21
  54. package/src/components/ui/panels/parametric-inspector.tsx +3 -15
  55. package/src/components/ui/primitives/shortcut-token.tsx +4 -0
  56. package/src/components/ui/sidebar/panels/settings-panel/audio-settings-dialog.tsx +2 -2
  57. package/src/components/ui/sidebar/panels/settings-panel/index.tsx +585 -369
  58. package/src/components/ui/sidebar/panels/settings-panel/keyboard-shortcuts-dialog.tsx +2 -2
  59. package/src/components/ui/sidebar/panels/settings-panel/print-export-button.tsx +1 -1
  60. package/src/components/viewer/floorplan-preview-visibility.test.ts +35 -0
  61. package/src/components/viewer/floorplan-preview-visibility.ts +19 -0
  62. package/src/components/viewer/floorplan-preview.tsx +1 -12
  63. package/src/components/viewer-zone-system.tsx +7 -2
  64. package/src/hooks/use-auto-save.integration.test.tsx +197 -0
  65. package/src/hooks/use-auto-save.ts +21 -6
  66. package/src/hooks/use-ceiling-events.test.ts +1 -0
  67. package/src/hooks/use-ceiling-events.ts +2 -0
  68. package/src/hooks/use-grid-events.test.ts +2 -0
  69. package/src/hooks/use-grid-events.ts +16 -11
  70. package/src/hooks/use-keyboard.test.ts +7 -0
  71. package/src/hooks/use-keyboard.ts +42 -29
  72. package/src/index.tsx +63 -3
  73. package/src/lib/catalog-panel-model.ts +39 -0
  74. package/src/lib/catalog-selection.test.ts +27 -0
  75. package/src/lib/catalog-selection.ts +8 -0
  76. package/src/lib/contextual-help.test.ts +27 -1
  77. package/src/lib/contextual-help.ts +16 -9
  78. package/src/lib/floorplan/floorplan-export.test.ts +3 -1
  79. package/src/lib/floorplan/floorplan-extension.ts +16 -0
  80. package/src/lib/fresh-planar-placement.ts +168 -36
  81. package/src/lib/glb-export.test.ts +59 -16
  82. package/src/lib/glb-export.ts +26 -13
  83. package/src/lib/grid-frame.test.ts +19 -0
  84. package/src/lib/grid-frame.ts +18 -0
  85. package/src/lib/interaction/scope.ts +9 -1
  86. package/src/lib/keyboard-pan.test.ts +62 -0
  87. package/src/lib/keyboard-pan.ts +89 -0
  88. package/src/lib/material-catalog-model.ts +72 -0
  89. package/src/lib/material-paint-panel-model.ts +76 -0
  90. package/src/lib/overlay-transform.test.ts +28 -0
  91. package/src/lib/overlay-transform.ts +12 -0
  92. package/src/lib/panel-rows.ts +75 -0
  93. package/src/lib/panel-tool-options.test.ts +34 -0
  94. package/src/lib/panel-tool-options.ts +46 -0
  95. package/src/lib/parametric-node-update.ts +37 -0
  96. package/src/lib/scene.test.ts +99 -0
  97. package/src/lib/scene.ts +21 -3
  98. package/src/lib/snapping-mode.test.ts +13 -2
  99. package/src/lib/snapping-mode.ts +11 -6
  100. package/src/lib/spatial-drag-plane.test.ts +53 -0
  101. package/src/lib/spatial-drag-plane.ts +19 -0
  102. package/src/lib/spatial-pointer-input.test.ts +72 -0
  103. package/src/lib/spatial-pointer-input.ts +62 -0
  104. package/src/lib/spatial-snap.test.ts +47 -0
  105. package/src/lib/terrain-panel-model.ts +117 -0
  106. package/src/lib/world-grid-snap.test.ts +48 -0
  107. package/src/lib/world-grid-snap.ts +9 -5
  108. package/src/store/rotation-snapping.test.ts +53 -0
  109. package/src/store/use-editor.tsx +10 -2
  110. package/src/store/use-floorplan-draft-preview.ts +10 -1
  111. package/src/store/use-interaction-scope.ts +155 -6
@@ -1,29 +1,39 @@
1
1
  import {
2
2
  clearSceneHistory,
3
+ DEFAULT_LEVEL_HEIGHT,
3
4
  emitter,
5
+ getLevelDisplayName,
6
+ LevelNode,
7
+ type AnyNodeId,
8
+ type BuildingNode,
4
9
  isNodeKindEnabled,
5
10
  nodeRegistry,
11
+ type ParsedBuildJson,
6
12
  useRegistryVersion,
7
13
  useScene,
8
- type ParsedBuildJson,
9
14
  validateBuildJson,
10
15
  } from '@pascal-app/core'
11
16
  import { useViewer, viewerPresentationRegistry } from '@pascal-app/viewer'
12
17
  import { TreeView, VisualJson } from '@visual-json/react'
13
18
  import {
19
+ ArrowDown,
20
+ ArrowUp,
14
21
  Camera,
15
22
  Check,
16
- ChevronDown,
17
23
  Copy,
18
24
  Download,
25
+ Layers,
26
+ ListTree,
19
27
  Map as MapIcon,
20
28
  Save,
29
+ ChevronDown,
21
30
  Send,
22
31
  Trash2,
23
32
  Upload,
24
33
  } from 'lucide-react'
25
34
  import {
26
35
  type KeyboardEvent,
36
+ type ReactNode,
27
37
  type SyntheticEvent,
28
38
  useCallback,
29
39
  useEffect,
@@ -33,6 +43,7 @@ import {
33
43
  useState,
34
44
  useSyncExternalStore,
35
45
  } from 'react'
46
+ import { useShallow } from 'zustand/react/shallow'
36
47
  import {
37
48
  exportFloorplanPdf,
38
49
  type FloorplanExportScope,
@@ -52,9 +63,11 @@ import {
52
63
  } from './../../../../../components/ui/primitives/dialog'
53
64
  import { Input } from './../../../../../components/ui/primitives/input'
54
65
  import { Switch } from './../../../../../components/ui/primitives/switch'
66
+ import { cn } from './../../../../../lib/utils'
67
+ import { deleteLevelWithFallbackSelection } from './../../../../../lib/level-selection'
55
68
  import useEditor, { selectDefaultBuildingAndLevel } from './../../../../../store/use-editor'
56
- import { type SendToAppStep, useSendToApp } from './../../../../../store/use-send-to-app'
57
69
  import useFloorplanMode from './../../../../../store/use-floorplan-mode'
70
+ import { type SendToAppStep, useSendToApp } from './../../../../../store/use-send-to-app'
58
71
  import { AudioSettingsDialog } from './audio-settings-dialog'
59
72
  import { KeyboardShortcutsDialog } from './keyboard-shortcuts-dialog'
60
73
  import { LoadBuildDialog, type PendingImport } from './load-build-dialog'
@@ -223,7 +236,69 @@ export interface ProjectVisibility {
223
236
  showGuidesPublic: boolean
224
237
  }
225
238
 
239
+ function SettingsSection({
240
+ children,
241
+ description,
242
+ title,
243
+ tone = 'default',
244
+ }: {
245
+ children: ReactNode
246
+ description?: string
247
+ title: string
248
+ tone?: 'default' | 'destructive'
249
+ }) {
250
+ const headingId = useId()
251
+ return (
252
+ <section aria-labelledby={headingId} className="space-y-3 py-5 first:pt-0 last:pb-0">
253
+ <div className="space-y-0.5">
254
+ <h3
255
+ className={cn(
256
+ 'font-semibold text-sm',
257
+ tone === 'destructive' ? 'text-destructive' : 'text-foreground',
258
+ )}
259
+ id={headingId}
260
+ >
261
+ {title}
262
+ </h3>
263
+ {description ? <p className="text-muted-foreground text-xs">{description}</p> : null}
264
+ </div>
265
+ {children}
266
+ </section>
267
+ )
268
+ }
269
+
270
+ function SettingsSubheading({ children }: { children: ReactNode }) {
271
+ return <h4 className="font-medium text-muted-foreground text-xs">{children}</h4>
272
+ }
273
+
274
+ function SettingsSwitchRow({
275
+ checked,
276
+ description,
277
+ label,
278
+ onCheckedChange,
279
+ }: {
280
+ checked: boolean
281
+ description: string
282
+ label: string
283
+ onCheckedChange: (checked: boolean) => void
284
+ }) {
285
+ const id = useId()
286
+ return (
287
+ <div className="flex items-center justify-between gap-4 py-1">
288
+ <div className="min-w-0 space-y-0.5">
289
+ <label className="block font-medium text-sm" htmlFor={id}>
290
+ {label}
291
+ </label>
292
+ <p className="text-muted-foreground text-xs">{description}</p>
293
+ </div>
294
+ <Switch checked={checked} id={id} onCheckedChange={onCheckedChange} />
295
+ </div>
296
+ )
297
+ }
298
+
226
299
  export interface SettingsPanelProps {
300
+ /** Merged onto the scrolling root so hosts can restyle padding (e.g. inside a dialog). */
301
+ className?: string
227
302
  projectId?: string
228
303
  /** Shown as the scene name in apps the scene is sent to (Blender collection name). */
229
304
  projectName?: string
@@ -234,7 +309,124 @@ export interface SettingsPanelProps {
234
309
  ) => Promise<void>
235
310
  }
236
311
 
312
+ function FloorSettingsSection() {
313
+ const selectedBuildingId = useViewer((state) => state.selection.buildingId)
314
+ const selectedLevelId = useViewer((state) => state.selection.levelId)
315
+ const setSelection = useViewer((state) => state.setSelection)
316
+ const createNode = useScene((state) => state.createNode)
317
+ const building = useScene((state) => {
318
+ const selected = selectedBuildingId ? state.nodes[selectedBuildingId] : undefined
319
+ if (selected?.type === 'building') return selected as BuildingNode
320
+
321
+ const site = state.rootNodeIds
322
+ .map((nodeId) => state.nodes[nodeId])
323
+ .find((node) => node?.type === 'site')
324
+ if (site?.type !== 'site') return null
325
+
326
+ return (
327
+ site.children
328
+ .map((childId) => state.nodes[childId as AnyNodeId])
329
+ .find((node): node is BuildingNode => node?.type === 'building') ?? null
330
+ )
331
+ })
332
+ const levels = useScene(
333
+ useShallow((state) => {
334
+ if (!building) return []
335
+
336
+ return building.children
337
+ .map((childId) => state.nodes[childId as AnyNodeId])
338
+ .filter((node): node is LevelNode => node?.type === 'level')
339
+ .sort((a, b) => b.level - a.level)
340
+ }),
341
+ )
342
+
343
+ if (!building) return null
344
+
345
+ const addLevel = (level: number) => {
346
+ const newLevel = LevelNode.parse({
347
+ level,
348
+ height: DEFAULT_LEVEL_HEIGHT,
349
+ children: [],
350
+ parentId: building.id,
351
+ })
352
+ createNode(newLevel, building.id)
353
+ setSelection({ buildingId: building.id, levelId: newLevel.id })
354
+ }
355
+
356
+ const addFloor = () =>
357
+ addLevel(levels.length === 0 ? 0 : Math.max(0, ...levels.map((level) => level.level)) + 1)
358
+ const addBasement = () => addLevel(Math.min(0, ...levels.map((level) => level.level)) - 1)
359
+
360
+ return (
361
+ <div className="space-y-3">
362
+ <label className="font-medium text-muted-foreground text-xs uppercase">Floors</label>
363
+ <div className="grid grid-cols-2 gap-2">
364
+ <Button className="justify-start" onClick={addFloor} size="sm" type="button" variant="outline">
365
+ <ArrowUp className="size-3.5" />
366
+ Add floor
367
+ </Button>
368
+ <Button
369
+ className="justify-start"
370
+ onClick={addBasement}
371
+ size="sm"
372
+ type="button"
373
+ variant="outline"
374
+ >
375
+ <ArrowDown className="size-3.5" />
376
+ Add basement
377
+ </Button>
378
+ </div>
379
+
380
+ <div className="space-y-1 rounded-md border p-1">
381
+ {levels.length === 0 ? (
382
+ <div className="px-2 py-2 text-muted-foreground text-xs">No floors yet</div>
383
+ ) : (
384
+ levels.map((level) => {
385
+ const isSelected = level.id === selectedLevelId
386
+ const canDelete = level.level !== 0
387
+
388
+ return (
389
+ <div className="flex items-center gap-1" key={level.id}>
390
+ <button
391
+ className={cn(
392
+ 'flex min-w-0 flex-1 items-center gap-2 rounded px-2 py-1.5 text-left text-sm transition-colors',
393
+ isSelected
394
+ ? 'bg-accent text-foreground'
395
+ : 'text-muted-foreground hover:bg-accent/60 hover:text-foreground',
396
+ )}
397
+ onClick={() => setSelection({ buildingId: building.id, levelId: level.id })}
398
+ type="button"
399
+ >
400
+ <Layers className="size-3.5 shrink-0" />
401
+ <span className="truncate">{getLevelDisplayName(level)}</span>
402
+ <span className="ml-auto shrink-0 text-muted-foreground text-xs">
403
+ {level.level === 0 ? '0' : level.level > 0 ? `+${level.level}` : level.level}
404
+ </span>
405
+ </button>
406
+ <button
407
+ aria-label={`Remove ${getLevelDisplayName(level)}`}
408
+ className="flex size-7 shrink-0 items-center justify-center rounded text-muted-foreground hover:bg-destructive/10 hover:text-destructive disabled:cursor-not-allowed disabled:opacity-30"
409
+ disabled={!canDelete}
410
+ onClick={() => deleteLevelWithFallbackSelection(level.id)}
411
+ title={canDelete ? 'Remove floor' : 'The ground floor cannot be removed'}
412
+ type="button"
413
+ >
414
+ <Trash2 className="size-3.5" />
415
+ </button>
416
+ </div>
417
+ )
418
+ })
419
+ )}
420
+ </div>
421
+ <p className="text-muted-foreground text-xs">
422
+ Select a floor to make it active. The ground floor is always kept as the building datum.
423
+ </p>
424
+ </div>
425
+ )
426
+ }
427
+
237
428
  export function SettingsPanel({
429
+ className,
238
430
  projectId,
239
431
  projectName,
240
432
  projectVisibility,
@@ -591,409 +783,433 @@ export function SettingsPanel({
591
783
  }
592
784
 
593
785
  return (
594
- <div className="subtle-scrollbar min-h-0 flex-1 space-y-6 overflow-x-hidden overflow-y-auto overscroll-contain p-3">
595
- {projectId && (
596
- <div className="space-y-2">
597
- <label className="font-medium text-muted-foreground text-xs uppercase">Project</label>
598
- <div className="font-medium text-sm">Project ID</div>
599
- <div className="flex items-center gap-2">
600
- <Input
601
- aria-label="Project ID"
602
- className="font-mono text-xs"
603
- readOnly
604
- value={projectId}
605
- />
606
- <Button
607
- aria-label={projectIdCopyState === 'copied' ? 'Project ID copied' : 'Copy project ID'}
608
- className="rounded-full"
609
- onClick={() => void handleCopyProjectId()}
610
- size="sm"
611
- type="button"
612
- variant="outline"
613
- >
614
- {projectIdCopyState === 'copied' ? (
615
- <Check className="size-3.5" />
616
- ) : (
617
- <Copy className="size-3.5" />
618
- )}
619
- {projectIdCopyState === 'copied'
620
- ? 'Copied'
621
- : projectIdCopyState === 'error'
622
- ? 'Try again'
623
- : 'Copy'}
624
- </Button>
625
- </div>
626
- </div>
786
+ <div
787
+ className={cn(
788
+ 'subtle-scrollbar @container min-h-0 flex-1 overflow-x-hidden overflow-y-auto overscroll-contain p-3',
789
+ className,
627
790
  )}
628
-
629
- {/* Visibility Section (only for cloud projects) */}
630
- {projectId && !isLocalProject && (
631
- <div className="space-y-3">
632
- <label className="font-medium text-muted-foreground text-xs uppercase">Visibility</label>
633
- <div className="flex items-center justify-between">
634
- <div>
635
- <div className="font-medium text-sm">Public</div>
636
- <div className="text-muted-foreground text-xs">
637
- {projectVisibility?.isPrivate ? 'Only you' : 'Anyone'} can view
638
- </div>
791
+ >
792
+ <div className="divide-y divide-border/60">
793
+ <section className="space-y-3 py-5 first:pt-0 last:pb-0">
794
+ <FloorSettingsSection />
795
+ </section>
796
+ {projectId && (
797
+ <SettingsSection
798
+ description="Reference this project from the API, MCP tools, or support."
799
+ title="Project"
800
+ >
801
+ <div className="flex items-center gap-2">
802
+ <Input
803
+ aria-label="Project ID"
804
+ className="font-mono text-xs"
805
+ readOnly
806
+ value={projectId}
807
+ />
808
+ <Button
809
+ aria-label={
810
+ projectIdCopyState === 'copied' ? 'Project ID copied' : 'Copy project ID'
811
+ }
812
+ className="rounded-full"
813
+ onClick={() => void handleCopyProjectId()}
814
+ size="sm"
815
+ type="button"
816
+ variant="outline"
817
+ >
818
+ {projectIdCopyState === 'copied' ? (
819
+ <Check className="size-3.5" />
820
+ ) : (
821
+ <Copy className="size-3.5" />
822
+ )}
823
+ {projectIdCopyState === 'copied'
824
+ ? 'Copied'
825
+ : projectIdCopyState === 'error'
826
+ ? 'Try again'
827
+ : 'Copy'}
828
+ </Button>
639
829
  </div>
640
- <Switch
641
- aria-label="Make project public"
830
+ </SettingsSection>
831
+ )}
832
+
833
+ {/* Sharing (only for cloud projects) */}
834
+ {projectId && !isLocalProject && (
835
+ <SettingsSection description="Control who can open this project." title="Sharing">
836
+ <SettingsSwitchRow
642
837
  checked={!(projectVisibility?.isPrivate ?? false)}
838
+ description={
839
+ projectVisibility?.isPrivate
840
+ ? 'Only you can view it.'
841
+ : 'Anyone with the link can view it.'
842
+ }
843
+ label="Public project"
643
844
  onCheckedChange={(checked) => handleVisibilityChange('isPrivate', !checked)}
644
845
  />
645
- </div>
646
- <div className="flex items-center justify-between">
647
- <div>
648
- <div className="font-medium text-sm">Show 3D Scans</div>
649
- <div className="text-muted-foreground text-xs">Visible to public viewers</div>
650
- </div>
651
- <Switch
652
- aria-label="Show 3D scans to public viewers"
846
+ <SettingsSwitchRow
653
847
  checked={projectVisibility?.showScansPublic ?? true}
848
+ description="Visible in the public viewer."
849
+ label="Show 3D scans"
654
850
  onCheckedChange={(checked) => handleVisibilityChange('showScansPublic', checked)}
655
851
  />
656
- </div>
657
- <div className="flex items-center justify-between">
658
- <div>
659
- <div className="font-medium text-sm">Show Floorplans</div>
660
- <div className="text-muted-foreground text-xs">Visible to public viewers</div>
661
- </div>
662
- <Switch
663
- aria-label="Show floorplans to public viewers"
852
+ <SettingsSwitchRow
664
853
  checked={projectVisibility?.showGuidesPublic ?? true}
854
+ description="Visible in the public viewer."
855
+ label="Show floor plans"
665
856
  onCheckedChange={(checked) => handleVisibilityChange('showGuidesPublic', checked)}
666
857
  />
667
- </div>
668
- <div className="flex items-center justify-between">
669
- <div>
670
- <div className="font-medium text-sm">Shadows</div>
671
- <div className="text-muted-foreground text-xs">Cast shadows from lights</div>
672
- </div>
673
- <Switch
674
- aria-label="Enable shadows"
675
- checked={shadows}
676
- onCheckedChange={(checked) => useViewer.getState().setShadows(checked)}
677
- />
678
- </div>
679
- </div>
680
- )}
681
-
682
- {/* Export Section */}
683
- <div className="space-y-4">
684
- <label className="font-medium text-muted-foreground text-xs uppercase">Export</label>
685
-
686
- <div className="space-y-2">
687
- <div className="font-medium text-muted-foreground text-xs">3D model</div>
688
- <details
689
- className="group"
690
- onKeyDownCapture={(event) => {
691
- // Keep Space available to the disclosure and switches, not canvas panning.
692
- if (event.code === 'Space') event.stopPropagation()
693
- }}
694
- >
695
- <summary className="flex min-h-10 cursor-pointer list-none items-center justify-between rounded-md border px-3 text-sm font-medium focus-visible:outline-2 focus-visible:outline-ring">
696
- Export options
697
- <ChevronDown aria-hidden="true" className="size-4 group-open:rotate-180" />
698
- </summary>
699
- <div className="space-y-3 pt-3">
700
- <div className="flex items-center justify-between gap-4 rounded-md border p-3">
701
- <div className="min-w-0">
702
- <label className="font-medium text-sm" htmlFor={visibleOnlySwitchId}>
703
- Visible nodes only
704
- </label>
705
- <div className="text-muted-foreground text-xs">
706
- Exclude hidden furniture and other hidden scene nodes
858
+ </SettingsSection>
859
+ )}
860
+
861
+ <SettingsSection description="Rendering options for this editor session." title="Viewer">
862
+ <SettingsSwitchRow
863
+ checked={shadows}
864
+ description="Cast shadows from lights."
865
+ label="Shadows"
866
+ onCheckedChange={(checked) => useViewer.getState().setShadows(checked)}
867
+ />
868
+ </SettingsSection>
869
+
870
+ <SettingsSection description="Download the scene or hand it to another app." title="Export">
871
+ <div className="space-y-3">
872
+ <SettingsSubheading>3D model</SettingsSubheading>
873
+ <details
874
+ className="group"
875
+ onKeyDownCapture={(event) => {
876
+ // Keep Space available to the disclosure and switches, not canvas panning.
877
+ if (event.code === 'Space') event.stopPropagation()
878
+ }}
879
+ >
880
+ <summary className="flex min-h-10 cursor-pointer list-none items-center justify-between rounded-md border px-3 font-medium text-sm focus-visible:outline-2 focus-visible:outline-ring">
881
+ Export options
882
+ <ChevronDown aria-hidden="true" className="size-4 group-open:rotate-180" />
883
+ </summary>
884
+ <div className="space-y-3 pt-3">
885
+ <div className="flex items-center justify-between gap-4 rounded-md border p-3">
886
+ <div className="min-w-0">
887
+ <label className="font-medium text-sm" htmlFor={visibleOnlySwitchId}>
888
+ Visible nodes only
889
+ </label>
890
+ <div className="text-muted-foreground text-xs">
891
+ Exclude hidden furniture and other hidden scene nodes
892
+ </div>
707
893
  </div>
894
+ <Switch
895
+ aria-label="Export visible nodes only"
896
+ checked={exportOnlyVisible}
897
+ id={visibleOnlySwitchId}
898
+ onCheckedChange={setExportOnlyVisible}
899
+ />
708
900
  </div>
709
- <Switch
710
- aria-label="Export visible nodes only"
711
- checked={exportOnlyVisible}
712
- id={visibleOnlySwitchId}
713
- onCheckedChange={setExportOnlyVisible}
714
- />
715
- </div>
716
901
 
717
- <fieldset className="space-y-2 rounded-md border p-3">
718
- <legend className="px-1 font-medium text-sm">Include in file</legend>
719
- <p className="text-muted-foreground text-xs">
720
- Choose which procedural content is baked into model files. GLB and USDZ use the
721
- textured portable path; STL and OBJ remain geometry-only.
722
- </p>
723
- {exportableNodeTypes.length > 0 ? (
724
- <div className="space-y-2 pt-1">
725
- {exportableNodeTypes.map(({ type, label, supportsGeometryOnly }, index) => {
726
- const switchId = `${includeNodeTypeIdPrefix}-${index}`
727
- return (
728
- <div className="flex items-center justify-between gap-4" key={type}>
729
- <label className="min-w-0 font-medium text-sm" htmlFor={switchId}>
730
- {label}
731
- {!supportsGeometryOnly && (
732
- <span className="text-muted-foreground text-xs"> (GLB/USDZ only)</span>
733
- )}
734
- </label>
735
- <Switch
736
- aria-label={`Include ${label} in model files`}
737
- checked={!excludedNodeTypes.includes(type)}
738
- id={switchId}
739
- onCheckedChange={(included) => handleNodeTypeInclusion(type, included)}
740
- />
741
- </div>
742
- )
743
- })}
744
- </div>
745
- ) : (
902
+ <fieldset className="space-y-2 rounded-md border p-3">
903
+ <legend className="px-1 font-medium text-sm">Include in file</legend>
746
904
  <p className="text-muted-foreground text-xs">
747
- No optional procedural content is present.
905
+ Choose which procedural content is baked into model files. GLB and USDZ use the
906
+ textured portable path; STL and OBJ remain geometry-only.
748
907
  </p>
749
- )}
750
- <p className="text-muted-foreground text-xs">
751
- Viewer surroundings are excluded unless selected separately below.
752
- </p>
753
- </fieldset>
754
- {exportablePresentations.length > 0 ? (
755
- <fieldset className="space-y-2 rounded-md border p-3">
756
- <legend className="px-1 font-medium text-sm">Viewer surroundings</legend>
908
+ {exportableNodeTypes.length > 0 ? (
909
+ <div className="space-y-2 pt-1">
910
+ {exportableNodeTypes.map(({ type, label, supportsGeometryOnly }, index) => {
911
+ const switchId = `${includeNodeTypeIdPrefix}-${index}`
912
+ return (
913
+ <div className="flex items-center justify-between gap-4" key={type}>
914
+ <label className="min-w-0 font-medium text-sm" htmlFor={switchId}>
915
+ {label}
916
+ {!supportsGeometryOnly && (
917
+ <span className="text-muted-foreground text-xs">
918
+ {' '}
919
+ (GLB/USDZ only)
920
+ </span>
921
+ )}
922
+ </label>
923
+ <Switch
924
+ aria-label={`Include ${label} in model files`}
925
+ checked={!excludedNodeTypes.includes(type)}
926
+ id={switchId}
927
+ onCheckedChange={(included) =>
928
+ handleNodeTypeInclusion(type, included)
929
+ }
930
+ />
931
+ </div>
932
+ )
933
+ })}
934
+ </div>
935
+ ) : (
936
+ <p className="text-muted-foreground text-xs">
937
+ No optional procedural content is present.
938
+ </p>
939
+ )}
757
940
  <p className="text-muted-foreground text-xs">
758
- Optional static surroundings are included only in GLB and USDZ.
941
+ Viewer surroundings are excluded unless selected separately below.
759
942
  </p>
760
- <div className="space-y-2 pt-1">
761
- {exportablePresentations.map((contribution, index) => {
762
- const switchId = `${includePresentationIdPrefix}-${index}`
763
- const label = contribution.staticExport!.label
764
- return (
765
- <div
766
- className="flex items-center justify-between gap-4"
767
- key={contribution.id}
768
- >
769
- <label className="min-w-0 font-medium text-sm" htmlFor={switchId}>
770
- {label}
771
- </label>
772
- <Switch
773
- aria-label={`Include ${label} in GLB and USDZ`}
774
- checked={includedPresentationIds.includes(contribution.id)}
775
- id={switchId}
776
- onCheckedChange={(included) =>
777
- handlePresentationInclusion(contribution.id, included)
778
- }
779
- />
780
- </div>
781
- )
782
- })}
783
- </div>
784
943
  </fieldset>
785
- ) : null}
944
+ {exportablePresentations.length > 0 ? (
945
+ <fieldset className="space-y-2 rounded-md border p-3">
946
+ <legend className="px-1 font-medium text-sm">Viewer surroundings</legend>
947
+ <p className="text-muted-foreground text-xs">
948
+ Optional static surroundings are included only in GLB and USDZ.
949
+ </p>
950
+ <div className="space-y-2 pt-1">
951
+ {exportablePresentations.map((contribution, index) => {
952
+ const switchId = `${includePresentationIdPrefix}-${index}`
953
+ const label = contribution.staticExport!.label
954
+ return (
955
+ <div
956
+ className="flex items-center justify-between gap-4"
957
+ key={contribution.id}
958
+ >
959
+ <label className="min-w-0 font-medium text-sm" htmlFor={switchId}>
960
+ {label}
961
+ </label>
962
+ <Switch
963
+ aria-label={`Include ${label} in GLB and USDZ`}
964
+ checked={includedPresentationIds.includes(contribution.id)}
965
+ id={switchId}
966
+ onCheckedChange={(included) =>
967
+ handlePresentationInclusion(contribution.id, included)
968
+ }
969
+ />
970
+ </div>
971
+ )
972
+ })}
973
+ </div>
974
+ </fieldset>
975
+ ) : null}
976
+ </div>
977
+ </details>
978
+
979
+ <div className="grid gap-2 @sm:grid-cols-2">
980
+ {MODEL_EXPORT_FORMATS.map(({ format, label }) => {
981
+ const isActive = activeModelExport === format
982
+ return (
983
+ <Button
984
+ aria-busy={isActive}
985
+ className="w-full justify-start gap-2"
986
+ disabled={
987
+ activeModelExport !== null || sendToBlenderStep !== null || !modelExport
988
+ }
989
+ key={format}
990
+ onClick={() => void handleModelExport(format, label)}
991
+ variant="outline"
992
+ >
993
+ <Download aria-hidden="true" className="size-4" />
994
+ {isActive ? `Exporting ${label}…` : `Export ${label}`}
995
+ </Button>
996
+ )
997
+ })}
786
998
  </div>
787
- </details>
788
999
 
789
- {MODEL_EXPORT_FORMATS.map(({ format, label }) => {
790
- const isActive = activeModelExport === format
791
- return (
1000
+ <div className="space-y-2">
792
1001
  <Button
793
- aria-busy={isActive}
1002
+ aria-busy={sendToBlenderStep !== null}
794
1003
  className="w-full justify-start gap-2"
795
1004
  disabled={activeModelExport !== null || sendToBlenderStep !== null || !modelExport}
796
- key={format}
797
- onClick={() => void handleModelExport(format, label)}
1005
+ onClick={() => void handleSendToBlender()}
798
1006
  variant="outline"
799
1007
  >
800
- <Download aria-hidden="true" className="size-4" />
801
- {isActive ? `Exporting ${label}…` : `Export ${label}`}
1008
+ <Send aria-hidden="true" className="size-4" />
1009
+ {sendToBlenderStep
1010
+ ? SEND_TO_BLENDER_STEP_LABEL[sendToBlenderStep]
1011
+ : 'Send to Blender'}
802
1012
  </Button>
803
- )
804
- })}
805
-
806
- <Button
807
- aria-busy={sendToBlenderStep !== null}
808
- className="w-full justify-start gap-2"
809
- disabled={activeModelExport !== null || sendToBlenderStep !== null || !modelExport}
810
- onClick={() => void handleSendToBlender()}
811
- variant="outline"
812
- >
813
- <Send aria-hidden="true" className="size-4" />
814
- {sendToBlenderStep ? SEND_TO_BLENDER_STEP_LABEL[sendToBlenderStep] : 'Send to Blender'}
815
- </Button>
816
- <p className="text-muted-foreground text-xs">
817
- Needs the{' '}
818
- <a
819
- className="underline underline-offset-2"
820
- href={BLENDER_ADDON_URL}
821
- rel="noreferrer"
822
- target="_blank"
823
- >
824
- Pascal add-on for Blender
825
- </a>{' '}
826
- running in an open Blender.
827
- </p>
828
- {sendToBlenderMessage ? (
829
- <p
830
- className={
831
- sendToBlenderMessage.tone === 'error'
832
- ? 'text-destructive text-xs'
833
- : 'text-foreground text-xs'
834
- }
835
- role={sendToBlenderMessage.tone === 'error' ? 'alert' : 'status'}
836
- >
837
- {sendToBlenderMessage.text}
838
- </p>
839
- ) : null}
840
-
841
- {activeModelExport ? (
842
- <p className="text-muted-foreground text-xs" role="status">
843
- Preparing {activeModelExport.toUpperCase()} file…
844
- </p>
845
- ) : null}
846
- {modelExportError ? (
847
- <p className="text-destructive text-xs" role="alert">
848
- {modelExportError}
849
- </p>
850
- ) : null}
851
- {modelExportWarning ? (
852
- <p className="text-foreground text-xs" role="status">
853
- Warning: {modelExportWarning}
854
- </p>
855
- ) : null}
856
-
857
- <PrintExportButton onlyVisible={exportOnlyVisible} />
858
- </div>
859
-
860
- <div className="space-y-2">
861
- <div className="flex items-center justify-between font-medium text-muted-foreground text-xs">
862
- <span>Floor plan</span>
863
- <span>{floorplanMode === 'default' ? 'Default mode' : 'Expert mode'}</span>
1013
+ <p className="text-muted-foreground text-xs">
1014
+ Needs the{' '}
1015
+ <a
1016
+ className="underline underline-offset-2"
1017
+ href={BLENDER_ADDON_URL}
1018
+ rel="noreferrer"
1019
+ target="_blank"
1020
+ >
1021
+ Pascal add-on for Blender
1022
+ </a>{' '}
1023
+ running in an open Blender.
1024
+ </p>
1025
+ </div>
1026
+ {sendToBlenderMessage ? (
1027
+ <p
1028
+ className={
1029
+ sendToBlenderMessage.tone === 'error'
1030
+ ? 'text-destructive text-xs'
1031
+ : 'text-foreground text-xs'
1032
+ }
1033
+ role={sendToBlenderMessage.tone === 'error' ? 'alert' : 'status'}
1034
+ >
1035
+ {sendToBlenderMessage.text}
1036
+ </p>
1037
+ ) : null}
1038
+
1039
+ {activeModelExport ? (
1040
+ <p className="text-muted-foreground text-xs" role="status">
1041
+ Preparing {activeModelExport.toUpperCase()} file…
1042
+ </p>
1043
+ ) : null}
1044
+ {modelExportError ? (
1045
+ <p className="text-destructive text-xs" role="alert">
1046
+ {modelExportError}
1047
+ </p>
1048
+ ) : null}
1049
+ {modelExportWarning ? (
1050
+ <p className="text-foreground text-xs" role="status">
1051
+ Warning: {modelExportWarning}
1052
+ </p>
1053
+ ) : null}
1054
+
1055
+ <div className="grid gap-2 @sm:grid-cols-2">
1056
+ <PrintExportButton onlyVisible={exportOnlyVisible} />
1057
+ </div>
864
1058
  </div>
865
- <Button
866
- aria-busy={activeFloorplanExport === 'full'}
867
- className="w-full justify-start gap-2"
868
- disabled={activeFloorplanExport !== null}
869
- onClick={() => void handleFloorplanExport('full')}
870
- variant="outline"
871
- >
872
- <MapIcon className="size-4" />
873
- Full floor plan
874
- </Button>
875
- <Button
876
- aria-busy={activeFloorplanExport === 'structure'}
877
- className="w-full justify-start gap-2"
878
- disabled={activeFloorplanExport !== null}
879
- onClick={() => void handleFloorplanExport('structure')}
880
- variant="outline"
881
- >
882
- <MapIcon className="size-4" />
883
- Structure only
884
- </Button>
885
- {activeFloorplanExport ? (
886
- <p className="text-muted-foreground text-xs" role="status">
887
- Preparing floor-plan PDF…
888
- </p>
889
- ) : null}
890
- {floorplanExportError ? (
891
- <p className="break-words text-destructive text-xs" role="alert">
892
- {floorplanExportError}
893
- </p>
894
- ) : null}
895
- </div>
896
- </div>
897
1059
 
898
- {/* Thumbnail Section (only for cloud projects) */}
899
- {projectId && !isLocalProject && (
900
- <div className="space-y-2">
901
- <label className="font-medium text-muted-foreground text-xs uppercase">Thumbnail</label>
902
- <Button
903
- className="w-full justify-start gap-2"
904
- disabled={isGeneratingThumbnail}
905
- onClick={handleGenerateThumbnail}
906
- variant="outline"
907
- >
908
- <Camera className="size-4" />
909
- {isGeneratingThumbnail ? 'Generating...' : 'Generate Thumbnail'}
910
- </Button>
911
- </div>
912
- )}
913
-
914
- {/* Save/Load Section */}
915
- <div className="space-y-2">
916
- <label className="font-medium text-muted-foreground text-xs uppercase">Save & Load</label>
1060
+ <div className="space-y-3 pt-2">
1061
+ <div className="flex items-center justify-between">
1062
+ <SettingsSubheading>Floor plan</SettingsSubheading>
1063
+ <span className="text-muted-foreground text-xs">
1064
+ {floorplanMode === 'default' ? 'Default mode' : 'Expert mode'}
1065
+ </span>
1066
+ </div>
1067
+ <div className="grid gap-2 @sm:grid-cols-2">
1068
+ <Button
1069
+ aria-busy={activeFloorplanExport === 'full'}
1070
+ className="w-full justify-start gap-2"
1071
+ disabled={activeFloorplanExport !== null}
1072
+ onClick={() => void handleFloorplanExport('full')}
1073
+ variant="outline"
1074
+ >
1075
+ <MapIcon className="size-4" />
1076
+ Full floor plan
1077
+ </Button>
1078
+ <Button
1079
+ aria-busy={activeFloorplanExport === 'structure'}
1080
+ className="w-full justify-start gap-2"
1081
+ disabled={activeFloorplanExport !== null}
1082
+ onClick={() => void handleFloorplanExport('structure')}
1083
+ variant="outline"
1084
+ >
1085
+ <MapIcon className="size-4" />
1086
+ Structure only
1087
+ </Button>
1088
+ </div>
1089
+ {activeFloorplanExport ? (
1090
+ <p className="text-muted-foreground text-xs" role="status">
1091
+ Preparing floor-plan PDF…
1092
+ </p>
1093
+ ) : null}
1094
+ {floorplanExportError ? (
1095
+ <p className="break-words text-destructive text-xs" role="alert">
1096
+ {floorplanExportError}
1097
+ </p>
1098
+ ) : null}
1099
+ </div>
1100
+ </SettingsSection>
917
1101
 
918
- <Button className="w-full justify-start gap-2" onClick={handleSaveBuild} variant="outline">
919
- <Save className="size-4" />
920
- Save Build
921
- </Button>
1102
+ {/* Thumbnail (only for cloud projects) */}
1103
+ {projectId && !isLocalProject && (
1104
+ <SettingsSection
1105
+ description="Refresh the preview shown in your project list."
1106
+ title="Thumbnail"
1107
+ >
1108
+ <div className="grid gap-2 @sm:grid-cols-2">
1109
+ <Button
1110
+ className="w-full justify-start gap-2"
1111
+ disabled={isGeneratingThumbnail}
1112
+ onClick={handleGenerateThumbnail}
1113
+ variant="outline"
1114
+ >
1115
+ <Camera className="size-4" />
1116
+ {isGeneratingThumbnail ? 'Generating…' : 'Generate thumbnail'}
1117
+ </Button>
1118
+ </div>
1119
+ </SettingsSection>
1120
+ )}
922
1121
 
923
- <Button
924
- className="w-full justify-start gap-2"
925
- onClick={() => fileInputRef.current?.click()}
926
- variant="outline"
1122
+ <SettingsSection
1123
+ description="Keep a JSON copy of the scene, or restore one."
1124
+ title="Save and load"
927
1125
  >
928
- <Upload className="size-4" />
929
- Load Build
930
- </Button>
931
-
932
- <input
933
- accept="application/json"
934
- className="hidden"
935
- onChange={handleFileLoad}
936
- ref={fileInputRef}
937
- type="file"
938
- />
939
-
940
- <LoadBuildDialog
941
- onCancel={() => setPendingImport(null)}
942
- onConfirm={handleConfirmImport}
943
- pending={pendingImport}
944
- />
945
- </div>
946
-
947
- {/* Audio Section */}
948
- <div className="space-y-2">
949
- <label className="font-medium text-muted-foreground text-xs uppercase">Audio</label>
950
- <AudioSettingsDialog />
951
- </div>
952
-
953
- {/* Keyboard Section */}
954
- <div className="space-y-2">
955
- <label className="font-medium text-muted-foreground text-xs uppercase">Keyboard</label>
956
- <KeyboardShortcutsDialog />
957
- </div>
958
-
959
- {/* Scene Graph */}
960
- <div className="space-y-1">
961
- <label className="font-medium text-muted-foreground text-xs uppercase">Scene Graph</label>
962
- <Dialog>
963
- <DialogTrigger asChild>
964
- <Button className="h-auto justify-start p-0 text-sm" variant="link">
965
- Explore scene graph
1126
+ <div className="grid gap-2 @sm:grid-cols-2">
1127
+ <Button
1128
+ className="w-full justify-start gap-2"
1129
+ onClick={handleSaveBuild}
1130
+ variant="outline"
1131
+ >
1132
+ <Save className="size-4" />
1133
+ Save build
966
1134
  </Button>
967
- </DialogTrigger>
968
- <DialogContent className="h-[80vh] max-w-[95vw] gap-0 overflow-hidden border-0 bg-[#1e1e1e] p-0 shadow-none sm:max-w-5xl">
969
- <DialogTitle className="sr-only">Scene Graph</DialogTitle>
970
- <div
971
- className="flex h-full min-h-0 w-full min-w-0 *:h-full *:w-full *:overflow-y-auto"
972
- onContextMenuCapture={blockSceneGraphMutations}
973
- onDragStartCapture={blockSceneGraphMutations}
974
- onDropCapture={blockSceneGraphMutations}
975
- onKeyDownCapture={blockSceneGraphDeletion}
1135
+ <Button
1136
+ className="w-full justify-start gap-2"
1137
+ onClick={() => fileInputRef.current?.click()}
1138
+ variant="outline"
976
1139
  >
977
- <VisualJson value={sceneGraphValue}>
978
- <TreeView showCounts />
979
- </VisualJson>
980
- </div>
981
- </DialogContent>
982
- </Dialog>
983
- </div>
1140
+ <Upload className="size-4" />
1141
+ Load build
1142
+ </Button>
1143
+ </div>
984
1144
 
985
- {/* Danger Zone */}
986
- <div className="space-y-2">
987
- <label className="font-medium text-destructive text-xs uppercase">Danger Zone</label>
1145
+ <input
1146
+ accept="application/json"
1147
+ className="hidden"
1148
+ onChange={handleFileLoad}
1149
+ ref={fileInputRef}
1150
+ type="file"
1151
+ />
1152
+
1153
+ <LoadBuildDialog
1154
+ onCancel={() => setPendingImport(null)}
1155
+ onConfirm={handleConfirmImport}
1156
+ pending={pendingImport}
1157
+ />
1158
+ </SettingsSection>
1159
+
1160
+ <SettingsSection description="Sound levels and keyboard shortcuts." title="Preferences">
1161
+ <div className="grid gap-2 @sm:grid-cols-2">
1162
+ <AudioSettingsDialog />
1163
+ <KeyboardShortcutsDialog />
1164
+ </div>
1165
+ </SettingsSection>
988
1166
 
989
- <Button
990
- className="w-full justify-start gap-2"
991
- onClick={handleResetToDefault}
992
- variant="destructive"
1167
+ <SettingsSection
1168
+ description="Inspect how nodes are nested in this scene."
1169
+ title="Scene graph"
993
1170
  >
994
- <Trash2 className="size-4" />
995
- Clear & Start New
996
- </Button>
1171
+ <Dialog>
1172
+ <DialogTrigger asChild>
1173
+ <div className="grid gap-2 @sm:grid-cols-2">
1174
+ <Button className="w-full justify-start gap-2" variant="outline">
1175
+ <ListTree className="size-4" />
1176
+ Explore scene graph
1177
+ </Button>
1178
+ </div>
1179
+ </DialogTrigger>
1180
+ <DialogContent className="h-[80vh] max-w-[95vw] gap-0 overflow-hidden border-0 bg-[#1e1e1e] p-0 shadow-none sm:max-w-5xl">
1181
+ <DialogTitle className="sr-only">Scene Graph</DialogTitle>
1182
+ <div
1183
+ className="flex h-full min-h-0 w-full min-w-0 *:h-full *:w-full *:overflow-y-auto"
1184
+ onContextMenuCapture={blockSceneGraphMutations}
1185
+ onDragStartCapture={blockSceneGraphMutations}
1186
+ onDropCapture={blockSceneGraphMutations}
1187
+ onKeyDownCapture={blockSceneGraphDeletion}
1188
+ >
1189
+ <VisualJson value={sceneGraphValue}>
1190
+ <TreeView showCounts />
1191
+ </VisualJson>
1192
+ </div>
1193
+ </DialogContent>
1194
+ </Dialog>
1195
+ </SettingsSection>
1196
+
1197
+ <SettingsSection
1198
+ description="Removes every node from this scene. This cannot be undone."
1199
+ title="Danger zone"
1200
+ tone="destructive"
1201
+ >
1202
+ <div className="grid gap-2 @sm:grid-cols-2">
1203
+ <Button
1204
+ className="w-full justify-start gap-2"
1205
+ onClick={handleResetToDefault}
1206
+ variant="destructive"
1207
+ >
1208
+ <Trash2 className="size-4" />
1209
+ Clear and start new
1210
+ </Button>
1211
+ </div>
1212
+ </SettingsSection>
997
1213
  </div>
998
1214
  </div>
999
1215
  )