@abraca/nuxt 2.0.1 → 2.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/dist/module.d.mts +18 -7
- package/dist/module.json +1 -1
- package/dist/module.mjs +21 -5
- package/dist/runtime/assets/aware-tokens.css +1 -0
- package/dist/runtime/components/AAccountSwitcherModal.d.vue.ts +16 -1
- package/dist/runtime/components/AAccountSwitcherModal.vue +33 -4
- package/dist/runtime/components/AAccountSwitcherModal.vue.d.ts +16 -1
- package/dist/runtime/components/AAuthLinkLanding.d.vue.ts +3 -0
- package/dist/runtime/components/AAuthLinkLanding.vue +85 -0
- package/dist/runtime/components/AAuthLinkLanding.vue.d.ts +3 -0
- package/dist/runtime/components/AClaimAccountModal.d.vue.ts +7 -1
- package/dist/runtime/components/AClaimAccountModal.vue +28 -13
- package/dist/runtime/components/AClaimAccountModal.vue.d.ts +7 -1
- package/dist/runtime/components/AEmailVerifyConfirmModal.d.vue.ts +30 -0
- package/dist/runtime/components/AEmailVerifyConfirmModal.vue +100 -0
- package/dist/runtime/components/AEmailVerifyConfirmModal.vue.d.ts +30 -0
- package/dist/runtime/components/AEmailVerifyRequestCard.d.vue.ts +22 -0
- package/dist/runtime/components/AEmailVerifyRequestCard.vue +65 -0
- package/dist/runtime/components/AEmailVerifyRequestCard.vue.d.ts +22 -0
- package/dist/runtime/components/AMnemonicLoginModal.d.vue.ts +1 -1
- package/dist/runtime/components/AMnemonicLoginModal.vue.d.ts +1 -1
- package/dist/runtime/components/ANodePanel.vue +2 -0
- package/dist/runtime/components/ANotificationBell.d.vue.ts +2 -2
- package/dist/runtime/components/ANotificationBell.vue.d.ts +2 -2
- package/dist/runtime/components/APasswordChangeModal.d.vue.ts +28 -0
- package/dist/runtime/components/APasswordChangeModal.vue +178 -0
- package/dist/runtime/components/APasswordChangeModal.vue.d.ts +28 -0
- package/dist/runtime/components/APasswordLoginModal.d.vue.ts +42 -0
- package/dist/runtime/components/APasswordLoginModal.vue +177 -0
- package/dist/runtime/components/APasswordLoginModal.vue.d.ts +42 -0
- package/dist/runtime/components/APasswordRegisterModal.d.vue.ts +49 -0
- package/dist/runtime/components/APasswordRegisterModal.vue +262 -0
- package/dist/runtime/components/APasswordRegisterModal.vue.d.ts +49 -0
- package/dist/runtime/components/APasswordResetConfirmModal.d.vue.ts +31 -0
- package/dist/runtime/components/APasswordResetConfirmModal.vue +154 -0
- package/dist/runtime/components/APasswordResetConfirmModal.vue.d.ts +31 -0
- package/dist/runtime/components/APasswordResetRequestModal.d.vue.ts +35 -0
- package/dist/runtime/components/APasswordResetRequestModal.vue +113 -0
- package/dist/runtime/components/APasswordResetRequestModal.vue.d.ts +35 -0
- package/dist/runtime/components/ASetPasswordCard.d.vue.ts +26 -0
- package/dist/runtime/components/ASetPasswordCard.vue +139 -0
- package/dist/runtime/components/ASetPasswordCard.vue.d.ts +26 -0
- package/dist/runtime/components/aware/AAccordion.d.vue.ts +2 -0
- package/dist/runtime/components/aware/AAccordion.vue +11 -1
- package/dist/runtime/components/aware/AAccordion.vue.d.ts +2 -0
- package/dist/runtime/components/aware/AButton.vue +3 -3
- package/dist/runtime/components/aware/ACollapsible.d.vue.ts +2 -0
- package/dist/runtime/components/aware/ACollapsible.vue +9 -1
- package/dist/runtime/components/aware/ACollapsible.vue.d.ts +2 -0
- package/dist/runtime/components/aware/AGlobalFocusLayer.vue +1 -1
- package/dist/runtime/components/aware/AHoverItem.vue +28 -3
- package/dist/runtime/components/aware/AMedia.d.vue.ts +1 -1
- package/dist/runtime/components/aware/AMedia.vue.d.ts +1 -1
- package/dist/runtime/components/aware/AModal.d.vue.ts +2 -0
- package/dist/runtime/components/aware/AModal.vue +9 -1
- package/dist/runtime/components/aware/AModal.vue.d.ts +2 -0
- package/dist/runtime/components/aware/APresenceBlobs.vue +1 -1
- package/dist/runtime/components/aware/APresenceCursors.vue +1 -1
- package/dist/runtime/components/aware/AScroll.d.vue.ts +2 -0
- package/dist/runtime/components/aware/AScroll.vue +13 -3
- package/dist/runtime/components/aware/AScroll.vue.d.ts +2 -0
- package/dist/runtime/components/aware/ASlideover.d.vue.ts +2 -0
- package/dist/runtime/components/aware/ASlideover.vue +9 -1
- package/dist/runtime/components/aware/ASlideover.vue.d.ts +2 -0
- package/dist/runtime/components/aware/ASlider.vue +1 -0
- package/dist/runtime/components/aware/ATabs.d.vue.ts +2 -0
- package/dist/runtime/components/aware/ATabs.vue +9 -1
- package/dist/runtime/components/aware/ATabs.vue.d.ts +2 -0
- package/dist/runtime/components/chat/ANodeChatPanel.vue +1 -0
- package/dist/runtime/components/editor/AEditorRedoButton.d.vue.ts +2 -2
- package/dist/runtime/components/editor/AEditorRedoButton.vue.d.ts +2 -2
- package/dist/runtime/components/editor/AEditorUndoButton.d.vue.ts +2 -2
- package/dist/runtime/components/editor/AEditorUndoButton.vue.d.ts +2 -2
- package/dist/runtime/components/shell/AUserMenu.d.vue.ts +2 -2
- package/dist/runtime/components/shell/AUserMenu.vue.d.ts +2 -2
- package/dist/runtime/components/shell/AUserProfilePopover.d.vue.ts +1 -1
- package/dist/runtime/components/shell/AUserProfilePopover.vue.d.ts +1 -1
- package/dist/runtime/composables/useAAField.js +7 -4
- package/dist/runtime/composables/useAAFocus.js +10 -5
- package/dist/runtime/composables/useAAFollowAnchor.js +68 -34
- package/dist/runtime/composables/useAAFollowPeer.d.ts +7 -4
- package/dist/runtime/composables/useAAFollowPeer.js +60 -11
- package/dist/runtime/composables/useAAViewport.d.ts +1 -1
- package/dist/runtime/composables/useAbracadabraAuth.d.ts +2 -0
- package/dist/runtime/composables/useAbracadabraAuth.js +2 -0
- package/dist/runtime/composables/useEmailVerification.d.ts +40 -26
- package/dist/runtime/composables/useEmailVerification.js +95 -43
- package/dist/runtime/composables/usePasswordAuth.d.ts +64 -0
- package/dist/runtime/composables/usePasswordAuth.js +126 -0
- package/dist/runtime/composables/useTiptapHistory.d.ts +2 -2
- package/dist/runtime/composables/useTiptapHistory.js +5 -5
- package/dist/runtime/extensions/views/MetaFieldView.vue +23 -6
- package/dist/runtime/plugin-abracadabra.client.js +57 -8
- package/dist/runtime/plugin-abracadabra.server.js +2 -0
- package/dist/runtime/server/plugins/abracadabra-service.js +20 -9
- package/dist/runtime/types.d.ts +11 -0
- package/dist/runtime/utils/awareRingStyle.js +1 -1
- package/package.json +7 -7
- package/dist/runtime/components/renderers/ASpatialRenderer.d.vue.ts +0 -19
- package/dist/runtime/components/renderers/ASpatialRenderer.vue +0 -459
- package/dist/runtime/components/renderers/ASpatialRenderer.vue.d.ts +0 -19
- package/dist/runtime/components/renderers/spatial/SpatialGround.d.vue.ts +0 -20
- package/dist/runtime/components/renderers/spatial/SpatialGround.vue +0 -26
- package/dist/runtime/components/renderers/spatial/SpatialGround.vue.d.ts +0 -20
- package/dist/runtime/components/renderers/spatial/SpatialObject.d.vue.ts +0 -17
- package/dist/runtime/components/renderers/spatial/SpatialObject.vue +0 -257
- package/dist/runtime/components/renderers/spatial/SpatialObject.vue.d.ts +0 -17
- package/dist/runtime/components/renderers/spatial/SpatialSceneBridge.d.vue.ts +0 -15
- package/dist/runtime/components/renderers/spatial/SpatialSceneBridge.vue +0 -18
- package/dist/runtime/components/renderers/spatial/SpatialSceneBridge.vue.d.ts +0 -15
- package/dist/runtime/components/renderers/spatial/SpatialTransformInputs.d.vue.ts +0 -16
- package/dist/runtime/components/renderers/spatial/SpatialTransformInputs.vue +0 -66
- package/dist/runtime/components/renderers/spatial/SpatialTransformInputs.vue.d.ts +0 -16
- package/dist/runtime/components/renderers/spatial/SpatialUserAvatar.d.vue.ts +0 -8
- package/dist/runtime/components/renderers/spatial/SpatialUserAvatar.vue +0 -53
- package/dist/runtime/components/renderers/spatial/SpatialUserAvatar.vue.d.ts +0 -8
- package/dist/runtime/composables/useSpatialCamera.d.ts +0 -16
- package/dist/runtime/composables/useSpatialCamera.js +0 -175
- package/dist/runtime/composables/useSpatialDrag.d.ts +0 -14
- package/dist/runtime/composables/useSpatialDrag.js +0 -137
|
@@ -1,175 +0,0 @@
|
|
|
1
|
-
import { ref, computed, onMounted, onBeforeUnmount } from "vue";
|
|
2
|
-
export function useSpatialCamera(setLocalState, isFollowing = () => false) {
|
|
3
|
-
const azimuth = ref(Math.PI / 4);
|
|
4
|
-
const elevation = ref(Math.PI / 6);
|
|
5
|
-
const distance = ref(12);
|
|
6
|
-
const targetX = ref(0);
|
|
7
|
-
const targetY = ref(0);
|
|
8
|
-
const targetZ = ref(0);
|
|
9
|
-
const controlMode = ref("orbit");
|
|
10
|
-
const isDragging = ref(false);
|
|
11
|
-
const dragButton = ref(0);
|
|
12
|
-
let lastPX = 0;
|
|
13
|
-
let lastPY = 0;
|
|
14
|
-
let focusAnim = null;
|
|
15
|
-
const keysDown = /* @__PURE__ */ new Set();
|
|
16
|
-
const cameraPosition = computed(() => {
|
|
17
|
-
const el = Math.max(0.05, Math.min(Math.PI / 2 - 0.05, elevation.value));
|
|
18
|
-
const x = targetX.value + distance.value * Math.cos(el) * Math.sin(azimuth.value);
|
|
19
|
-
const y = targetY.value + distance.value * Math.sin(el);
|
|
20
|
-
const z = targetZ.value + distance.value * Math.cos(el) * Math.cos(azimuth.value);
|
|
21
|
-
return [x, y, z];
|
|
22
|
-
});
|
|
23
|
-
const cameraTarget = computed(() => [
|
|
24
|
-
targetX.value,
|
|
25
|
-
targetY.value,
|
|
26
|
-
targetZ.value
|
|
27
|
-
]);
|
|
28
|
-
const cameraRef = ref(null);
|
|
29
|
-
function onCanvasPointerDown(ev) {
|
|
30
|
-
isDragging.value = true;
|
|
31
|
-
dragButton.value = ev.button;
|
|
32
|
-
lastPX = ev.clientX;
|
|
33
|
-
lastPY = ev.clientY;
|
|
34
|
-
}
|
|
35
|
-
function onCanvasPointerMove(ev) {
|
|
36
|
-
if (!isDragging.value) return;
|
|
37
|
-
const dx = ev.clientX - lastPX;
|
|
38
|
-
const dy = ev.clientY - lastPY;
|
|
39
|
-
lastPX = ev.clientX;
|
|
40
|
-
lastPY = ev.clientY;
|
|
41
|
-
if (dragButton.value === 0 && !ev.shiftKey) {
|
|
42
|
-
azimuth.value -= dx * 5e-3;
|
|
43
|
-
elevation.value += dy * 5e-3;
|
|
44
|
-
elevation.value = Math.max(0.05, Math.min(Math.PI / 2 - 0.05, elevation.value));
|
|
45
|
-
} else {
|
|
46
|
-
const panSpeed = 5e-3 * distance.value;
|
|
47
|
-
const sinA = Math.sin(azimuth.value);
|
|
48
|
-
const cosA = Math.cos(azimuth.value);
|
|
49
|
-
targetX.value += -cosA * dx * panSpeed;
|
|
50
|
-
targetZ.value += sinA * dx * panSpeed;
|
|
51
|
-
targetY.value += dy * panSpeed;
|
|
52
|
-
}
|
|
53
|
-
broadcastCamera();
|
|
54
|
-
}
|
|
55
|
-
function onCanvasPointerUp() {
|
|
56
|
-
isDragging.value = false;
|
|
57
|
-
broadcastCamera();
|
|
58
|
-
}
|
|
59
|
-
function onCanvasWheel(ev) {
|
|
60
|
-
ev.preventDefault();
|
|
61
|
-
distance.value *= 1 + ev.deltaY * 1e-3;
|
|
62
|
-
distance.value = Math.max(1, Math.min(200, distance.value));
|
|
63
|
-
broadcastCamera();
|
|
64
|
-
}
|
|
65
|
-
function focusOn(worldPos) {
|
|
66
|
-
focusAnim = {
|
|
67
|
-
start: performance.now(),
|
|
68
|
-
fromX: targetX.value,
|
|
69
|
-
fromY: targetY.value,
|
|
70
|
-
fromZ: targetZ.value,
|
|
71
|
-
toX: worldPos[0],
|
|
72
|
-
toY: worldPos[1],
|
|
73
|
-
toZ: worldPos[2]
|
|
74
|
-
};
|
|
75
|
-
}
|
|
76
|
-
function onKeyDown(ev) {
|
|
77
|
-
if (controlMode.value !== "fly") return;
|
|
78
|
-
keysDown.add(ev.key.toLowerCase());
|
|
79
|
-
}
|
|
80
|
-
function onKeyUp(ev) {
|
|
81
|
-
keysDown.delete(ev.key.toLowerCase());
|
|
82
|
-
}
|
|
83
|
-
let rafId = 0;
|
|
84
|
-
function tick() {
|
|
85
|
-
rafId = requestAnimationFrame(tick);
|
|
86
|
-
if (focusAnim) {
|
|
87
|
-
const t = Math.min(1, (performance.now() - focusAnim.start) / 500);
|
|
88
|
-
const ease = t * (2 - t);
|
|
89
|
-
targetX.value = focusAnim.fromX + (focusAnim.toX - focusAnim.fromX) * ease;
|
|
90
|
-
targetY.value = focusAnim.fromY + (focusAnim.toY - focusAnim.fromY) * ease;
|
|
91
|
-
targetZ.value = focusAnim.fromZ + (focusAnim.toZ - focusAnim.fromZ) * ease;
|
|
92
|
-
if (t >= 1) focusAnim = null;
|
|
93
|
-
broadcastCamera();
|
|
94
|
-
}
|
|
95
|
-
if (controlMode.value === "fly") {
|
|
96
|
-
const speed = 0.15;
|
|
97
|
-
const sinA = Math.sin(azimuth.value);
|
|
98
|
-
const cosA = Math.cos(azimuth.value);
|
|
99
|
-
if (keysDown.has("w")) {
|
|
100
|
-
targetX.value -= sinA * speed;
|
|
101
|
-
targetZ.value -= cosA * speed;
|
|
102
|
-
}
|
|
103
|
-
if (keysDown.has("s")) {
|
|
104
|
-
targetX.value += sinA * speed;
|
|
105
|
-
targetZ.value += cosA * speed;
|
|
106
|
-
}
|
|
107
|
-
if (keysDown.has("a")) {
|
|
108
|
-
targetX.value -= cosA * speed;
|
|
109
|
-
targetZ.value += sinA * speed;
|
|
110
|
-
}
|
|
111
|
-
if (keysDown.has("d")) {
|
|
112
|
-
targetX.value += cosA * speed;
|
|
113
|
-
targetZ.value -= sinA * speed;
|
|
114
|
-
}
|
|
115
|
-
if (keysDown.has(" ")) targetY.value += speed;
|
|
116
|
-
if (keysDown.has("shift")) targetY.value -= speed;
|
|
117
|
-
if (keysDown.size > 0) broadcastCamera();
|
|
118
|
-
}
|
|
119
|
-
}
|
|
120
|
-
let lastBroadcast = 0;
|
|
121
|
-
function broadcastCamera() {
|
|
122
|
-
if (isFollowing()) return;
|
|
123
|
-
const now = Date.now();
|
|
124
|
-
if (now - lastBroadcast < 80) return;
|
|
125
|
-
lastBroadcast = now;
|
|
126
|
-
setLocalState({
|
|
127
|
-
spatial: {
|
|
128
|
-
camera: {
|
|
129
|
-
position: cameraPosition.value,
|
|
130
|
-
target: cameraTarget.value,
|
|
131
|
-
timestamp: now
|
|
132
|
-
}
|
|
133
|
-
}
|
|
134
|
-
});
|
|
135
|
-
}
|
|
136
|
-
function applyCameraState(position, target) {
|
|
137
|
-
targetX.value = target[0];
|
|
138
|
-
targetY.value = target[1];
|
|
139
|
-
targetZ.value = target[2];
|
|
140
|
-
const dx = position[0] - target[0];
|
|
141
|
-
const dy = position[1] - target[1];
|
|
142
|
-
const dz = position[2] - target[2];
|
|
143
|
-
distance.value = Math.sqrt(dx * dx + dy * dy + dz * dz);
|
|
144
|
-
if (distance.value > 1e-3) {
|
|
145
|
-
elevation.value = Math.asin(dy / distance.value);
|
|
146
|
-
azimuth.value = Math.atan2(dx, dz);
|
|
147
|
-
}
|
|
148
|
-
}
|
|
149
|
-
onMounted(() => {
|
|
150
|
-
rafId = requestAnimationFrame(tick);
|
|
151
|
-
window.addEventListener("keydown", onKeyDown);
|
|
152
|
-
window.addEventListener("keyup", onKeyUp);
|
|
153
|
-
});
|
|
154
|
-
onBeforeUnmount(() => {
|
|
155
|
-
cancelAnimationFrame(rafId);
|
|
156
|
-
window.removeEventListener("keydown", onKeyDown);
|
|
157
|
-
window.removeEventListener("keyup", onKeyUp);
|
|
158
|
-
});
|
|
159
|
-
return {
|
|
160
|
-
cameraRef,
|
|
161
|
-
cameraPosition,
|
|
162
|
-
cameraTarget,
|
|
163
|
-
controlMode,
|
|
164
|
-
azimuth,
|
|
165
|
-
elevation,
|
|
166
|
-
distance,
|
|
167
|
-
focusOn,
|
|
168
|
-
broadcastCamera,
|
|
169
|
-
applyCameraState,
|
|
170
|
-
onCanvasPointerDown,
|
|
171
|
-
onCanvasPointerMove,
|
|
172
|
-
onCanvasPointerUp,
|
|
173
|
-
onCanvasWheel
|
|
174
|
-
};
|
|
175
|
-
}
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import type { Ref } from 'vue';
|
|
2
|
-
import type { TreeEntry } from '../types.js';
|
|
3
|
-
export declare function useSpatialDrag(tree: {
|
|
4
|
-
entries: Ref<TreeEntry[]>;
|
|
5
|
-
updateMeta: (id: string, meta: Record<string, unknown>) => void;
|
|
6
|
-
}, selectedIds: Ref<Set<string>>, _cameraRef: Ref<any>, setLocalState: (state: Record<string, unknown>) => void, sceneSettings: {
|
|
7
|
-
data: Record<string, unknown>;
|
|
8
|
-
}): {
|
|
9
|
-
draggingId: Ref<string | null, string | null>;
|
|
10
|
-
bindScene: (canvas: HTMLCanvasElement, sceneObj: any, cameraObj: any) => void;
|
|
11
|
-
onPointerDown: (ev: PointerEvent) => string | null;
|
|
12
|
-
onPointerMove: (ev: PointerEvent) => void;
|
|
13
|
-
onPointerUp: (_ev: PointerEvent) => void;
|
|
14
|
-
};
|
|
@@ -1,137 +0,0 @@
|
|
|
1
|
-
import { ref, onMounted, onBeforeUnmount } from "vue";
|
|
2
|
-
export function useSpatialDrag(tree, selectedIds, _cameraRef, setLocalState, sceneSettings) {
|
|
3
|
-
const draggingId = ref(null);
|
|
4
|
-
let canvasEl = null;
|
|
5
|
-
let scene = null;
|
|
6
|
-
let camera = null;
|
|
7
|
-
let isDragging = false;
|
|
8
|
-
let dragStartWorldX = 0;
|
|
9
|
-
let dragStartWorldZ = 0;
|
|
10
|
-
const dragEntryStartPositions = /* @__PURE__ */ new Map();
|
|
11
|
-
const keysDown = /* @__PURE__ */ new Set();
|
|
12
|
-
function onKeyDown(ev) {
|
|
13
|
-
keysDown.add(ev.key.toLowerCase());
|
|
14
|
-
}
|
|
15
|
-
function onKeyUp(ev) {
|
|
16
|
-
keysDown.delete(ev.key.toLowerCase());
|
|
17
|
-
}
|
|
18
|
-
onMounted(() => {
|
|
19
|
-
window.addEventListener("keydown", onKeyDown);
|
|
20
|
-
window.addEventListener("keyup", onKeyUp);
|
|
21
|
-
});
|
|
22
|
-
onBeforeUnmount(() => {
|
|
23
|
-
window.removeEventListener("keydown", onKeyDown);
|
|
24
|
-
window.removeEventListener("keyup", onKeyUp);
|
|
25
|
-
});
|
|
26
|
-
function bindScene(canvas, sceneObj, cameraObj) {
|
|
27
|
-
canvasEl = canvas;
|
|
28
|
-
scene = sceneObj;
|
|
29
|
-
camera = cameraObj;
|
|
30
|
-
}
|
|
31
|
-
function raycastEntryId(ev) {
|
|
32
|
-
if (!canvasEl || !scene || !camera) return null;
|
|
33
|
-
try {
|
|
34
|
-
const THREE = globalThis.__ABRACA_SHARED__?.three;
|
|
35
|
-
if (!THREE) return null;
|
|
36
|
-
const rect = canvasEl.getBoundingClientRect();
|
|
37
|
-
const pointer = new THREE.Vector2(
|
|
38
|
-
(ev.clientX - rect.left) / rect.width * 2 - 1,
|
|
39
|
-
-((ev.clientY - rect.top) / rect.height) * 2 + 1
|
|
40
|
-
);
|
|
41
|
-
const raycaster = new THREE.Raycaster();
|
|
42
|
-
raycaster.setFromCamera(pointer, camera);
|
|
43
|
-
const intersects = raycaster.intersectObjects(scene.children, true);
|
|
44
|
-
for (const hit of intersects) {
|
|
45
|
-
let obj = hit.object;
|
|
46
|
-
while (obj) {
|
|
47
|
-
if (obj.userData?.entryId) return obj.userData.entryId;
|
|
48
|
-
obj = obj.parent;
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
} catch {
|
|
52
|
-
}
|
|
53
|
-
return null;
|
|
54
|
-
}
|
|
55
|
-
function getGroundIntersection(ev) {
|
|
56
|
-
if (!canvasEl || !camera) return null;
|
|
57
|
-
try {
|
|
58
|
-
const THREE = globalThis.__ABRACA_SHARED__?.three;
|
|
59
|
-
if (!THREE) return null;
|
|
60
|
-
const rect = canvasEl.getBoundingClientRect();
|
|
61
|
-
const pointer = new THREE.Vector2(
|
|
62
|
-
(ev.clientX - rect.left) / rect.width * 2 - 1,
|
|
63
|
-
-((ev.clientY - rect.top) / rect.height) * 2 + 1
|
|
64
|
-
);
|
|
65
|
-
const raycaster = new THREE.Raycaster();
|
|
66
|
-
raycaster.setFromCamera(pointer, camera);
|
|
67
|
-
const plane = new THREE.Plane(new THREE.Vector3(0, 1, 0), 0);
|
|
68
|
-
const target = new THREE.Vector3();
|
|
69
|
-
const hit = raycaster.ray.intersectPlane(plane, target);
|
|
70
|
-
return hit ? { x: target.x, z: target.z } : null;
|
|
71
|
-
} catch {
|
|
72
|
-
return null;
|
|
73
|
-
}
|
|
74
|
-
}
|
|
75
|
-
function onPointerDown(ev) {
|
|
76
|
-
if (ev.button !== 0) return null;
|
|
77
|
-
const hitId = raycastEntryId(ev);
|
|
78
|
-
if (!hitId) return null;
|
|
79
|
-
isDragging = true;
|
|
80
|
-
draggingId.value = hitId;
|
|
81
|
-
dragEntryStartPositions.clear();
|
|
82
|
-
const worldPos = getGroundIntersection(ev);
|
|
83
|
-
if (worldPos) {
|
|
84
|
-
dragStartWorldX = worldPos.x;
|
|
85
|
-
dragStartWorldZ = worldPos.z;
|
|
86
|
-
}
|
|
87
|
-
setLocalState({ spatial: { dragging: hitId } });
|
|
88
|
-
return hitId;
|
|
89
|
-
}
|
|
90
|
-
function onPointerMove(ev) {
|
|
91
|
-
if (!isDragging || !draggingId.value) return;
|
|
92
|
-
if (dragEntryStartPositions.size === 0) {
|
|
93
|
-
for (const id of selectedIds.value) {
|
|
94
|
-
const entry = tree.entries.value.find((e) => e.id === id);
|
|
95
|
-
if (entry) {
|
|
96
|
-
dragEntryStartPositions.set(id, {
|
|
97
|
-
x: entry.meta?.spX ?? 0,
|
|
98
|
-
y: entry.meta?.spY ?? 0,
|
|
99
|
-
z: entry.meta?.spZ ?? 0
|
|
100
|
-
});
|
|
101
|
-
}
|
|
102
|
-
}
|
|
103
|
-
}
|
|
104
|
-
const worldPos = getGroundIntersection(ev);
|
|
105
|
-
if (!worldPos) return;
|
|
106
|
-
let dx = worldPos.x - dragStartWorldX;
|
|
107
|
-
const dy = 0;
|
|
108
|
-
let dz = worldPos.z - dragStartWorldZ;
|
|
109
|
-
if (keysDown.has("x")) {
|
|
110
|
-
dz = 0;
|
|
111
|
-
}
|
|
112
|
-
if (keysDown.has("z")) {
|
|
113
|
-
dx = 0;
|
|
114
|
-
}
|
|
115
|
-
const snapSize = sceneSettings.data.snapSize || 0;
|
|
116
|
-
const snap = (v) => snapSize > 0 ? Math.round(v / snapSize) * snapSize : v;
|
|
117
|
-
for (const [id, start] of dragEntryStartPositions) {
|
|
118
|
-
const newX = snap(start.x + dx);
|
|
119
|
-
const newY = snap(start.y + dy);
|
|
120
|
-
const newZ = snap(start.z + dz);
|
|
121
|
-
tree.updateMeta(id, { spX: newX, spY: newY, spZ: newZ });
|
|
122
|
-
}
|
|
123
|
-
}
|
|
124
|
-
function onPointerUp(_ev) {
|
|
125
|
-
isDragging = false;
|
|
126
|
-
draggingId.value = null;
|
|
127
|
-
dragEntryStartPositions.clear();
|
|
128
|
-
setLocalState({ spatial: { dragging: null } });
|
|
129
|
-
}
|
|
130
|
-
return {
|
|
131
|
-
draggingId,
|
|
132
|
-
bindScene,
|
|
133
|
-
onPointerDown,
|
|
134
|
-
onPointerMove,
|
|
135
|
-
onPointerUp
|
|
136
|
-
};
|
|
137
|
-
}
|