@pascal-app/core 0.9.2 → 1.0.0-beta.2
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/README.md +17 -10
- package/dist/events/bus.d.ts +21 -2
- package/dist/events/bus.d.ts.map +1 -1
- package/dist/hooks/spatial-grid/floor-placed-elevation.d.ts +17 -1
- package/dist/hooks/spatial-grid/floor-placed-elevation.d.ts.map +1 -1
- package/dist/hooks/spatial-grid/floor-placed-elevation.js +61 -8
- package/dist/hooks/spatial-grid/spatial-grid-manager.d.ts +116 -66
- package/dist/hooks/spatial-grid/spatial-grid-manager.d.ts.map +1 -1
- package/dist/hooks/spatial-grid/spatial-grid-manager.js +319 -441
- package/dist/hooks/spatial-grid/spatial-grid-sync.d.ts +46 -1
- package/dist/hooks/spatial-grid/spatial-grid-sync.d.ts.map +1 -1
- package/dist/hooks/spatial-grid/spatial-grid-sync.js +204 -12
- package/dist/hooks/spatial-grid/support-host-id.d.ts +3 -0
- package/dist/hooks/spatial-grid/support-host-id.d.ts.map +1 -0
- package/dist/hooks/spatial-grid/support-host-id.js +2 -0
- package/dist/hooks/spatial-grid/support-host-patch.d.ts +51 -0
- package/dist/hooks/spatial-grid/support-host-patch.d.ts.map +1 -0
- package/dist/hooks/spatial-grid/support-host-patch.js +164 -0
- package/dist/index.d.ts +23 -11
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +22 -10
- package/dist/lib/measurement-geometry.d.ts +4 -0
- package/dist/lib/measurement-geometry.d.ts.map +1 -1
- package/dist/lib/measurement-geometry.js +27 -10
- package/dist/lib/slab-polygon.d.ts.map +1 -1
- package/dist/lib/slab-polygon.js +33 -1
- package/dist/lib/space-detection.d.ts +15 -4
- package/dist/lib/space-detection.d.ts.map +1 -1
- package/dist/lib/space-detection.js +232 -91
- package/dist/lib/terrain-brush.d.ts +163 -0
- package/dist/lib/terrain-brush.d.ts.map +1 -0
- package/dist/lib/terrain-brush.js +359 -0
- package/dist/lib/terrain-codec.d.ts +51 -0
- package/dist/lib/terrain-codec.d.ts.map +1 -0
- package/dist/lib/terrain-codec.js +167 -0
- package/dist/lib/terrain-field.d.ts +150 -0
- package/dist/lib/terrain-field.d.ts.map +1 -0
- package/dist/lib/terrain-field.js +248 -0
- package/dist/lib/terrain-raycast.d.ts +44 -0
- package/dist/lib/terrain-raycast.d.ts.map +1 -0
- package/dist/lib/terrain-raycast.js +188 -0
- package/dist/lib/terrain-source.d.ts +60 -0
- package/dist/lib/terrain-source.d.ts.map +1 -0
- package/dist/lib/terrain-source.js +90 -0
- package/dist/lib/terrain-support.d.ts +85 -0
- package/dist/lib/terrain-support.d.ts.map +1 -0
- package/dist/lib/terrain-support.js +218 -0
- package/dist/lib/zone-quantities.d.ts +1 -1
- package/dist/lib/zone-quantities.d.ts.map +1 -1
- package/dist/lib/zone-quantities.js +311 -66
- package/dist/material-library.d.ts +9 -1
- package/dist/material-library.d.ts.map +1 -1
- package/dist/material-library.js +56 -4
- package/dist/registry/handles.d.ts +16 -1
- package/dist/registry/handles.d.ts.map +1 -1
- package/dist/registry/index.d.ts +1 -1
- package/dist/registry/index.d.ts.map +1 -1
- package/dist/registry/subtree.d.ts.map +1 -1
- package/dist/registry/subtree.js +5 -2
- package/dist/registry/types.d.ts +83 -1
- package/dist/registry/types.d.ts.map +1 -1
- package/dist/schema/index.d.ts +6 -3
- package/dist/schema/index.d.ts.map +1 -1
- package/dist/schema/index.js +6 -3
- package/dist/schema/nodes/cabinet.d.ts +2 -0
- package/dist/schema/nodes/cabinet.d.ts.map +1 -1
- package/dist/schema/nodes/cabinet.js +4 -2
- package/dist/schema/nodes/ceiling.d.ts +1 -1
- package/dist/schema/nodes/ceiling.d.ts.map +1 -1
- package/dist/schema/nodes/ceiling.js +7 -1
- package/dist/schema/nodes/column.d.ts +1 -0
- package/dist/schema/nodes/column.d.ts.map +1 -1
- package/dist/schema/nodes/column.js +2 -0
- package/dist/schema/nodes/construction-dimension.d.ts +195 -0
- package/dist/schema/nodes/construction-dimension.d.ts.map +1 -0
- package/dist/schema/nodes/construction-dimension.js +151 -0
- package/dist/schema/nodes/door.d.ts +29 -0
- package/dist/schema/nodes/door.d.ts.map +1 -1
- package/dist/schema/nodes/door.js +20 -0
- package/dist/schema/nodes/duct-terminal.d.ts +1 -0
- package/dist/schema/nodes/duct-terminal.d.ts.map +1 -1
- package/dist/schema/nodes/duct-terminal.js +2 -0
- package/dist/schema/nodes/fence.d.ts +2 -0
- package/dist/schema/nodes/fence.d.ts.map +1 -1
- package/dist/schema/nodes/fence.js +8 -0
- package/dist/schema/nodes/hvac-equipment.d.ts +1 -0
- package/dist/schema/nodes/hvac-equipment.d.ts.map +1 -1
- package/dist/schema/nodes/hvac-equipment.js +2 -0
- package/dist/schema/nodes/item.d.ts +1 -0
- package/dist/schema/nodes/item.d.ts.map +1 -1
- package/dist/schema/nodes/item.js +13 -0
- package/dist/schema/nodes/level.d.ts +2 -1
- package/dist/schema/nodes/level.d.ts.map +1 -1
- package/dist/schema/nodes/level.js +12 -33
- package/dist/schema/nodes/shelf.d.ts +1 -0
- package/dist/schema/nodes/shelf.d.ts.map +1 -1
- package/dist/schema/nodes/shelf.js +2 -0
- package/dist/schema/nodes/site.d.ts +9 -0
- package/dist/schema/nodes/site.d.ts.map +1 -1
- package/dist/schema/nodes/site.js +8 -6
- package/dist/schema/nodes/slab.d.ts +5 -0
- package/dist/schema/nodes/slab.d.ts.map +1 -1
- package/dist/schema/nodes/slab.js +14 -2
- package/dist/schema/nodes/spawn.d.ts +1 -0
- package/dist/schema/nodes/spawn.d.ts.map +1 -1
- package/dist/schema/nodes/spawn.js +2 -0
- package/dist/schema/nodes/stair.d.ts +3 -1
- package/dist/schema/nodes/stair.d.ts.map +1 -1
- package/dist/schema/nodes/stair.js +8 -1
- package/dist/schema/nodes/structural-grid.d.ts +27 -0
- package/dist/schema/nodes/structural-grid.d.ts.map +1 -0
- package/dist/schema/nodes/structural-grid.js +17 -0
- package/dist/schema/nodes/wall.d.ts +5 -2
- package/dist/schema/nodes/wall.d.ts.map +1 -1
- package/dist/schema/nodes/wall.js +13 -4
- package/dist/schema/nodes/window.d.ts +29 -0
- package/dist/schema/nodes/window.d.ts.map +1 -1
- package/dist/schema/nodes/window.js +18 -0
- package/dist/schema/nodes/zone.d.ts +20 -0
- package/dist/schema/nodes/zone.d.ts.map +1 -1
- package/dist/schema/nodes/zone.js +15 -0
- package/dist/schema/terrain.d.ts +28 -0
- package/dist/schema/terrain.d.ts.map +1 -0
- package/dist/schema/terrain.js +30 -0
- package/dist/schema/types.d.ts +211 -3
- package/dist/schema/types.d.ts.map +1 -1
- package/dist/schema/types.js +4 -0
- package/dist/services/__fixtures__/wall-plane-top-boundary-repro.d.ts +80 -0
- package/dist/services/__fixtures__/wall-plane-top-boundary-repro.d.ts.map +1 -0
- package/dist/services/__fixtures__/wall-plane-top-boundary-repro.js +89 -0
- package/dist/services/index.d.ts +2 -1
- package/dist/services/index.d.ts.map +1 -1
- package/dist/services/index.js +2 -1
- package/dist/services/level-height.d.ts +8 -9
- package/dist/services/level-height.d.ts.map +1 -1
- package/dist/services/level-height.js +48 -16
- package/dist/services/storey.d.ts +103 -0
- package/dist/services/storey.d.ts.map +1 -0
- package/dist/services/storey.js +296 -0
- package/dist/store/actions/node-actions.d.ts.map +1 -1
- package/dist/store/actions/node-actions.js +47 -3
- package/dist/store/history-control.d.ts +20 -0
- package/dist/store/history-control.d.ts.map +1 -1
- package/dist/store/history-control.js +110 -13
- package/dist/store/use-live-terrain.d.ts +65 -0
- package/dist/store/use-live-terrain.d.ts.map +1 -0
- package/dist/store/use-live-terrain.js +31 -0
- package/dist/store/use-live-transforms.d.ts +8 -0
- package/dist/store/use-live-transforms.d.ts.map +1 -1
- package/dist/store/use-scene.d.ts +31 -2
- package/dist/store/use-scene.d.ts.map +1 -1
- package/dist/store/use-scene.js +638 -8
- package/dist/systems/elevator/elevator-opening-system.d.ts +1 -0
- package/dist/systems/elevator/elevator-opening-system.d.ts.map +1 -1
- package/dist/systems/elevator/elevator-opening-system.js +27 -21
- package/dist/systems/elevator/elevator-service.d.ts +0 -2
- package/dist/systems/elevator/elevator-service.d.ts.map +1 -1
- package/dist/systems/elevator/elevator-service.js +2 -24
- package/dist/systems/slab/slab-placement.d.ts +11 -0
- package/dist/systems/slab/slab-placement.d.ts.map +1 -0
- package/dist/systems/slab/slab-placement.js +14 -0
- package/dist/systems/slab/slab-support.d.ts +150 -0
- package/dist/systems/slab/slab-support.d.ts.map +1 -0
- package/dist/systems/slab/slab-support.js +575 -0
- package/dist/systems/stair/stair-opening-preview.d.ts +1060 -935
- package/dist/systems/stair/stair-opening-preview.d.ts.map +1 -1
- package/dist/systems/stair/stair-opening-sync.d.ts.map +1 -1
- package/dist/systems/stair/stair-opening-sync.js +18 -15
- package/dist/systems/stair/stair-opening-system.d.ts.map +1 -1
- package/dist/systems/stair/stair-opening-system.js +32 -4
- package/dist/systems/stair/stair-rise.d.ts +22 -0
- package/dist/systems/stair/stair-rise.d.ts.map +1 -0
- package/dist/systems/stair/stair-rise.js +79 -0
- package/dist/systems/wall/wall-curve.d.ts +10 -0
- package/dist/systems/wall/wall-curve.d.ts.map +1 -1
- package/dist/systems/wall/wall-curve.js +1 -1
- package/dist/systems/wall/wall-mitering.js +6 -6
- package/dist/systems/wall/wall-top.d.ts +40 -0
- package/dist/systems/wall/wall-top.d.ts.map +1 -0
- package/dist/systems/wall/wall-top.js +46 -0
- package/dist/utils/clone-scene-graph.d.ts.map +1 -1
- package/dist/utils/clone-scene-graph.js +34 -3
- package/dist/utils/heal-scene-graph.d.ts +1 -1
- package/dist/utils/heal-scene-graph.d.ts.map +1 -1
- package/dist/utils/heal-scene-graph.js +25 -9
- package/dist/validation/validate-build-json.d.ts +2 -0
- package/dist/validation/validate-build-json.d.ts.map +1 -1
- package/dist/validation/validate-build-json.js +59 -3
- package/package.json +2 -2
- package/dist/hooks/scene-registry/scene-registry.test.d.ts +0 -2
- package/dist/hooks/scene-registry/scene-registry.test.d.ts.map +0 -1
- package/dist/hooks/scene-registry/scene-registry.test.js +0 -26
- package/dist/hooks/spatial-grid/floor-placed-elevation.test.d.ts +0 -2
- package/dist/hooks/spatial-grid/floor-placed-elevation.test.d.ts.map +0 -1
- package/dist/hooks/spatial-grid/floor-placed-elevation.test.js +0 -366
- package/dist/hooks/spatial-grid/wall-slab-overlap.test.d.ts +0 -2
- package/dist/hooks/spatial-grid/wall-slab-overlap.test.d.ts.map +0 -1
- package/dist/hooks/spatial-grid/wall-slab-overlap.test.js +0 -363
- package/dist/lib/measurement-geometry.test.d.ts +0 -2
- package/dist/lib/measurement-geometry.test.d.ts.map +0 -1
- package/dist/lib/measurement-geometry.test.js +0 -102
- package/dist/lib/slab-polygon.test.d.ts +0 -2
- package/dist/lib/slab-polygon.test.d.ts.map +0 -1
- package/dist/lib/slab-polygon.test.js +0 -635
- package/dist/lib/space-detection-pause.test.d.ts +0 -2
- package/dist/lib/space-detection-pause.test.d.ts.map +0 -1
- package/dist/lib/space-detection-pause.test.js +0 -42
- package/dist/lib/space-detection.test.d.ts +0 -2
- package/dist/lib/space-detection.test.d.ts.map +0 -1
- package/dist/lib/space-detection.test.js +0 -376
- package/dist/lib/zone-quantities.test.d.ts +0 -2
- package/dist/lib/zone-quantities.test.d.ts.map +0 -1
- package/dist/lib/zone-quantities.test.js +0 -82
- package/dist/registry/registry.test.d.ts +0 -2
- package/dist/registry/registry.test.d.ts.map +0 -1
- package/dist/registry/registry.test.js +0 -196
- package/dist/registry/relations-resolver.test.d.ts +0 -2
- package/dist/registry/relations-resolver.test.d.ts.map +0 -1
- package/dist/registry/relations-resolver.test.js +0 -183
- package/dist/registry/scene-api.test.d.ts +0 -2
- package/dist/registry/scene-api.test.d.ts.map +0 -1
- package/dist/registry/scene-api.test.js +0 -183
- package/dist/registry/subtree.test.d.ts +0 -2
- package/dist/registry/subtree.test.d.ts.map +0 -1
- package/dist/registry/subtree.test.js +0 -163
- package/dist/schema/asset-url.test.d.ts +0 -2
- package/dist/schema/asset-url.test.d.ts.map +0 -1
- package/dist/schema/asset-url.test.js +0 -134
- package/dist/schema/material.test.d.ts +0 -2
- package/dist/schema/material.test.d.ts.map +0 -1
- package/dist/schema/material.test.js +0 -43
- package/dist/schema/nodes/measurement.test.d.ts +0 -2
- package/dist/schema/nodes/measurement.test.d.ts.map +0 -1
- package/dist/schema/nodes/measurement.test.js +0 -139
- package/dist/schema/nodes/ridge-vent-defaults.test.d.ts +0 -2
- package/dist/schema/nodes/ridge-vent-defaults.test.d.ts.map +0 -1
- package/dist/schema/nodes/ridge-vent-defaults.test.js +0 -205
- package/dist/schema/nodes/roof-segment-shape.test.d.ts +0 -2
- package/dist/schema/nodes/roof-segment-shape.test.d.ts.map +0 -1
- package/dist/schema/nodes/roof-segment-shape.test.js +0 -175
- package/dist/schema/nodes/roof-segment-surface.test.d.ts +0 -2
- package/dist/schema/nodes/roof-segment-surface.test.d.ts.map +0 -1
- package/dist/schema/nodes/roof-segment-surface.test.js +0 -48
- package/dist/schema/nodes/roof-segment-trim.test.d.ts +0 -2
- package/dist/schema/nodes/roof-segment-trim.test.d.ts.map +0 -1
- package/dist/schema/nodes/roof-segment-trim.test.js +0 -107
- package/dist/schema/nodes/roof-segment-walls.test.d.ts +0 -2
- package/dist/schema/nodes/roof-segment-walls.test.d.ts.map +0 -1
- package/dist/schema/nodes/roof-segment-walls.test.js +0 -92
- package/dist/schema/nodes/wall.test.d.ts +0 -2
- package/dist/schema/nodes/wall.test.d.ts.map +0 -1
- package/dist/schema/nodes/wall.test.js +0 -208
- package/dist/services/alignment-anchors.test.d.ts +0 -2
- package/dist/services/alignment-anchors.test.d.ts.map +0 -1
- package/dist/services/alignment-anchors.test.js +0 -383
- package/dist/services/alignment.test.d.ts +0 -2
- package/dist/services/alignment.test.d.ts.map +0 -1
- package/dist/services/alignment.test.js +0 -92
- package/dist/services/drag-session.test.d.ts +0 -2
- package/dist/services/drag-session.test.d.ts.map +0 -1
- package/dist/services/drag-session.test.js +0 -219
- package/dist/services/hosting.test.d.ts +0 -2
- package/dist/services/hosting.test.d.ts.map +0 -1
- package/dist/services/hosting.test.js +0 -230
- package/dist/services/movement.test.d.ts +0 -2
- package/dist/services/movement.test.d.ts.map +0 -1
- package/dist/services/movement.test.js +0 -133
- package/dist/services/opening-guides.test.d.ts +0 -2
- package/dist/services/opening-guides.test.d.ts.map +0 -1
- package/dist/services/opening-guides.test.js +0 -208
- package/dist/services/port-connectivity.test.d.ts +0 -2
- package/dist/services/port-connectivity.test.d.ts.map +0 -1
- package/dist/services/port-connectivity.test.js +0 -297
- package/dist/services/riser-diagram.test.d.ts +0 -2
- package/dist/services/riser-diagram.test.d.ts.map +0 -1
- package/dist/services/riser-diagram.test.js +0 -66
- package/dist/services/single-undo-dance.test.d.ts +0 -2
- package/dist/services/single-undo-dance.test.d.ts.map +0 -1
- package/dist/services/single-undo-dance.test.js +0 -210
- package/dist/services/snap.test.d.ts +0 -2
- package/dist/services/snap.test.d.ts.map +0 -1
- package/dist/services/snap.test.js +0 -137
- package/dist/services/system-graph.test.d.ts +0 -2
- package/dist/services/system-graph.test.d.ts.map +0 -1
- package/dist/services/system-graph.test.js +0 -138
- package/dist/services/validate-dwv.test.d.ts +0 -2
- package/dist/services/validate-dwv.test.d.ts.map +0 -1
- package/dist/services/validate-dwv.test.js +0 -109
- package/dist/store/actions/node-mutation-sanitize.test.d.ts +0 -2
- package/dist/store/actions/node-mutation-sanitize.test.d.ts.map +0 -1
- package/dist/store/actions/node-mutation-sanitize.test.js +0 -147
- package/dist/store/actions/reparent.test.d.ts +0 -2
- package/dist/store/actions/reparent.test.d.ts.map +0 -1
- package/dist/store/actions/reparent.test.js +0 -212
- package/dist/store/actions/ridge-vent-update.test.d.ts +0 -2
- package/dist/store/actions/ridge-vent-update.test.d.ts.map +0 -1
- package/dist/store/actions/ridge-vent-update.test.js +0 -264
- package/dist/store/use-scene-dirty-tracking.test.d.ts +0 -2
- package/dist/store/use-scene-dirty-tracking.test.d.ts.map +0 -1
- package/dist/store/use-scene-dirty-tracking.test.js +0 -68
- package/dist/store/use-scene-elevator-migration.test.d.ts +0 -2
- package/dist/store/use-scene-elevator-migration.test.d.ts.map +0 -1
- package/dist/store/use-scene-elevator-migration.test.js +0 -109
- package/dist/store/use-scene-measurement-roundtrip.test.d.ts +0 -2
- package/dist/store/use-scene-measurement-roundtrip.test.d.ts.map +0 -1
- package/dist/store/use-scene-measurement-roundtrip.test.js +0 -97
- package/dist/store/use-scene-plugins.test.d.ts +0 -2
- package/dist/store/use-scene-plugins.test.d.ts.map +0 -1
- package/dist/store/use-scene-plugins.test.js +0 -51
- package/dist/store/use-scene-wall-slot-migration.test.d.ts +0 -2
- package/dist/store/use-scene-wall-slot-migration.test.d.ts.map +0 -1
- package/dist/store/use-scene-wall-slot-migration.test.js +0 -210
- package/dist/store/use-scene-window-migration.test.d.ts +0 -2
- package/dist/store/use-scene-window-migration.test.d.ts.map +0 -1
- package/dist/store/use-scene-window-migration.test.js +0 -85
- package/dist/systems/elevator/elevator-opening-sync.test.d.ts +0 -2
- package/dist/systems/elevator/elevator-opening-sync.test.d.ts.map +0 -1
- package/dist/systems/elevator/elevator-opening-sync.test.js +0 -146
- package/dist/systems/elevator/elevator-runtime.test.d.ts +0 -2
- package/dist/systems/elevator/elevator-runtime.test.d.ts.map +0 -1
- package/dist/systems/elevator/elevator-runtime.test.js +0 -64
- package/dist/systems/fence/fence-spline.test.d.ts +0 -2
- package/dist/systems/fence/fence-spline.test.d.ts.map +0 -1
- package/dist/systems/fence/fence-spline.test.js +0 -136
- package/dist/systems/stair/stair-opening-preview.test.d.ts +0 -2
- package/dist/systems/stair/stair-opening-preview.test.d.ts.map +0 -1
- package/dist/systems/stair/stair-opening-preview.test.js +0 -80
- package/dist/systems/stair/stair-opening-sync.test.d.ts +0 -2
- package/dist/systems/stair/stair-opening-sync.test.d.ts.map +0 -1
- package/dist/systems/stair/stair-opening-sync.test.js +0 -485
- package/dist/systems/wall/wall-mitering.test.d.ts +0 -2
- package/dist/systems/wall/wall-mitering.test.d.ts.map +0 -1
- package/dist/systems/wall/wall-mitering.test.js +0 -63
- package/dist/utils/clone-scene-graph.test.d.ts +0 -2
- package/dist/utils/clone-scene-graph.test.d.ts.map +0 -1
- package/dist/utils/clone-scene-graph.test.js +0 -62
- package/dist/utils/heal-scene-graph.test.d.ts +0 -2
- package/dist/utils/heal-scene-graph.test.d.ts.map +0 -1
- package/dist/utils/heal-scene-graph.test.js +0 -88
|
@@ -1,383 +0,0 @@
|
|
|
1
|
-
import { beforeEach, describe, expect, test } from 'bun:test';
|
|
2
|
-
import { z } from 'zod';
|
|
3
|
-
import { nodeRegistry, registerNode } from '../registry';
|
|
4
|
-
import { getElevatorShaftDepth, getElevatorShaftWallThickness, getElevatorShaftWidth, } from '../systems/elevator/elevator-geometry';
|
|
5
|
-
import { stairFootprintAABB } from '../systems/stair/stair-footprint';
|
|
6
|
-
import { collectAlignmentAnchors, footprintAABB, footprintAABBFrom, movingAlignmentAnchors, movingFootprintAnchors, polygonAnchors, wallSegmentAnchors, } from './alignment-anchors';
|
|
7
|
-
// Minimal floor-placed def whose footprint reads `dimensions` / `rotation`
|
|
8
|
-
// straight off the node, so tests can drive the AABB math directly.
|
|
9
|
-
function floorPlacedDef(kind, applies) {
|
|
10
|
-
return {
|
|
11
|
-
kind,
|
|
12
|
-
schemaVersion: 1,
|
|
13
|
-
schema: z.object({ type: z.literal(kind) }),
|
|
14
|
-
category: 'utility',
|
|
15
|
-
defaults: () => ({}),
|
|
16
|
-
capabilities: {
|
|
17
|
-
floorPlaced: {
|
|
18
|
-
footprint: (n) => ({
|
|
19
|
-
dimensions: n.dimensions ?? [1, 1, 1],
|
|
20
|
-
rotation: n.rotation ?? [0, 0, 0],
|
|
21
|
-
}),
|
|
22
|
-
...(applies ? { applies } : {}),
|
|
23
|
-
},
|
|
24
|
-
},
|
|
25
|
-
renderer: { kind: 'parametric', module: async () => ({ default: () => null }) },
|
|
26
|
-
};
|
|
27
|
-
}
|
|
28
|
-
// Mirrors the real elevator/stair definitions, which expose their plan
|
|
29
|
-
// footprint via the `alignmentFootprint` capability rather than a hardcoded
|
|
30
|
-
// branch in the anchor bridge. The glue (shaft-outset box / stair AABB) is
|
|
31
|
-
// reproduced here from the same core helpers production uses.
|
|
32
|
-
function elevatorDef() {
|
|
33
|
-
return {
|
|
34
|
-
kind: 'elevator',
|
|
35
|
-
schemaVersion: 1,
|
|
36
|
-
schema: z.object({ type: z.literal('elevator') }),
|
|
37
|
-
category: 'structure',
|
|
38
|
-
defaults: () => ({}),
|
|
39
|
-
capabilities: {
|
|
40
|
-
alignmentFootprint: (n) => {
|
|
41
|
-
const e = n;
|
|
42
|
-
const wall = getElevatorShaftWallThickness(e);
|
|
43
|
-
return {
|
|
44
|
-
shape: 'box',
|
|
45
|
-
dimensions: [getElevatorShaftWidth(e) + wall * 2, 1, getElevatorShaftDepth(e) + wall * 2],
|
|
46
|
-
rotation: [0, e.rotation ?? 0, 0],
|
|
47
|
-
};
|
|
48
|
-
},
|
|
49
|
-
},
|
|
50
|
-
renderer: { kind: 'parametric', module: async () => ({ default: () => null }) },
|
|
51
|
-
};
|
|
52
|
-
}
|
|
53
|
-
function stairDef() {
|
|
54
|
-
return {
|
|
55
|
-
kind: 'stair',
|
|
56
|
-
schemaVersion: 1,
|
|
57
|
-
schema: z.object({ type: z.literal('stair') }),
|
|
58
|
-
category: 'structure',
|
|
59
|
-
defaults: () => ({}),
|
|
60
|
-
capabilities: {
|
|
61
|
-
alignmentFootprint: (n, nodes) => {
|
|
62
|
-
const aabb = stairFootprintAABB(n, nodes);
|
|
63
|
-
return aabb ? { shape: 'aabb', ...aabb } : null;
|
|
64
|
-
},
|
|
65
|
-
},
|
|
66
|
-
renderer: { kind: 'parametric', module: async () => ({ default: () => null }) },
|
|
67
|
-
};
|
|
68
|
-
}
|
|
69
|
-
function plainDef(kind) {
|
|
70
|
-
return {
|
|
71
|
-
kind,
|
|
72
|
-
schemaVersion: 1,
|
|
73
|
-
schema: z.object({ type: z.literal(kind) }),
|
|
74
|
-
category: 'utility',
|
|
75
|
-
defaults: () => ({}),
|
|
76
|
-
capabilities: {},
|
|
77
|
-
renderer: { kind: 'parametric', module: async () => ({ default: () => null }) },
|
|
78
|
-
};
|
|
79
|
-
}
|
|
80
|
-
const node = (over) => over;
|
|
81
|
-
describe('footprintAABBFrom', () => {
|
|
82
|
-
test('unrotated box is centred at position', () => {
|
|
83
|
-
const aabb = footprintAABBFrom([10, 0, 20], [2, 1, 4], 0);
|
|
84
|
-
expect(aabb).toEqual({ minX: 9, minZ: 18, maxX: 11, maxZ: 22 });
|
|
85
|
-
});
|
|
86
|
-
test('90° rotation swaps width and depth extents', () => {
|
|
87
|
-
const aabb = footprintAABBFrom([0, 0, 0], [2, 1, 4], Math.PI / 2);
|
|
88
|
-
expect(aabb.minX).toBeCloseTo(-2, 10);
|
|
89
|
-
expect(aabb.maxX).toBeCloseTo(2, 10);
|
|
90
|
-
expect(aabb.minZ).toBeCloseTo(-1, 10);
|
|
91
|
-
expect(aabb.maxZ).toBeCloseTo(1, 10);
|
|
92
|
-
});
|
|
93
|
-
});
|
|
94
|
-
describe('footprintAABB', () => {
|
|
95
|
-
beforeEach(() => nodeRegistry._reset());
|
|
96
|
-
test('reads dimensions + rotation from a floor-placed kind', () => {
|
|
97
|
-
registerNode(floorPlacedDef('box'));
|
|
98
|
-
const aabb = footprintAABB(node({ id: 'b1', type: 'box', position: [10, 0, 20], dimensions: [2, 1, 4] }));
|
|
99
|
-
expect(aabb).toEqual({ minX: 9, minZ: 18, maxX: 11, maxZ: 22 });
|
|
100
|
-
});
|
|
101
|
-
test('returns null for a kind without a footprint', () => {
|
|
102
|
-
registerNode(plainDef('wall'));
|
|
103
|
-
expect(footprintAABB(node({ id: 'w1', type: 'wall', position: [0, 0, 0] }))).toBeNull();
|
|
104
|
-
});
|
|
105
|
-
test('derives an elevator footprint from its OUTER SHAFT, not the cab', () => {
|
|
106
|
-
// Aligns to the visible shaft outline: cab 2×4 + 0.09 m wall each side →
|
|
107
|
-
// 2.18 × 4.18, centred at (10, 20). The cab corners alone would sit ~9 cm
|
|
108
|
-
// inside the drawn edge (past the 8 cm snap), so a guide never appeared.
|
|
109
|
-
// The footprint comes from the elevator's `alignmentFootprint` (box) cap.
|
|
110
|
-
registerNode(elevatorDef());
|
|
111
|
-
const aabb = footprintAABB(node({ id: 'e1', type: 'elevator', position: [10, 0, 20], width: 2, depth: 4, rotation: 0 }));
|
|
112
|
-
expect(aabb).toEqual({ minX: 8.91, minZ: 17.91, maxX: 11.09, maxZ: 22.09 });
|
|
113
|
-
});
|
|
114
|
-
test('returns null when the kind predicate excludes the node', () => {
|
|
115
|
-
registerNode(floorPlacedDef('lamp', (n) => !n.attached));
|
|
116
|
-
expect(footprintAABB(node({ id: 'l1', type: 'lamp', position: [0, 0, 0], attached: true }))).toBeNull();
|
|
117
|
-
expect(footprintAABB(node({ id: 'l2', type: 'lamp', position: [0, 0, 0], attached: false }))).not.toBeNull();
|
|
118
|
-
});
|
|
119
|
-
});
|
|
120
|
-
describe('movingFootprintAnchors', () => {
|
|
121
|
-
beforeEach(() => nodeRegistry._reset());
|
|
122
|
-
test('relocates the footprint corners around the proposed centre (edges only, no centre anchor)', () => {
|
|
123
|
-
registerNode(floorPlacedDef('box'));
|
|
124
|
-
const anchors = movingFootprintAnchors(node({ id: 'm', type: 'box', position: [0, 0, 0], dimensions: [2, 1, 4] }), 10, 20);
|
|
125
|
-
// 2×4 box centred at (10, 20): corners at x∈{9,11}, z∈{18,22}.
|
|
126
|
-
expect(anchors).toHaveLength(4);
|
|
127
|
-
expect(anchors.every((a) => a.kind === 'corner')).toBe(true);
|
|
128
|
-
expect(new Set(anchors.map((a) => a.x))).toEqual(new Set([9, 11]));
|
|
129
|
-
expect(new Set(anchors.map((a) => a.z))).toEqual(new Set([18, 22]));
|
|
130
|
-
});
|
|
131
|
-
test('rotationY override drives the AABB regardless of node rotation', () => {
|
|
132
|
-
registerNode(floorPlacedDef('box'));
|
|
133
|
-
const anchors = movingFootprintAnchors(node({
|
|
134
|
-
id: 'm',
|
|
135
|
-
type: 'box',
|
|
136
|
-
position: [0, 0, 0],
|
|
137
|
-
dimensions: [2, 1, 4],
|
|
138
|
-
rotation: [0, 0, 0],
|
|
139
|
-
}), 0, 0, Math.PI / 2);
|
|
140
|
-
const xs = anchors.map((a) => a.x);
|
|
141
|
-
// Rotated 90°, the 2×4 box spans ±2 in X (its depth) rather than ±1.
|
|
142
|
-
expect(Math.max(...xs)).toBeCloseTo(2, 10);
|
|
143
|
-
expect(Math.min(...xs)).toBeCloseTo(-2, 10);
|
|
144
|
-
});
|
|
145
|
-
test('returns empty for a footprintless kind', () => {
|
|
146
|
-
registerNode(plainDef('wall'));
|
|
147
|
-
expect(movingFootprintAnchors(node({ id: 'w', type: 'wall', position: [0, 0, 0] }), 1, 1)).toEqual([]);
|
|
148
|
-
});
|
|
149
|
-
});
|
|
150
|
-
describe('movingAlignmentAnchors', () => {
|
|
151
|
-
beforeEach(() => nodeRegistry._reset());
|
|
152
|
-
test('relocates a straight stair by its segment-chain footprint', () => {
|
|
153
|
-
registerNode(stairDef());
|
|
154
|
-
const nodes = {
|
|
155
|
-
st: node({
|
|
156
|
-
id: 'st',
|
|
157
|
-
type: 'stair',
|
|
158
|
-
position: [0, 0, 0],
|
|
159
|
-
rotation: 0,
|
|
160
|
-
stairType: 'straight',
|
|
161
|
-
width: 1,
|
|
162
|
-
children: ['seg'],
|
|
163
|
-
}),
|
|
164
|
-
seg: node({
|
|
165
|
-
id: 'seg',
|
|
166
|
-
type: 'stair-segment',
|
|
167
|
-
parentId: 'st',
|
|
168
|
-
width: 1,
|
|
169
|
-
length: 3,
|
|
170
|
-
height: 2.5,
|
|
171
|
-
attachmentSide: 'front',
|
|
172
|
-
}),
|
|
173
|
-
};
|
|
174
|
-
const anchors = movingAlignmentAnchors(nodes.st, nodes, 10, 20, 0);
|
|
175
|
-
expect(anchors).toHaveLength(4);
|
|
176
|
-
expect(new Set(anchors.map((a) => a.x))).toEqual(new Set([9.5, 10.5]));
|
|
177
|
-
expect(new Set(anchors.map((a) => a.z))).toEqual(new Set([20, 23]));
|
|
178
|
-
});
|
|
179
|
-
test('rotation override drives a moving straight stair footprint', () => {
|
|
180
|
-
registerNode(stairDef());
|
|
181
|
-
const nodes = {
|
|
182
|
-
st: node({
|
|
183
|
-
id: 'st',
|
|
184
|
-
type: 'stair',
|
|
185
|
-
position: [0, 0, 0],
|
|
186
|
-
rotation: 0,
|
|
187
|
-
stairType: 'straight',
|
|
188
|
-
width: 1,
|
|
189
|
-
children: ['seg'],
|
|
190
|
-
}),
|
|
191
|
-
seg: node({
|
|
192
|
-
id: 'seg',
|
|
193
|
-
type: 'stair-segment',
|
|
194
|
-
parentId: 'st',
|
|
195
|
-
width: 1,
|
|
196
|
-
length: 3,
|
|
197
|
-
height: 2.5,
|
|
198
|
-
attachmentSide: 'front',
|
|
199
|
-
}),
|
|
200
|
-
};
|
|
201
|
-
const anchors = movingAlignmentAnchors(nodes.st, nodes, 10, 20, Math.PI / 2);
|
|
202
|
-
const xs = anchors.map((a) => a.x);
|
|
203
|
-
const zs = anchors.map((a) => a.z);
|
|
204
|
-
expect(Math.min(...xs)).toBeCloseTo(10, 10);
|
|
205
|
-
expect(Math.max(...xs)).toBeCloseTo(13, 10);
|
|
206
|
-
expect(Math.min(...zs)).toBeCloseTo(19.5, 10);
|
|
207
|
-
expect(Math.max(...zs)).toBeCloseTo(20.5, 10);
|
|
208
|
-
});
|
|
209
|
-
});
|
|
210
|
-
describe('wallSegmentAnchors', () => {
|
|
211
|
-
test('returns both endpoints as corners and the chord midpoint as center', () => {
|
|
212
|
-
const anchors = wallSegmentAnchors('w', [0, 0], [4, 2]);
|
|
213
|
-
expect(anchors).toEqual([
|
|
214
|
-
{ nodeId: 'w', kind: 'corner', x: 0, z: 0 },
|
|
215
|
-
{ nodeId: 'w', kind: 'corner', x: 4, z: 2 },
|
|
216
|
-
{ nodeId: 'w', kind: 'center', x: 2, z: 1 },
|
|
217
|
-
]);
|
|
218
|
-
});
|
|
219
|
-
test('adds ±thickness/2 face corners on each endpoint when thickness is given', () => {
|
|
220
|
-
// Horizontal wall along +X: perpendicular is ±Z, so faces sit at z = ±0.1.
|
|
221
|
-
const anchors = wallSegmentAnchors('w', [0, 0], [4, 0], 0.2);
|
|
222
|
-
expect(anchors).toEqual([
|
|
223
|
-
{ nodeId: 'w', kind: 'corner', x: 0, z: 0 },
|
|
224
|
-
{ nodeId: 'w', kind: 'corner', x: 4, z: 0 },
|
|
225
|
-
{ nodeId: 'w', kind: 'center', x: 2, z: 0 },
|
|
226
|
-
{ nodeId: 'w', kind: 'corner', x: 0, z: 0.1 },
|
|
227
|
-
{ nodeId: 'w', kind: 'corner', x: 0, z: -0.1 },
|
|
228
|
-
{ nodeId: 'w', kind: 'corner', x: 4, z: 0.1 },
|
|
229
|
-
{ nodeId: 'w', kind: 'corner', x: 4, z: -0.1 },
|
|
230
|
-
]);
|
|
231
|
-
});
|
|
232
|
-
test('skips face corners for zero/degenerate input', () => {
|
|
233
|
-
expect(wallSegmentAnchors('w', [0, 0], [4, 0], 0)).toHaveLength(3);
|
|
234
|
-
expect(wallSegmentAnchors('w', [1, 1], [1, 1], 0.2)).toHaveLength(3);
|
|
235
|
-
});
|
|
236
|
-
});
|
|
237
|
-
describe('polygonAnchors', () => {
|
|
238
|
-
test('returns each vertex as a corner anchor', () => {
|
|
239
|
-
expect(polygonAnchors('s', [
|
|
240
|
-
[0, 0],
|
|
241
|
-
[2, 0],
|
|
242
|
-
[2, 3],
|
|
243
|
-
])).toEqual([
|
|
244
|
-
{ nodeId: 's', kind: 'corner', x: 0, z: 0 },
|
|
245
|
-
{ nodeId: 's', kind: 'corner', x: 2, z: 0 },
|
|
246
|
-
{ nodeId: 's', kind: 'corner', x: 2, z: 3 },
|
|
247
|
-
]);
|
|
248
|
-
});
|
|
249
|
-
});
|
|
250
|
-
describe('collectAlignmentAnchors', () => {
|
|
251
|
-
beforeEach(() => nodeRegistry._reset());
|
|
252
|
-
test('unions footprint corners, segment anchors and polygon vertices, excluding the moving node', () => {
|
|
253
|
-
registerNode(floorPlacedDef('box'));
|
|
254
|
-
const nodes = {
|
|
255
|
-
moving: node({ id: 'moving', type: 'box', position: [0, 0, 0], dimensions: [1, 1, 1] }),
|
|
256
|
-
box: node({ id: 'box', type: 'box', position: [5, 0, 5], dimensions: [2, 1, 2] }),
|
|
257
|
-
wall: node({ id: 'wall', type: 'wall', start: [0, 0], end: [4, 0] }),
|
|
258
|
-
slab: node({
|
|
259
|
-
id: 'slab',
|
|
260
|
-
type: 'slab',
|
|
261
|
-
polygon: [
|
|
262
|
-
[0, 0],
|
|
263
|
-
[2, 0],
|
|
264
|
-
[2, 2],
|
|
265
|
-
],
|
|
266
|
-
}),
|
|
267
|
-
};
|
|
268
|
-
const anchors = collectAlignmentAnchors(nodes, 'moving');
|
|
269
|
-
const ids = anchors.map((a) => a.nodeId);
|
|
270
|
-
expect(ids).not.toContain('moving');
|
|
271
|
-
expect(ids.filter((id) => id === 'box')).toHaveLength(4); // corner anchors
|
|
272
|
-
expect(ids.filter((id) => id === 'wall')).toHaveLength(7); // endpoints + midpoint + 4 face corners
|
|
273
|
-
expect(ids.filter((id) => id === 'slab')).toHaveLength(3); // polygon vertices
|
|
274
|
-
});
|
|
275
|
-
test('levelId filter keeps only nodes resolving to that level (incl. nested)', () => {
|
|
276
|
-
registerNode(floorPlacedDef('box'));
|
|
277
|
-
registerNode(elevatorDef());
|
|
278
|
-
const nodes = {
|
|
279
|
-
b: node({ id: 'b', type: 'building' }),
|
|
280
|
-
L1: node({ id: 'L1', type: 'level', parentId: 'b' }),
|
|
281
|
-
L2: node({ id: 'L2', type: 'level', parentId: 'b' }),
|
|
282
|
-
moving: node({ id: 'moving', type: 'box', parentId: 'L1', position: [0, 0, 0] }),
|
|
283
|
-
sameFloor: node({ id: 'sameFloor', type: 'box', parentId: 'L1', position: [5, 0, 5] }),
|
|
284
|
-
// Item resting on `sameFloor` — resolves to L1 through the parent chain.
|
|
285
|
-
nested: node({ id: 'nested', type: 'box', parentId: 'sameFloor', position: [5, 0, 5] }),
|
|
286
|
-
otherFloor: node({ id: 'otherFloor', type: 'box', parentId: 'L2', position: [5, 0, 5] }),
|
|
287
|
-
// Building-scoped (parented to the building, no level ancestor) — spans
|
|
288
|
-
// every floor, so it stays in the pool regardless of the active level.
|
|
289
|
-
elevator: node({
|
|
290
|
-
id: 'elevator',
|
|
291
|
-
type: 'elevator',
|
|
292
|
-
parentId: 'b',
|
|
293
|
-
position: [9, 0, 9],
|
|
294
|
-
width: 1.6,
|
|
295
|
-
depth: 1.6,
|
|
296
|
-
}),
|
|
297
|
-
};
|
|
298
|
-
const ids = collectAlignmentAnchors(nodes, 'moving', 'L1').map((a) => a.nodeId);
|
|
299
|
-
expect(ids.filter((id) => id === 'sameFloor')).toHaveLength(4);
|
|
300
|
-
expect(ids.filter((id) => id === 'nested')).toHaveLength(4);
|
|
301
|
-
expect(ids.filter((id) => id === 'elevator')).toHaveLength(4);
|
|
302
|
-
expect(ids).not.toContain('otherFloor');
|
|
303
|
-
});
|
|
304
|
-
test('straight stair contributes its segment-chain footprint corners', () => {
|
|
305
|
-
registerNode(stairDef());
|
|
306
|
-
const nodes = {
|
|
307
|
-
st: node({
|
|
308
|
-
id: 'st',
|
|
309
|
-
type: 'stair',
|
|
310
|
-
position: [0, 0, 0],
|
|
311
|
-
rotation: 0,
|
|
312
|
-
stairType: 'straight',
|
|
313
|
-
width: 1,
|
|
314
|
-
children: ['seg'],
|
|
315
|
-
}),
|
|
316
|
-
// Single 1×3 flight; origin at the run start, extending +Z by length.
|
|
317
|
-
seg: node({
|
|
318
|
-
id: 'seg',
|
|
319
|
-
type: 'stair-segment',
|
|
320
|
-
parentId: 'st',
|
|
321
|
-
width: 1,
|
|
322
|
-
length: 3,
|
|
323
|
-
height: 2.5,
|
|
324
|
-
attachmentSide: 'front',
|
|
325
|
-
}),
|
|
326
|
-
};
|
|
327
|
-
const anchors = collectAlignmentAnchors(nodes, '').filter((a) => a.nodeId === 'st');
|
|
328
|
-
expect(anchors).toHaveLength(4);
|
|
329
|
-
expect(anchors.every((a) => a.kind === 'corner')).toBe(true);
|
|
330
|
-
expect(new Set(anchors.map((a) => a.x))).toEqual(new Set([-0.5, 0.5]));
|
|
331
|
-
expect(new Set(anchors.map((a) => a.z))).toEqual(new Set([0, 3]));
|
|
332
|
-
});
|
|
333
|
-
test('curved stair contributes its sector bounding-box corners', () => {
|
|
334
|
-
registerNode(stairDef());
|
|
335
|
-
const nodes = {
|
|
336
|
-
cs: node({
|
|
337
|
-
id: 'cs',
|
|
338
|
-
type: 'stair',
|
|
339
|
-
position: [0, 0, 0],
|
|
340
|
-
rotation: 0,
|
|
341
|
-
stairType: 'curved',
|
|
342
|
-
width: 1,
|
|
343
|
-
innerRadius: 1,
|
|
344
|
-
sweepAngle: Math.PI / 2,
|
|
345
|
-
}),
|
|
346
|
-
};
|
|
347
|
-
const anchors = collectAlignmentAnchors(nodes, '').filter((a) => a.nodeId === 'cs');
|
|
348
|
-
expect(anchors).toHaveLength(4);
|
|
349
|
-
// outerRadius = inner(1) + width(1) = 2, sweep π/2 centred on +X. Outer rim
|
|
350
|
-
// reaches X=2 at the bisector; min X is the inner rim's ±π/4 ends (cos45·1);
|
|
351
|
-
// Z spans ±(outer·sin45).
|
|
352
|
-
const xs = anchors.map((a) => a.x);
|
|
353
|
-
const zs = anchors.map((a) => a.z);
|
|
354
|
-
expect(Math.max(...xs)).toBeCloseTo(2, 5);
|
|
355
|
-
expect(Math.min(...xs)).toBeCloseTo(Math.SQRT1_2, 5);
|
|
356
|
-
expect(Math.max(...zs)).toBeCloseTo(Math.SQRT2, 5);
|
|
357
|
-
expect(Math.min(...zs)).toBeCloseTo(-Math.SQRT2, 5);
|
|
358
|
-
});
|
|
359
|
-
test('spiral stair contributes a full-circle bounding box', () => {
|
|
360
|
-
registerNode(stairDef());
|
|
361
|
-
const nodes = {
|
|
362
|
-
sp: node({
|
|
363
|
-
id: 'sp',
|
|
364
|
-
type: 'stair',
|
|
365
|
-
position: [5, 0, 5],
|
|
366
|
-
rotation: 0,
|
|
367
|
-
stairType: 'spiral',
|
|
368
|
-
width: 1,
|
|
369
|
-
innerRadius: 0.5,
|
|
370
|
-
sweepAngle: Math.PI * 2,
|
|
371
|
-
}),
|
|
372
|
-
};
|
|
373
|
-
const anchors = collectAlignmentAnchors(nodes, '').filter((a) => a.nodeId === 'sp');
|
|
374
|
-
expect(anchors).toHaveLength(4);
|
|
375
|
-
// outerRadius = inner(0.5) + width(1) = 1.5, a full revolution about (5, 5).
|
|
376
|
-
const xs = anchors.map((a) => a.x);
|
|
377
|
-
const zs = anchors.map((a) => a.z);
|
|
378
|
-
expect(Math.max(...xs)).toBeCloseTo(6.5, 2);
|
|
379
|
-
expect(Math.min(...xs)).toBeCloseTo(3.5, 2);
|
|
380
|
-
expect(Math.max(...zs)).toBeCloseTo(6.5, 2);
|
|
381
|
-
expect(Math.min(...zs)).toBeCloseTo(3.5, 2);
|
|
382
|
-
});
|
|
383
|
-
});
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"alignment.test.d.ts","sourceRoot":"","sources":["../../src/services/alignment.test.ts"],"names":[],"mappings":""}
|
|
@@ -1,92 +0,0 @@
|
|
|
1
|
-
import { describe, expect, test } from 'bun:test';
|
|
2
|
-
import { bboxAnchors, resolveAlignment } from './alignment';
|
|
3
|
-
function center(nodeId, x, z) {
|
|
4
|
-
return { nodeId, kind: 'center', x, z };
|
|
5
|
-
}
|
|
6
|
-
function corner(nodeId, x, z) {
|
|
7
|
-
return { nodeId, kind: 'corner', x, z };
|
|
8
|
-
}
|
|
9
|
-
describe('resolveAlignment', () => {
|
|
10
|
-
test('returns empty when no candidates within threshold', () => {
|
|
11
|
-
const result = resolveAlignment({
|
|
12
|
-
moving: [center('m', 0, 0)],
|
|
13
|
-
candidates: [center('a', 1, 1)],
|
|
14
|
-
threshold: 0.5,
|
|
15
|
-
});
|
|
16
|
-
expect(result.guides).toEqual([]);
|
|
17
|
-
expect(result.snap).toBeNull();
|
|
18
|
-
});
|
|
19
|
-
test('snaps moving anchor onto candidate X when within threshold', () => {
|
|
20
|
-
const result = resolveAlignment({
|
|
21
|
-
moving: [center('m', 0.03, 5)],
|
|
22
|
-
candidates: [center('a', 0, 2)],
|
|
23
|
-
threshold: 0.1,
|
|
24
|
-
});
|
|
25
|
-
expect(result.snap).toEqual({ dx: -0.03, dz: 0 });
|
|
26
|
-
expect(result.guides).toHaveLength(1);
|
|
27
|
-
expect(result.guides[0].axis).toBe('x');
|
|
28
|
-
expect(result.guides[0].coord).toBe(0);
|
|
29
|
-
expect(result.guides[0].from.z).toBe(2);
|
|
30
|
-
expect(result.guides[0].to.z).toBe(5);
|
|
31
|
-
});
|
|
32
|
-
test('snaps both axes when both match', () => {
|
|
33
|
-
const result = resolveAlignment({
|
|
34
|
-
moving: [center('m', 0.03, 0.04)],
|
|
35
|
-
candidates: [center('a', 0, 0)],
|
|
36
|
-
threshold: 0.1,
|
|
37
|
-
});
|
|
38
|
-
expect(result.snap).toEqual({ dx: -0.03, dz: -0.04 });
|
|
39
|
-
expect(result.guides).toHaveLength(2);
|
|
40
|
-
});
|
|
41
|
-
test('picks closest candidate per axis', () => {
|
|
42
|
-
const result = resolveAlignment({
|
|
43
|
-
moving: [center('m', 0.08, 0)],
|
|
44
|
-
candidates: [center('a', 0, 5), center('b', 0.1, 5), center('c', 0.05, 10)],
|
|
45
|
-
threshold: 0.1,
|
|
46
|
-
});
|
|
47
|
-
// |0.1 - 0.08| = 0.02 wins over |0.05 - 0.08| = 0.03 and |0 - 0.08| = 0.08
|
|
48
|
-
expect(result.snap?.dx).toBeCloseTo(0.02, 10);
|
|
49
|
-
expect(result.guides[0].candidateNodeId).toBe('b');
|
|
50
|
-
});
|
|
51
|
-
test('ties on the matched axis break toward the nearest perpendicular anchor', () => {
|
|
52
|
-
const result = resolveAlignment({
|
|
53
|
-
moving: [corner('m', 0.02, 4)],
|
|
54
|
-
candidates: [corner('far', 0, 0), corner('near', 0, 5)],
|
|
55
|
-
threshold: 0.1,
|
|
56
|
-
});
|
|
57
|
-
// Both share X (Δx = 0.02); 'near' (z=5) is closer to the moving z=4 than
|
|
58
|
-
// 'far' (z=0), so the guide connects to the nearest real anchor.
|
|
59
|
-
expect(result.guides[0].candidateNodeId).toBe('near');
|
|
60
|
-
});
|
|
61
|
-
test('threshold = 0 disables alignment', () => {
|
|
62
|
-
const result = resolveAlignment({
|
|
63
|
-
moving: [center('m', 0, 0)],
|
|
64
|
-
candidates: [center('a', 0, 0)],
|
|
65
|
-
threshold: 0,
|
|
66
|
-
});
|
|
67
|
-
expect(result.guides).toEqual([]);
|
|
68
|
-
expect(result.snap).toBeNull();
|
|
69
|
-
});
|
|
70
|
-
test('distance is the perpendicular gap to the matched axis', () => {
|
|
71
|
-
const result = resolveAlignment({
|
|
72
|
-
moving: [center('m', 0.02, 3)],
|
|
73
|
-
candidates: [center('a', 0, 0)],
|
|
74
|
-
threshold: 0.1,
|
|
75
|
-
});
|
|
76
|
-
// After snap: moving at (0, 3). X guide runs along x=0 from z=0 to z=3.
|
|
77
|
-
expect(result.guides[0].distance).toBeCloseTo(3, 10);
|
|
78
|
-
});
|
|
79
|
-
});
|
|
80
|
-
describe('bboxAnchors', () => {
|
|
81
|
-
test('returns 9 anchors with correct kinds and positions', () => {
|
|
82
|
-
const anchors = bboxAnchors('node', 0, 0, 2, 4);
|
|
83
|
-
expect(anchors).toHaveLength(9);
|
|
84
|
-
const corners = anchors.filter((a) => a.kind === 'corner');
|
|
85
|
-
const edges = anchors.filter((a) => a.kind === 'edge-mid');
|
|
86
|
-
const centers = anchors.filter((a) => a.kind === 'center');
|
|
87
|
-
expect(corners).toHaveLength(4);
|
|
88
|
-
expect(edges).toHaveLength(4);
|
|
89
|
-
expect(centers).toHaveLength(1);
|
|
90
|
-
expect(centers[0]).toEqual({ nodeId: 'node', kind: 'center', x: 1, z: 2 });
|
|
91
|
-
});
|
|
92
|
-
});
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"drag-session.test.d.ts","sourceRoot":"","sources":["../../src/services/drag-session.test.ts"],"names":[],"mappings":""}
|