@pascal-app/editor 0.9.1 → 1.0.0-beta.1
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 +14 -9
- package/src/components/editor/alignment-3d-guide-layer.tsx +10 -2
- package/src/components/editor/bake-exporter.tsx +49 -0
- package/src/components/editor/bake-thumbnail.tsx +95 -0
- package/src/components/editor/camera-dragging-lifecycle.test.ts +49 -0
- package/src/components/editor/camera-dragging-lifecycle.ts +41 -0
- package/src/components/editor/custom-camera-controls.tsx +332 -199
- package/src/components/editor/delete-confirmation-dialog.tsx +54 -0
- package/src/components/editor/editor-layout-mobile.tsx +5 -0
- package/src/components/editor/editor-layout-v2.tsx +18 -0
- package/src/components/editor/elevation-3d-guide-layer.tsx +120 -0
- package/src/components/editor/export-manager.tsx +71 -63
- package/src/components/editor/fence-tangent-lines-3d.tsx +87 -0
- package/src/components/editor/first-person/build-collider-world.test.ts +102 -5
- package/src/components/editor/first-person/build-collider-world.ts +52 -5
- package/src/components/editor/first-person/terrain-collider.test.ts +132 -0
- package/src/components/editor/first-person/terrain-collider.ts +212 -0
- package/src/components/editor/first-person-controls.tsx +410 -136
- package/src/components/editor/floating-action-menu.tsx +435 -64
- package/src/components/editor/floating-building-action-menu.tsx +1 -1
- package/src/components/editor/floorplan-background-selection.test.ts +72 -0
- package/src/components/editor/floorplan-background-selection.ts +7 -20
- package/src/components/editor/floorplan-camera-sync.test.ts +249 -0
- package/src/components/editor/floorplan-camera-sync.ts +213 -0
- package/src/components/editor/floorplan-mode-coordinator.tsx +82 -0
- package/src/components/editor/floorplan-navigation-presentation.test.ts +142 -0
- package/src/components/editor/floorplan-navigation-presentation.ts +156 -0
- package/src/components/editor/floorplan-panel.tsx +2517 -1492
- package/src/components/editor/grid.tsx +166 -39
- package/src/components/editor/group-actions.ts +597 -0
- package/src/components/editor/group-floating-action-menu.tsx +130 -0
- package/src/components/editor/group-move-3d.ts +397 -0
- package/src/components/editor/group-rotate-handle.tsx +102 -64
- package/src/components/editor/group-selection-box-3d.tsx +173 -0
- package/src/components/editor/group-transform-shared.test.ts +192 -1
- package/src/components/editor/group-transform-shared.ts +240 -7
- package/src/components/editor/handles/handle-arrow.tsx +81 -23
- package/src/components/editor/handles/handle-drag-history.test.ts +96 -0
- package/src/components/editor/handles/handle-drag-history.ts +14 -0
- package/src/components/editor/handles/preview-overrides.test.ts +26 -0
- package/src/components/editor/handles/preview-overrides.ts +13 -0
- package/src/components/editor/handles/resize-snap.test.ts +52 -0
- package/src/components/editor/handles/resize-snap.ts +23 -0
- package/src/components/editor/handles/use-handle-drag.ts +49 -6
- package/src/components/editor/index.tsx +289 -35
- package/src/components/editor/measurement-pill.tsx +68 -23
- package/src/components/editor/node-action-menu.tsx +14 -1
- package/src/components/editor/node-arrow-handles.tsx +409 -180
- package/src/components/editor/opening-guides-3d-layer.tsx +144 -0
- package/src/components/editor/quick-measurement-card.tsx +76 -0
- package/src/components/editor/quick-measurement-hud.tsx +34 -0
- package/src/components/editor/riser-diagram-panel.tsx +137 -0
- package/src/components/editor/selection-manager.tsx +814 -466
- package/src/components/editor/site-edge-labels.tsx +28 -6
- package/src/components/editor/slab-hole-highlights.tsx +13 -5
- package/src/components/editor/snapshot-capture-overlay.tsx +258 -115
- package/src/components/editor/three-context-bridge.ts +22 -0
- package/src/components/editor/thumbnail-generator.tsx +118 -253
- package/src/components/editor/use-floorplan-background-placement.ts +113 -45
- package/src/components/editor/use-floorplan-hit-testing.test.ts +82 -0
- package/src/components/editor/use-floorplan-hit-testing.ts +144 -161
- package/src/components/editor/use-floorplan-scene-data.ts +5 -5
- package/src/components/editor/use-mesh-settle-epoch.ts +27 -0
- package/src/components/editor/wall-measurement-label.tsx +10 -28
- package/src/components/editor/wall-move-side-handles.tsx +229 -39
- package/src/components/editor/wall-opening-highlights.tsx +63 -32
- package/src/components/editor/wall-snap-beacon-layer.tsx +162 -6
- package/src/components/editor-2d/floorplan-action-menu-layer.tsx +9 -5
- package/src/components/editor-2d/floorplan-alignment-guide-layer.tsx +2 -1
- package/src/components/editor-2d/floorplan-cursor-indicator-overlay.tsx +40 -9
- package/src/components/editor-2d/floorplan-cursor-indicator-position.test.ts +31 -0
- package/src/components/editor-2d/floorplan-cursor-indicator-position.ts +39 -0
- package/src/components/editor-2d/floorplan-group-action-menu.tsx +87 -0
- package/src/components/editor-2d/floorplan-group-move.tsx +744 -0
- package/src/components/editor-2d/floorplan-measurement-tool-layer.test.ts +113 -0
- package/src/components/editor-2d/floorplan-measurement-tool-layer.tsx +1672 -0
- package/src/components/editor-2d/floorplan-quick-measure-layer.tsx +212 -0
- package/src/components/editor-2d/floorplan-registered-tool-layer.tsx +72 -0
- package/src/components/editor-2d/floorplan-registry-action-menu.tsx +219 -20
- package/src/components/editor-2d/floorplan-registry-move-overlay.tsx +327 -59
- package/src/components/editor-2d/floorplan-render-context.test.ts +27 -0
- package/src/components/editor-2d/floorplan-render-context.tsx +113 -8
- package/src/components/editor-2d/floorplan-snap-beacon-layer.tsx +5 -3
- package/src/components/editor-2d/renderers/floorplan-annotation-layout.test.ts +285 -0
- package/src/components/editor-2d/renderers/floorplan-annotation-layout.ts +516 -0
- package/src/components/editor-2d/renderers/floorplan-dimension-renderer.test.tsx +236 -0
- package/src/components/editor-2d/renderers/floorplan-dimension-renderer.tsx +618 -0
- package/src/components/editor-2d/renderers/floorplan-geometry-renderer.test.tsx +369 -0
- package/src/components/editor-2d/renderers/floorplan-geometry-renderer.tsx +431 -32
- package/src/components/editor-2d/renderers/floorplan-label-angle.test.ts +89 -0
- package/src/components/editor-2d/renderers/floorplan-label-angle.ts +106 -0
- package/src/components/editor-2d/renderers/floorplan-placement-preview-layer.tsx +94 -26
- package/src/components/editor-2d/renderers/floorplan-registry-layer.test.ts +587 -0
- package/src/components/editor-2d/renderers/floorplan-registry-layer.tsx +2280 -578
- package/src/components/editor-2d/renderers/floorplan-stair-layer.tsx +20 -10
- package/src/components/editor-2d/renderers/floorplan-voronoi-layer.tsx +128 -0
- package/src/components/systems/ceiling/ceiling-selection-affordance-system.tsx +425 -61
- package/src/components/systems/ceiling/ceiling-system.tsx +97 -4
- package/src/components/systems/roof/roof-edit-system.tsx +1768 -13
- package/src/components/systems/selection-affordance-manager.tsx +38 -0
- package/src/components/systems/zone/zone-label-editor-system.tsx +14 -1
- package/src/components/systems/zone/zone-system.tsx +42 -13
- package/src/components/tools/elevator/elevator-tool.tsx +34 -8
- package/src/components/tools/elevator/move-elevator-tool.tsx +13 -2
- package/src/components/tools/fence/fence-drafting.ts +107 -8
- package/src/components/tools/item/move-tool.tsx +17 -13
- package/src/components/tools/item/placement-math.test.ts +13 -1
- package/src/components/tools/item/placement-math.ts +28 -2
- package/src/components/tools/item/placement-strategies.ts +246 -5
- package/src/components/tools/item/placement-types.ts +13 -1
- package/src/components/tools/item/use-draft-node.ts +146 -57
- package/src/components/tools/item/use-placement-coordinator.tsx +813 -125
- package/src/components/tools/registry/move-registry-node-tool.tsx +636 -103
- package/src/components/tools/roof/roof-tool.tsx +336 -94
- package/src/components/tools/select/box-select-state.ts +18 -7
- package/src/components/tools/select/box-select-tool.tsx +176 -40
- package/src/components/tools/select/marquee-geometry.test.ts +161 -0
- package/src/components/tools/select/marquee-geometry.ts +155 -0
- package/src/components/tools/select/plane-box-select-tool.tsx +1 -8
- package/src/components/tools/select/select-candidates.ts +1 -1
- package/src/components/tools/shared/cursor-sphere.tsx +62 -26
- package/src/components/tools/shared/drag-bounding-box.tsx +28 -4
- package/src/components/tools/shared/facing-indicator.tsx +87 -0
- package/src/components/tools/shared/facing-pose-indicator.tsx +54 -0
- package/src/components/tools/shared/floor-stack-preview.ts +4 -0
- package/src/components/tools/shared/horizontal-construction-plane.ts +123 -0
- package/src/components/tools/shared/placement-box.tsx +183 -1
- package/src/components/tools/shared/pointer-support-cap.test.ts +98 -0
- package/src/components/tools/shared/pointer-support-cap.ts +273 -0
- package/src/components/tools/shared/polygon-editor.tsx +276 -35
- package/src/components/tools/site/site-boundary-editor.tsx +101 -42
- package/src/components/tools/site/stroke-pointer-ownership.test.ts +91 -0
- package/src/components/tools/site/stroke-pointer-ownership.ts +57 -0
- package/src/components/tools/site/terrain-brush-cursor.tsx +247 -0
- package/src/components/tools/site/terrain-sculpt-grid.tsx +192 -0
- package/src/components/tools/site/terrain-sculpt-tool.tsx +356 -0
- package/src/components/tools/stair/stair-click-guard.test.ts +58 -0
- package/src/components/tools/stair/stair-click-guard.ts +72 -0
- package/src/components/tools/stair/stair-defaults.ts +1 -0
- package/src/components/tools/stair/stair-tool.tsx +164 -42
- package/src/components/tools/tool-manager.tsx +149 -30
- package/src/components/tools/wall/wall-drafting.test.ts +447 -0
- package/src/components/tools/wall/wall-drafting.ts +304 -108
- package/src/components/tools/wall/wall-snap-geometry.test.ts +52 -0
- package/src/components/tools/wall/wall-snap-geometry.ts +137 -9
- package/src/components/tools/zone/zone-boundary-editor.tsx +5 -1
- package/src/components/tools/zone/zone-tool.tsx +98 -88
- package/src/components/ui/action-menu/camera-actions.tsx +24 -17
- package/src/components/ui/action-menu/control-modes.tsx +44 -94
- package/src/components/ui/action-menu/furnish-tools.tsx +5 -5
- package/src/components/ui/action-menu/index.tsx +2 -4
- package/src/components/ui/action-menu/measurement-control.tsx +267 -0
- package/src/components/ui/action-menu/structure-tools.tsx +22 -13
- package/src/components/ui/action-menu/view-toggles.tsx +42 -90
- package/src/components/ui/command-palette/editor-commands.tsx +16 -3
- package/src/components/ui/command-palette/index.tsx +4 -3
- package/src/components/ui/controls/material-paint-panel.tsx +93 -18
- package/src/components/ui/controls/material-picker.tsx +162 -152
- package/src/components/ui/controls/material-properties-editor.tsx +108 -0
- package/src/components/ui/controls/metric-control.tsx +118 -44
- package/src/components/ui/controls/scene-material-list.tsx +247 -0
- package/src/components/ui/controls/slider-control.tsx +88 -38
- package/src/components/ui/controls/terrain-sculpt-panel.tsx +193 -0
- package/src/components/ui/floating-level-selector.tsx +74 -20
- package/src/components/ui/helpers/building-helper.tsx +10 -23
- package/src/components/ui/helpers/contextual-helper-panel.tsx +428 -0
- package/src/components/ui/helpers/helper-manager.tsx +273 -14
- package/src/components/ui/helpers/item-helper.tsx +28 -32
- package/src/components/ui/helpers/registered-tool-helper.tsx +45 -11
- package/src/components/ui/helpers/roof-helper.tsx +10 -12
- package/src/components/ui/icon-ref.tsx +47 -0
- package/src/components/ui/item-catalog/catalog-items.tsx +39 -1
- package/src/components/ui/item-catalog/item-catalog.tsx +13 -36
- package/src/components/ui/level-duplicate-dialog.tsx +1 -1
- package/src/components/ui/panels/multi-selection-panel.tsx +57 -0
- package/src/components/ui/panels/node-display.ts +17 -17
- package/src/components/ui/panels/panel-manager.tsx +36 -14
- package/src/components/ui/panels/panel-wrapper.tsx +24 -3
- package/src/components/ui/panels/parametric-inspector.tsx +19 -4
- package/src/components/ui/panels/reference-panel.tsx +54 -19
- package/src/components/ui/panels/selection-breakdown.test.ts +24 -0
- package/src/components/ui/panels/selection-breakdown.ts +20 -0
- package/src/components/ui/primitives/shortcut-token.tsx +39 -3
- package/src/components/ui/primitives/sidebar.tsx +1 -0
- package/src/components/ui/sidebar/app-sidebar.tsx +5 -1
- package/src/components/ui/sidebar/icon-rail.tsx +50 -31
- package/src/components/ui/sidebar/panels/plugins-panel.tsx +218 -0
- package/src/components/ui/sidebar/panels/settings-panel/index.tsx +82 -41
- package/src/components/ui/sidebar/panels/settings-panel/keyboard-shortcuts-dialog.tsx +76 -6
- package/src/components/ui/sidebar/panels/settings-panel/load-build-dialog.tsx +12 -4
- package/src/components/ui/sidebar/panels/site-panel/building-tree-node.tsx +2 -1
- package/src/components/ui/sidebar/panels/site-panel/ceiling-tree-node.tsx +4 -3
- package/src/components/ui/sidebar/panels/site-panel/chimney-tree-node.tsx +10 -7
- package/src/components/ui/sidebar/panels/site-panel/column-tree-node.tsx +1 -1
- package/src/components/ui/sidebar/panels/site-panel/door-tree-node.tsx +7 -2
- package/src/components/ui/sidebar/panels/site-panel/dormer-tree-node.tsx +10 -7
- package/src/components/ui/sidebar/panels/site-panel/elevator-tree-node.tsx +1 -1
- package/src/components/ui/sidebar/panels/site-panel/fence-tree-node.tsx +1 -1
- package/src/components/ui/sidebar/panels/site-panel/gutter-tree-node.tsx +10 -7
- package/src/components/ui/sidebar/panels/site-panel/index.tsx +42 -17
- package/src/components/ui/sidebar/panels/site-panel/item-tree-node.tsx +31 -17
- package/src/components/ui/sidebar/panels/site-panel/level-tree-node.tsx +1 -1
- package/src/components/ui/sidebar/panels/site-panel/registry-tree-node.tsx +72 -25
- package/src/components/ui/sidebar/panels/site-panel/roof-tree-node.tsx +7 -3
- package/src/components/ui/sidebar/panels/site-panel/shelf-tree-node.tsx +12 -8
- package/src/components/ui/sidebar/panels/site-panel/slab-tree-node.tsx +4 -3
- package/src/components/ui/sidebar/panels/site-panel/solar-panel-tree-node.tsx +10 -7
- package/src/components/ui/sidebar/panels/site-panel/spawn-tree-node.tsx +1 -1
- package/src/components/ui/sidebar/panels/site-panel/stair-tree-node.tsx +2 -2
- package/src/components/ui/sidebar/panels/site-panel/tree-node.tsx +44 -3
- package/src/components/ui/sidebar/panels/site-panel/tree-structure.ts +36 -0
- package/src/components/ui/sidebar/panels/site-panel/wall-tree-node.tsx +1 -1
- package/src/components/ui/sidebar/panels/site-panel/window-tree-node.tsx +7 -2
- package/src/components/ui/sidebar/panels/site-panel/zone-tree-node.tsx +3 -3
- package/src/components/ui/sidebar/tab-bar.tsx +42 -28
- package/src/components/ui/sidebar/use-plugin-panels.tsx +132 -0
- package/src/components/ui/snap-target-badge.test.tsx +40 -0
- package/src/components/ui/snap-target-badge.tsx +88 -0
- package/src/components/viewer/viewer-controls-bar.tsx +466 -0
- package/src/components/viewer/viewer-scene-header.tsx +235 -0
- package/src/components/viewer-overlay.tsx +36 -596
- package/src/components/viewer-zone-system.tsx +6 -1
- package/src/components/walkthrough-hud.tsx +111 -0
- package/src/hooks/use-auto-save.test.ts +14 -0
- package/src/hooks/use-auto-save.ts +54 -7
- package/src/hooks/use-ceiling-events.ts +3 -2
- package/src/hooks/use-drag-action.ts +4 -1
- package/src/hooks/use-grid-events.ts +24 -0
- package/src/hooks/use-keyboard.ts +438 -70
- package/src/index.tsx +355 -9
- package/src/lib/active-placement-surface.test.ts +24 -0
- package/src/lib/active-placement-surface.ts +42 -0
- package/src/lib/camera-pose.test.ts +237 -0
- package/src/lib/camera-pose.ts +172 -0
- package/src/lib/ceiling-plan-snap.ts +24 -0
- package/src/lib/contextual-help.test.ts +112 -0
- package/src/lib/contextual-help.ts +144 -0
- package/src/lib/continuation.ts +64 -0
- package/src/lib/direct-manipulation.test.ts +275 -0
- package/src/lib/direct-manipulation.ts +118 -0
- package/src/lib/door-interaction.ts +1 -1
- package/src/lib/editor-api.ts +23 -35
- package/src/lib/elevation-guides.test.ts +107 -0
- package/src/lib/elevation-guides.ts +236 -0
- package/src/lib/floorplan/annotation-visibility.test.ts +327 -0
- package/src/lib/floorplan/annotation-visibility.ts +133 -0
- package/src/lib/floorplan/apply-alignment.test.ts +25 -0
- package/src/lib/floorplan/apply-alignment.ts +18 -12
- package/src/lib/floorplan/drawing-coordination.test.ts +46 -0
- package/src/lib/floorplan/drawing-coordination.ts +13 -0
- package/src/lib/floorplan/floorplan-export.test.ts +319 -0
- package/src/lib/floorplan/floorplan-export.tsx +978 -0
- package/src/lib/floorplan/floorplan-extension.test.ts +43 -0
- package/src/lib/floorplan/floorplan-extension.ts +181 -0
- package/src/lib/floorplan/floorplan-mode.test.ts +120 -0
- package/src/lib/floorplan/floorplan-mode.ts +73 -0
- package/src/lib/floorplan/floorplan-pdfkit-document.ts +194 -0
- package/src/lib/floorplan/floorplan-pdfkit-renderer.test.ts +107 -0
- package/src/lib/floorplan/floorplan-pdfkit-renderer.ts +680 -0
- package/src/lib/floorplan/geometry.ts +52 -0
- package/src/lib/floorplan/index.ts +3 -0
- package/src/lib/floorplan/items.ts +5 -2
- package/src/lib/floorplan/plan-coords.ts +21 -0
- package/src/lib/fresh-planar-placement.test.ts +283 -3
- package/src/lib/fresh-planar-placement.ts +85 -1
- package/src/lib/glb-export.test.ts +556 -0
- package/src/lib/glb-export.ts +1071 -0
- package/src/lib/ground-surface.ts +95 -0
- package/src/lib/history.test.ts +96 -0
- package/src/lib/history.ts +31 -0
- package/src/lib/interaction/hot-set.test.ts +133 -0
- package/src/lib/interaction/hot-set.ts +67 -0
- package/src/lib/interaction/overlay-policy.test.ts +52 -0
- package/src/lib/interaction/overlay-policy.ts +59 -0
- package/src/lib/interaction/scope.ts +243 -0
- package/src/lib/level-duplication.test.ts +2 -1
- package/src/lib/level-selection.ts +2 -2
- package/src/lib/material-paint.ts +36 -49
- package/src/lib/measurement-kind.test.ts +30 -0
- package/src/lib/measurement-kind.ts +19 -0
- package/src/lib/measurement-label.test.ts +47 -0
- package/src/lib/measurement-label.ts +68 -0
- package/src/lib/measurement-parser.ts +116 -0
- package/src/lib/measurements.test.ts +188 -0
- package/src/lib/measurements.ts +210 -0
- package/src/lib/paint-scope.test.ts +454 -0
- package/src/lib/paint-scope.ts +461 -0
- package/src/lib/placement-drag-release.ts +23 -0
- package/src/lib/planar-cursor-placement.test.ts +57 -0
- package/src/lib/plugin-panels.test.ts +19 -0
- package/src/lib/plugin-panels.ts +91 -0
- package/src/lib/quick-action-feedback.ts +33 -0
- package/src/lib/quick-action-nodes.test.ts +94 -0
- package/src/lib/quick-action-nodes.ts +47 -0
- package/src/lib/quick-measurement.test.ts +77 -0
- package/src/lib/quick-measurement.ts +109 -0
- package/src/lib/roof-duplication.ts +6 -6
- package/src/lib/roof-hover-outline-proxy.ts +22 -0
- package/src/lib/roof-wall-hit.ts +164 -0
- package/src/lib/scene-clipboard.test.ts +325 -0
- package/src/lib/scene-clipboard.ts +310 -21
- package/src/lib/scene.ts +28 -5
- package/src/lib/selection-routing.test.ts +313 -0
- package/src/lib/selection-routing.ts +180 -0
- package/src/lib/sfx/index.ts +1 -0
- package/src/lib/sfx/movement-tick.test.ts +65 -0
- package/src/lib/sfx/movement-tick.ts +18 -0
- package/src/lib/sfx-bus.ts +82 -14
- package/src/lib/sfx-player.test.ts +266 -0
- package/src/lib/sfx-player.ts +262 -69
- package/src/lib/site-boundary.test.ts +53 -0
- package/src/lib/site-boundary.ts +27 -0
- package/src/lib/slab-plan-snap.test.ts +93 -0
- package/src/lib/slab-plan-snap.ts +108 -0
- package/src/lib/snapping-mode.test.ts +165 -0
- package/src/lib/snapping-mode.ts +191 -0
- package/src/lib/stair-duplication.test.ts +103 -0
- package/src/lib/stair-duplication.ts +58 -86
- package/src/lib/stair-levels.ts +2 -0
- package/src/lib/surface-plan-snap.test.ts +71 -0
- package/src/lib/surface-plan-snap.ts +256 -0
- package/src/lib/terrain-sculpt.test.ts +429 -0
- package/src/lib/terrain-sculpt.ts +301 -0
- package/src/lib/terrain-verb-color.test.ts +51 -0
- package/src/lib/terrain-verb-color.ts +58 -0
- package/src/lib/touch-gesture-priority.test.ts +45 -0
- package/src/lib/touch-gesture-priority.ts +30 -0
- package/src/lib/use-linear-display.ts +40 -0
- package/src/lib/window-interaction.ts +1 -1
- package/src/lib/world-grid-snap.ts +37 -5
- package/src/store/camera-pose-store.test.ts +29 -0
- package/src/store/camera-pose-store.ts +27 -0
- package/src/store/live-draft-preview-stores.test.ts +136 -0
- package/src/store/navigation-sync-pose-store.test.ts +34 -0
- package/src/store/navigation-sync-pose-store.ts +27 -0
- package/src/store/terrain-sculpt-mode.test.ts +223 -0
- package/src/store/use-delete-confirmation.ts +27 -0
- package/src/store/use-direct-manipulation-feedback.ts +20 -0
- package/src/store/use-drawing-view.test.ts +23 -0
- package/src/store/use-drawing-view.ts +84 -0
- package/src/store/use-editor.tsx +665 -126
- package/src/store/use-elevation-guides.ts +40 -0
- package/src/store/use-facing-pose.ts +44 -0
- package/src/store/use-fence-curve-draft.ts +51 -0
- package/src/store/use-first-person-hud.ts +40 -0
- package/src/store/use-floorplan-annotation-visibility.ts +60 -0
- package/src/store/use-floorplan-draft-preview.ts +151 -0
- package/src/store/use-floorplan-marquee.ts +50 -0
- package/src/store/use-floorplan-mode.ts +110 -0
- package/src/store/use-interaction-scope.test.ts +206 -0
- package/src/store/use-interaction-scope.ts +140 -0
- package/src/store/use-measurement-draft.test.ts +559 -0
- package/src/store/use-measurement-draft.ts +570 -0
- package/src/store/use-opening-guides.ts +41 -0
- package/src/store/use-path-draft-preview.ts +90 -0
- package/src/store/use-placement-preview.ts +11 -3
- package/src/store/use-quick-measurement-hud.test.ts +53 -0
- package/src/store/use-quick-measurement-hud.ts +77 -0
- package/src/store/use-segment-draft-chain.ts +28 -0
- package/src/store/use-stair-build-preview.ts +53 -0
- package/src/store/use-wall-snap-indicator.ts +2 -0
- package/src/components/editor/first-person/bvh-ecctrl.tsx +0 -860
- package/src/components/editor/group-move-handle.tsx +0 -316
- package/src/components/ui/panels/paint-panel.tsx +0 -163
- package/src/lib/floorplan/selection-tool.ts +0 -271
- package/src/lib/level-name.ts +0 -11
package/src/lib/sfx-bus.ts
CHANGED
|
@@ -1,5 +1,14 @@
|
|
|
1
|
+
import type { TerrainVerb } from '@pascal-app/core'
|
|
1
2
|
import mitt from 'mitt'
|
|
2
|
-
import
|
|
3
|
+
import useAudio from '../store/use-audio'
|
|
4
|
+
import {
|
|
5
|
+
disposeSFX,
|
|
6
|
+
type LoopSFXName,
|
|
7
|
+
playSFX,
|
|
8
|
+
startLoopSFX,
|
|
9
|
+
stopLoopSFX,
|
|
10
|
+
updateSFXVolumes,
|
|
11
|
+
} from './sfx-player'
|
|
3
12
|
|
|
4
13
|
/**
|
|
5
14
|
* SFX-specific events that tools can trigger
|
|
@@ -10,14 +19,22 @@ type SFXEvents = {
|
|
|
10
19
|
'sfx:item-pick': undefined
|
|
11
20
|
'sfx:item-place': undefined
|
|
12
21
|
'sfx:item-rotate': undefined
|
|
22
|
+
'sfx:resize': undefined
|
|
13
23
|
'sfx:structure-build-start': undefined
|
|
14
24
|
'sfx:structure-build': undefined
|
|
15
25
|
'sfx:structure-delete': undefined
|
|
16
26
|
'sfx:snapshot-capture': undefined
|
|
17
27
|
'sfx:menu-hover': undefined
|
|
18
28
|
'sfx:menu-click': undefined
|
|
29
|
+
'sfx:paint-apply': undefined
|
|
30
|
+
'sfx:terrain-sculpt-start': TerrainVerb
|
|
31
|
+
'sfx:terrain-sculpt-stop': undefined
|
|
19
32
|
}
|
|
20
33
|
|
|
34
|
+
type TriggerSFXEvent = {
|
|
35
|
+
[Event in keyof SFXEvents]: SFXEvents[Event] extends undefined ? Event : never
|
|
36
|
+
}[keyof SFXEvents]
|
|
37
|
+
|
|
21
38
|
/**
|
|
22
39
|
* Dedicated event emitter for SFX
|
|
23
40
|
* Tools should use this to trigger sound effects
|
|
@@ -26,6 +43,29 @@ export const sfxEmitter = mitt<SFXEvents>()
|
|
|
26
43
|
|
|
27
44
|
let sfxBusInitialized = false
|
|
28
45
|
|
|
46
|
+
const handleGridSnap = () => playSFX('gridSnap')
|
|
47
|
+
const handleItemDelete = () => playSFX('itemDelete')
|
|
48
|
+
const handleItemPick = () => playSFX('itemPick')
|
|
49
|
+
const handleItemPlace = () => playSFX('itemPlace')
|
|
50
|
+
const handleItemRotate = () => playSFX('itemRotate')
|
|
51
|
+
const handleResize = () => playSFX('resize')
|
|
52
|
+
const handleStructureBuildStart = () => playSFX('structureBuildStart')
|
|
53
|
+
const handleStructureBuild = () => playSFX('structureBuildEnd')
|
|
54
|
+
const handleStructureDelete = () => playSFX('structureDelete')
|
|
55
|
+
const handleSnapshotCapture = () => playSFX('snapshotCapture')
|
|
56
|
+
const handleMenuHover = () => playSFX('menuHover')
|
|
57
|
+
const handleMenuClick = () => playSFX('menuClick')
|
|
58
|
+
const handlePaintApply = () => playSFX('paintApply')
|
|
59
|
+
const TERRAIN_LOOP_BY_VERB = {
|
|
60
|
+
raise: 'terrainRaise',
|
|
61
|
+
lower: 'terrainLower',
|
|
62
|
+
flatten: 'terrainFlatten',
|
|
63
|
+
smooth: 'terrainSmooth',
|
|
64
|
+
} as const satisfies Record<TerrainVerb, LoopSFXName>
|
|
65
|
+
const handleTerrainSculptStart = (verb: TerrainVerb) => startLoopSFX(TERRAIN_LOOP_BY_VERB[verb])
|
|
66
|
+
const handleTerrainSculptStop = () => stopLoopSFX()
|
|
67
|
+
let unsubscribeAudio: (() => void) | null = null
|
|
68
|
+
|
|
29
69
|
/**
|
|
30
70
|
* Initialize SFX Bus - connects SFX events to actual sound playback.
|
|
31
71
|
* Safe to call multiple times; re-registration is a no-op once initialized.
|
|
@@ -33,18 +73,46 @@ let sfxBusInitialized = false
|
|
|
33
73
|
export function initSFXBus() {
|
|
34
74
|
if (sfxBusInitialized) return
|
|
35
75
|
sfxBusInitialized = true
|
|
36
|
-
|
|
37
|
-
sfxEmitter.on('sfx:
|
|
38
|
-
sfxEmitter.on('sfx:item-
|
|
39
|
-
sfxEmitter.on('sfx:item-
|
|
40
|
-
sfxEmitter.on('sfx:item-
|
|
41
|
-
sfxEmitter.on('sfx:
|
|
42
|
-
sfxEmitter.on('sfx:structure-build-start',
|
|
43
|
-
sfxEmitter.on('sfx:structure-build',
|
|
44
|
-
sfxEmitter.on('sfx:structure-delete',
|
|
45
|
-
sfxEmitter.on('sfx:snapshot-capture',
|
|
46
|
-
sfxEmitter.on('sfx:menu-hover',
|
|
47
|
-
sfxEmitter.on('sfx:menu-click',
|
|
76
|
+
sfxEmitter.on('sfx:grid-snap', handleGridSnap)
|
|
77
|
+
sfxEmitter.on('sfx:item-delete', handleItemDelete)
|
|
78
|
+
sfxEmitter.on('sfx:item-pick', handleItemPick)
|
|
79
|
+
sfxEmitter.on('sfx:item-place', handleItemPlace)
|
|
80
|
+
sfxEmitter.on('sfx:item-rotate', handleItemRotate)
|
|
81
|
+
sfxEmitter.on('sfx:resize', handleResize)
|
|
82
|
+
sfxEmitter.on('sfx:structure-build-start', handleStructureBuildStart)
|
|
83
|
+
sfxEmitter.on('sfx:structure-build', handleStructureBuild)
|
|
84
|
+
sfxEmitter.on('sfx:structure-delete', handleStructureDelete)
|
|
85
|
+
sfxEmitter.on('sfx:snapshot-capture', handleSnapshotCapture)
|
|
86
|
+
sfxEmitter.on('sfx:menu-hover', handleMenuHover)
|
|
87
|
+
sfxEmitter.on('sfx:menu-click', handleMenuClick)
|
|
88
|
+
sfxEmitter.on('sfx:paint-apply', handlePaintApply)
|
|
89
|
+
sfxEmitter.on('sfx:terrain-sculpt-start', handleTerrainSculptStart)
|
|
90
|
+
sfxEmitter.on('sfx:terrain-sculpt-stop', handleTerrainSculptStop)
|
|
91
|
+
unsubscribeAudio = useAudio.subscribe(updateSFXVolumes)
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
export function disposeSFXBus() {
|
|
95
|
+
if (sfxBusInitialized) {
|
|
96
|
+
sfxEmitter.off('sfx:grid-snap', handleGridSnap)
|
|
97
|
+
sfxEmitter.off('sfx:item-delete', handleItemDelete)
|
|
98
|
+
sfxEmitter.off('sfx:item-pick', handleItemPick)
|
|
99
|
+
sfxEmitter.off('sfx:item-place', handleItemPlace)
|
|
100
|
+
sfxEmitter.off('sfx:item-rotate', handleItemRotate)
|
|
101
|
+
sfxEmitter.off('sfx:resize', handleResize)
|
|
102
|
+
sfxEmitter.off('sfx:structure-build-start', handleStructureBuildStart)
|
|
103
|
+
sfxEmitter.off('sfx:structure-build', handleStructureBuild)
|
|
104
|
+
sfxEmitter.off('sfx:structure-delete', handleStructureDelete)
|
|
105
|
+
sfxEmitter.off('sfx:snapshot-capture', handleSnapshotCapture)
|
|
106
|
+
sfxEmitter.off('sfx:menu-hover', handleMenuHover)
|
|
107
|
+
sfxEmitter.off('sfx:menu-click', handleMenuClick)
|
|
108
|
+
sfxEmitter.off('sfx:paint-apply', handlePaintApply)
|
|
109
|
+
sfxEmitter.off('sfx:terrain-sculpt-start', handleTerrainSculptStart)
|
|
110
|
+
sfxEmitter.off('sfx:terrain-sculpt-stop', handleTerrainSculptStop)
|
|
111
|
+
unsubscribeAudio?.()
|
|
112
|
+
unsubscribeAudio = null
|
|
113
|
+
sfxBusInitialized = false
|
|
114
|
+
}
|
|
115
|
+
disposeSFX()
|
|
48
116
|
}
|
|
49
117
|
|
|
50
118
|
/**
|
|
@@ -52,7 +120,7 @@ export function initSFXBus() {
|
|
|
52
120
|
* @example
|
|
53
121
|
* triggerSFX('sfx:item-place')
|
|
54
122
|
*/
|
|
55
|
-
export function triggerSFX(event:
|
|
123
|
+
export function triggerSFX(event: TriggerSFXEvent) {
|
|
56
124
|
sfxEmitter.emit(event)
|
|
57
125
|
}
|
|
58
126
|
|
|
@@ -0,0 +1,266 @@
|
|
|
1
|
+
import { afterAll, beforeEach, describe, expect, mock, test } from 'bun:test'
|
|
2
|
+
|
|
3
|
+
type FakeContext = { id: string }
|
|
4
|
+
|
|
5
|
+
let activeContext: FakeContext = { id: 'first' }
|
|
6
|
+
let initialState: 'loaded' | 'loading' = 'loaded'
|
|
7
|
+
let muted = false
|
|
8
|
+
let throwOnPlay = false
|
|
9
|
+
const instances: FakeHowl[] = []
|
|
10
|
+
|
|
11
|
+
class FakeHowl {
|
|
12
|
+
loadCallbacks: Array<() => void> = []
|
|
13
|
+
loop = false
|
|
14
|
+
src: string | undefined
|
|
15
|
+
stateValue: 'loaded' | 'loading' | 'unloaded' = initialState
|
|
16
|
+
unloadCount = 0
|
|
17
|
+
playCount = 0
|
|
18
|
+
stopCount = 0
|
|
19
|
+
fadeCalls: Array<[number, number, number, number | undefined]> = []
|
|
20
|
+
stereoCalls: Array<[number, number | undefined]> = []
|
|
21
|
+
volumeCalls: Array<[number, number | undefined]> = []
|
|
22
|
+
|
|
23
|
+
constructor(options: { loop?: boolean; src?: string[] }) {
|
|
24
|
+
this.loop = options.loop ?? false
|
|
25
|
+
this.src = options.src?.[0]
|
|
26
|
+
instances.push(this)
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
play() {
|
|
30
|
+
this.playCount++
|
|
31
|
+
if (throwOnPlay) throw new DOMException('stale graph', 'InvalidAccessError')
|
|
32
|
+
return 1
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
volume(value: number, id?: number) {
|
|
36
|
+
this.volumeCalls.push([value, id])
|
|
37
|
+
return this
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
fade(from: number, to: number, duration: number, id?: number) {
|
|
41
|
+
this.fadeCalls.push([from, to, duration, id])
|
|
42
|
+
return this
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
once(event: string, callback: () => void) {
|
|
46
|
+
if (event === 'load') {
|
|
47
|
+
this.loadCallbacks.push(callback)
|
|
48
|
+
return this
|
|
49
|
+
}
|
|
50
|
+
callback()
|
|
51
|
+
return this
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
finishLoading() {
|
|
55
|
+
this.stateValue = 'loaded'
|
|
56
|
+
for (const callback of this.loadCallbacks.splice(0)) callback()
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
playing() {
|
|
60
|
+
return this.playCount > this.stopCount
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
stop() {
|
|
64
|
+
this.stopCount++
|
|
65
|
+
return this
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
stereo(value: number, id?: number) {
|
|
69
|
+
this.stereoCalls.push([value, id])
|
|
70
|
+
return this
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
rate() {
|
|
74
|
+
return this
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
state() {
|
|
78
|
+
return this.stateValue
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
unload() {
|
|
82
|
+
this.unloadCount++
|
|
83
|
+
this.stateValue = 'unloaded'
|
|
84
|
+
return null
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
const fakeHowler = {
|
|
89
|
+
get ctx() {
|
|
90
|
+
return activeContext
|
|
91
|
+
},
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
mock.module('howler', () => ({ Howl: FakeHowl, Howler: fakeHowler }))
|
|
95
|
+
mock.module('../store/use-audio', () => ({
|
|
96
|
+
default: {
|
|
97
|
+
getState: () => ({ masterVolume: 100, muted, sfxVolume: 100 }),
|
|
98
|
+
subscribe: () => () => {},
|
|
99
|
+
},
|
|
100
|
+
}))
|
|
101
|
+
|
|
102
|
+
const { disposeSFX, playSFX, preloadSFX, startLoopSFX, stopLoopSFX, updateSFXVolumes } =
|
|
103
|
+
await import('./sfx-player')
|
|
104
|
+
const { disposeSFXBus, initSFXBus, sfxEmitter, triggerSFX } = await import('./sfx-bus')
|
|
105
|
+
|
|
106
|
+
beforeEach(() => {
|
|
107
|
+
disposeSFXBus()
|
|
108
|
+
activeContext = { id: 'first' }
|
|
109
|
+
initialState = 'loaded'
|
|
110
|
+
muted = false
|
|
111
|
+
throwOnPlay = false
|
|
112
|
+
instances.length = 0
|
|
113
|
+
})
|
|
114
|
+
|
|
115
|
+
afterAll(() => {
|
|
116
|
+
disposeSFXBus()
|
|
117
|
+
mock.restore()
|
|
118
|
+
})
|
|
119
|
+
|
|
120
|
+
describe('SFX audio context lifecycle', () => {
|
|
121
|
+
test('reuses the preloaded cache while the Howler context is unchanged', () => {
|
|
122
|
+
preloadSFX()
|
|
123
|
+
const initialCount = instances.length
|
|
124
|
+
|
|
125
|
+
playSFX('itemDelete')
|
|
126
|
+
|
|
127
|
+
expect(instances).toHaveLength(initialCount)
|
|
128
|
+
})
|
|
129
|
+
|
|
130
|
+
test('rebuilds every cached Howl before playing against a new context', () => {
|
|
131
|
+
preloadSFX()
|
|
132
|
+
const oldSounds = [...instances]
|
|
133
|
+
const initialCount = instances.length
|
|
134
|
+
activeContext = { id: 'second' }
|
|
135
|
+
|
|
136
|
+
playSFX('itemDelete')
|
|
137
|
+
|
|
138
|
+
expect(oldSounds.every((sound) => sound.unloadCount === 1)).toBe(true)
|
|
139
|
+
expect(instances.length).toBe(initialCount * 2)
|
|
140
|
+
expect(instances.slice(initialCount).some((sound) => sound.playCount === 1)).toBe(true)
|
|
141
|
+
})
|
|
142
|
+
|
|
143
|
+
test('contains a stale graph failure and backs off instead of rebuilding per cue', () => {
|
|
144
|
+
preloadSFX()
|
|
145
|
+
const initialCount = instances.length
|
|
146
|
+
throwOnPlay = true
|
|
147
|
+
|
|
148
|
+
expect(() => playSFX('menuHover')).not.toThrow()
|
|
149
|
+
expect(instances.slice(0, initialCount).every((sound) => sound.unloadCount === 1)).toBe(true)
|
|
150
|
+
|
|
151
|
+
throwOnPlay = false
|
|
152
|
+
playSFX('menuHover')
|
|
153
|
+
expect(instances.length).toBe(initialCount)
|
|
154
|
+
})
|
|
155
|
+
|
|
156
|
+
test('does not queue spatial mutations while a sound is still loading', () => {
|
|
157
|
+
initialState = 'loading'
|
|
158
|
+
|
|
159
|
+
playSFX('itemDelete', { source: 'remote', stereo: 0.65, volumeMultiplier: 0.25 })
|
|
160
|
+
|
|
161
|
+
expect(instances.every((sound) => sound.playCount === 0)).toBe(true)
|
|
162
|
+
expect(instances.every((sound) => sound.stereoCalls.length === 0)).toBe(true)
|
|
163
|
+
expect(instances.every((sound) => sound.volumeCalls.length === 0)).toBe(true)
|
|
164
|
+
})
|
|
165
|
+
|
|
166
|
+
test('disposes idempotently and recreates sounds after remount', () => {
|
|
167
|
+
preloadSFX()
|
|
168
|
+
const initialCount = instances.length
|
|
169
|
+
|
|
170
|
+
disposeSFX()
|
|
171
|
+
disposeSFX()
|
|
172
|
+
playSFX('itemDelete')
|
|
173
|
+
|
|
174
|
+
expect(instances.length).toBe(initialCount * 2)
|
|
175
|
+
})
|
|
176
|
+
|
|
177
|
+
test('does not let an emitted SFX failure escape an editor callback', () => {
|
|
178
|
+
initSFXBus()
|
|
179
|
+
throwOnPlay = true
|
|
180
|
+
|
|
181
|
+
expect(() => triggerSFX('sfx:item-delete')).not.toThrow()
|
|
182
|
+
})
|
|
183
|
+
|
|
184
|
+
test('applies bounded gain and stereo positioning to a remote cue', () => {
|
|
185
|
+
playSFX('itemDelete', { source: 'remote', stereo: 0.65, volumeMultiplier: 0.25 })
|
|
186
|
+
|
|
187
|
+
const played = instances.find((sound) => sound.playCount === 1)
|
|
188
|
+
expect(played?.volumeCalls[0]?.[0]).toBeGreaterThanOrEqual(0.225)
|
|
189
|
+
expect(played?.volumeCalls[0]?.[0]).toBeLessThanOrEqual(0.25)
|
|
190
|
+
expect(played?.stereoCalls).toEqual([[0.65, 1]])
|
|
191
|
+
})
|
|
192
|
+
|
|
193
|
+
test('keeps local feedback audible after the same remote cue', () => {
|
|
194
|
+
playSFX('itemDelete', { source: 'remote', volumeMultiplier: 0.25 })
|
|
195
|
+
playSFX('itemDelete')
|
|
196
|
+
|
|
197
|
+
expect(instances.reduce((total, sound) => total + sound.playCount, 0)).toBe(2)
|
|
198
|
+
})
|
|
199
|
+
|
|
200
|
+
test('keeps one faded terrain loop active and stops it on release', () => {
|
|
201
|
+
startLoopSFX('terrainRaise')
|
|
202
|
+
const raise = instances.find((sound) => sound.loop && sound.playCount === 1)
|
|
203
|
+
|
|
204
|
+
expect(raise?.volumeCalls[0]).toEqual([0, 1])
|
|
205
|
+
expect(raise?.fadeCalls).toEqual([[0, 0.2, 90, 1]])
|
|
206
|
+
|
|
207
|
+
startLoopSFX('terrainRaise')
|
|
208
|
+
expect(raise?.playCount).toBe(1)
|
|
209
|
+
|
|
210
|
+
stopLoopSFX()
|
|
211
|
+
expect(raise?.stopCount).toBe(1)
|
|
212
|
+
expect(raise?.fadeCalls.at(-1)).toEqual([0.2, 0, 90, 1])
|
|
213
|
+
})
|
|
214
|
+
|
|
215
|
+
test('maps each terrain verb to a distinct loop through the SFX bus', () => {
|
|
216
|
+
initSFXBus()
|
|
217
|
+
|
|
218
|
+
for (const verb of ['raise', 'lower', 'flatten', 'smooth'] as const) {
|
|
219
|
+
sfxEmitter.emit('sfx:terrain-sculpt-start', verb)
|
|
220
|
+
sfxEmitter.emit('sfx:terrain-sculpt-stop')
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
expect(
|
|
224
|
+
instances.filter((sound) => sound.loop && sound.playCount === 1).map((sound) => sound.src),
|
|
225
|
+
).toEqual([
|
|
226
|
+
'/audios/sfx/terrain_raise.mp3',
|
|
227
|
+
'/audios/sfx/terrain_lower.mp3',
|
|
228
|
+
'/audios/sfx/terrain_flatten.mp3',
|
|
229
|
+
'/audios/sfx/terrain_smooth.mp3',
|
|
230
|
+
])
|
|
231
|
+
})
|
|
232
|
+
|
|
233
|
+
test('fades an active terrain loop out when sound is muted', () => {
|
|
234
|
+
startLoopSFX('terrainLower')
|
|
235
|
+
const lower = instances.find((sound) => sound.loop && sound.playCount === 1)
|
|
236
|
+
|
|
237
|
+
muted = true
|
|
238
|
+
updateSFXVolumes()
|
|
239
|
+
|
|
240
|
+
expect(lower?.fadeCalls.at(-1)).toEqual([0.2, 0, 90, 1])
|
|
241
|
+
expect(lower?.stopCount).toBe(1)
|
|
242
|
+
})
|
|
243
|
+
|
|
244
|
+
test('starts a requested terrain loop when its asset finishes loading', () => {
|
|
245
|
+
initialState = 'loading'
|
|
246
|
+
startLoopSFX('terrainRaise')
|
|
247
|
+
const raise = instances.find((sound) => sound.src === '/audios/sfx/terrain_raise.mp3')
|
|
248
|
+
|
|
249
|
+
expect(raise?.playCount).toBe(0)
|
|
250
|
+
|
|
251
|
+
raise?.finishLoading()
|
|
252
|
+
|
|
253
|
+
expect(raise?.playCount).toBe(1)
|
|
254
|
+
})
|
|
255
|
+
|
|
256
|
+
test('does not start a terrain loop after the sculpt press was released', () => {
|
|
257
|
+
initialState = 'loading'
|
|
258
|
+
startLoopSFX('terrainLower')
|
|
259
|
+
const lower = instances.find((sound) => sound.src === '/audios/sfx/terrain_lower.mp3')
|
|
260
|
+
|
|
261
|
+
stopLoopSFX()
|
|
262
|
+
lower?.finishLoading()
|
|
263
|
+
|
|
264
|
+
expect(lower?.playCount).toBe(0)
|
|
265
|
+
})
|
|
266
|
+
})
|