@pascal-app/editor 1.0.0 → 1.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +12 -6
- package/src/components/editor/bake-exporter.tsx +4 -0
- package/src/components/editor/bake-thumbnail.tsx +4 -1
- package/src/components/editor/custom-camera-controls.tsx +22 -74
- package/src/components/editor/editor-layout-mobile.tsx +1 -0
- package/src/components/editor/floating-action-menu.tsx +14 -1
- package/src/components/editor/floorplan-panel.tsx +233 -166
- package/src/components/editor/grid.tsx +31 -7
- package/src/components/editor/group-actions.ts +5 -9
- package/src/components/editor/group-floating-action-menu.tsx +19 -9
- package/src/components/editor/group-move-3d.ts +4 -6
- package/src/components/editor/group-rotate-handle.tsx +81 -35
- package/src/components/editor/group-selection-box-3d.tsx +25 -17
- package/src/components/editor/group-transform-shared.test.ts +126 -1
- package/src/components/editor/group-transform-shared.ts +79 -73
- package/src/components/editor/handles/handle-arrow.tsx +72 -2
- package/src/components/editor/handles/handle-placement.test.ts +111 -0
- package/src/components/editor/handles/handle-placement.ts +69 -0
- package/src/components/editor/handles/linear-resize-drag.ts +13 -2
- package/src/components/editor/handles/use-handle-drag.ts +80 -8
- package/src/components/editor/index.tsx +36 -13
- package/src/components/editor/node-action-menu.tsx +2 -0
- package/src/components/editor/node-arrow-handles.tsx +162 -69
- package/src/components/editor/registry-action-contributions.tsx +53 -0
- package/src/components/editor/selection-manager.tsx +49 -0
- package/src/components/editor/thumbnail-generator.tsx +11 -2
- package/src/components/editor/wall-move-side-handles.tsx +71 -21
- package/src/components/editor/wall-opening-highlights.tsx +2 -3
- package/src/components/editor-2d/floorplan-group-move.tsx +17 -24
- package/src/components/editor-2d/floorplan-registered-tool-layer.tsx +33 -12
- package/src/components/editor-2d/floorplan-registry-action-menu.tsx +12 -1
- package/src/components/editor-2d/floorplan-registry-move-overlay.tsx +154 -49
- package/src/components/editor-2d/renderers/floorplan-draft-wall-measurement.tsx +166 -0
- package/src/components/editor-2d/renderers/floorplan-registry-layer.test.ts +49 -0
- package/src/components/editor-2d/renderers/floorplan-registry-layer.tsx +113 -24
- package/src/components/procedural-items/inspector.tsx +223 -0
- package/src/components/systems/ceiling/ceiling-system.tsx +3 -1
- package/src/components/systems/zone/zone-system.tsx +8 -4
- package/src/components/tools/__fixtures__/hosting.ts +10 -0
- package/src/components/tools/item/item-surface-placement.test.ts +169 -0
- package/src/components/tools/item/item-surface-strategy-resolver.test.ts +204 -0
- package/src/components/tools/item/placement-strategies.ts +212 -200
- package/src/components/tools/item/placement-types.ts +4 -0
- package/src/components/tools/item/shelf-surface-strategy-resolver.test.ts +257 -0
- package/src/components/tools/item/use-draft-node.ts +136 -47
- package/src/components/tools/item/use-placement-coordinator.tsx +391 -157
- package/src/components/tools/registry/item-surface-child-frame.test.ts +90 -0
- package/src/components/tools/registry/item-surface-move.test.ts +509 -0
- package/src/components/tools/registry/item-surface-move.ts +463 -0
- package/src/components/tools/registry/item-surface-resolver.test.ts +257 -0
- package/src/components/tools/registry/move-registry-node-tool.tsx +237 -78
- package/src/components/tools/shared/affordance-dispatch.test.ts +24 -0
- package/src/components/tools/shared/affordance-dispatch.ts +13 -0
- package/src/components/tools/shared/draft-measurement-label.tsx +38 -0
- package/src/components/tools/shared/pointer-support-cap.test.ts +27 -0
- package/src/components/tools/shared/pointer-support-cap.ts +27 -13
- package/src/components/tools/shared/shelf-stickiness.ts +54 -0
- package/src/components/tools/shared/surface-hit.test.ts +56 -0
- package/src/components/tools/shared/surface-hit.ts +23 -0
- package/src/components/tools/shared/surface-rejection.test.tsx +107 -0
- package/src/components/tools/shared/surface-rejection.tsx +43 -0
- package/src/components/tools/tool-manager.tsx +36 -3
- package/src/components/tools/zone/zone-tool.tsx +13 -4
- package/src/components/ui/command-palette/editor-commands.tsx +54 -1
- package/src/components/ui/controls/material-paint-panel.tsx +6 -67
- package/src/components/ui/controls/material-picker.tsx +5 -67
- package/src/components/ui/controls/metric-control.tsx +29 -13
- package/src/components/ui/controls/slider-control.tsx +87 -35
- package/src/components/ui/floating-level-selector.tsx +81 -5
- package/src/components/ui/helpers/helper-manager.tsx +24 -6
- package/src/components/ui/helpers/registered-tool-helper.tsx +2 -32
- package/src/components/ui/item-catalog/item-catalog.tsx +5 -30
- package/src/components/ui/panels/multi-height-mode.tsx +27 -21
- package/src/components/ui/panels/multi-parametric-inspector.tsx +6 -3
- package/src/components/ui/panels/parametric-field-control.tsx +1 -1
- package/src/components/ui/panels/parametric-inspector.tsx +9 -17
- package/src/components/ui/panels/reference-panel.tsx +3 -3
- package/src/components/ui/primitives/checkbox.tsx +34 -0
- package/src/components/ui/primitives/shortcut-token.tsx +4 -0
- package/src/components/ui/sidebar/panels/settings-panel/audio-settings-dialog.tsx +2 -2
- package/src/components/ui/sidebar/panels/settings-panel/index.tsx +669 -336
- package/src/components/ui/sidebar/panels/settings-panel/keyboard-shortcuts-dialog.tsx +2 -2
- package/src/components/ui/sidebar/panels/settings-panel/print-export-button.test.ts +31 -4
- package/src/components/ui/sidebar/panels/settings-panel/print-export-button.tsx +30 -11
- package/src/components/ui/sidebar/panels/site-panel/building-tree-node.tsx +8 -1
- package/src/components/ui/sidebar/panels/site-panel/index.tsx +106 -4
- package/src/components/ui/sidebar/panels/site-panel/item-tree-node.tsx +2 -7
- package/src/components/ui/sidebar/panels/site-panel/shelf-tree-node.tsx +3 -8
- package/src/components/ui/sidebar/panels/site-panel/tree-node.tsx +6 -1
- package/src/components/ui/sidebar/panels/site-panel/unit-tree-node.tsx +224 -0
- package/src/components/ui/sidebar/panels/site-panel/zone-membership-checkbox.tsx +22 -0
- package/src/components/ui/sidebar/panels/site-panel/zone-tree-node.tsx +24 -7
- package/src/components/ui/snap-target-badge.tsx +2 -0
- package/src/components/viewer/floorplan-preview-visibility.test.ts +35 -0
- package/src/components/viewer/floorplan-preview-visibility.ts +19 -0
- package/src/components/viewer/floorplan-preview.tsx +1 -12
- package/src/components/viewer/viewer-scene-header.tsx +3 -0
- package/src/components/viewer/viewer-units-panel.tsx +116 -0
- package/src/components/viewer-zone-system.tsx +7 -2
- package/src/hooks/use-auto-save.integration.test.tsx +197 -0
- package/src/hooks/use-auto-save.ts +21 -6
- package/src/hooks/use-ceiling-events.test.ts +25 -2
- package/src/hooks/use-ceiling-events.ts +7 -1
- package/src/hooks/use-grid-events.test.ts +2 -0
- package/src/hooks/use-grid-events.ts +16 -11
- package/src/hooks/use-keyboard.test.ts +7 -0
- package/src/hooks/use-keyboard.ts +43 -28
- package/src/index.tsx +68 -3
- package/src/lib/catalog-panel-model.ts +39 -0
- package/src/lib/catalog-selection.test.ts +27 -0
- package/src/lib/catalog-selection.ts +8 -0
- package/src/lib/contextual-help.test.ts +27 -1
- package/src/lib/contextual-help.ts +16 -9
- package/src/lib/export-texture-utils.test.ts +167 -0
- package/src/lib/export-texture-utils.ts +121 -0
- package/src/lib/export-user-data.test.ts +48 -0
- package/src/lib/export-user-data.ts +69 -0
- package/src/lib/floorplan/floorplan-export.test.ts +142 -2
- package/src/lib/floorplan/floorplan-export.tsx +9 -3
- package/src/lib/floorplan/floorplan-extension.ts +16 -0
- package/src/lib/floorplan/floorplan-readonly.ts +4 -0
- package/src/lib/fresh-planar-placement.ts +173 -33
- package/src/lib/glb-export-serialize.test.ts +280 -0
- package/src/lib/glb-export.test.ts +265 -16
- package/src/lib/glb-export.ts +197 -37
- package/src/lib/grid-frame.test.ts +19 -0
- package/src/lib/grid-frame.ts +18 -0
- package/src/lib/interaction/scope.ts +9 -1
- package/src/lib/keyboard-pan.test.ts +62 -0
- package/src/lib/keyboard-pan.ts +89 -0
- package/src/lib/level-duplication.test.ts +73 -0
- package/src/lib/level-duplication.ts +32 -2
- package/src/lib/linear-display.test.ts +59 -0
- package/src/lib/linear-display.ts +39 -0
- package/src/lib/local-guide-image.test.ts +24 -0
- package/src/lib/local-guide-image.ts +34 -1
- package/src/lib/material-catalog-model.ts +72 -0
- package/src/lib/material-paint-panel-model.ts +76 -0
- package/src/lib/node-action-movement.ts +21 -0
- package/src/lib/overlay-transform.test.ts +28 -0
- package/src/lib/overlay-transform.ts +12 -0
- package/src/lib/panel-rows.ts +75 -0
- package/src/lib/panel-tool-options.test.ts +34 -0
- package/src/lib/panel-tool-options.ts +46 -0
- package/src/lib/parametric-node-update.ts +37 -0
- package/src/lib/portable-export.test.ts +89 -0
- package/src/lib/portable-export.ts +84 -11
- package/src/lib/print-shell-compiler-manifold-core.ts +59 -10
- package/src/lib/print-shell-compiler-manifold-worker.ts +14 -1
- package/src/lib/print-shell-compiler-manifold.worker.ts +1 -1
- package/src/lib/print-shell-compiler-protocol.ts +8 -0
- package/src/lib/scene-clipboard.ts +1 -1
- package/src/lib/scene.test.ts +99 -0
- package/src/lib/scene.ts +21 -3
- package/src/lib/send-to-app.test.ts +108 -0
- package/src/lib/send-to-app.ts +121 -0
- package/src/lib/sfx/movement-tick.ts +37 -0
- package/src/lib/snapping-mode.test.ts +13 -2
- package/src/lib/snapping-mode.ts +11 -6
- package/src/lib/spatial-drag-plane.test.ts +53 -0
- package/src/lib/spatial-drag-plane.ts +19 -0
- package/src/lib/spatial-pointer-input.test.ts +72 -0
- package/src/lib/spatial-pointer-input.ts +62 -0
- package/src/lib/spatial-snap.test.ts +47 -0
- package/src/lib/surface-attachment.ts +77 -0
- package/src/lib/terrain-panel-model.ts +117 -0
- package/src/lib/units.ts +254 -0
- package/src/lib/usdz-export.ts +43 -16
- package/src/lib/use-linear-display.ts +8 -32
- package/src/lib/world-grid-snap.test.ts +48 -0
- package/src/lib/world-grid-snap.ts +9 -5
- package/src/store/rotation-snapping.test.ts +53 -0
- package/src/store/use-editor.tsx +10 -2
- package/src/store/use-floorplan-draft-preview.ts +10 -1
- package/src/store/use-handle-group.ts +4 -0
- package/src/store/use-interaction-scope.ts +155 -6
- package/src/store/use-send-to-app.ts +21 -0
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
import { expect, spyOn, test } from 'bun:test'
|
|
2
|
+
import * as core from '@pascal-app/core'
|
|
3
|
+
import {
|
|
4
|
+
type AnyNode,
|
|
5
|
+
type ItemEvent,
|
|
6
|
+
ItemNode,
|
|
7
|
+
nodeRegistry,
|
|
8
|
+
registerNode,
|
|
9
|
+
sceneRegistry,
|
|
10
|
+
useScene,
|
|
11
|
+
} from '@pascal-app/core'
|
|
12
|
+
import { Group } from 'three'
|
|
13
|
+
import { createRegistryItemSurfaceMove } from './item-surface-move'
|
|
14
|
+
|
|
15
|
+
test('a surface-local provider writes full rotation even when the original rotation was scalar', () => {
|
|
16
|
+
const restoreRegistry = nodeRegistry._snapshot()
|
|
17
|
+
const savedNodes = useScene.getState().nodes
|
|
18
|
+
const savedRaf = globalThis.requestAnimationFrame
|
|
19
|
+
const savedCancelRaf = globalThis.cancelAnimationFrame
|
|
20
|
+
const resolver = spyOn(core, 'resolveSurfacePlacement')
|
|
21
|
+
const asset = {
|
|
22
|
+
id: 'host',
|
|
23
|
+
name: 'Host',
|
|
24
|
+
category: 'furniture',
|
|
25
|
+
thumbnail: '',
|
|
26
|
+
src: '/host.glb',
|
|
27
|
+
}
|
|
28
|
+
const host = ItemNode.parse({ id: 'item_scalar-frame-host', asset })
|
|
29
|
+
const child = {
|
|
30
|
+
...ItemNode.parse({ id: 'item_scalar-frame-child', asset }),
|
|
31
|
+
rotation: 0.3,
|
|
32
|
+
} as unknown as AnyNode
|
|
33
|
+
try {
|
|
34
|
+
globalThis.requestAnimationFrame = (callback) => {
|
|
35
|
+
callback(0)
|
|
36
|
+
return 0
|
|
37
|
+
}
|
|
38
|
+
globalThis.cancelAnimationFrame = () => {}
|
|
39
|
+
nodeRegistry._reset()
|
|
40
|
+
registerNode({
|
|
41
|
+
kind: 'item',
|
|
42
|
+
schemaVersion: 1,
|
|
43
|
+
schema: ItemNode,
|
|
44
|
+
category: 'furnish',
|
|
45
|
+
defaults: () => ({}),
|
|
46
|
+
capabilities: {
|
|
47
|
+
hostable: { parents: ['item'], align: 'face' },
|
|
48
|
+
floorPlaced: {},
|
|
49
|
+
},
|
|
50
|
+
})
|
|
51
|
+
useScene.setState({ nodes: { [host.id]: host, [child.id]: child } })
|
|
52
|
+
const object = new Group()
|
|
53
|
+
sceneRegistry.nodes.set(host.id, object)
|
|
54
|
+
resolver.mockReturnValue({
|
|
55
|
+
position: [0.25, 1.5, -0.75],
|
|
56
|
+
rotationY: 0.4,
|
|
57
|
+
surfaceId: 'test-surface',
|
|
58
|
+
childFrame: 'surface-local',
|
|
59
|
+
surfaceLocal: { position: [-0.5, 0, 0.25], rotationY: -0.2, rotation: [0.7, -0.2, 0.8] },
|
|
60
|
+
})
|
|
61
|
+
const session = createRegistryItemSurfaceMove(child)!
|
|
62
|
+
expect(
|
|
63
|
+
session.enter(
|
|
64
|
+
{
|
|
65
|
+
node: host,
|
|
66
|
+
object,
|
|
67
|
+
position: [0, 1, 0],
|
|
68
|
+
localPosition: [0, 1, 0],
|
|
69
|
+
normal: [0, 1, 0],
|
|
70
|
+
nativeEvent: {} as ItemEvent['nativeEvent'],
|
|
71
|
+
stopPropagation() {},
|
|
72
|
+
} as ItemEvent,
|
|
73
|
+
[0.5, 1, 0.5],
|
|
74
|
+
0.3,
|
|
75
|
+
),
|
|
76
|
+
).not.toBeNull()
|
|
77
|
+
expect(useScene.getState().nodes[child.id]).toMatchObject({
|
|
78
|
+
parentId: host.id,
|
|
79
|
+
position: [-0.5, 0, 0.25],
|
|
80
|
+
rotation: [0.7, -0.2, 0.8],
|
|
81
|
+
})
|
|
82
|
+
} finally {
|
|
83
|
+
resolver.mockRestore()
|
|
84
|
+
restoreRegistry()
|
|
85
|
+
sceneRegistry.nodes.delete(host.id)
|
|
86
|
+
useScene.setState({ nodes: savedNodes })
|
|
87
|
+
globalThis.requestAnimationFrame = savedRaf
|
|
88
|
+
globalThis.cancelAnimationFrame = savedCancelRaf
|
|
89
|
+
}
|
|
90
|
+
})
|
|
@@ -0,0 +1,509 @@
|
|
|
1
|
+
import { afterEach, beforeEach, describe, expect, test } from 'bun:test'
|
|
2
|
+
import {
|
|
3
|
+
type AnyNode,
|
|
4
|
+
type AnyNodeId,
|
|
5
|
+
type GridEvent,
|
|
6
|
+
getFloorPlacedElevation,
|
|
7
|
+
getFloorPlacedFootprints,
|
|
8
|
+
type ItemEvent,
|
|
9
|
+
ItemNode,
|
|
10
|
+
LevelNode,
|
|
11
|
+
nodeRegistry,
|
|
12
|
+
resolveSupportSlabPatch,
|
|
13
|
+
sceneRegistry,
|
|
14
|
+
spatialGridManager,
|
|
15
|
+
useLiveTransforms,
|
|
16
|
+
useScene,
|
|
17
|
+
} from '@pascal-app/core'
|
|
18
|
+
import {
|
|
19
|
+
ProceduralItemNode,
|
|
20
|
+
proceduralFootprint,
|
|
21
|
+
shelfRecipe,
|
|
22
|
+
} from '@pascal-app/core/procedural-items'
|
|
23
|
+
import { Group, Vector3 } from 'three'
|
|
24
|
+
import { commitFreshPlacementSubtree } from '../../../lib/fresh-planar-placement'
|
|
25
|
+
import { registerHostingTestNode } from '../__fixtures__/hosting'
|
|
26
|
+
import {
|
|
27
|
+
createItemSurfaceGridDispatch,
|
|
28
|
+
createItemSurfacePointerArbitration,
|
|
29
|
+
createRegistryItemSurfaceMove,
|
|
30
|
+
resolveItemSurfaceGrab,
|
|
31
|
+
} from './item-surface-move'
|
|
32
|
+
|
|
33
|
+
const originalRaf = globalThis.requestAnimationFrame
|
|
34
|
+
const originalCancelRaf = globalThis.cancelAnimationFrame
|
|
35
|
+
|
|
36
|
+
const dimensions: [number, number, number] = [1, 1, 0.5]
|
|
37
|
+
const original = ProceduralItemNode.parse({
|
|
38
|
+
id: 'procedural-item_moving',
|
|
39
|
+
parentId: 'level_surface-move',
|
|
40
|
+
recipe: shelfRecipe,
|
|
41
|
+
position: [1, 0, 2],
|
|
42
|
+
rotation: [0.1, 0.3, 0.2],
|
|
43
|
+
supportSlabId: 'ground',
|
|
44
|
+
}) as unknown as AnyNode & {
|
|
45
|
+
position: [number, number, number]
|
|
46
|
+
rotation: [number, number, number]
|
|
47
|
+
}
|
|
48
|
+
const host = ItemNode.parse({
|
|
49
|
+
id: 'item_surface-move',
|
|
50
|
+
parentId: 'level_surface-move',
|
|
51
|
+
position: [4, 0, 5],
|
|
52
|
+
rotation: [0, 0.6, 0],
|
|
53
|
+
asset: {
|
|
54
|
+
id: 'table',
|
|
55
|
+
name: 'Table',
|
|
56
|
+
category: 'furniture',
|
|
57
|
+
thumbnail: '',
|
|
58
|
+
src: '/table.glb',
|
|
59
|
+
dimensions: [3, 1, 3],
|
|
60
|
+
},
|
|
61
|
+
})
|
|
62
|
+
let restoreRegistry: () => void
|
|
63
|
+
let oldNodes: ReturnType<typeof useScene.getState>['nodes']
|
|
64
|
+
let oldRoots: AnyNodeId[]
|
|
65
|
+
|
|
66
|
+
beforeEach(() => {
|
|
67
|
+
globalThis.requestAnimationFrame = (callback) => {
|
|
68
|
+
callback(0)
|
|
69
|
+
return 0
|
|
70
|
+
}
|
|
71
|
+
globalThis.cancelAnimationFrame = () => {}
|
|
72
|
+
restoreRegistry = nodeRegistry._snapshot()
|
|
73
|
+
oldNodes = useScene.getState().nodes
|
|
74
|
+
oldRoots = useScene.getState().rootNodeIds
|
|
75
|
+
nodeRegistry._reset()
|
|
76
|
+
registerHostingTestNode({
|
|
77
|
+
kind: 'item',
|
|
78
|
+
schemaVersion: 1,
|
|
79
|
+
schema: ItemNode,
|
|
80
|
+
category: 'furnish',
|
|
81
|
+
defaults: () => ({}),
|
|
82
|
+
capabilities: {},
|
|
83
|
+
})
|
|
84
|
+
registerHostingTestNode({
|
|
85
|
+
kind: 'procedural-item',
|
|
86
|
+
schemaVersion: 1,
|
|
87
|
+
schema: ProceduralItemNode,
|
|
88
|
+
category: 'furnish',
|
|
89
|
+
defaults: () => ({}),
|
|
90
|
+
capabilities: {
|
|
91
|
+
hostable: { parents: ['level', 'item'], align: 'face' },
|
|
92
|
+
floorPlaced: {
|
|
93
|
+
applies: (n) => !(n as unknown as ProceduralItemNode).wallId,
|
|
94
|
+
footprint: (n) => proceduralFootprint(n as unknown as ProceduralItemNode),
|
|
95
|
+
collides: true,
|
|
96
|
+
},
|
|
97
|
+
},
|
|
98
|
+
})
|
|
99
|
+
const level = LevelNode.parse({ id: 'level_surface-move', children: [original.id, host.id] })
|
|
100
|
+
useScene.setState({
|
|
101
|
+
nodes: { [level.id]: level, [original.id]: original, [host.id]: host },
|
|
102
|
+
rootNodeIds: [level.id],
|
|
103
|
+
})
|
|
104
|
+
useScene.temporal.getState().clear()
|
|
105
|
+
useScene.temporal.getState().pause()
|
|
106
|
+
const levelMesh = new Group()
|
|
107
|
+
levelMesh.position.set(10, 3, 20)
|
|
108
|
+
levelMesh.rotation.y = 0.4
|
|
109
|
+
const hostMesh = new Group()
|
|
110
|
+
hostMesh.position.set(...host.position)
|
|
111
|
+
hostMesh.rotation.set(...host.rotation)
|
|
112
|
+
levelMesh.add(hostMesh)
|
|
113
|
+
levelMesh.updateMatrixWorld(true)
|
|
114
|
+
sceneRegistry.nodes.set(level.id, levelMesh)
|
|
115
|
+
sceneRegistry.nodes.set(host.id, hostMesh)
|
|
116
|
+
})
|
|
117
|
+
|
|
118
|
+
afterEach(() => {
|
|
119
|
+
globalThis.requestAnimationFrame = originalRaf
|
|
120
|
+
globalThis.cancelAnimationFrame = originalCancelRaf
|
|
121
|
+
restoreRegistry()
|
|
122
|
+
useLiveTransforms.getState().clear(original.id)
|
|
123
|
+
for (const id of ['level_surface-move', host.id, 'item_second-host'])
|
|
124
|
+
sceneRegistry.nodes.delete(id)
|
|
125
|
+
useScene.setState({ nodes: oldNodes, rootNodeIds: oldRoots })
|
|
126
|
+
useScene.temporal.getState().clear()
|
|
127
|
+
useScene.temporal.getState().resume()
|
|
128
|
+
})
|
|
129
|
+
|
|
130
|
+
function eventFor(item = host, local: [number, number, number] = [0.2, 1, 0.3]) {
|
|
131
|
+
const mesh = sceneRegistry.nodes.get(item.id)!
|
|
132
|
+
let stopped = false
|
|
133
|
+
const event = {
|
|
134
|
+
node: item,
|
|
135
|
+
object: mesh,
|
|
136
|
+
normal: [0, 1, 0],
|
|
137
|
+
localPosition: local,
|
|
138
|
+
position: mesh.localToWorld(new Vector3(...local)).toArray(),
|
|
139
|
+
stopPropagation: () => {
|
|
140
|
+
stopped = true
|
|
141
|
+
},
|
|
142
|
+
nativeEvent: {},
|
|
143
|
+
} as ItemEvent
|
|
144
|
+
return { event, stopped: () => stopped }
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
describe('registry item-surface move session', () => {
|
|
148
|
+
test('a hidden fresh draft survives effect replay and can still host and commit', async () => {
|
|
149
|
+
useScene.getState().updateNode(original.id, { metadata: { isNew: true }, visible: false })
|
|
150
|
+
const draft = useScene.getState().nodes[original.id]!
|
|
151
|
+
const session = createRegistryItemSurfaceMove(draft)!
|
|
152
|
+
session.restore()
|
|
153
|
+
await Promise.resolve()
|
|
154
|
+
expect(useScene.getState().nodes[draft.id]).toBe(draft)
|
|
155
|
+
const pose = session.enter(eventFor().event, dimensions, 0.3)!
|
|
156
|
+
expect(session.hosted).toBe(true)
|
|
157
|
+
const finalId = commitFreshPlacementSubtree(draft.id, { visible: true })!
|
|
158
|
+
expect(useScene.getState().nodes[finalId]).toMatchObject({
|
|
159
|
+
parentId: host.id,
|
|
160
|
+
position: pose.position,
|
|
161
|
+
})
|
|
162
|
+
expect(useScene.temporal.getState().pastStates).toHaveLength(1)
|
|
163
|
+
})
|
|
164
|
+
|
|
165
|
+
test('cleanup restores a fresh hosted draft without deleting it or recording history', async () => {
|
|
166
|
+
useScene.getState().updateNode(original.id, { metadata: { isNew: true }, visible: false })
|
|
167
|
+
const draft = useScene.getState().nodes[original.id]!
|
|
168
|
+
const session = createRegistryItemSurfaceMove(draft)!
|
|
169
|
+
session.enter(eventFor().event, dimensions, 0.3)
|
|
170
|
+
session.restore()
|
|
171
|
+
await Promise.resolve()
|
|
172
|
+
expect(useScene.getState().nodes[original.id]).toEqual(draft)
|
|
173
|
+
expect(useScene.temporal.getState().pastStates).toHaveLength(0)
|
|
174
|
+
expect((useScene.getState().nodes[host.id] as ItemNode).children as string[]).not.toContain(
|
|
175
|
+
original.id,
|
|
176
|
+
)
|
|
177
|
+
expect(
|
|
178
|
+
(useScene.getState().nodes['level_surface-move'] as LevelNode).children as string[],
|
|
179
|
+
).toContain(original.id)
|
|
180
|
+
expect(session.enter(eventFor().event, dimensions, 0.3)).not.toBeNull()
|
|
181
|
+
})
|
|
182
|
+
|
|
183
|
+
test('grid arbitration matches the native pointer event', () => {
|
|
184
|
+
const pointer = createItemSurfacePointerArbitration()
|
|
185
|
+
const native = {}
|
|
186
|
+
expect(pointer.blocksGrid(native)).toBe(false)
|
|
187
|
+
pointer.hit(host.id, native)
|
|
188
|
+
expect(pointer.blocksGrid(native)).toBe(true)
|
|
189
|
+
expect(pointer.blocksGrid({})).toBe(false)
|
|
190
|
+
pointer.clear()
|
|
191
|
+
expect(pointer.blocksGrid(native)).toBe(false)
|
|
192
|
+
})
|
|
193
|
+
|
|
194
|
+
test('canvas grid waits for wrapper host dispatch, including spaced moves; an unmatched grid detaches', async () => {
|
|
195
|
+
const session = createRegistryItemSurfaceMove(original)!
|
|
196
|
+
let yaw = 0.3
|
|
197
|
+
let applied = 0
|
|
198
|
+
const dispatch = createItemSurfaceGridDispatch((grid) => {
|
|
199
|
+
applied += 1
|
|
200
|
+
if (!session.blocksGrid(grid)) session.detach(grid.position, yaw)
|
|
201
|
+
})
|
|
202
|
+
for (let move = 0; move < 3; move += 1) {
|
|
203
|
+
const hit = eventFor().event
|
|
204
|
+
const native = {}
|
|
205
|
+
const grid = { position: hit.position, nativeEvent: native } as GridEvent
|
|
206
|
+
hit.nativeEvent = { nativeEvent: native } as ItemEvent['nativeEvent']
|
|
207
|
+
dispatch.schedule(grid)
|
|
208
|
+
const before = applied
|
|
209
|
+
await Promise.resolve()
|
|
210
|
+
expect(applied).toBe(before)
|
|
211
|
+
const pose = session.enter(hit, dimensions, yaw)!
|
|
212
|
+
yaw = pose.rotationY
|
|
213
|
+
await new Promise((resolve) => setTimeout(resolve, 5))
|
|
214
|
+
expect(session.hosted).toBe(true)
|
|
215
|
+
expect(useScene.getState().nodes[original.id]?.parentId).toBe(host.id)
|
|
216
|
+
}
|
|
217
|
+
expect(applied).toBe(3)
|
|
218
|
+
dispatch.schedule({ position: [0, 0, 0], nativeEvent: {} } as GridEvent)
|
|
219
|
+
dispatch.flush()
|
|
220
|
+
expect(session.hosted).toBe(false)
|
|
221
|
+
expect(applied).toBe(4)
|
|
222
|
+
dispatch.schedule({ position: [0, 0, 0], nativeEvent: {} } as GridEvent)
|
|
223
|
+
dispatch.cancel()
|
|
224
|
+
await new Promise((resolve) => setTimeout(resolve, 5))
|
|
225
|
+
expect(applied).toBe(4)
|
|
226
|
+
})
|
|
227
|
+
|
|
228
|
+
test('grid after a host hit preserves hosting; a real leave immediately detaches', () => {
|
|
229
|
+
const session = createRegistryItemSurfaceMove(original)!
|
|
230
|
+
const hit = eventFor()
|
|
231
|
+
const pose = session.enter(hit.event, dimensions, 0.3)!
|
|
232
|
+
if (!session.blocksGrid(hit.event as unknown as GridEvent))
|
|
233
|
+
session.detach([0, 0, 0], pose.rotationY)
|
|
234
|
+
expect(useScene.getState().nodes[original.id]?.parentId).toBe(host.id)
|
|
235
|
+
expect(
|
|
236
|
+
session.leave({ ...hit.event, node: { ...host, id: 'item_other' } }, pose.rotationY),
|
|
237
|
+
).toBeNull()
|
|
238
|
+
expect(session.hosted).toBe(true)
|
|
239
|
+
expect(session.leave(hit.event, pose.rotationY)).not.toBeNull()
|
|
240
|
+
expect(session.hosted).toBe(false)
|
|
241
|
+
expect(session.blocksGrid(hit.event as unknown as GridEvent)).toBe(false)
|
|
242
|
+
})
|
|
243
|
+
|
|
244
|
+
test('a rejected surface hit permits the paired grid to detach without stopping propagation', () => {
|
|
245
|
+
const session = createRegistryItemSurfaceMove(original)!
|
|
246
|
+
const pose = session.enter(eventFor().event, dimensions, 0.3)!
|
|
247
|
+
const hit = eventFor()
|
|
248
|
+
hit.event.normal = [1, 0, 0]
|
|
249
|
+
expect(session.enter(hit.event, dimensions, pose.rotationY)).toBeNull()
|
|
250
|
+
expect(hit.stopped()).toBe(false)
|
|
251
|
+
expect(session.blocksGrid(hit.event as unknown as GridEvent)).toBe(false)
|
|
252
|
+
session.detach(hit.event.position, pose.rotationY)
|
|
253
|
+
expect(session.hosted).toBe(false)
|
|
254
|
+
})
|
|
255
|
+
|
|
256
|
+
test('hosted R/T rotates around the stored local position under a translated and rotated host', () => {
|
|
257
|
+
const session = createRegistryItemSurfaceMove(original)!
|
|
258
|
+
const pose = session.enter(eventFor().event, dimensions, 0.3)!
|
|
259
|
+
const initialPlan = session.planPose(pose.position, pose.rotationY)
|
|
260
|
+
for (const yaw of [pose.rotationY + Math.PI / 4, pose.rotationY]) {
|
|
261
|
+
const rotated = session.rotate(yaw)!
|
|
262
|
+
expect(rotated.position).toEqual(pose.position)
|
|
263
|
+
expect(session.planPose(rotated.position, yaw).position).toEqual(initialPlan.position)
|
|
264
|
+
expect(useScene.getState().nodes[original.id]).toMatchObject({
|
|
265
|
+
parentId: host.id,
|
|
266
|
+
position: pose.position,
|
|
267
|
+
rotation: [0.1, yaw, 0.2],
|
|
268
|
+
})
|
|
269
|
+
}
|
|
270
|
+
})
|
|
271
|
+
|
|
272
|
+
test('pure grab math preserves offset on the original host and forgets it on a host switch', () => {
|
|
273
|
+
const first = resolveItemSurfaceGrab(
|
|
274
|
+
{ hostId: host.id, start: [0.5, 1, -0.5], anchor: null },
|
|
275
|
+
host.id,
|
|
276
|
+
[0.2, 1, 0.3],
|
|
277
|
+
)
|
|
278
|
+
expect(first.position).toEqual([0.5, 1, -0.5])
|
|
279
|
+
const moved = resolveItemSurfaceGrab(first.grab, host.id, [0.4, 1, 0.6])
|
|
280
|
+
expect(moved.position[0]).toBeCloseTo(0.7)
|
|
281
|
+
expect(moved.position[2]).toBeCloseTo(-0.2)
|
|
282
|
+
const switched = resolveItemSurfaceGrab(moved.grab, 'item_second-host', [1, 1, 2])
|
|
283
|
+
expect(switched).toEqual({ grab: null, position: [1, 1, 2] })
|
|
284
|
+
expect(resolveItemSurfaceGrab(switched.grab, host.id, [0.2, 1, 0.3]).position).toEqual([
|
|
285
|
+
0.2, 1, 0.3,
|
|
286
|
+
])
|
|
287
|
+
})
|
|
288
|
+
|
|
289
|
+
test('moving an existing hosted design preserves its grab until detach, then centers on return', () => {
|
|
290
|
+
useScene
|
|
291
|
+
.getState()
|
|
292
|
+
.updateNode(original.id, { parentId: host.id, position: [0.5, 1, -0.5] } as Partial<AnyNode>)
|
|
293
|
+
const session = createRegistryItemSurfaceMove(useScene.getState().nodes[original.id]!)!
|
|
294
|
+
let pose = session.enter(eventFor().event, dimensions, 0.3)!
|
|
295
|
+
expect(pose.position[0]).toBeCloseTo(0.5)
|
|
296
|
+
expect(pose.position[2]).toBeCloseTo(-0.5)
|
|
297
|
+
pose = session.enter(eventFor(host, [0.4, 1, 0.6]).event, dimensions, pose.rotationY)!
|
|
298
|
+
expect(pose.position[0]).toBeCloseTo(0.7)
|
|
299
|
+
expect(pose.position[2]).toBeCloseTo(-0.2)
|
|
300
|
+
const floor = session.detach(eventFor().event.position, pose.rotationY)!
|
|
301
|
+
pose = session.enter(eventFor().event, dimensions, floor.rotationY)!
|
|
302
|
+
expect(pose.position[0]).toBeCloseTo(0.2)
|
|
303
|
+
expect(pose.position[2]).toBeCloseTo(0.3)
|
|
304
|
+
})
|
|
305
|
+
|
|
306
|
+
test('reparents previews, keeps the box in the level frame, and clears floor support and live transforms', () => {
|
|
307
|
+
const session = createRegistryItemSurfaceMove(original)!
|
|
308
|
+
useLiveTransforms.getState().set(original.id, { position: [7, 0, 9], rotation: 0.3 })
|
|
309
|
+
const hit = eventFor()
|
|
310
|
+
const pose = session.enter(hit.event, dimensions, 0.3)!
|
|
311
|
+
expect(hit.stopped()).toBe(true)
|
|
312
|
+
expect(session.hosted).toBe(true)
|
|
313
|
+
expect(useLiveTransforms.getState().get(original.id)).toBeUndefined()
|
|
314
|
+
const live = useScene.getState().nodes[original.id]!
|
|
315
|
+
expect(live.parentId).toBe(host.id)
|
|
316
|
+
expect((useScene.getState().nodes[host.id] as ItemNode).children as string[]).toContain(
|
|
317
|
+
original.id,
|
|
318
|
+
)
|
|
319
|
+
expect((useScene.getState().nodes['level_surface-move'] as LevelNode).children).not.toContain(
|
|
320
|
+
original.id,
|
|
321
|
+
)
|
|
322
|
+
expect(session.worldYaw(pose.rotationY)).toBeCloseTo(0.7)
|
|
323
|
+
const plan = session.planPose(pose.position, pose.rotationY)
|
|
324
|
+
expect(plan.rotationY).toBeCloseTo(0.3)
|
|
325
|
+
expect(plan.position[0]).toBeCloseTo(4 + 0.2 * Math.cos(0.6) + 0.3 * Math.sin(0.6))
|
|
326
|
+
expect(plan.position[1]).toBeCloseTo(1)
|
|
327
|
+
expect(
|
|
328
|
+
getFloorPlacedElevation({
|
|
329
|
+
node: live,
|
|
330
|
+
nodes: useScene.getState().nodes,
|
|
331
|
+
position: pose.position,
|
|
332
|
+
}),
|
|
333
|
+
).toBe(0)
|
|
334
|
+
expect(
|
|
335
|
+
resolveSupportSlabPatch(live, useScene.getState().nodes, {
|
|
336
|
+
preferredSlabId: 'slab_above',
|
|
337
|
+
pinSupport: true,
|
|
338
|
+
}),
|
|
339
|
+
).toEqual({ supportSlabId: undefined })
|
|
340
|
+
expect(useScene.temporal.getState().pastStates).toHaveLength(0)
|
|
341
|
+
})
|
|
342
|
+
|
|
343
|
+
test('invalid hosts leave propagation and the scene untouched', () => {
|
|
344
|
+
const session = createRegistryItemSurfaceMove(original)!
|
|
345
|
+
expect(session.enter(eventFor().event, [4, 1, 4], 0.3)).not.toBeNull()
|
|
346
|
+
session.restore()
|
|
347
|
+
const restored = useScene.getState().nodes[original.id]
|
|
348
|
+
const hit = eventFor(host, [2, 1, 0])
|
|
349
|
+
expect(session.enter(hit.event, [4, 1, 4], 0.3)).toBeNull()
|
|
350
|
+
expect(hit.stopped()).toBe(false)
|
|
351
|
+
expect(useScene.getState().nodes[original.id]).toBe(restored)
|
|
352
|
+
expect(
|
|
353
|
+
createRegistryItemSurfaceMove({ ...original, wallId: 'wall_test' } as AnyNode),
|
|
354
|
+
).toBeNull()
|
|
355
|
+
expect(createRegistryItemSurfaceMove(host)).toBeNull()
|
|
356
|
+
})
|
|
357
|
+
|
|
358
|
+
test('moves across and between hosts, then detaches at the level-local cursor without rotating', () => {
|
|
359
|
+
const session = createRegistryItemSurfaceMove(original)!
|
|
360
|
+
let pose = session.enter(eventFor().event, dimensions, 0.3)!
|
|
361
|
+
pose = session.enter(eventFor(host, [0.7, 1, -0.4]).event, dimensions, pose.rotationY)!
|
|
362
|
+
expect(pose.position[0]).toBeCloseTo(0.7)
|
|
363
|
+
const second = {
|
|
364
|
+
...host,
|
|
365
|
+
id: 'item_second-host',
|
|
366
|
+
rotation: [0, -0.8, 0],
|
|
367
|
+
position: [-2, 0, 1],
|
|
368
|
+
children: [],
|
|
369
|
+
} as ItemNode
|
|
370
|
+
useScene.getState().createNode(second, host.parentId as AnyNodeId)
|
|
371
|
+
const mesh = new Group()
|
|
372
|
+
mesh.rotation.set(...second.rotation)
|
|
373
|
+
mesh.position.set(...second.position)
|
|
374
|
+
sceneRegistry.nodes.get('level_surface-move')!.add(mesh)
|
|
375
|
+
sceneRegistry.nodes.set(second.id, mesh)
|
|
376
|
+
pose = session.enter(eventFor(second).event, dimensions, pose.rotationY)!
|
|
377
|
+
expect(session.worldYaw(pose.rotationY)).toBeCloseTo(0.7)
|
|
378
|
+
const world = sceneRegistry.nodes.get('level_surface-move')!.localToWorld(new Vector3(8, 2, 9))
|
|
379
|
+
const floor = session.detach(world.toArray(), pose.rotationY)!
|
|
380
|
+
expect(floor.position[0]).toBeCloseTo(8)
|
|
381
|
+
expect(floor.position[1]).toBe(0)
|
|
382
|
+
expect(floor.position[2]).toBeCloseTo(9)
|
|
383
|
+
expect(floor.rotationY).toBeCloseTo(0.3)
|
|
384
|
+
expect(session.hosted).toBe(false)
|
|
385
|
+
expect(useScene.getState().nodes[original.id]?.parentId).toBe('level_surface-move')
|
|
386
|
+
})
|
|
387
|
+
|
|
388
|
+
test('restores parent and full pose for cancellation, including a drag that starts hosted', () => {
|
|
389
|
+
const session = createRegistryItemSurfaceMove(original)!
|
|
390
|
+
session.enter(eventFor().event, dimensions, 0.3)
|
|
391
|
+
const hosted = useScene.getState().nodes[original.id]!
|
|
392
|
+
const hostedSession = createRegistryItemSurfaceMove(hosted)!
|
|
393
|
+
hostedSession.detach([0, 0, 0], -0.3)
|
|
394
|
+
hostedSession.restore()
|
|
395
|
+
expect(useScene.getState().nodes[original.id]).toEqual(hosted)
|
|
396
|
+
session.restore()
|
|
397
|
+
expect(useScene.getState().nodes[original.id]).toEqual(original)
|
|
398
|
+
expect((useScene.getState().nodes[host.id] as ItemNode).children as string[]).not.toContain(
|
|
399
|
+
original.id,
|
|
400
|
+
)
|
|
401
|
+
expect(useScene.temporal.getState().pastStates).toHaveLength(0)
|
|
402
|
+
})
|
|
403
|
+
|
|
404
|
+
test('restoring before the tracked commit makes hosting one undo step with the original parent and pose', () => {
|
|
405
|
+
const session = createRegistryItemSurfaceMove(original)!
|
|
406
|
+
session.enter(eventFor().event, dimensions, 0.3)
|
|
407
|
+
const final = useScene.getState().nodes[original.id]!
|
|
408
|
+
session.restore()
|
|
409
|
+
useScene.temporal.getState().resume()
|
|
410
|
+
useScene.getState().updateNodes([
|
|
411
|
+
{
|
|
412
|
+
id: original.id,
|
|
413
|
+
data: { ...final, ...resolveSupportSlabPatch(final, useScene.getState().nodes) },
|
|
414
|
+
},
|
|
415
|
+
])
|
|
416
|
+
useScene.temporal.getState().pause()
|
|
417
|
+
expect(useScene.temporal.getState().pastStates).toHaveLength(1)
|
|
418
|
+
useScene.temporal.getState().undo()
|
|
419
|
+
expect(useScene.getState().nodes[original.id]).toEqual(original)
|
|
420
|
+
expect((useScene.getState().nodes[host.id] as ItemNode).children as string[]).not.toContain(
|
|
421
|
+
original.id,
|
|
422
|
+
)
|
|
423
|
+
useScene.temporal.getState().redo()
|
|
424
|
+
expect(useScene.getState().nodes[original.id]).toEqual(final)
|
|
425
|
+
})
|
|
426
|
+
|
|
427
|
+
test('fresh procedural placements commit directly to a host and undo removes the entire placement', () => {
|
|
428
|
+
useScene.getState().updateNode(original.id, { metadata: { isNew: true } })
|
|
429
|
+
const session = createRegistryItemSurfaceMove(useScene.getState().nodes[original.id]!)!
|
|
430
|
+
const pose = session.enter(eventFor().event, dimensions, 0.3)!
|
|
431
|
+
const finalId = commitFreshPlacementSubtree(original.id, { parentId: host.id, visible: true })!
|
|
432
|
+
expect(finalId).toBeTruthy()
|
|
433
|
+
expect(useScene.getState().nodes[finalId]?.parentId).toBe(host.id)
|
|
434
|
+
expect(useScene.getState().nodes[finalId]).toMatchObject({
|
|
435
|
+
position: pose.position,
|
|
436
|
+
rotation: [0.1, pose.rotationY, 0.2],
|
|
437
|
+
})
|
|
438
|
+
expect((useScene.getState().nodes[host.id] as ItemNode).children as string[]).toContain(finalId)
|
|
439
|
+
expect(useScene.temporal.getState().pastStates).toHaveLength(1)
|
|
440
|
+
useScene.temporal.getState().undo()
|
|
441
|
+
expect(useScene.getState().nodes[finalId]).toBeUndefined()
|
|
442
|
+
expect(useScene.getState().nodes[original.id]).toBeUndefined()
|
|
443
|
+
expect((useScene.getState().nodes[host.id] as ItemNode).children as string[]).toEqual([])
|
|
444
|
+
})
|
|
445
|
+
|
|
446
|
+
test.each([
|
|
447
|
+
'floor',
|
|
448
|
+
'same host',
|
|
449
|
+
'floor then host',
|
|
450
|
+
])('a hosted move to %s commits once and undo restores the original parent and pose', (destination) => {
|
|
451
|
+
const initial = createRegistryItemSurfaceMove(original)!
|
|
452
|
+
const hostedPose = initial.enter(eventFor().event, dimensions, 0.3)!
|
|
453
|
+
const hosted = useScene.getState().nodes[original.id]!
|
|
454
|
+
const session = createRegistryItemSurfaceMove(hosted)!
|
|
455
|
+
let pose: { position: [number, number, number]; rotationY: number } = session.enter(
|
|
456
|
+
eventFor().event,
|
|
457
|
+
dimensions,
|
|
458
|
+
hostedPose.rotationY,
|
|
459
|
+
)!
|
|
460
|
+
if (destination !== 'same host') {
|
|
461
|
+
const world = sceneRegistry.nodes
|
|
462
|
+
.get('level_surface-move')!
|
|
463
|
+
.localToWorld(new Vector3(8, 0, 9))
|
|
464
|
+
pose = session.detach(world.toArray(), pose.rotationY)!
|
|
465
|
+
const detached = useScene.getState().nodes[original.id]!
|
|
466
|
+
expect(
|
|
467
|
+
getFloorPlacedElevation({
|
|
468
|
+
node: detached,
|
|
469
|
+
nodes: useScene.getState().nodes,
|
|
470
|
+
position: pose.position,
|
|
471
|
+
maxElevation: 0,
|
|
472
|
+
}),
|
|
473
|
+
).toBe(0)
|
|
474
|
+
const footprints = getFloorPlacedFootprints(
|
|
475
|
+
nodeRegistry.get(original.type)!.capabilities.floorPlaced!,
|
|
476
|
+
detached,
|
|
477
|
+
{ nodes: useScene.getState().nodes },
|
|
478
|
+
).map((footprint) => ({ ...footprint, position: footprint.position ?? pose.position }))
|
|
479
|
+
expect(
|
|
480
|
+
spatialGridManager.canPlaceOnFloorFootprints('level_surface-move', footprints, [
|
|
481
|
+
original.id,
|
|
482
|
+
]).valid,
|
|
483
|
+
).toBe(true)
|
|
484
|
+
}
|
|
485
|
+
if (destination !== 'floor') {
|
|
486
|
+
pose = session.enter(eventFor(host, [0.6, 1, -0.4]).event, dimensions, pose.rotationY)!
|
|
487
|
+
}
|
|
488
|
+
const final = useScene.getState().nodes[original.id]!
|
|
489
|
+
const patch = {
|
|
490
|
+
...final,
|
|
491
|
+
...resolveSupportSlabPatch(final, useScene.getState().nodes, { maxElevation: 0 }),
|
|
492
|
+
}
|
|
493
|
+
session.restore()
|
|
494
|
+
useScene.temporal.getState().resume()
|
|
495
|
+
useScene.getState().updateNodes([{ id: original.id, data: patch }])
|
|
496
|
+
useScene.temporal.getState().pause()
|
|
497
|
+
expect(useScene.getState().nodes[original.id]?.parentId).toBe(
|
|
498
|
+
destination === 'floor' ? 'level_surface-move' : host.id,
|
|
499
|
+
)
|
|
500
|
+
expect(useScene.temporal.getState().pastStates).toHaveLength(1)
|
|
501
|
+
useScene.temporal.getState().undo()
|
|
502
|
+
expect(useScene.getState().nodes[original.id]).toEqual(hosted)
|
|
503
|
+
expect((useScene.getState().nodes[host.id] as ItemNode).children as string[]).toContain(
|
|
504
|
+
original.id,
|
|
505
|
+
)
|
|
506
|
+
useScene.temporal.getState().redo()
|
|
507
|
+
expect(useScene.getState().nodes[original.id]).toEqual(patch)
|
|
508
|
+
})
|
|
509
|
+
})
|