@pascal-app/editor 1.0.3 → 1.0.4
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 +11 -9
- package/src/components/editor/action-menu-button.tsx +83 -0
- package/src/components/editor/bake-thumbnail.tsx +315 -4
- package/src/components/editor/capture-level-picker.tsx +72 -0
- package/src/components/editor/custom-camera-controls.tsx +202 -57
- package/src/components/editor/delete-confirmation-dialog.tsx +297 -7
- package/src/components/editor/duplicate-node.ts +244 -0
- package/src/components/editor/editor-layout-mobile.tsx +36 -25
- package/src/components/editor/editor-layout-v2.tsx +131 -58
- package/src/components/editor/export-manager.tsx +34 -8
- package/src/components/editor/first-person/build-collider-world.test.ts +51 -0
- package/src/components/editor/first-person/build-collider-world.ts +6 -2
- package/src/components/editor/first-person/mechanism-targets.test.ts +75 -0
- package/src/components/editor/first-person/mechanism-targets.ts +36 -0
- package/src/components/editor/first-person-controls.tsx +205 -2
- package/src/components/editor/floating-action-menu.tsx +63 -207
- package/src/components/editor/floor-aware-camera-controls.test.ts +442 -0
- package/src/components/editor/floor-aware-camera-controls.ts +324 -0
- package/src/components/editor/floor-openings-overlay.tsx +243 -0
- package/src/components/editor/floor-region-controls.tsx +846 -0
- package/src/components/editor/floor-region-webgpu-materials.test.ts +12 -0
- package/src/components/editor/floor-surface.test.ts +165 -0
- package/src/components/editor/floor-surface.ts +182 -0
- package/src/components/editor/floorplan-background-selection.test.ts +11 -2
- package/src/components/editor/floorplan-background-selection.ts +1 -3
- package/src/components/editor/floorplan-panel.tsx +344 -342
- package/src/components/editor/footprint-height-handle.tsx +204 -0
- package/src/components/editor/group-actions.ts +54 -2
- package/src/components/editor/handles/handle-hit-priority.test.tsx +63 -0
- package/src/components/editor/handles/handle-hit-priority.tsx +37 -0
- package/src/components/editor/handles/swallow-next-click.test.ts +28 -0
- package/src/components/editor/handles/use-handle-drag.ts +269 -197
- package/src/components/editor/index.tsx +294 -169
- package/src/components/editor/join-walls-pill.tsx +44 -0
- package/src/components/editor/node-action-menu.tsx +68 -70
- package/src/components/editor/node-arrow-handles.tsx +25 -6
- package/src/components/editor/open-wall-ends-3d-layer.tsx +273 -0
- package/src/components/editor/open-wall-ends-hint.tsx +89 -0
- package/src/components/editor/quick-measurement-hud.tsx +3 -2
- package/src/components/editor/registry-action-contributions.test.tsx +63 -0
- package/src/components/editor/registry-action-contributions.tsx +80 -1
- package/src/components/editor/room-controls.tsx +847 -0
- package/src/components/editor/room-floor-highlight.tsx +128 -0
- package/src/components/editor/room-handles-2d.tsx +354 -0
- package/src/components/editor/room-handles.tsx +675 -0
- package/src/components/editor/room-highlight.tsx +225 -0
- package/src/components/editor/room-labels.test.ts +357 -0
- package/src/components/editor/room-labels.tsx +990 -0
- package/src/components/editor/room-transform-ghost.tsx +256 -0
- package/src/components/editor/room-webgpu-materials.test.ts +27 -0
- package/src/components/editor/selection-manager.tsx +451 -317
- package/src/components/editor/slab-hole-highlights.tsx +3 -0
- package/src/components/editor/snapshot-capture-overlay.tsx +4 -0
- package/src/components/editor/snapshot-capture.test.ts +52 -4
- package/src/components/editor/snapshot-capture.ts +30 -5
- package/src/components/editor/thumbnail-generator.test.ts +308 -0
- package/src/components/editor/thumbnail-generator.tsx +1035 -229
- package/src/components/editor/use-floorplan-background-placement.ts +31 -11
- package/src/components/editor/vector-edge-extractor.tsx +121 -0
- package/src/components/editor/views/host-view.tsx +61 -0
- package/src/components/editor/views/plugins-view.tsx +670 -0
- package/src/components/editor/views/scene-region.tsx +59 -0
- package/src/components/editor/views/use-editor-views.ts +57 -0
- package/src/components/editor/views/view-bar.tsx +220 -0
- package/src/components/editor/wall-justification.test.ts +140 -0
- package/src/components/editor/wall-move-side-handles.tsx +43 -142
- package/src/components/editor/wall-push-arrow.tsx +92 -0
- package/src/components/editor/wall-region-handles.tsx +509 -0
- package/src/components/editor/wall-snap-beacon-layer.tsx +3 -0
- package/src/components/editor-2d/floorplan-cursor-indicator-overlay.tsx +8 -4
- package/src/components/editor-2d/floorplan-open-wall-ends-layer.test.tsx +86 -0
- package/src/components/editor-2d/floorplan-open-wall-ends-layer.tsx +290 -0
- package/src/components/editor-2d/floorplan-registry-action-menu.tsx +11 -1
- package/src/components/editor-2d/floorplan-registry-move-overlay.tsx +113 -102
- package/src/components/editor-2d/renderers/floorplan-dimension-edit-overlay.test.ts +156 -0
- package/src/components/editor-2d/renderers/floorplan-dimension-edit-overlay.tsx +278 -0
- package/src/components/editor-2d/renderers/floorplan-dimension-renderer.tsx +77 -0
- package/src/components/editor-2d/renderers/{floorplan-draft-wall-measurement.tsx → floorplan-draft-measurement.tsx} +8 -8
- package/src/components/editor-2d/renderers/floorplan-geometry-renderer.tsx +4 -1
- package/src/components/editor-2d/renderers/floorplan-registry-layer.test.ts +38 -8
- package/src/components/editor-2d/renderers/floorplan-registry-layer.tsx +291 -227
- package/src/components/editor-2d/svg-paths.ts +12 -15
- package/src/components/procedural-items/inspector.tsx +40 -15
- package/src/components/systems/ceiling/ceiling-selection-affordance-system.test.ts +97 -14
- package/src/components/systems/ceiling/ceiling-selection-affordance-system.tsx +18 -18
- package/src/components/systems/zone/zone-system.test.ts +47 -0
- package/src/components/systems/zone/zone-system.tsx +29 -68
- package/src/components/tools/item/placement-history.test.tsx +474 -0
- package/src/components/tools/item/placement-strategies.ts +8 -4
- package/src/components/tools/item/use-draft-node.test.tsx +432 -1
- package/src/components/tools/item/use-draft-node.ts +166 -95
- package/src/components/tools/item/use-placement-coordinator.tsx +93 -46
- package/src/components/tools/paint-region/use-paint-tint.ts +37 -0
- package/src/components/tools/paint-region/wall-paint-region-tool.tsx +466 -0
- package/src/components/tools/registry/move-registry-node-tool.tsx +3 -1
- package/src/components/tools/select/box-select-tool.tsx +2 -12
- package/src/components/tools/select/plane-box-select-tool.test.tsx +79 -0
- package/src/components/tools/select/plane-box-select-tool.tsx +35 -22
- package/src/components/tools/select/select-candidates.test.ts +37 -4
- package/src/components/tools/select/select-candidates.ts +15 -11
- package/src/components/tools/shared/cursor-sphere.tsx +36 -12
- package/src/components/tools/site/site-boundary-editor.tsx +1 -2
- package/src/components/tools/stair/stair-defaults.ts +0 -3
- package/src/components/tools/stair/stair-tool.tsx +90 -42
- package/src/components/tools/tool-manager.tsx +46 -20
- package/src/components/tools/wall/wall-drafting.test.ts +19 -4
- package/src/components/tools/zone/zone-tool.tsx +4 -12
- package/src/components/ui/action-menu/action-button.tsx +3 -0
- package/src/components/ui/action-menu/camera-actions.tsx +2 -1
- package/src/components/ui/action-menu/control-modes.tsx +2 -35
- package/src/components/ui/action-menu/measurement-control.tsx +3 -10
- package/src/components/ui/build-panel/build-panel.tsx +235 -0
- package/src/components/ui/command-palette/editor-commands.tsx +4 -30
- package/src/components/ui/command-palette/index.tsx +5 -24
- package/src/components/ui/controls/finish-swatch.tsx +110 -0
- package/src/components/ui/controls/material-paint-panel.tsx +97 -26
- package/src/components/ui/controls/material-picker.tsx +4 -1
- package/src/components/ui/controls/scene-material-list.tsx +4 -32
- package/src/components/ui/controls/select-control.tsx +65 -0
- package/src/components/ui/floating-level-selector.tsx +9 -14
- package/src/components/ui/helpers/building-helper.tsx +4 -1
- package/src/components/ui/helpers/contextual-helper-panel.tsx +154 -70
- package/src/components/ui/helpers/helper-manager.test.tsx +69 -0
- package/src/components/ui/helpers/helper-manager.tsx +325 -14
- package/src/components/ui/helpers/item-helper.tsx +8 -0
- package/src/components/ui/helpers/registered-tool-helper.tsx +8 -1
- package/src/components/ui/icon-ref.tsx +45 -1
- package/src/components/ui/level-duplicate-dialog.tsx +1 -1
- package/src/components/ui/node-icon-image.tsx +16 -0
- package/src/components/ui/panels/collections/collections-popover.tsx +20 -14
- package/src/components/ui/panels/floor-foundation-panel.tsx +551 -0
- package/src/components/ui/panels/floor-opening-panel.tsx +143 -0
- package/src/components/ui/panels/mobile-panel-sheet.tsx +2 -2
- package/src/components/ui/panels/mobile-selection-bar.tsx +2 -2
- package/src/components/ui/panels/multi-field-value.test.ts +26 -3
- package/src/components/ui/panels/multi-field-value.ts +6 -3
- package/src/components/ui/panels/multi-parametric-inspector.tsx +52 -2
- package/src/components/ui/panels/multi-selection-panel.tsx +43 -4
- package/src/components/ui/panels/node-display.ts +8 -3
- package/src/components/ui/panels/panel-manager.tsx +103 -68
- package/src/components/ui/panels/panel-wrapper.tsx +78 -36
- package/src/components/ui/panels/parametric-field-control.tsx +1 -1
- package/src/components/ui/panels/parametric-inspector.tsx +4 -4
- package/src/components/ui/panels/reference-panel.tsx +2 -3
- package/src/components/ui/panels/room-construction-rows.tsx +774 -0
- package/src/components/ui/panels/room-name-options.test.ts +55 -0
- package/src/components/ui/panels/room-name-options.ts +47 -0
- package/src/components/ui/panels/room-openings-field.tsx +110 -0
- package/src/components/ui/panels/room-panel.tsx +725 -0
- package/src/components/ui/panels/shape-choice.tsx +58 -0
- package/src/components/ui/panels/wall-region-list.tsx +109 -0
- package/src/components/ui/primitives/color-dot.tsx +36 -24
- package/src/components/ui/primitives/sidebar.tsx +2 -0
- package/src/components/ui/right-stack.test.ts +29 -0
- package/src/components/ui/right-stack.tsx +145 -0
- package/src/components/ui/sidebar/icon-rail.tsx +5 -0
- package/src/components/ui/sidebar/panels/settings-panel/index.tsx +31 -4
- package/src/components/ui/sidebar/panels/settings-panel/keyboard-shortcuts-dialog.tsx +5 -5
- package/src/components/ui/sidebar/panels/site-panel/ceiling-tree-node.tsx +4 -4
- package/src/components/ui/sidebar/panels/site-panel/chimney-tree-node.tsx +1 -5
- package/src/components/ui/sidebar/panels/site-panel/collection-tree-node.tsx +197 -0
- package/src/components/ui/sidebar/panels/site-panel/column-tree-node.tsx +1 -5
- package/src/components/ui/sidebar/panels/site-panel/door-tree-node.tsx +1 -5
- package/src/components/ui/sidebar/panels/site-panel/dormer-tree-node.tsx +1 -5
- package/src/components/ui/sidebar/panels/site-panel/elevator-tree-node.tsx +1 -5
- package/src/components/ui/sidebar/panels/site-panel/fence-tree-node.tsx +24 -11
- package/src/components/ui/sidebar/panels/site-panel/gutter-tree-node.tsx +1 -5
- package/src/components/ui/sidebar/panels/site-panel/index.tsx +176 -211
- package/src/components/ui/sidebar/panels/site-panel/inline-rename-input.tsx +30 -8
- package/src/components/ui/sidebar/panels/site-panel/item-tree-node.tsx +1 -3
- package/src/components/ui/sidebar/panels/site-panel/level-tree-node.tsx +4 -1
- package/src/components/ui/sidebar/panels/site-panel/registry-tree-node.tsx +1 -3
- package/src/components/ui/sidebar/panels/site-panel/roof-tree-node.tsx +1 -4
- package/src/components/ui/sidebar/panels/site-panel/shelf-tree-node.tsx +1 -3
- package/src/components/ui/sidebar/panels/site-panel/slab-tree-node.tsx +21 -13
- package/src/components/ui/sidebar/panels/site-panel/solar-panel-tree-node.tsx +1 -5
- package/src/components/ui/sidebar/panels/site-panel/spawn-tree-node.tsx +1 -5
- package/src/components/ui/sidebar/panels/site-panel/stair-tree-node.tsx +1 -5
- package/src/components/ui/sidebar/panels/site-panel/tree-node.tsx +0 -27
- package/src/components/ui/sidebar/panels/site-panel/unit-tree-node.tsx +2 -3
- package/src/components/ui/sidebar/panels/site-panel/wall-tree-node.tsx +1 -5
- package/src/components/ui/sidebar/panels/site-panel/window-tree-node.tsx +1 -5
- package/src/components/ui/sidebar/panels/site-panel/zone-tree-node.tsx +9 -4
- package/src/components/ui/sidebar/panels/zone-panel/index.tsx +0 -2
- package/src/components/ui/sidebar/tab-bar.tsx +10 -0
- package/src/components/ui/sidebar/use-plugin-panels.tsx +15 -5
- package/src/components/viewer/floorplan-compass-button.tsx +9 -1
- package/src/components/viewer/floorplan-preview.tsx +5 -6
- package/src/components/viewer/viewer-hover-label.tsx +34 -0
- package/src/components/viewer/viewer-rooms.tsx +175 -0
- package/src/components/viewer/viewer-scene-header.tsx +181 -145
- package/src/components/viewer/viewer-selection-manager.tsx +124 -0
- package/src/components/viewer/viewer-stage.tsx +2 -2
- package/src/components/viewer-zone-system.tsx +3 -8
- package/src/hooks/use-auto-save.integration.test.tsx +123 -9
- package/src/hooks/use-auto-save.ts +34 -8
- package/src/hooks/use-keyboard.test.ts +178 -3
- package/src/hooks/use-keyboard.ts +89 -71
- package/src/hooks/use-open-wall-ends.test.ts +99 -0
- package/src/hooks/use-open-wall-ends.ts +238 -0
- package/src/hooks/use-placement-notice.test.ts +48 -0
- package/src/hooks/use-placement-notice.ts +42 -0
- package/src/hooks/use-selected-room.ts +143 -0
- package/src/index.tsx +246 -39
- package/src/lib/ceiling-edit-session.test.ts +321 -0
- package/src/lib/ceiling-edit-session.ts +206 -0
- package/src/lib/ceiling-region-session.test.ts +179 -0
- package/src/lib/continuation.test.ts +19 -1
- package/src/lib/continuation.ts +25 -4
- package/src/lib/door-interaction.ts +14 -0
- package/src/lib/editor-level-display.test.ts +96 -0
- package/src/lib/editor-level-display.ts +48 -0
- package/src/lib/editor-views.ts +144 -0
- package/src/lib/export-geometry-wait.test.ts +90 -0
- package/src/lib/floor-edit-session.ts +153 -0
- package/src/lib/floor-footprints.test.ts +563 -0
- package/src/lib/floor-footprints.ts +395 -0
- package/src/lib/floor-foundation-support.test.ts +283 -0
- package/src/lib/floor-opening-draft.ts +218 -0
- package/src/lib/floor-openings.test.ts +216 -0
- package/src/lib/floor-region-geometry.ts +191 -0
- package/src/lib/floor-region-session.test.ts +485 -0
- package/src/lib/floor-region-session.ts +589 -0
- package/src/lib/floor-region-snap.ts +101 -0
- package/src/lib/floor-step-hover.test.ts +32 -0
- package/src/lib/floorplan/annotation-visibility.ts +17 -0
- package/src/lib/floorplan/dimension-drive.test.ts +360 -0
- package/src/lib/floorplan/dimension-drive.ts +479 -0
- package/src/lib/floorplan/floorplan-export.test.ts +12 -8
- package/src/lib/floorplan/floorplan-export.tsx +32 -8
- package/src/lib/floorplan/floorplan-extension.ts +32 -0
- package/src/lib/floorplan/floorplan-mode.test.ts +4 -0
- package/src/lib/floorplan/floorplan-mode.ts +2 -0
- package/src/lib/floorplan/floorplan-pdfkit-document.ts +339 -18
- package/src/lib/floorplan/floorplan-pdfkit-renderer.test.ts +138 -8
- package/src/lib/floorplan/floorplan-pdfkit-renderer.ts +56 -25
- package/src/lib/floorplan/floorplan-plugin-install.test.tsx +138 -0
- package/src/lib/floorplan/floorplan-readonly.ts +6 -0
- package/src/lib/floorplan/geometry.ts +13 -6
- package/src/lib/floorplan/index.ts +0 -9
- package/src/lib/floorplan/items.ts +5 -2
- package/src/lib/floorplan/marks.test.ts +213 -0
- package/src/lib/floorplan/marks.ts +238 -0
- package/src/lib/floorplan/open-wall-ends.test.ts +268 -0
- package/src/lib/floorplan/open-wall-ends.ts +162 -0
- package/src/lib/floorplan/pdf-fonts/GeistMono-Bold.ttf +0 -0
- package/src/lib/floorplan/pdf-fonts/GeistMono-Regular.ttf +0 -0
- package/src/lib/floorplan/pdf-fonts/LICENSE-GeistMono.txt +92 -0
- package/src/lib/floorplan/pdf-fonts/LICENSE-LiberationSans.txt +102 -0
- package/src/lib/floorplan/pdf-fonts/LiberationSans-Bold.ttf +0 -0
- package/src/lib/floorplan/pdf-fonts/LiberationSans-Regular.ttf +0 -0
- package/src/lib/floorplan/schedules.test.ts +189 -0
- package/src/lib/floorplan/schedules.ts +339 -0
- package/src/lib/floorplan/sheet-export.test.ts +100 -0
- package/src/lib/floorplan/sheet-export.ts +318 -0
- package/src/lib/floorplan/site-plan/build-site-plan-drawing.ts +779 -0
- package/src/lib/floorplan/site-plan/contours.test.ts +43 -0
- package/src/lib/floorplan/site-plan/contributors.ts +97 -0
- package/src/lib/floorplan/site-plan/coverage.ts +232 -0
- package/src/lib/floorplan/site-plan/drawing-type-switch.test.ts +15 -0
- package/src/lib/floorplan/site-plan/drawing-type-switch.tsx +86 -0
- package/src/lib/floorplan/site-plan/front-edge.test.ts +103 -0
- package/src/lib/floorplan/site-plan/front-edge.ts +156 -0
- package/src/lib/floorplan/site-plan/geometry.test.ts +275 -0
- package/src/lib/floorplan/site-plan/geometry.ts +557 -0
- package/src/lib/floorplan/site-plan/index.ts +71 -0
- package/src/lib/floorplan/site-plan/site-annotations.test.ts +366 -0
- package/src/lib/floorplan/site-plan/site-annotations.ts +1083 -0
- package/src/lib/floorplan/site-plan/site-parts.ts +379 -0
- package/src/lib/floorplan/site-plan/site-plan-layer.tsx +138 -0
- package/src/lib/floorplan/site-plan/street-name.test.ts +69 -0
- package/src/lib/floorplan/site-plan/street-name.ts +302 -0
- package/src/lib/floorplan/site-plan/yards.test.ts +69 -0
- package/src/lib/floorplan/types.ts +1 -27
- package/src/lib/fresh-planar-placement.test.ts +36 -0
- package/src/lib/fresh-planar-placement.ts +59 -36
- package/src/lib/geometry-script/author.ts +152 -0
- package/src/lib/geometry-script/client.ts +152 -0
- package/src/lib/geometry-script/protocol.ts +12 -0
- package/src/lib/gesture-lifecycle.test.ts +595 -0
- package/src/lib/gesture-lifecycle.ts +290 -0
- package/src/lib/glb-export-zone-holes.test.ts +41 -0
- package/src/lib/glb-export.test.ts +485 -0
- package/src/lib/glb-export.ts +237 -119
- package/src/lib/history.test.ts +6 -0
- package/src/lib/history.ts +7 -0
- package/src/lib/hud-title.ts +109 -0
- package/src/lib/hydration-gated-storage.ts +49 -0
- package/src/lib/ifc-export.test.ts +174 -0
- package/src/lib/ifc-export.ts +201 -0
- package/src/lib/ifc-parts.ts +15 -0
- package/src/lib/inspector-expanded.test.ts +44 -0
- package/src/lib/inspector-expanded.ts +36 -0
- package/src/lib/interaction/scope.ts +18 -0
- package/src/lib/keyboard-pan.test.ts +129 -7
- package/src/lib/keyboard-pan.ts +161 -12
- package/src/lib/live-gesture-round-trip.test.ts +360 -0
- package/src/lib/lot/__fixtures__/map-dossier-miami-shores.json +1 -0
- package/src/lib/lot/__fixtures__/map-dossier-stpete.json +1 -0
- package/src/lib/lot/clean-ring.test.ts +186 -0
- package/src/lib/lot/clean-ring.ts +217 -0
- package/src/lib/lot/dossier.test.ts +202 -0
- package/src/lib/lot/dossier.ts +498 -0
- package/src/lib/lot/drop-in.test.ts +326 -0
- package/src/lib/lot/drop-in.ts +407 -0
- package/src/lib/lot/index.ts +43 -0
- package/src/lib/lot/lot-patch.test.ts +340 -0
- package/src/lib/lot/lot-patch.ts +394 -0
- package/src/lib/lot/parcel-provider.ts +43 -0
- package/src/lib/lot/terrain.test.ts +161 -0
- package/src/lib/lot/terrain.ts +266 -0
- package/src/lib/material-catalog-model.ts +3 -1
- package/src/lib/material-paint-panel-model.ts +9 -5
- package/src/lib/material-paint.ts +4 -0
- package/src/lib/mezzanine-actions.test.ts +342 -0
- package/src/lib/mezzanine-draft.test.ts +501 -0
- package/src/lib/mezzanine-draft.ts +278 -0
- package/src/lib/mezzanine-messages.ts +26 -0
- package/src/lib/mezzanine-selection.test.ts +207 -0
- package/src/lib/mezzanine-stairs.ts +46 -0
- package/src/lib/model-export.ts +3 -1
- package/src/lib/node-action-movement.ts +17 -6
- package/src/lib/node-display-label.ts +37 -0
- package/src/lib/orbit-floor-clearance.test.ts +165 -0
- package/src/lib/orbit-floor-clearance.ts +106 -0
- package/src/lib/paint-commit-route.test.ts +37 -0
- package/src/lib/paint-commit-route.ts +17 -0
- package/src/lib/paint-eyedropper.test.tsx +165 -0
- package/src/lib/paint-eyedropper.ts +99 -0
- package/src/lib/paint-pass-through.test.ts +111 -0
- package/src/lib/paint-pass-through.ts +76 -0
- package/src/lib/paint-region-hover.ts +25 -0
- package/src/lib/paint-region-mode.ts +154 -0
- package/src/lib/paint-regions.test.ts +166 -0
- package/src/lib/paint-regions.ts +192 -0
- package/src/lib/paint-scope.test.ts +317 -35
- package/src/lib/paint-scope.ts +266 -25
- package/src/lib/panel-rows.ts +21 -0
- package/src/lib/parametric-node-update.ts +1 -1
- package/src/lib/plate-paint-affected.test.ts +300 -0
- package/src/lib/plate-paint-affected.ts +177 -0
- package/src/lib/plugin-chat.ts +50 -0
- package/src/lib/plugin-panels.test.ts +25 -0
- package/src/lib/plugin-panels.ts +94 -0
- package/src/lib/print-shell-compiler.ts +1 -0
- package/src/lib/registered-draft-snap.ts +12 -0
- package/src/lib/roof-duplication.ts +10 -2
- package/src/lib/room-assembly-overlay.test.ts +275 -0
- package/src/lib/room-assembly-overlay.ts +266 -0
- package/src/lib/room-built-on.test.ts +379 -0
- package/src/lib/room-built-on.ts +138 -0
- package/src/lib/room-construction-commands.ts +712 -0
- package/src/lib/room-construction.test.ts +746 -0
- package/src/lib/room-construction.ts +385 -0
- package/src/lib/room-controls-phase6.test.ts +630 -0
- package/src/lib/room-divide-session.ts +523 -0
- package/src/lib/room-handle-drag.ts +1068 -0
- package/src/lib/room-name-catalog.test.ts +90 -0
- package/src/lib/room-name-catalog.ts +168 -0
- package/src/lib/room-push-dimensions.test.ts +311 -0
- package/src/lib/room-push-dimensions.ts +251 -0
- package/src/lib/room-selection-commands.ts +62 -0
- package/src/lib/room-selection.test.ts +973 -0
- package/src/lib/room-selection.ts +417 -0
- package/src/lib/room-structure-commands.ts +94 -0
- package/src/lib/room-structure.test.ts +921 -0
- package/src/lib/room-transform-session.ts +570 -0
- package/src/lib/room-zone-routing.test.ts +294 -0
- package/src/lib/room-zone-routing.ts +197 -0
- package/src/lib/scene-clipboard.test.ts +364 -0
- package/src/lib/scene-clipboard.ts +229 -48
- package/src/lib/scene-material-refs.test.ts +79 -0
- package/src/lib/scene-material-refs.ts +79 -0
- package/src/lib/scene.test.ts +24 -36
- package/src/lib/scene.ts +33 -57
- package/src/lib/selection-routing.test.ts +129 -45
- package/src/lib/selection-routing.ts +53 -74
- package/src/lib/session-writes.test.ts +120 -0
- package/src/lib/session-writes.ts +205 -0
- package/src/lib/sidebar-panel.ts +62 -0
- package/src/lib/site-boundary.test.ts +4 -6
- package/src/lib/site-boundary.ts +1 -1
- package/src/lib/snapping-mode.test.ts +4 -0
- package/src/lib/snapping-mode.ts +8 -1
- package/src/lib/terrace-draft.test.ts +145 -0
- package/src/lib/terrace-draft.ts +213 -0
- package/src/lib/tool-cursor-icon.test.ts +16 -0
- package/src/lib/tool-cursor-icon.ts +11 -0
- package/src/lib/typing-target.ts +9 -0
- package/src/lib/units.ts +77 -39
- package/src/lib/vector-edges.test.ts +58 -0
- package/src/lib/vector-edges.ts +400 -0
- package/src/lib/viewer-selection.test.ts +577 -0
- package/src/lib/viewer-selection.ts +569 -0
- package/src/lib/wall-draw-variant.test.ts +71 -0
- package/src/lib/wall-draw-variant.ts +91 -0
- package/src/lib/wall-paint-region-session.ts +246 -0
- package/src/lib/wall-paint-region.test.ts +373 -0
- package/src/lib/wall-polygon-draft.test.ts +262 -0
- package/src/lib/wall-polygon-draft.ts +286 -0
- package/src/lib/wall-push.test.ts +453 -0
- package/src/lib/wall-region-face.ts +352 -0
- package/src/lib/wall-region-handles.test.ts +304 -0
- package/src/lib/wall-region-handles.ts +368 -0
- package/src/lib/wall-region-list.test.ts +119 -0
- package/src/lib/wall-region-list.ts +136 -0
- package/src/lib/wall-region-snap.ts +110 -0
- package/src/lib/window-interaction.ts +14 -0
- package/src/lib/zone-content.ts +4 -1
- package/src/lib/zone-name.test.ts +17 -0
- package/src/lib/zone-name.ts +17 -0
- package/src/store/opens-in-select-mode.test.ts +223 -0
- package/src/store/paint-mode.test.ts +188 -0
- package/src/store/terrain-sculpt-mode.test.ts +19 -21
- package/src/store/tool-mode.test.ts +137 -6
- package/src/store/use-delete-confirmation.ts +28 -1
- package/src/store/use-drawing-view.test.ts +24 -3
- package/src/store/use-drawing-view.ts +29 -1
- package/src/store/use-editor.tsx +432 -321
- package/src/store/use-floorplan-draft-preview.ts +13 -0
- package/src/store/use-floorplan-marquee.ts +12 -2
- package/src/store/use-quick-measurement-hud.ts +3 -3
- package/src/store/use-stair-build-preview.ts +13 -5
- package/src/store/use-wall-move-ghosts.ts +4 -2
- package/src/store/use-wall-region-handles-selection.test.ts +222 -0
- package/src/store/use-wall-region-handles-selection.ts +139 -0
- package/src/store/view-layout.test.ts +175 -0
- package/src/store/view-layout.ts +196 -0
- package/src/test-utils/immediate-animation-frames.ts +16 -0
- package/src/test-utils/live-gesture-round-trip.ts +224 -0
- package/src/test-utils/selection-harness.ts +82 -0
- package/src/components/editor-2d/renderers/floorplan-stair-layer.tsx +0 -499
- package/src/components/systems/zone/zone-label-editor-system.tsx +0 -333
- package/src/components/tools/fence/fence-drafting.test.ts +0 -100
- package/src/components/tools/fence/fence-drafting.ts +0 -266
- package/src/components/ui/sidebar/panels/plugins-panel.tsx +0 -218
- package/src/components/viewer/viewer-units-panel.tsx +0 -116
- package/src/lib/floorplan/stairs.ts +0 -489
- package/src/lib/level-duplication.test.ts +0 -144
- package/src/lib/level-duplication.ts +0 -195
|
@@ -1,489 +0,0 @@
|
|
|
1
|
-
import type { Point2D, StairNode, StairSegmentNode } from '@pascal-app/core'
|
|
2
|
-
import {
|
|
3
|
-
clampPlanValue,
|
|
4
|
-
getPlanPointDistance,
|
|
5
|
-
getThickPlanLinePolygon,
|
|
6
|
-
interpolatePlanPoint,
|
|
7
|
-
movePlanPointTowards,
|
|
8
|
-
rotatePlanVector,
|
|
9
|
-
} from './geometry'
|
|
10
|
-
import type {
|
|
11
|
-
FloorplanLineSegment,
|
|
12
|
-
FloorplanStairArrowEntry,
|
|
13
|
-
FloorplanStairEntry,
|
|
14
|
-
FloorplanStairSegmentEntry,
|
|
15
|
-
StairSegmentTransform,
|
|
16
|
-
} from './types'
|
|
17
|
-
|
|
18
|
-
const FLOORPLAN_STAIR_OUTLINE_BAND_THICKNESS = 0.05
|
|
19
|
-
const FLOORPLAN_STAIR_OUTLINE_MAX_FRACTION = 0.18
|
|
20
|
-
const FLOORPLAN_STAIR_TREAD_BAND_THICKNESS = 0.05 * 0.82
|
|
21
|
-
const FLOORPLAN_STAIR_TREAD_MIN_THICKNESS = 0.02 * 1.5
|
|
22
|
-
const FLOORPLAN_STAIR_ARROW_HEAD_MIN_SIZE = 0.14
|
|
23
|
-
const FLOORPLAN_STAIR_ARROW_HEAD_MAX_SIZE = 0.24
|
|
24
|
-
|
|
25
|
-
type FloorplanStairArrowSide = 'back' | 'front' | 'left' | 'right'
|
|
26
|
-
|
|
27
|
-
function getFloorplanStairSegmentCenterLine(polygon: Point2D[]): FloorplanLineSegment | null {
|
|
28
|
-
if (polygon.length < 4) {
|
|
29
|
-
return null
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
const [backLeft, backRight, frontRight, frontLeft] = polygon
|
|
33
|
-
|
|
34
|
-
return {
|
|
35
|
-
start: interpolatePlanPoint(backLeft!, backRight!, 0.5),
|
|
36
|
-
end: interpolatePlanPoint(frontLeft!, frontRight!, 0.5),
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
function getFloorplanStairInnerPolygon(polygon: Point2D[]): Point2D[] {
|
|
41
|
-
if (polygon.length < 4) {
|
|
42
|
-
return polygon
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
const [backLeft, backRight, frontRight, frontLeft] = polygon
|
|
46
|
-
const outerWidth = getPlanPointDistance(backLeft!, backRight!)
|
|
47
|
-
const outerLength = getPlanPointDistance(backLeft!, frontLeft!)
|
|
48
|
-
const widthInset = Math.min(
|
|
49
|
-
FLOORPLAN_STAIR_OUTLINE_BAND_THICKNESS,
|
|
50
|
-
outerWidth * FLOORPLAN_STAIR_OUTLINE_MAX_FRACTION,
|
|
51
|
-
)
|
|
52
|
-
const lengthInset = Math.min(
|
|
53
|
-
FLOORPLAN_STAIR_OUTLINE_BAND_THICKNESS,
|
|
54
|
-
outerLength * FLOORPLAN_STAIR_OUTLINE_MAX_FRACTION,
|
|
55
|
-
)
|
|
56
|
-
|
|
57
|
-
const insetBackLeft = movePlanPointTowards(backLeft!, frontLeft!, lengthInset)
|
|
58
|
-
const insetBackRight = movePlanPointTowards(backRight!, frontRight!, lengthInset)
|
|
59
|
-
const insetFrontLeft = movePlanPointTowards(frontLeft!, backLeft!, lengthInset)
|
|
60
|
-
const insetFrontRight = movePlanPointTowards(frontRight!, backRight!, lengthInset)
|
|
61
|
-
|
|
62
|
-
const innerPolygon = [
|
|
63
|
-
movePlanPointTowards(insetBackLeft, insetBackRight, widthInset),
|
|
64
|
-
movePlanPointTowards(insetBackRight, insetBackLeft, widthInset),
|
|
65
|
-
movePlanPointTowards(insetFrontRight, insetFrontLeft, widthInset),
|
|
66
|
-
movePlanPointTowards(insetFrontLeft, insetFrontRight, widthInset),
|
|
67
|
-
]
|
|
68
|
-
|
|
69
|
-
const innerWidth = getPlanPointDistance(innerPolygon[0]!, innerPolygon[1]!)
|
|
70
|
-
const innerLength = getPlanPointDistance(innerPolygon[0]!, innerPolygon[3]!)
|
|
71
|
-
|
|
72
|
-
return innerWidth > 0.06 && innerLength > 0.06 ? innerPolygon : polygon
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
function getFloorplanStairTreadLines(
|
|
76
|
-
segment: StairSegmentNode,
|
|
77
|
-
innerPolygon: Point2D[],
|
|
78
|
-
): FloorplanLineSegment[] {
|
|
79
|
-
if (segment.segmentType !== 'stair' || segment.stepCount <= 1 || innerPolygon.length < 4) {
|
|
80
|
-
return []
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
const [backLeft, backRight, frontRight, frontLeft] = innerPolygon
|
|
84
|
-
const treadLines: FloorplanLineSegment[] = []
|
|
85
|
-
|
|
86
|
-
for (let stepIndex = 1; stepIndex < segment.stepCount; stepIndex += 1) {
|
|
87
|
-
const t = stepIndex / segment.stepCount
|
|
88
|
-
treadLines.push({
|
|
89
|
-
start: interpolatePlanPoint(backLeft!, frontLeft!, t),
|
|
90
|
-
end: interpolatePlanPoint(backRight!, frontRight!, t),
|
|
91
|
-
})
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
return treadLines
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
function getFloorplanStairTreadThickness(segment: StairSegmentNode, innerPolygon: Point2D[]) {
|
|
98
|
-
if (segment.segmentType !== 'stair' || segment.stepCount <= 1 || innerPolygon.length < 4) {
|
|
99
|
-
return 0
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
const innerWidth = getPlanPointDistance(innerPolygon[0]!, innerPolygon[1]!)
|
|
103
|
-
const innerLength = getPlanPointDistance(innerPolygon[0]!, innerPolygon[3]!)
|
|
104
|
-
const treadRun = innerLength / Math.max(segment.stepCount, 1)
|
|
105
|
-
return clampPlanValue(
|
|
106
|
-
Math.min(FLOORPLAN_STAIR_TREAD_BAND_THICKNESS, innerWidth * 0.12, treadRun * 0.44),
|
|
107
|
-
FLOORPLAN_STAIR_TREAD_MIN_THICKNESS,
|
|
108
|
-
FLOORPLAN_STAIR_TREAD_BAND_THICKNESS,
|
|
109
|
-
)
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
function getFloorplanStairTreadBars(
|
|
113
|
-
segment: StairSegmentNode,
|
|
114
|
-
innerPolygon: Point2D[],
|
|
115
|
-
treadThickness = getFloorplanStairTreadThickness(segment, innerPolygon),
|
|
116
|
-
): Point2D[][] {
|
|
117
|
-
const treadLines = getFloorplanStairTreadLines(segment, innerPolygon)
|
|
118
|
-
if (treadLines.length === 0 || treadThickness <= 0) {
|
|
119
|
-
return []
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
return treadLines.map((line) => getThickPlanLinePolygon(line, treadThickness))
|
|
123
|
-
}
|
|
124
|
-
|
|
125
|
-
function getFloorplanStairSegmentCenterPoint(segment: FloorplanStairSegmentEntry): Point2D | null {
|
|
126
|
-
if (segment.centerLine) {
|
|
127
|
-
return interpolatePlanPoint(segment.centerLine.start, segment.centerLine.end, 0.5)
|
|
128
|
-
}
|
|
129
|
-
|
|
130
|
-
if (segment.polygon.length < 4) {
|
|
131
|
-
return null
|
|
132
|
-
}
|
|
133
|
-
|
|
134
|
-
const [backLeft, backRight, frontRight, frontLeft] = segment.polygon
|
|
135
|
-
|
|
136
|
-
return {
|
|
137
|
-
x: (backLeft!.x + backRight!.x + frontRight!.x + frontLeft!.x) / 4,
|
|
138
|
-
y: (backLeft!.y + backRight!.y + frontRight!.y + frontLeft!.y) / 4,
|
|
139
|
-
}
|
|
140
|
-
}
|
|
141
|
-
|
|
142
|
-
function getFloorplanStairSegmentSidePoint(
|
|
143
|
-
segment: FloorplanStairSegmentEntry,
|
|
144
|
-
side: FloorplanStairArrowSide,
|
|
145
|
-
): Point2D | null {
|
|
146
|
-
if (segment.polygon.length < 4) {
|
|
147
|
-
return null
|
|
148
|
-
}
|
|
149
|
-
|
|
150
|
-
const [backLeft, backRight, frontRight, frontLeft] = segment.polygon
|
|
151
|
-
|
|
152
|
-
switch (side) {
|
|
153
|
-
case 'back':
|
|
154
|
-
return interpolatePlanPoint(backLeft!, backRight!, 0.5)
|
|
155
|
-
case 'front':
|
|
156
|
-
return interpolatePlanPoint(frontLeft!, frontRight!, 0.5)
|
|
157
|
-
case 'left':
|
|
158
|
-
return interpolatePlanPoint(backLeft!, frontLeft!, 0.5)
|
|
159
|
-
case 'right':
|
|
160
|
-
return interpolatePlanPoint(backRight!, frontRight!, 0.5)
|
|
161
|
-
}
|
|
162
|
-
}
|
|
163
|
-
|
|
164
|
-
function getFloorplanStairExitSide(
|
|
165
|
-
nextSegment: StairSegmentNode | undefined,
|
|
166
|
-
): FloorplanStairArrowSide {
|
|
167
|
-
if (!nextSegment) {
|
|
168
|
-
return 'front'
|
|
169
|
-
}
|
|
170
|
-
|
|
171
|
-
if (nextSegment.attachmentSide === 'left') {
|
|
172
|
-
return 'right'
|
|
173
|
-
}
|
|
174
|
-
if (nextSegment.attachmentSide === 'right') {
|
|
175
|
-
return 'left'
|
|
176
|
-
}
|
|
177
|
-
|
|
178
|
-
return 'front'
|
|
179
|
-
}
|
|
180
|
-
|
|
181
|
-
function appendUniquePlanPoint(points: Point2D[], point: Point2D | null) {
|
|
182
|
-
if (!point) {
|
|
183
|
-
return
|
|
184
|
-
}
|
|
185
|
-
|
|
186
|
-
const lastPoint = points[points.length - 1]
|
|
187
|
-
if (lastPoint && getPlanPointDistance(lastPoint, point) <= 0.001) {
|
|
188
|
-
return
|
|
189
|
-
}
|
|
190
|
-
|
|
191
|
-
points.push(point)
|
|
192
|
-
}
|
|
193
|
-
|
|
194
|
-
function getFloorplanArcPoint(center: Point2D, radius: number, angle: number): Point2D {
|
|
195
|
-
return {
|
|
196
|
-
x: center.x + Math.cos(angle) * radius,
|
|
197
|
-
y: center.y + Math.sin(angle) * radius,
|
|
198
|
-
}
|
|
199
|
-
}
|
|
200
|
-
|
|
201
|
-
function getNormalizedFloorplanStairSweepAngle(stair: StairNode) {
|
|
202
|
-
const stairType = stair.stairType ?? 'straight'
|
|
203
|
-
const baseSweepAngle = stair.sweepAngle ?? (stairType === 'spiral' ? Math.PI * 2 : Math.PI / 2)
|
|
204
|
-
|
|
205
|
-
if (Math.abs(baseSweepAngle) >= Math.PI * 2) {
|
|
206
|
-
return Math.sign(baseSweepAngle || 1) * (Math.PI * 2 - 0.001)
|
|
207
|
-
}
|
|
208
|
-
|
|
209
|
-
return baseSweepAngle
|
|
210
|
-
}
|
|
211
|
-
|
|
212
|
-
function clampFloorplanCircularSweepAngle(sweepAngle: number) {
|
|
213
|
-
if (Math.abs(sweepAngle) >= Math.PI * 2) {
|
|
214
|
-
return Math.sign(sweepAngle || 1) * (Math.PI * 2 - 0.001)
|
|
215
|
-
}
|
|
216
|
-
|
|
217
|
-
return sweepAngle
|
|
218
|
-
}
|
|
219
|
-
|
|
220
|
-
function getFloorplanSpiralLandingSweep(stair: StairNode, sweepAngle: number) {
|
|
221
|
-
if (
|
|
222
|
-
(stair.stairType ?? 'straight') !== 'spiral' ||
|
|
223
|
-
(stair.topLandingMode ?? 'none') !== 'integrated'
|
|
224
|
-
) {
|
|
225
|
-
return 0
|
|
226
|
-
}
|
|
227
|
-
|
|
228
|
-
const innerRadius = Math.max(0.05, stair.innerRadius ?? 0.9)
|
|
229
|
-
const width = Math.max(stair.width ?? 1, 0.4)
|
|
230
|
-
const landingDepth = Math.max(0.3, stair.topLandingDepth ?? Math.max(width * 0.9, 0.8))
|
|
231
|
-
|
|
232
|
-
return (
|
|
233
|
-
Math.min(Math.PI * 0.75, landingDepth / Math.max(innerRadius + width / 2, 0.1)) *
|
|
234
|
-
Math.sign(sweepAngle || 1)
|
|
235
|
-
)
|
|
236
|
-
}
|
|
237
|
-
|
|
238
|
-
function getFloorplanCurvedStairHitPolygon(stair: StairNode): Point2D[] {
|
|
239
|
-
const stairType = stair.stairType ?? 'straight'
|
|
240
|
-
const sweepAngle = getNormalizedFloorplanStairSweepAngle(stair)
|
|
241
|
-
const visualSweepAngle = clampFloorplanCircularSweepAngle(
|
|
242
|
-
sweepAngle + getFloorplanSpiralLandingSweep(stair, sweepAngle),
|
|
243
|
-
)
|
|
244
|
-
const startAngle = -stair.rotation - sweepAngle / 2
|
|
245
|
-
const endAngle = startAngle + visualSweepAngle
|
|
246
|
-
const center = {
|
|
247
|
-
x: stair.position[0],
|
|
248
|
-
y: stair.position[2],
|
|
249
|
-
}
|
|
250
|
-
const innerRadius = Math.max(
|
|
251
|
-
stairType === 'spiral' ? 0.05 : 0.2,
|
|
252
|
-
stair.innerRadius ?? (stairType === 'spiral' ? 0.2 : 0.9),
|
|
253
|
-
)
|
|
254
|
-
const outerRadius = innerRadius + stair.width
|
|
255
|
-
const outerArcLength = Math.abs(sweepAngle) * outerRadius
|
|
256
|
-
const segmentCount = Math.max(
|
|
257
|
-
24,
|
|
258
|
-
Math.ceil(Math.abs(sweepAngle) / (Math.PI / 24)),
|
|
259
|
-
Math.ceil(outerArcLength / 0.14),
|
|
260
|
-
)
|
|
261
|
-
const outerPoints: Point2D[] = []
|
|
262
|
-
const innerPoints: Point2D[] = []
|
|
263
|
-
|
|
264
|
-
for (let index = 0; index <= segmentCount; index += 1) {
|
|
265
|
-
const t = index / segmentCount
|
|
266
|
-
const angle = startAngle + (endAngle - startAngle) * t
|
|
267
|
-
outerPoints.push(getFloorplanArcPoint(center, outerRadius, angle))
|
|
268
|
-
innerPoints.push(getFloorplanArcPoint(center, innerRadius, angle))
|
|
269
|
-
}
|
|
270
|
-
|
|
271
|
-
return [...outerPoints, ...innerPoints.reverse()]
|
|
272
|
-
}
|
|
273
|
-
|
|
274
|
-
function buildFloorplanStairArrow(
|
|
275
|
-
segments: FloorplanStairSegmentEntry[],
|
|
276
|
-
): FloorplanStairArrowEntry | null {
|
|
277
|
-
const rawPoints: Point2D[] = []
|
|
278
|
-
|
|
279
|
-
for (let segmentIndex = 0; segmentIndex < segments.length; segmentIndex += 1) {
|
|
280
|
-
const segment = segments[segmentIndex]!
|
|
281
|
-
const nextSegment = segments[segmentIndex + 1]?.segment
|
|
282
|
-
const entryPoint = getFloorplanStairSegmentSidePoint(segment, 'back')
|
|
283
|
-
const exitPoint = getFloorplanStairSegmentSidePoint(
|
|
284
|
-
segment,
|
|
285
|
-
getFloorplanStairExitSide(nextSegment),
|
|
286
|
-
)
|
|
287
|
-
|
|
288
|
-
if (!(entryPoint && exitPoint)) {
|
|
289
|
-
continue
|
|
290
|
-
}
|
|
291
|
-
|
|
292
|
-
appendUniquePlanPoint(rawPoints, entryPoint)
|
|
293
|
-
|
|
294
|
-
const isStraightSegment = getPlanPointDistance(entryPoint, exitPoint) <= 0.001
|
|
295
|
-
if (isStraightSegment) {
|
|
296
|
-
continue
|
|
297
|
-
}
|
|
298
|
-
|
|
299
|
-
const exitSide = getFloorplanStairExitSide(nextSegment)
|
|
300
|
-
if (exitSide === 'front') {
|
|
301
|
-
appendUniquePlanPoint(rawPoints, exitPoint)
|
|
302
|
-
continue
|
|
303
|
-
}
|
|
304
|
-
|
|
305
|
-
appendUniquePlanPoint(rawPoints, getFloorplanStairSegmentCenterPoint(segment))
|
|
306
|
-
appendUniquePlanPoint(rawPoints, exitPoint)
|
|
307
|
-
}
|
|
308
|
-
|
|
309
|
-
if (rawPoints.length < 2) {
|
|
310
|
-
return null
|
|
311
|
-
}
|
|
312
|
-
|
|
313
|
-
const firstPoint = rawPoints[0]!
|
|
314
|
-
const secondPoint = rawPoints[1]!
|
|
315
|
-
const beforeLastPoint = rawPoints[rawPoints.length - 2]!
|
|
316
|
-
const lastPoint = rawPoints[rawPoints.length - 1]!
|
|
317
|
-
const firstLength = getPlanPointDistance(firstPoint, secondPoint)
|
|
318
|
-
const lastLength = getPlanPointDistance(beforeLastPoint, lastPoint)
|
|
319
|
-
|
|
320
|
-
if (firstLength <= Number.EPSILON || lastLength <= Number.EPSILON) {
|
|
321
|
-
return null
|
|
322
|
-
}
|
|
323
|
-
|
|
324
|
-
const polyline = [
|
|
325
|
-
movePlanPointTowards(firstPoint, secondPoint, Math.min(0.24, firstLength * 0.18)),
|
|
326
|
-
...rawPoints.slice(1, -1),
|
|
327
|
-
movePlanPointTowards(lastPoint, beforeLastPoint, Math.min(0.3, lastLength * 0.22)),
|
|
328
|
-
]
|
|
329
|
-
const arrowTailPoint = polyline[polyline.length - 2]
|
|
330
|
-
const arrowTip = polyline[polyline.length - 1]
|
|
331
|
-
|
|
332
|
-
if (!(arrowTailPoint && arrowTip)) {
|
|
333
|
-
return null
|
|
334
|
-
}
|
|
335
|
-
|
|
336
|
-
const arrowBodyLength = getPlanPointDistance(arrowTailPoint, arrowTip)
|
|
337
|
-
if (arrowBodyLength <= Number.EPSILON) {
|
|
338
|
-
return null
|
|
339
|
-
}
|
|
340
|
-
|
|
341
|
-
const arrowHeadLength = clampPlanValue(
|
|
342
|
-
arrowBodyLength * 0.72,
|
|
343
|
-
FLOORPLAN_STAIR_ARROW_HEAD_MIN_SIZE,
|
|
344
|
-
FLOORPLAN_STAIR_ARROW_HEAD_MAX_SIZE,
|
|
345
|
-
)
|
|
346
|
-
const arrowHeadBase = movePlanPointTowards(arrowTip, arrowTailPoint, arrowHeadLength)
|
|
347
|
-
const directionX = arrowTip.x - arrowHeadBase.x
|
|
348
|
-
const directionY = arrowTip.y - arrowHeadBase.y
|
|
349
|
-
const directionLength = Math.hypot(directionX, directionY)
|
|
350
|
-
|
|
351
|
-
if (directionLength <= Number.EPSILON) {
|
|
352
|
-
return null
|
|
353
|
-
}
|
|
354
|
-
|
|
355
|
-
const normalX = -directionY / directionLength
|
|
356
|
-
const normalY = directionX / directionLength
|
|
357
|
-
const arrowHeadHalfWidth = arrowHeadLength * 0.34
|
|
358
|
-
|
|
359
|
-
return {
|
|
360
|
-
head: [
|
|
361
|
-
arrowTip,
|
|
362
|
-
{
|
|
363
|
-
x: arrowHeadBase.x + normalX * arrowHeadHalfWidth,
|
|
364
|
-
y: arrowHeadBase.y + normalY * arrowHeadHalfWidth,
|
|
365
|
-
},
|
|
366
|
-
{
|
|
367
|
-
x: arrowHeadBase.x - normalX * arrowHeadHalfWidth,
|
|
368
|
-
y: arrowHeadBase.y - normalY * arrowHeadHalfWidth,
|
|
369
|
-
},
|
|
370
|
-
],
|
|
371
|
-
polyline,
|
|
372
|
-
}
|
|
373
|
-
}
|
|
374
|
-
|
|
375
|
-
export function computeFloorplanStairSegmentTransforms(
|
|
376
|
-
segments: StairSegmentNode[],
|
|
377
|
-
): StairSegmentTransform[] {
|
|
378
|
-
const transforms: StairSegmentTransform[] = []
|
|
379
|
-
let currentX = 0
|
|
380
|
-
let currentY = 0
|
|
381
|
-
let currentZ = 0
|
|
382
|
-
let currentRotation = 0
|
|
383
|
-
|
|
384
|
-
for (let index = 0; index < segments.length; index += 1) {
|
|
385
|
-
const segment = segments[index]!
|
|
386
|
-
|
|
387
|
-
if (index === 0) {
|
|
388
|
-
transforms.push({
|
|
389
|
-
position: [currentX, currentY, currentZ],
|
|
390
|
-
rotation: currentRotation,
|
|
391
|
-
})
|
|
392
|
-
continue
|
|
393
|
-
}
|
|
394
|
-
|
|
395
|
-
const previousSegment = segments[index - 1]!
|
|
396
|
-
let attachX = 0
|
|
397
|
-
let attachY = previousSegment.height
|
|
398
|
-
let attachZ = previousSegment.length
|
|
399
|
-
let rotationDelta = 0
|
|
400
|
-
|
|
401
|
-
if (segment.attachmentSide === 'left') {
|
|
402
|
-
attachX = previousSegment.width / 2
|
|
403
|
-
attachZ = previousSegment.length / 2
|
|
404
|
-
rotationDelta = Math.PI / 2
|
|
405
|
-
} else if (segment.attachmentSide === 'right') {
|
|
406
|
-
attachX = -previousSegment.width / 2
|
|
407
|
-
attachZ = previousSegment.length / 2
|
|
408
|
-
rotationDelta = -Math.PI / 2
|
|
409
|
-
}
|
|
410
|
-
|
|
411
|
-
const [rotatedAttachX, rotatedAttachZ] = rotatePlanVector(attachX, attachZ, currentRotation)
|
|
412
|
-
currentX += rotatedAttachX
|
|
413
|
-
currentY += attachY
|
|
414
|
-
currentZ += rotatedAttachZ
|
|
415
|
-
currentRotation += rotationDelta
|
|
416
|
-
|
|
417
|
-
transforms.push({
|
|
418
|
-
position: [currentX, currentY, currentZ],
|
|
419
|
-
rotation: currentRotation,
|
|
420
|
-
})
|
|
421
|
-
}
|
|
422
|
-
|
|
423
|
-
return transforms
|
|
424
|
-
}
|
|
425
|
-
|
|
426
|
-
export function getFloorplanStairSegmentPolygon(
|
|
427
|
-
stair: StairNode,
|
|
428
|
-
segment: StairSegmentNode,
|
|
429
|
-
transform: StairSegmentTransform,
|
|
430
|
-
): Point2D[] {
|
|
431
|
-
const halfWidth = segment.width / 2
|
|
432
|
-
const localCorners: Array<[number, number]> = [
|
|
433
|
-
[-halfWidth, 0],
|
|
434
|
-
[halfWidth, 0],
|
|
435
|
-
[halfWidth, segment.length],
|
|
436
|
-
[-halfWidth, segment.length],
|
|
437
|
-
]
|
|
438
|
-
|
|
439
|
-
return localCorners.map(([localX, localY]) => {
|
|
440
|
-
const [segmentX, segmentY] = rotatePlanVector(localX, localY, transform.rotation)
|
|
441
|
-
const groupX = transform.position[0] + segmentX
|
|
442
|
-
const groupY = transform.position[2] + segmentY
|
|
443
|
-
const [worldOffsetX, worldOffsetY] = rotatePlanVector(groupX, groupY, stair.rotation)
|
|
444
|
-
|
|
445
|
-
return {
|
|
446
|
-
x: stair.position[0] + worldOffsetX,
|
|
447
|
-
y: stair.position[2] + worldOffsetY,
|
|
448
|
-
}
|
|
449
|
-
})
|
|
450
|
-
}
|
|
451
|
-
|
|
452
|
-
export function buildFloorplanStairEntry(
|
|
453
|
-
stair: StairNode,
|
|
454
|
-
segments: StairSegmentNode[],
|
|
455
|
-
): FloorplanStairEntry | null {
|
|
456
|
-
const stairType = stair.stairType ?? 'straight'
|
|
457
|
-
|
|
458
|
-
if (segments.length === 0 && stairType === 'straight') {
|
|
459
|
-
return null
|
|
460
|
-
}
|
|
461
|
-
|
|
462
|
-
const transforms = computeFloorplanStairSegmentTransforms(segments)
|
|
463
|
-
const segmentEntries = segments.map((segment, index) => {
|
|
464
|
-
const polygon = getFloorplanStairSegmentPolygon(stair, segment, transforms[index]!)
|
|
465
|
-
const centerLine = getFloorplanStairSegmentCenterLine(polygon)
|
|
466
|
-
const innerPolygon = getFloorplanStairInnerPolygon(polygon)
|
|
467
|
-
const treadThickness = getFloorplanStairTreadThickness(segment, innerPolygon)
|
|
468
|
-
|
|
469
|
-
return {
|
|
470
|
-
centerLine,
|
|
471
|
-
innerPolygon,
|
|
472
|
-
segment,
|
|
473
|
-
polygon,
|
|
474
|
-
treadBars: getFloorplanStairTreadBars(segment, innerPolygon, treadThickness),
|
|
475
|
-
treadThickness,
|
|
476
|
-
}
|
|
477
|
-
})
|
|
478
|
-
const hitPolygons =
|
|
479
|
-
stairType === 'straight'
|
|
480
|
-
? segmentEntries.map(({ polygon }) => polygon)
|
|
481
|
-
: [getFloorplanCurvedStairHitPolygon(stair)]
|
|
482
|
-
|
|
483
|
-
return {
|
|
484
|
-
arrow: buildFloorplanStairArrow(segmentEntries),
|
|
485
|
-
hitPolygons,
|
|
486
|
-
stair,
|
|
487
|
-
segments: segmentEntries,
|
|
488
|
-
}
|
|
489
|
-
}
|
|
@@ -1,144 +0,0 @@
|
|
|
1
|
-
import { describe, expect, test } from 'bun:test'
|
|
2
|
-
import {
|
|
3
|
-
type AnyNode,
|
|
4
|
-
type AnyNodeId,
|
|
5
|
-
BuildingNode,
|
|
6
|
-
LevelNode,
|
|
7
|
-
SpawnNode,
|
|
8
|
-
UnitNode,
|
|
9
|
-
WallNode,
|
|
10
|
-
ZoneNode,
|
|
11
|
-
} from '@pascal-app/core/schema'
|
|
12
|
-
import { buildLevelDuplicateCreateOps } from './level-duplication'
|
|
13
|
-
|
|
14
|
-
describe('buildLevelDuplicateCreateOps', () => {
|
|
15
|
-
test('parents a duplicated bootstrap level back to its building', () => {
|
|
16
|
-
const level = LevelNode.parse({ level: 0, height: 3.25, children: [] })
|
|
17
|
-
const building = BuildingNode.parse({ children: [level.id] })
|
|
18
|
-
const wall = WallNode.parse({
|
|
19
|
-
parentId: level.id,
|
|
20
|
-
start: [0, 0],
|
|
21
|
-
end: [4, 0],
|
|
22
|
-
})
|
|
23
|
-
const sourceLevel = { ...level, children: [wall.id] } satisfies LevelNode
|
|
24
|
-
const nodes = {
|
|
25
|
-
[building.id]: building,
|
|
26
|
-
[sourceLevel.id]: sourceLevel,
|
|
27
|
-
[wall.id]: wall,
|
|
28
|
-
} as Record<AnyNodeId, AnyNode>
|
|
29
|
-
|
|
30
|
-
const { createOps, newLevelId } = buildLevelDuplicateCreateOps({
|
|
31
|
-
nodes,
|
|
32
|
-
level: sourceLevel,
|
|
33
|
-
levels: [sourceLevel],
|
|
34
|
-
preset: 'everything',
|
|
35
|
-
})
|
|
36
|
-
|
|
37
|
-
const levelCreateOp = createOps.find((op) => op.node.id === newLevelId)
|
|
38
|
-
|
|
39
|
-
expect(sourceLevel.parentId).toBeNull()
|
|
40
|
-
expect(levelCreateOp?.parentId).toBe(building.id)
|
|
41
|
-
expect(levelCreateOp?.node.type === 'level' ? levelCreateOp.node.height : undefined).toBe(3.25)
|
|
42
|
-
})
|
|
43
|
-
|
|
44
|
-
test('does not copy spawn points from the source level', () => {
|
|
45
|
-
const building = BuildingNode.parse({})
|
|
46
|
-
const spawn = SpawnNode.parse({ parentId: 'level_source' })
|
|
47
|
-
const level = LevelNode.parse({
|
|
48
|
-
id: 'level_source',
|
|
49
|
-
level: 0,
|
|
50
|
-
parentId: building.id,
|
|
51
|
-
children: [spawn.id],
|
|
52
|
-
})
|
|
53
|
-
const nodes = {
|
|
54
|
-
[building.id]: { ...building, children: [level.id] },
|
|
55
|
-
[level.id]: level,
|
|
56
|
-
[spawn.id]: spawn,
|
|
57
|
-
} as Record<AnyNodeId, AnyNode>
|
|
58
|
-
|
|
59
|
-
const { createOps, newLevelId } = buildLevelDuplicateCreateOps({
|
|
60
|
-
nodes,
|
|
61
|
-
level,
|
|
62
|
-
levels: [level],
|
|
63
|
-
preset: 'everything',
|
|
64
|
-
})
|
|
65
|
-
|
|
66
|
-
const copiedLevel = createOps.find((op) => op.node.id === newLevelId)?.node as
|
|
67
|
-
| LevelNode
|
|
68
|
-
| undefined
|
|
69
|
-
|
|
70
|
-
expect(createOps.some((op) => op.node.type === 'spawn')).toBe(false)
|
|
71
|
-
expect(copiedLevel?.children).toEqual([])
|
|
72
|
-
})
|
|
73
|
-
})
|
|
74
|
-
|
|
75
|
-
describe('unit duplication', () => {
|
|
76
|
-
for (const preset of [
|
|
77
|
-
'everything',
|
|
78
|
-
'structure',
|
|
79
|
-
'structure-materials',
|
|
80
|
-
'structure-furniture',
|
|
81
|
-
] as const) {
|
|
82
|
-
test(`duplicates only units wholly on the source level with ${preset}`, () => {
|
|
83
|
-
const building = BuildingNode.parse({})
|
|
84
|
-
const level = LevelNode.parse({ parentId: building.id, level: 0 })
|
|
85
|
-
const upper = LevelNode.parse({ parentId: building.id, level: 1 })
|
|
86
|
-
const kitchen = ZoneNode.parse({ parentId: level.id, name: 'Kitchen', polygon: [] })
|
|
87
|
-
const living = ZoneNode.parse({ parentId: level.id, name: 'Living', polygon: [] })
|
|
88
|
-
const bedroom = ZoneNode.parse({ parentId: upper.id, name: 'Bedroom', polygon: [] })
|
|
89
|
-
const single = UnitNode.parse({
|
|
90
|
-
parentId: building.id,
|
|
91
|
-
name: 'Suite',
|
|
92
|
-
kind: 'hotel-room',
|
|
93
|
-
color: '#123456',
|
|
94
|
-
members: [kitchen.id, living.id],
|
|
95
|
-
})
|
|
96
|
-
const duplex = UnitNode.parse({
|
|
97
|
-
parentId: building.id,
|
|
98
|
-
name: 'Duplex',
|
|
99
|
-
members: [living.id, bedroom.id],
|
|
100
|
-
})
|
|
101
|
-
const empty = UnitNode.parse({ parentId: building.id })
|
|
102
|
-
const dangling = UnitNode.parse({
|
|
103
|
-
parentId: building.id,
|
|
104
|
-
members: [kitchen.id, 'zone_missing'],
|
|
105
|
-
})
|
|
106
|
-
level.children = [kitchen.id, living.id]
|
|
107
|
-
upper.children = [bedroom.id]
|
|
108
|
-
building.children = [level.id, upper.id, single.id, duplex.id, empty.id, dangling.id]
|
|
109
|
-
const nodes: Record<AnyNodeId, AnyNode> = Object.fromEntries(
|
|
110
|
-
[building, level, upper, kitchen, living, bedroom, single, duplex, empty, dangling].map(
|
|
111
|
-
(node) => [node.id, node],
|
|
112
|
-
),
|
|
113
|
-
)
|
|
114
|
-
const before = structuredClone(nodes)
|
|
115
|
-
const { createOps, newLevelId, shiftedLevels } = buildLevelDuplicateCreateOps({
|
|
116
|
-
nodes,
|
|
117
|
-
level,
|
|
118
|
-
levels: [level, upper],
|
|
119
|
-
preset,
|
|
120
|
-
})
|
|
121
|
-
const unitOps = createOps.filter((op) => op.node.type === 'unit')
|
|
122
|
-
expect(unitOps).toHaveLength(1)
|
|
123
|
-
const op = unitOps[0]!
|
|
124
|
-
expect(op.parentId).toBe(building.id)
|
|
125
|
-
expect(op.node.type).toBe('unit')
|
|
126
|
-
if (op.node.type !== 'unit') return
|
|
127
|
-
expect(op.node.id).not.toBe(single.id)
|
|
128
|
-
expect(op.node.name).toBe('Suite copy')
|
|
129
|
-
expect(op.node.kind).toBe(single.kind)
|
|
130
|
-
expect(op.node.color).toBe(single.color)
|
|
131
|
-
expect(op.node.parentId).toBe(building.id)
|
|
132
|
-
expect(op.node.members).toEqual(
|
|
133
|
-
createOps.flatMap((entry) => (entry.node.type === 'zone' ? [entry.node.id] : [])),
|
|
134
|
-
)
|
|
135
|
-
expect(
|
|
136
|
-
createOps
|
|
137
|
-
.filter((entry) => entry.node.type === 'zone')
|
|
138
|
-
.every((entry) => entry.parentId === newLevelId),
|
|
139
|
-
).toBe(true)
|
|
140
|
-
expect(shiftedLevels).toEqual([{ id: upper.id, level: 2 }])
|
|
141
|
-
expect(nodes).toEqual(before)
|
|
142
|
-
})
|
|
143
|
-
}
|
|
144
|
-
})
|