@vesium/plot 1.0.1-beta.42 → 1.0.1-beta.45
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/index.cjs +47 -588
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.iife.js +48 -589
- package/dist/index.iife.js.map +1 -1
- package/dist/index.iife.min.js +1 -1
- package/dist/index.iife.min.js.map +1 -1
- package/dist/index.min.cjs +1 -1
- package/dist/index.min.cjs.map +1 -1
- package/dist/index.min.mjs +1 -1
- package/dist/index.min.mjs.map +1 -1
- package/dist/index.mjs +4 -545
- package/dist/index.mjs.map +1 -1
- package/package.json +2 -2
package/dist/index.cjs
CHANGED
|
@@ -4,550 +4,9 @@ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { en
|
|
|
4
4
|
var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
5
5
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
6
6
|
const cesium = require("cesium");
|
|
7
|
+
const vesium = require("vesium");
|
|
7
8
|
const core = require("@vueuse/core");
|
|
8
9
|
const vue = require("vue");
|
|
9
|
-
const shared = require("@vesium/shared");
|
|
10
|
-
const CREATE_VIEWER_INJECTION_KEY = Symbol("CREATE_VIEWER_INJECTION_KEY");
|
|
11
|
-
const CREATE_VIEWER_COLLECTION = /* @__PURE__ */ new WeakMap();
|
|
12
|
-
async function toPromiseValue(source, options = {}) {
|
|
13
|
-
try {
|
|
14
|
-
const { raw = true } = options;
|
|
15
|
-
let value;
|
|
16
|
-
if (shared.isFunction(source)) {
|
|
17
|
-
value = await source();
|
|
18
|
-
} else {
|
|
19
|
-
const result = vue.toValue(source);
|
|
20
|
-
value = shared.isPromise(result) ? await result : result;
|
|
21
|
-
}
|
|
22
|
-
return raw ? vue.toRaw(value) : value;
|
|
23
|
-
} catch (error) {
|
|
24
|
-
console.error(error);
|
|
25
|
-
throw error;
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
function useCesiumEventListener(event, listener, options = {}) {
|
|
29
|
-
const isActive = vue.toRef(options.isActive ?? true);
|
|
30
|
-
const cleanup = vue.watchEffect((onCleanup) => {
|
|
31
|
-
const _event = vue.toValue(event);
|
|
32
|
-
const events = Array.isArray(_event) ? _event : [_event];
|
|
33
|
-
if (events) {
|
|
34
|
-
if (events.length && isActive.value) {
|
|
35
|
-
const stopFns = events.map((event2) => {
|
|
36
|
-
const e = vue.toValue(event2);
|
|
37
|
-
return e == null ? void 0 : e.addEventListener(listener, e);
|
|
38
|
-
});
|
|
39
|
-
onCleanup(() => stopFns.forEach((stop) => stop == null ? void 0 : stop()));
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
});
|
|
43
|
-
core.tryOnScopeDispose(cleanup.stop);
|
|
44
|
-
return cleanup.stop;
|
|
45
|
-
}
|
|
46
|
-
function useViewer() {
|
|
47
|
-
const scope = vue.getCurrentScope();
|
|
48
|
-
const instanceViewer = scope ? CREATE_VIEWER_COLLECTION.get(scope) : void 0;
|
|
49
|
-
if (instanceViewer) {
|
|
50
|
-
return instanceViewer;
|
|
51
|
-
} else {
|
|
52
|
-
const injectViewer = vue.inject(CREATE_VIEWER_INJECTION_KEY);
|
|
53
|
-
if (!injectViewer) {
|
|
54
|
-
throw new Error(
|
|
55
|
-
"The `Viewer` instance injected by `createViewer` was not found in the current component or its ancestor components. Have you called `createViewer`?"
|
|
56
|
-
);
|
|
57
|
-
}
|
|
58
|
-
return injectViewer;
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
function useCollectionScope(addFn, removeFn, removeScopeArgs) {
|
|
62
|
-
const scope = vue.shallowReactive(/* @__PURE__ */ new Set());
|
|
63
|
-
const add = (instance, ...args) => {
|
|
64
|
-
const result = addFn(instance, ...args);
|
|
65
|
-
if (shared.isPromise(result)) {
|
|
66
|
-
return new Promise((resolve, reject) => {
|
|
67
|
-
result.then((i) => {
|
|
68
|
-
scope.add(i);
|
|
69
|
-
resolve(i);
|
|
70
|
-
}).catch((error) => reject(error));
|
|
71
|
-
});
|
|
72
|
-
} else {
|
|
73
|
-
scope.add(result);
|
|
74
|
-
return result;
|
|
75
|
-
}
|
|
76
|
-
};
|
|
77
|
-
const remove = (instance, ...args) => {
|
|
78
|
-
scope.delete(instance);
|
|
79
|
-
return removeFn(instance, ...args);
|
|
80
|
-
};
|
|
81
|
-
const removeWhere = (predicate, ...args) => {
|
|
82
|
-
scope.forEach((instance) => {
|
|
83
|
-
if (predicate(instance)) {
|
|
84
|
-
remove(instance, ...args);
|
|
85
|
-
}
|
|
86
|
-
});
|
|
87
|
-
};
|
|
88
|
-
const removeScope = (...args) => {
|
|
89
|
-
scope.forEach((instance) => {
|
|
90
|
-
remove(instance, ...args);
|
|
91
|
-
});
|
|
92
|
-
};
|
|
93
|
-
core.tryOnScopeDispose(() => removeScope(...removeScopeArgs));
|
|
94
|
-
return {
|
|
95
|
-
scope: vue.shallowReadonly(scope),
|
|
96
|
-
add,
|
|
97
|
-
remove,
|
|
98
|
-
removeWhere,
|
|
99
|
-
removeScope
|
|
100
|
-
};
|
|
101
|
-
}
|
|
102
|
-
function useDataSource(dataSources, options = {}) {
|
|
103
|
-
const {
|
|
104
|
-
destroyOnRemove,
|
|
105
|
-
collection,
|
|
106
|
-
isActive = true,
|
|
107
|
-
evaluating
|
|
108
|
-
} = options;
|
|
109
|
-
const result = core.computedAsync(
|
|
110
|
-
() => toPromiseValue(dataSources),
|
|
111
|
-
void 0,
|
|
112
|
-
{
|
|
113
|
-
evaluating
|
|
114
|
-
}
|
|
115
|
-
);
|
|
116
|
-
const viewer = useViewer();
|
|
117
|
-
vue.watchEffect((onCleanup) => {
|
|
118
|
-
var _a;
|
|
119
|
-
const _isActive = vue.toValue(isActive);
|
|
120
|
-
if (_isActive) {
|
|
121
|
-
const list = Array.isArray(result.value) ? [...result.value] : [result.value];
|
|
122
|
-
const _collection = collection ?? ((_a = viewer.value) == null ? void 0 : _a.dataSources);
|
|
123
|
-
list.forEach((item) => item && (_collection == null ? void 0 : _collection.add(item)));
|
|
124
|
-
onCleanup(() => {
|
|
125
|
-
const destroy = vue.toValue(destroyOnRemove);
|
|
126
|
-
!(_collection == null ? void 0 : _collection.isDestroyed()) && list.forEach((dataSource) => dataSource && (_collection == null ? void 0 : _collection.remove(dataSource, destroy)));
|
|
127
|
-
});
|
|
128
|
-
}
|
|
129
|
-
});
|
|
130
|
-
return result;
|
|
131
|
-
}
|
|
132
|
-
function useEntityScope(options = {}) {
|
|
133
|
-
const { collection: _collection } = options;
|
|
134
|
-
const viewer = useViewer();
|
|
135
|
-
const collection = vue.computed(() => {
|
|
136
|
-
var _a;
|
|
137
|
-
return vue.toValue(_collection) ?? ((_a = viewer.value) == null ? void 0 : _a.entities);
|
|
138
|
-
});
|
|
139
|
-
const addFn = (entity) => {
|
|
140
|
-
if (!collection.value) {
|
|
141
|
-
throw new Error("collection is not defined");
|
|
142
|
-
}
|
|
143
|
-
if (!collection.value.contains(entity)) {
|
|
144
|
-
collection.value.add(entity);
|
|
145
|
-
}
|
|
146
|
-
return entity;
|
|
147
|
-
};
|
|
148
|
-
const removeFn = (entity) => {
|
|
149
|
-
var _a;
|
|
150
|
-
return !!((_a = collection.value) == null ? void 0 : _a.remove(entity));
|
|
151
|
-
};
|
|
152
|
-
const { scope, add, remove, removeWhere, removeScope } = useCollectionScope(addFn, removeFn, []);
|
|
153
|
-
return {
|
|
154
|
-
scope,
|
|
155
|
-
add,
|
|
156
|
-
remove,
|
|
157
|
-
removeWhere,
|
|
158
|
-
removeScope
|
|
159
|
-
};
|
|
160
|
-
}
|
|
161
|
-
const pickCache = /* @__PURE__ */ new WeakMap();
|
|
162
|
-
function useScenePick(windowPosition, options = {}) {
|
|
163
|
-
const { width = 3, height = 3, throttled = 8 } = options;
|
|
164
|
-
const isActive = vue.toRef(options.isActive ?? true);
|
|
165
|
-
const viewer = useViewer();
|
|
166
|
-
const position = core.refThrottled(vue.computed(() => {
|
|
167
|
-
var _a;
|
|
168
|
-
return (_a = vue.toValue(windowPosition)) == null ? void 0 : _a.clone();
|
|
169
|
-
}), throttled, false, true);
|
|
170
|
-
const pick = vue.shallowRef();
|
|
171
|
-
vue.watchEffect(() => {
|
|
172
|
-
var _a;
|
|
173
|
-
if (viewer.value && position.value && isActive.value) {
|
|
174
|
-
const cache = pickCache.get(viewer.value);
|
|
175
|
-
if (cache && cache[0].equals(position.value)) {
|
|
176
|
-
pick.value = cache[1];
|
|
177
|
-
} else {
|
|
178
|
-
pickCache.set(viewer.value, [position.value.clone(), pick.value]);
|
|
179
|
-
pick.value = (_a = viewer.value) == null ? void 0 : _a.scene.pick(
|
|
180
|
-
position.value,
|
|
181
|
-
vue.toValue(width),
|
|
182
|
-
vue.toValue(height)
|
|
183
|
-
);
|
|
184
|
-
}
|
|
185
|
-
}
|
|
186
|
-
});
|
|
187
|
-
return pick;
|
|
188
|
-
}
|
|
189
|
-
function useScreenSpaceEventHandler(type, inputAction, options = {}) {
|
|
190
|
-
const { modifier } = options;
|
|
191
|
-
const viewer = useViewer();
|
|
192
|
-
const isActive = vue.toRef(options.isActive ?? true);
|
|
193
|
-
const handler = vue.computed(() => {
|
|
194
|
-
var _a, _b;
|
|
195
|
-
if ((_b = (_a = viewer.value) == null ? void 0 : _a.cesiumWidget) == null ? void 0 : _b.canvas) {
|
|
196
|
-
return new cesium.ScreenSpaceEventHandler(viewer.value.cesiumWidget.canvas);
|
|
197
|
-
}
|
|
198
|
-
});
|
|
199
|
-
const cleanup1 = vue.watch(handler, (_value, previous) => {
|
|
200
|
-
var _a;
|
|
201
|
-
((_a = viewer.value) == null ? void 0 : _a.cesiumWidget) && (previous == null ? void 0 : previous.destroy());
|
|
202
|
-
});
|
|
203
|
-
const cleanup2 = vue.watchEffect((onCleanup) => {
|
|
204
|
-
const typeValue = vue.toValue(type);
|
|
205
|
-
const modifierValue = vue.toValue(modifier);
|
|
206
|
-
const handlerValue = vue.toValue(handler);
|
|
207
|
-
if (!handlerValue || !isActive.value || !inputAction) {
|
|
208
|
-
return;
|
|
209
|
-
}
|
|
210
|
-
if (shared.isDef(typeValue)) {
|
|
211
|
-
handlerValue.setInputAction(inputAction, typeValue, modifierValue);
|
|
212
|
-
onCleanup(() => handlerValue.removeInputAction(typeValue, modifierValue));
|
|
213
|
-
}
|
|
214
|
-
});
|
|
215
|
-
const stop = () => {
|
|
216
|
-
cleanup1();
|
|
217
|
-
cleanup2();
|
|
218
|
-
};
|
|
219
|
-
core.tryOnScopeDispose(stop);
|
|
220
|
-
return stop;
|
|
221
|
-
}
|
|
222
|
-
function useDrag(listener) {
|
|
223
|
-
const position = vue.shallowRef();
|
|
224
|
-
const pick = useScenePick(position);
|
|
225
|
-
const motionEvent = vue.shallowRef();
|
|
226
|
-
const dragging = vue.ref(false);
|
|
227
|
-
const viewer = useViewer();
|
|
228
|
-
const cameraLocked = vue.ref(false);
|
|
229
|
-
vue.watch(cameraLocked, (cameraLocked2) => {
|
|
230
|
-
viewer.value && (viewer.value.scene.screenSpaceCameraController.enableRotate = !cameraLocked2);
|
|
231
|
-
});
|
|
232
|
-
const lockCamera = () => {
|
|
233
|
-
cameraLocked.value = true;
|
|
234
|
-
};
|
|
235
|
-
const execute = (pick2, startPosition, endPosition) => {
|
|
236
|
-
listener({
|
|
237
|
-
event: {
|
|
238
|
-
startPosition: startPosition.clone(),
|
|
239
|
-
endPosition: endPosition.clone()
|
|
240
|
-
},
|
|
241
|
-
pick: pick2,
|
|
242
|
-
dragging: dragging.value,
|
|
243
|
-
lockCamera
|
|
244
|
-
});
|
|
245
|
-
vue.nextTick(() => {
|
|
246
|
-
if (!dragging.value && cameraLocked.value) {
|
|
247
|
-
cameraLocked.value = false;
|
|
248
|
-
}
|
|
249
|
-
});
|
|
250
|
-
};
|
|
251
|
-
const stopLeftDownWatch = useScreenSpaceEventHandler(
|
|
252
|
-
cesium.ScreenSpaceEventType.LEFT_DOWN,
|
|
253
|
-
(event) => {
|
|
254
|
-
dragging.value = true;
|
|
255
|
-
position.value = event.position.clone();
|
|
256
|
-
}
|
|
257
|
-
);
|
|
258
|
-
const stopMouseMoveWatch = useScreenSpaceEventHandler(
|
|
259
|
-
cesium.ScreenSpaceEventType.MOUSE_MOVE,
|
|
260
|
-
shared.throttle(({ startPosition, endPosition }) => {
|
|
261
|
-
var _a;
|
|
262
|
-
motionEvent.value = {
|
|
263
|
-
startPosition: ((_a = motionEvent.value) == null ? void 0 : _a.endPosition.clone()) || startPosition.clone(),
|
|
264
|
-
endPosition: endPosition.clone()
|
|
265
|
-
};
|
|
266
|
-
}, 8, false, true)
|
|
267
|
-
);
|
|
268
|
-
vue.watch([pick, motionEvent], ([pick2, motionEvent2]) => {
|
|
269
|
-
if (pick2 && motionEvent2) {
|
|
270
|
-
const { startPosition, endPosition } = motionEvent2;
|
|
271
|
-
dragging.value && execute(pick2, startPosition, endPosition);
|
|
272
|
-
}
|
|
273
|
-
});
|
|
274
|
-
const stopLeftUpWatch = useScreenSpaceEventHandler(
|
|
275
|
-
cesium.ScreenSpaceEventType.LEFT_UP,
|
|
276
|
-
(event) => {
|
|
277
|
-
dragging.value = false;
|
|
278
|
-
if (pick.value && motionEvent.value) {
|
|
279
|
-
execute(pick.value, motionEvent.value.endPosition, event.position);
|
|
280
|
-
}
|
|
281
|
-
position.value = void 0;
|
|
282
|
-
motionEvent.value = void 0;
|
|
283
|
-
}
|
|
284
|
-
);
|
|
285
|
-
const stop = () => {
|
|
286
|
-
stopLeftDownWatch();
|
|
287
|
-
stopMouseMoveWatch();
|
|
288
|
-
stopLeftUpWatch();
|
|
289
|
-
};
|
|
290
|
-
core.tryOnScopeDispose(stop);
|
|
291
|
-
return stop;
|
|
292
|
-
}
|
|
293
|
-
function useHover(listener) {
|
|
294
|
-
const motionEvent = vue.shallowRef();
|
|
295
|
-
const pick = useScenePick(() => {
|
|
296
|
-
var _a;
|
|
297
|
-
return (_a = motionEvent.value) == null ? void 0 : _a.endPosition;
|
|
298
|
-
});
|
|
299
|
-
const execute = (pick2, startPosition, endPosition, hovering) => {
|
|
300
|
-
listener({
|
|
301
|
-
event: {
|
|
302
|
-
startPosition: startPosition.clone(),
|
|
303
|
-
endPosition: endPosition.clone()
|
|
304
|
-
},
|
|
305
|
-
pick: pick2,
|
|
306
|
-
hovering
|
|
307
|
-
});
|
|
308
|
-
};
|
|
309
|
-
useScreenSpaceEventHandler(
|
|
310
|
-
cesium.ScreenSpaceEventType.MOUSE_MOVE,
|
|
311
|
-
({ startPosition, endPosition }) => {
|
|
312
|
-
var _a, _b;
|
|
313
|
-
if (!startPosition.equals((_a = motionEvent.value) == null ? void 0 : _a.startPosition) || !endPosition.equals((_b = motionEvent.value) == null ? void 0 : _b.endPosition)) {
|
|
314
|
-
motionEvent.value = { startPosition: startPosition.clone(), endPosition: endPosition.clone() };
|
|
315
|
-
}
|
|
316
|
-
}
|
|
317
|
-
);
|
|
318
|
-
vue.watch([pick, motionEvent], ([pick2, motionEvent2]) => {
|
|
319
|
-
if (pick2 && motionEvent2) {
|
|
320
|
-
const { startPosition, endPosition } = motionEvent2;
|
|
321
|
-
execute(pick2, startPosition, endPosition, true);
|
|
322
|
-
}
|
|
323
|
-
});
|
|
324
|
-
vue.watch(pick, (pick2, prevPick) => {
|
|
325
|
-
if (prevPick && motionEvent.value) {
|
|
326
|
-
const { startPosition, endPosition } = motionEvent.value;
|
|
327
|
-
execute(prevPick, startPosition, endPosition, false);
|
|
328
|
-
}
|
|
329
|
-
});
|
|
330
|
-
}
|
|
331
|
-
const EVENT_TYPE_RECORD = {
|
|
332
|
-
LEFT_DOWN: cesium.ScreenSpaceEventType.LEFT_DOWN,
|
|
333
|
-
LEFT_UP: cesium.ScreenSpaceEventType.LEFT_UP,
|
|
334
|
-
LEFT_CLICK: cesium.ScreenSpaceEventType.LEFT_CLICK,
|
|
335
|
-
LEFT_DOUBLE_CLICK: cesium.ScreenSpaceEventType.LEFT_DOUBLE_CLICK,
|
|
336
|
-
RIGHT_DOWN: cesium.ScreenSpaceEventType.RIGHT_DOWN,
|
|
337
|
-
RIGHT_UP: cesium.ScreenSpaceEventType.RIGHT_UP,
|
|
338
|
-
RIGHT_CLICK: cesium.ScreenSpaceEventType.RIGHT_CLICK,
|
|
339
|
-
MIDDLE_DOWN: cesium.ScreenSpaceEventType.MIDDLE_DOWN,
|
|
340
|
-
MIDDLE_UP: cesium.ScreenSpaceEventType.MIDDLE_UP,
|
|
341
|
-
MIDDLE_CLICK: cesium.ScreenSpaceEventType.MIDDLE_CLICK
|
|
342
|
-
};
|
|
343
|
-
function usePositioned(type, listener) {
|
|
344
|
-
const screenEvent = EVENT_TYPE_RECORD[type];
|
|
345
|
-
const viewer = useViewer();
|
|
346
|
-
useScreenSpaceEventHandler(screenEvent, (event) => {
|
|
347
|
-
var _a;
|
|
348
|
-
const position = event.position;
|
|
349
|
-
const pick = (_a = viewer.value) == null ? void 0 : _a.scene.pick(position);
|
|
350
|
-
pick && position && listener({ event: { position }, pick });
|
|
351
|
-
});
|
|
352
|
-
}
|
|
353
|
-
const GLOBAL_GRAPHIC_SYMBOL = Symbol("GLOBAL_GRAPHIC_SYMBOL");
|
|
354
|
-
const POSITIONED_EVENT_TYPES = [
|
|
355
|
-
"LEFT_DOWN",
|
|
356
|
-
"LEFT_UP",
|
|
357
|
-
"LEFT_CLICK",
|
|
358
|
-
"LEFT_DOUBLE_CLICK",
|
|
359
|
-
"RIGHT_DOWN",
|
|
360
|
-
"RIGHT_UP",
|
|
361
|
-
"RIGHT_CLICK",
|
|
362
|
-
"MIDDLE_DOWN",
|
|
363
|
-
"MIDDLE_UP",
|
|
364
|
-
"MIDDLE_CLICK"
|
|
365
|
-
];
|
|
366
|
-
function useGraphicEvent() {
|
|
367
|
-
const collection = /* @__PURE__ */ new WeakMap();
|
|
368
|
-
const cursorCollection = /* @__PURE__ */ new WeakMap();
|
|
369
|
-
const dragCursorCollection = /* @__PURE__ */ new WeakMap();
|
|
370
|
-
const removeGraphicEvent = (graphic, type, listener) => {
|
|
371
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s;
|
|
372
|
-
const _graphic = graphic === "global" ? GLOBAL_GRAPHIC_SYMBOL : graphic;
|
|
373
|
-
(_b = (_a = collection == null ? void 0 : collection.get(_graphic)) == null ? void 0 : _a.get(type)) == null ? void 0 : _b.delete(listener);
|
|
374
|
-
(_d = (_c = cursorCollection == null ? void 0 : cursorCollection.get(_graphic)) == null ? void 0 : _c.get(type)) == null ? void 0 : _d.delete(listener);
|
|
375
|
-
if (((_f = (_e = collection == null ? void 0 : collection.get(_graphic)) == null ? void 0 : _e.get(type)) == null ? void 0 : _f.size) === 0) {
|
|
376
|
-
collection.get(_graphic).delete(type);
|
|
377
|
-
}
|
|
378
|
-
if (((_g = collection.get(_graphic)) == null ? void 0 : _g.size) === 0) {
|
|
379
|
-
collection.delete(_graphic);
|
|
380
|
-
}
|
|
381
|
-
(_i = (_h = cursorCollection == null ? void 0 : cursorCollection.get(_graphic)) == null ? void 0 : _h.get(type)) == null ? void 0 : _i.delete(listener);
|
|
382
|
-
if (((_k = (_j = cursorCollection == null ? void 0 : cursorCollection.get(_graphic)) == null ? void 0 : _j.get(type)) == null ? void 0 : _k.size) === 0) {
|
|
383
|
-
(_l = cursorCollection == null ? void 0 : cursorCollection.get(_graphic)) == null ? void 0 : _l.delete(type);
|
|
384
|
-
}
|
|
385
|
-
if (((_m = cursorCollection == null ? void 0 : cursorCollection.get(_graphic)) == null ? void 0 : _m.size) === 0) {
|
|
386
|
-
cursorCollection == null ? void 0 : cursorCollection.delete(_graphic);
|
|
387
|
-
}
|
|
388
|
-
(_o = (_n = dragCursorCollection == null ? void 0 : dragCursorCollection.get(_graphic)) == null ? void 0 : _n.get(type)) == null ? void 0 : _o.delete(listener);
|
|
389
|
-
if (((_q = (_p = dragCursorCollection == null ? void 0 : dragCursorCollection.get(_graphic)) == null ? void 0 : _p.get(type)) == null ? void 0 : _q.size) === 0) {
|
|
390
|
-
(_r = dragCursorCollection == null ? void 0 : dragCursorCollection.get(_graphic)) == null ? void 0 : _r.delete(type);
|
|
391
|
-
}
|
|
392
|
-
if (((_s = dragCursorCollection == null ? void 0 : dragCursorCollection.get(_graphic)) == null ? void 0 : _s.size) === 0) {
|
|
393
|
-
dragCursorCollection == null ? void 0 : dragCursorCollection.delete(_graphic);
|
|
394
|
-
}
|
|
395
|
-
};
|
|
396
|
-
const addGraphicEvent = (graphic, type, listener, options = {}) => {
|
|
397
|
-
const _graphic = graphic === "global" ? GLOBAL_GRAPHIC_SYMBOL : graphic;
|
|
398
|
-
collection.get(_graphic) ?? collection.set(_graphic, /* @__PURE__ */ new Map());
|
|
399
|
-
const eventTypeMap = collection.get(_graphic);
|
|
400
|
-
eventTypeMap.get(type) ?? eventTypeMap.set(type, /* @__PURE__ */ new Set());
|
|
401
|
-
const listeners = eventTypeMap.get(type);
|
|
402
|
-
listeners.add(listener);
|
|
403
|
-
let { cursor = "pointer", dragCursor } = options;
|
|
404
|
-
if (shared.isDef(cursor)) {
|
|
405
|
-
const _cursor = shared.isFunction(cursor) ? cursor : () => cursor;
|
|
406
|
-
cursorCollection.get(_graphic) ?? cursorCollection.set(_graphic, /* @__PURE__ */ new Map());
|
|
407
|
-
cursorCollection.get(_graphic).get(type) ?? cursorCollection.get(_graphic).set(type, /* @__PURE__ */ new Map());
|
|
408
|
-
cursorCollection.get(_graphic).get(type).set(listener, _cursor);
|
|
409
|
-
}
|
|
410
|
-
if (type === "DRAG") {
|
|
411
|
-
dragCursor ?? (dragCursor = (event) => (event == null ? void 0 : event.dragging) ? "crosshair" : void 0);
|
|
412
|
-
}
|
|
413
|
-
if (shared.isDef(dragCursor)) {
|
|
414
|
-
const _dragCursor = shared.isFunction(dragCursor) ? dragCursor : () => dragCursor;
|
|
415
|
-
dragCursorCollection.get(_graphic) ?? dragCursorCollection.set(_graphic, /* @__PURE__ */ new Map());
|
|
416
|
-
dragCursorCollection.get(_graphic).get(type) ?? dragCursorCollection.get(_graphic).set(type, /* @__PURE__ */ new Map());
|
|
417
|
-
dragCursorCollection.get(_graphic).get(type).set(listener, _dragCursor);
|
|
418
|
-
}
|
|
419
|
-
return () => removeGraphicEvent(graphic, type, listener);
|
|
420
|
-
};
|
|
421
|
-
const clearGraphicEvent = (graphic, type) => {
|
|
422
|
-
var _a, _b, _c, _d, _e, _f;
|
|
423
|
-
const _graphic = graphic === "global" ? GLOBAL_GRAPHIC_SYMBOL : graphic;
|
|
424
|
-
if (type === "all") {
|
|
425
|
-
collection.delete(_graphic);
|
|
426
|
-
cursorCollection.delete(_graphic);
|
|
427
|
-
dragCursorCollection.delete(_graphic);
|
|
428
|
-
return;
|
|
429
|
-
}
|
|
430
|
-
(_a = collection.get(_graphic)) == null ? void 0 : _a.delete(type);
|
|
431
|
-
if (((_b = collection.get(_graphic)) == null ? void 0 : _b.size) === 0) {
|
|
432
|
-
collection.delete(_graphic);
|
|
433
|
-
}
|
|
434
|
-
(_c = cursorCollection == null ? void 0 : cursorCollection.get(_graphic)) == null ? void 0 : _c.delete(type);
|
|
435
|
-
(_d = dragCursorCollection == null ? void 0 : dragCursorCollection.get(_graphic)) == null ? void 0 : _d.delete(type);
|
|
436
|
-
if (((_e = cursorCollection == null ? void 0 : cursorCollection.get(_graphic)) == null ? void 0 : _e.size) === 0) {
|
|
437
|
-
cursorCollection == null ? void 0 : cursorCollection.delete(_graphic);
|
|
438
|
-
}
|
|
439
|
-
if (((_f = dragCursorCollection == null ? void 0 : dragCursorCollection.get(_graphic)) == null ? void 0 : _f.size) === 0) {
|
|
440
|
-
dragCursorCollection == null ? void 0 : dragCursorCollection.delete(_graphic);
|
|
441
|
-
}
|
|
442
|
-
};
|
|
443
|
-
for (const type of POSITIONED_EVENT_TYPES) {
|
|
444
|
-
usePositioned(type, (event) => {
|
|
445
|
-
const graphics = shared.resolvePick(event.pick);
|
|
446
|
-
graphics.concat(GLOBAL_GRAPHIC_SYMBOL).forEach((graphic) => {
|
|
447
|
-
var _a, _b;
|
|
448
|
-
(_b = (_a = collection.get(graphic)) == null ? void 0 : _a.get(type)) == null ? void 0 : _b.forEach((fn) => {
|
|
449
|
-
var _a2;
|
|
450
|
-
return (_a2 = shared.tryRun(fn)) == null ? void 0 : _a2(event);
|
|
451
|
-
});
|
|
452
|
-
});
|
|
453
|
-
});
|
|
454
|
-
}
|
|
455
|
-
const dragging = vue.ref(false);
|
|
456
|
-
const viewer = useViewer();
|
|
457
|
-
useHover((event) => {
|
|
458
|
-
const graphics = shared.resolvePick(event.pick).concat(GLOBAL_GRAPHIC_SYMBOL);
|
|
459
|
-
graphics.forEach((graphic) => {
|
|
460
|
-
var _a, _b, _c;
|
|
461
|
-
(_b = (_a = collection.get(graphic)) == null ? void 0 : _a.get("HOVER")) == null ? void 0 : _b.forEach((fn) => {
|
|
462
|
-
var _a2;
|
|
463
|
-
return (_a2 = shared.tryRun(fn)) == null ? void 0 : _a2(event);
|
|
464
|
-
});
|
|
465
|
-
if (!dragging.value) {
|
|
466
|
-
(_c = cursorCollection.get(graphic)) == null ? void 0 : _c.forEach((map) => {
|
|
467
|
-
map.forEach((fn) => {
|
|
468
|
-
var _a2, _b2;
|
|
469
|
-
const cursor = event.hovering ? shared.tryRun(fn)(event) : "";
|
|
470
|
-
(_b2 = (_a2 = viewer.value) == null ? void 0 : _a2.canvas.style) == null ? void 0 : _b2.setProperty("cursor", cursor);
|
|
471
|
-
});
|
|
472
|
-
});
|
|
473
|
-
}
|
|
474
|
-
});
|
|
475
|
-
});
|
|
476
|
-
useDrag((event) => {
|
|
477
|
-
const graphics = shared.resolvePick(event.pick).concat(GLOBAL_GRAPHIC_SYMBOL);
|
|
478
|
-
dragging.value = event.dragging;
|
|
479
|
-
graphics.forEach((graphic) => {
|
|
480
|
-
var _a, _b, _c;
|
|
481
|
-
(_b = (_a = collection.get(graphic)) == null ? void 0 : _a.get("DRAG")) == null ? void 0 : _b.forEach((fn) => shared.tryRun(fn)(event));
|
|
482
|
-
(_c = dragCursorCollection.get(graphic)) == null ? void 0 : _c.forEach((map) => {
|
|
483
|
-
map.forEach((fn) => {
|
|
484
|
-
var _a2, _b2;
|
|
485
|
-
const cursor = event.dragging ? shared.tryRun(fn)(event) : "";
|
|
486
|
-
(_b2 = (_a2 = viewer.value) == null ? void 0 : _a2.canvas.style) == null ? void 0 : _b2.setProperty("cursor", cursor);
|
|
487
|
-
});
|
|
488
|
-
});
|
|
489
|
-
});
|
|
490
|
-
});
|
|
491
|
-
return {
|
|
492
|
-
addGraphicEvent,
|
|
493
|
-
removeGraphicEvent,
|
|
494
|
-
clearGraphicEvent
|
|
495
|
-
};
|
|
496
|
-
}
|
|
497
|
-
function usePrimitive(data, options = {}) {
|
|
498
|
-
const {
|
|
499
|
-
collection,
|
|
500
|
-
isActive = true,
|
|
501
|
-
evaluating
|
|
502
|
-
} = options;
|
|
503
|
-
const result = core.computedAsync(
|
|
504
|
-
() => toPromiseValue(data),
|
|
505
|
-
void 0,
|
|
506
|
-
{
|
|
507
|
-
evaluating
|
|
508
|
-
}
|
|
509
|
-
);
|
|
510
|
-
const viewer = useViewer();
|
|
511
|
-
vue.watchEffect((onCleanup) => {
|
|
512
|
-
var _a, _b;
|
|
513
|
-
const _isActive = vue.toValue(isActive);
|
|
514
|
-
if (_isActive) {
|
|
515
|
-
const list = Array.isArray(result.value) ? [...result.value] : [result.value];
|
|
516
|
-
const _collection = collection === "ground" ? (_a = viewer.value) == null ? void 0 : _a.scene.groundPrimitives : collection ?? ((_b = viewer.value) == null ? void 0 : _b.scene.primitives);
|
|
517
|
-
list.forEach((item) => item && (_collection == null ? void 0 : _collection.add(item)));
|
|
518
|
-
onCleanup(() => {
|
|
519
|
-
!(_collection == null ? void 0 : _collection.isDestroyed()) && list.forEach((item) => item && (_collection == null ? void 0 : _collection.remove(item)));
|
|
520
|
-
});
|
|
521
|
-
}
|
|
522
|
-
});
|
|
523
|
-
return result;
|
|
524
|
-
}
|
|
525
|
-
function usePrimitiveScope(options = {}) {
|
|
526
|
-
const { collection: _collection } = options;
|
|
527
|
-
const viewer = useViewer();
|
|
528
|
-
const collection = vue.computed(() => {
|
|
529
|
-
var _a;
|
|
530
|
-
return vue.toValue(_collection) ?? ((_a = viewer.value) == null ? void 0 : _a.scene.primitives);
|
|
531
|
-
});
|
|
532
|
-
const addFn = (primitive) => {
|
|
533
|
-
if (!collection.value) {
|
|
534
|
-
throw new Error("collection is not defined");
|
|
535
|
-
}
|
|
536
|
-
return collection.value.add(primitive);
|
|
537
|
-
};
|
|
538
|
-
const removeFn = (primitive) => {
|
|
539
|
-
var _a;
|
|
540
|
-
return !!((_a = collection.value) == null ? void 0 : _a.remove(primitive));
|
|
541
|
-
};
|
|
542
|
-
const { scope, add, remove, removeWhere, removeScope } = useCollectionScope(addFn, removeFn, []);
|
|
543
|
-
return {
|
|
544
|
-
scope,
|
|
545
|
-
add,
|
|
546
|
-
remove,
|
|
547
|
-
removeWhere,
|
|
548
|
-
removeScope
|
|
549
|
-
};
|
|
550
|
-
}
|
|
551
10
|
const _PlotScheme = class _PlotScheme {
|
|
552
11
|
constructor(options) {
|
|
553
12
|
__publicField(this, "type");
|
|
@@ -588,7 +47,7 @@ const _PlotScheme = class _PlotScheme {
|
|
|
588
47
|
return _PlotScheme._record.get(type);
|
|
589
48
|
}
|
|
590
49
|
static setCache(scheme) {
|
|
591
|
-
|
|
50
|
+
vesium.assertError(!scheme.type, "`scheme.type` is required");
|
|
592
51
|
_PlotScheme._record.set(scheme.type, scheme);
|
|
593
52
|
}
|
|
594
53
|
static resolve(maybeScheme) {
|
|
@@ -1034,18 +493,18 @@ class PlotSkeletonEntity extends cesium.Entity {
|
|
|
1034
493
|
}
|
|
1035
494
|
}
|
|
1036
495
|
function useRender(plots, current, getCurrentTime) {
|
|
1037
|
-
const viewer = useViewer();
|
|
1038
|
-
const primitiveCollection = usePrimitive(new cesium.PrimitiveCollection());
|
|
1039
|
-
const groundPrimitiveCollection = usePrimitive(new cesium.PrimitiveCollection(), { collection: "ground" });
|
|
1040
|
-
const dataSource = useDataSource(new cesium.CustomDataSource());
|
|
1041
|
-
const entityScope = useEntityScope({ collection: () => dataSource.value.entities });
|
|
1042
|
-
const primitiveScope = usePrimitiveScope({ collection: () => primitiveCollection.value });
|
|
1043
|
-
const groundPrimitiveScope = usePrimitiveScope({ collection: () => groundPrimitiveCollection.value });
|
|
496
|
+
const viewer = vesium.useViewer();
|
|
497
|
+
const primitiveCollection = vesium.usePrimitive(new cesium.PrimitiveCollection());
|
|
498
|
+
const groundPrimitiveCollection = vesium.usePrimitive(new cesium.PrimitiveCollection(), { collection: "ground" });
|
|
499
|
+
const dataSource = vesium.useDataSource(new cesium.CustomDataSource());
|
|
500
|
+
const entityScope = vesium.useEntityScope({ collection: () => dataSource.value.entities });
|
|
501
|
+
const primitiveScope = vesium.usePrimitiveScope({ collection: () => primitiveCollection.value });
|
|
502
|
+
const groundPrimitiveScope = vesium.usePrimitiveScope({ collection: () => groundPrimitiveCollection.value });
|
|
1044
503
|
const mouseCartesian = vue.shallowRef();
|
|
1045
|
-
useScreenSpaceEventHandler(
|
|
504
|
+
vesium.useScreenSpaceEventHandler(
|
|
1046
505
|
cesium.ScreenSpaceEventType.MOUSE_MOVE,
|
|
1047
506
|
(event) => {
|
|
1048
|
-
mouseCartesian.value =
|
|
507
|
+
mouseCartesian.value = vesium.canvasCoordToCartesian(event == null ? void 0 : event.endPosition, viewer.value.scene);
|
|
1049
508
|
}
|
|
1050
509
|
);
|
|
1051
510
|
core.watchArray(plots, (_value, _oldValue, added, removed = []) => {
|
|
@@ -1063,19 +522,19 @@ function useRender(plots, current, getCurrentTime) {
|
|
|
1063
522
|
immediate: true,
|
|
1064
523
|
flush: "post"
|
|
1065
524
|
});
|
|
1066
|
-
useCesiumEventListener(
|
|
525
|
+
vesium.useCesiumEventListener(
|
|
1067
526
|
() => plots.value.map((item) => item.definitionChanged),
|
|
1068
527
|
(_scope, key, newValue, oldValue) => {
|
|
1069
528
|
if (key === "entities") {
|
|
1070
|
-
const { added, removed } =
|
|
529
|
+
const { added, removed } = vesium.arrayDiff(newValue, oldValue);
|
|
1071
530
|
added.forEach((item) => entityScope.add(item));
|
|
1072
531
|
removed.forEach((item) => entityScope.remove(item));
|
|
1073
532
|
} else if (key === "primitives") {
|
|
1074
|
-
const { added, removed } =
|
|
533
|
+
const { added, removed } = vesium.arrayDiff(newValue, oldValue);
|
|
1075
534
|
added.forEach((item) => primitiveScope.add(item));
|
|
1076
535
|
removed.forEach((item) => primitiveScope.remove(item));
|
|
1077
536
|
} else if (key === "groundPrimitives") {
|
|
1078
|
-
const { added, removed } =
|
|
537
|
+
const { added, removed } = vesium.arrayDiff(newValue, oldValue);
|
|
1079
538
|
added.forEach((item) => groundPrimitiveScope.add(item));
|
|
1080
539
|
removed.forEach((item) => groundPrimitiveScope.remove(item));
|
|
1081
540
|
}
|
|
@@ -1100,7 +559,7 @@ function useRender(plots, current, getCurrentTime) {
|
|
|
1100
559
|
vue.watch(current, (plot, previous) => {
|
|
1101
560
|
previous && update(previous);
|
|
1102
561
|
});
|
|
1103
|
-
useCesiumEventListener(
|
|
562
|
+
vesium.useCesiumEventListener(
|
|
1104
563
|
() => plots.value.map((item) => item.definitionChanged),
|
|
1105
564
|
(plot, key) => {
|
|
1106
565
|
if (["disabled", "defining", "scheme", "sampled", "time"].includes(key)) {
|
|
@@ -1118,13 +577,13 @@ function useRender(plots, current, getCurrentTime) {
|
|
|
1118
577
|
};
|
|
1119
578
|
}
|
|
1120
579
|
function useSampled(current, getCurrentTime) {
|
|
1121
|
-
const viewer = useViewer();
|
|
580
|
+
const viewer = vesium.useViewer();
|
|
1122
581
|
const doubleClicking = vue.ref(false);
|
|
1123
582
|
const packable = vue.computed(() => {
|
|
1124
583
|
var _a;
|
|
1125
584
|
return (_a = current.value) == null ? void 0 : _a.sampled.getValue(getCurrentTime());
|
|
1126
585
|
});
|
|
1127
|
-
useScreenSpaceEventHandler(
|
|
586
|
+
vesium.useScreenSpaceEventHandler(
|
|
1128
587
|
cesium.ScreenSpaceEventType.LEFT_CLICK,
|
|
1129
588
|
async (ctx) => {
|
|
1130
589
|
var _a, _b;
|
|
@@ -1139,7 +598,7 @@ function useSampled(current, getCurrentTime) {
|
|
|
1139
598
|
if (!defining) {
|
|
1140
599
|
return;
|
|
1141
600
|
}
|
|
1142
|
-
const position =
|
|
601
|
+
const position = vesium.canvasCoordToCartesian(ctx.position, viewer.value.scene);
|
|
1143
602
|
if (!position) {
|
|
1144
603
|
return;
|
|
1145
604
|
}
|
|
@@ -1150,7 +609,7 @@ function useSampled(current, getCurrentTime) {
|
|
|
1150
609
|
completed && PlotFeature.setDefining(current.value, false);
|
|
1151
610
|
}
|
|
1152
611
|
);
|
|
1153
|
-
useScreenSpaceEventHandler(
|
|
612
|
+
vesium.useScreenSpaceEventHandler(
|
|
1154
613
|
cesium.ScreenSpaceEventType.LEFT_DOUBLE_CLICK,
|
|
1155
614
|
async (ctx) => {
|
|
1156
615
|
var _a;
|
|
@@ -1164,7 +623,7 @@ function useSampled(current, getCurrentTime) {
|
|
|
1164
623
|
if (!defining) {
|
|
1165
624
|
return;
|
|
1166
625
|
}
|
|
1167
|
-
const position =
|
|
626
|
+
const position = vesium.canvasCoordToCartesian(ctx.position, viewer.value.scene);
|
|
1168
627
|
if (!position) {
|
|
1169
628
|
return;
|
|
1170
629
|
}
|
|
@@ -1172,7 +631,7 @@ function useSampled(current, getCurrentTime) {
|
|
|
1172
631
|
completed && PlotFeature.setDefining(current.value, false);
|
|
1173
632
|
}
|
|
1174
633
|
);
|
|
1175
|
-
useScreenSpaceEventHandler(
|
|
634
|
+
vesium.useScreenSpaceEventHandler(
|
|
1176
635
|
cesium.ScreenSpaceEventType.RIGHT_CLICK,
|
|
1177
636
|
async () => {
|
|
1178
637
|
var _a;
|
|
@@ -1201,13 +660,13 @@ function useSampled(current, getCurrentTime) {
|
|
|
1201
660
|
}
|
|
1202
661
|
} else {
|
|
1203
662
|
const definingCursor = current.value.scheme.definingCursor;
|
|
1204
|
-
definingCursorCss.value =
|
|
663
|
+
definingCursorCss.value = vesium.isFunction(definingCursor) ? definingCursor(packable.value) : definingCursor;
|
|
1205
664
|
if (definingCursorCss.value) {
|
|
1206
665
|
(_b = viewer.value) == null ? void 0 : _b.container.parentElement.style.setProperty("cursor", definingCursorCss.value);
|
|
1207
666
|
}
|
|
1208
667
|
}
|
|
1209
668
|
};
|
|
1210
|
-
useCesiumEventListener(() => {
|
|
669
|
+
vesium.useCesiumEventListener(() => {
|
|
1211
670
|
var _a;
|
|
1212
671
|
return (_a = current.value) == null ? void 0 : _a.definitionChanged;
|
|
1213
672
|
}, (plot, key) => {
|
|
@@ -1218,9 +677,9 @@ function useSampled(current, getCurrentTime) {
|
|
|
1218
677
|
vue.watch(current, () => setDefiningCursorCss());
|
|
1219
678
|
}
|
|
1220
679
|
function useSkeleton(plots, current, getCurrentTime) {
|
|
1221
|
-
const viewer = useViewer();
|
|
1222
|
-
const dataSource = useDataSource(new cesium.CustomDataSource());
|
|
1223
|
-
const entityScope = useEntityScope({ collection: () => dataSource.value.entities });
|
|
680
|
+
const viewer = vesium.useViewer();
|
|
681
|
+
const dataSource = vesium.useDataSource(new cesium.CustomDataSource());
|
|
682
|
+
const entityScope = vesium.useEntityScope({ collection: () => dataSource.value.entities });
|
|
1224
683
|
const hoverEntity = vue.shallowRef();
|
|
1225
684
|
const activeEntity = vue.shallowRef();
|
|
1226
685
|
const getPointAction = (entity) => {
|
|
@@ -1242,7 +701,7 @@ function useSkeleton(plots, current, getCurrentTime) {
|
|
|
1242
701
|
const skeletons = plot.scheme.skeletons;
|
|
1243
702
|
skeletons.forEach((skeleton) => {
|
|
1244
703
|
var _a;
|
|
1245
|
-
const disabled =
|
|
704
|
+
const disabled = vesium.isFunction(skeleton.disabled) ? skeleton.disabled({ active, defining }) : skeleton.disabled;
|
|
1246
705
|
if (disabled) {
|
|
1247
706
|
return;
|
|
1248
707
|
}
|
|
@@ -1278,7 +737,7 @@ function useSkeleton(plots, current, getCurrentTime) {
|
|
|
1278
737
|
}
|
|
1279
738
|
plot.skeletons = entities;
|
|
1280
739
|
};
|
|
1281
|
-
const { addGraphicEvent } = useGraphicEvent();
|
|
740
|
+
const { addGraphicEvent } = vesium.useGraphicEvent();
|
|
1282
741
|
vue.watchEffect((onCleanup) => {
|
|
1283
742
|
const remove = addGraphicEvent("global", "DRAG", ({ event, pick, dragging, lockCamera }) => {
|
|
1284
743
|
var _a;
|
|
@@ -1310,14 +769,14 @@ function useSkeleton(plots, current, getCurrentTime) {
|
|
|
1310
769
|
var _a;
|
|
1311
770
|
if (!((_a = current.value) == null ? void 0 : _a.defining) && entityScope.scope.has(pick.id)) {
|
|
1312
771
|
const skeleton = pick.id.skeleton;
|
|
1313
|
-
return
|
|
772
|
+
return vesium.isFunction(skeleton == null ? void 0 : skeleton.cursor) ? skeleton.cursor(pick) : vue.toValue(skeleton == null ? void 0 : skeleton.cursor);
|
|
1314
773
|
}
|
|
1315
774
|
},
|
|
1316
775
|
dragCursor: ({ pick }) => {
|
|
1317
776
|
var _a;
|
|
1318
777
|
if (!((_a = current.value) == null ? void 0 : _a.defining) && entityScope.scope.has(pick.id)) {
|
|
1319
778
|
const skeleton = pick.id.skeleton;
|
|
1320
|
-
return
|
|
779
|
+
return vesium.isFunction(skeleton == null ? void 0 : skeleton.dragCursor) ? skeleton.dragCursor(pick) : vue.toValue(skeleton == null ? void 0 : skeleton.dragCursor);
|
|
1321
780
|
}
|
|
1322
781
|
}
|
|
1323
782
|
});
|
|
@@ -1380,13 +839,13 @@ function useSkeleton(plots, current, getCurrentTime) {
|
|
|
1380
839
|
added.forEach((plot) => update(plot));
|
|
1381
840
|
removed.forEach((plot) => update(plot, true));
|
|
1382
841
|
});
|
|
1383
|
-
useCesiumEventListener(
|
|
842
|
+
vesium.useCesiumEventListener(
|
|
1384
843
|
() => plots.value.map((plot) => plot.definitionChanged),
|
|
1385
844
|
(plot, key, newValue, oldValue) => {
|
|
1386
845
|
if (["disabled", "defining", "scheme", "sampled", "time"].includes(key)) {
|
|
1387
846
|
vue.nextTick(() => update(plot));
|
|
1388
847
|
} else if (key === "skeletons") {
|
|
1389
|
-
const { added, removed } =
|
|
848
|
+
const { added, removed } = vesium.arrayDiff(newValue, oldValue);
|
|
1390
849
|
added.forEach((item) => entityScope.add(item));
|
|
1391
850
|
removed.forEach((item) => entityScope.remove(item));
|
|
1392
851
|
}
|
|
@@ -1402,7 +861,7 @@ function useSkeleton(plots, current, getCurrentTime) {
|
|
|
1402
861
|
}
|
|
1403
862
|
function usePlot(options) {
|
|
1404
863
|
const time = (options == null ? void 0 : options.time) || vue.shallowRef();
|
|
1405
|
-
const viewer = useViewer();
|
|
864
|
+
const viewer = vesium.useViewer();
|
|
1406
865
|
const getCurrentTime = () => {
|
|
1407
866
|
var _a, _b, _c;
|
|
1408
867
|
return ((_a = time.value) == null ? void 0 : _a.clone()) || ((_c = (_b = viewer.value) == null ? void 0 : _b.clock.currentTime) == null ? void 0 : _c.clone()) || cesium.JulianDate.now();
|
|
@@ -1411,7 +870,7 @@ function usePlot(options) {
|
|
|
1411
870
|
const plots = vue.computed(() => Array.from(collection));
|
|
1412
871
|
const current = vue.shallowRef();
|
|
1413
872
|
const packable = vue.shallowRef();
|
|
1414
|
-
useCesiumEventListener([
|
|
873
|
+
vesium.useCesiumEventListener([
|
|
1415
874
|
() => {
|
|
1416
875
|
var _a;
|
|
1417
876
|
return (_a = current.value) == null ? void 0 : _a.sampled.definitionChanged;
|
|
@@ -1423,7 +882,7 @@ function usePlot(options) {
|
|
|
1423
882
|
useSampled(current, getCurrentTime);
|
|
1424
883
|
useRender(plots, current, getCurrentTime);
|
|
1425
884
|
useSkeleton(plots, current, getCurrentTime);
|
|
1426
|
-
useScreenSpaceEventHandler(cesium.ScreenSpaceEventType.LEFT_CLICK, (data) => {
|
|
885
|
+
vesium.useScreenSpaceEventHandler(cesium.ScreenSpaceEventType.LEFT_CLICK, (data) => {
|
|
1427
886
|
var _a, _b, _c;
|
|
1428
887
|
if ((_a = current.value) == null ? void 0 : _a.defining) {
|
|
1429
888
|
return;
|
|
@@ -1436,7 +895,7 @@ function usePlot(options) {
|
|
|
1436
895
|
current.value = void 0;
|
|
1437
896
|
return;
|
|
1438
897
|
}
|
|
1439
|
-
current.value = plots.value.find((plot) =>
|
|
898
|
+
current.value = plots.value.find((plot) => vesium.pickHitGraphic(pick, [...plot.entities, ...plot.primitives, ...plot.groundPrimitives]));
|
|
1440
899
|
});
|
|
1441
900
|
let operateResolve;
|
|
1442
901
|
let operateReject;
|
|
@@ -1492,7 +951,7 @@ function control() {
|
|
|
1492
951
|
dragCursor: "crosshair",
|
|
1493
952
|
onDrag({ viewer, sampled, packable, event, index, lockCamera }) {
|
|
1494
953
|
lockCamera();
|
|
1495
|
-
const position =
|
|
954
|
+
const position = vesium.canvasCoordToCartesian(event.endPosition, viewer.scene);
|
|
1496
955
|
if (position) {
|
|
1497
956
|
const positions = [...packable.positions ?? []];
|
|
1498
957
|
positions[index] = position;
|
|
@@ -1505,7 +964,7 @@ function control() {
|
|
|
1505
964
|
},
|
|
1506
965
|
onKeyPressed({ viewer, keyEvent, sampled, packable, index }) {
|
|
1507
966
|
var _a;
|
|
1508
|
-
const height = (_a =
|
|
967
|
+
const height = (_a = vesium.toCartographic(viewer.camera.position)) == null ? void 0 : _a.height;
|
|
1509
968
|
if (!height || !["ArrowUp", "ArrowRight", "ArrowDown", "ArrowLeft"].includes(keyEvent.key))
|
|
1510
969
|
return;
|
|
1511
970
|
keyEvent.preventDefault();
|
|
@@ -1526,12 +985,12 @@ function control() {
|
|
|
1526
985
|
}
|
|
1527
986
|
const newHeading = (viewer.camera.heading + headingAdjust) % (2 * Math.PI);
|
|
1528
987
|
const positions = [...packable.positions ?? []];
|
|
1529
|
-
const cartographic =
|
|
988
|
+
const cartographic = vesium.toCartographic(positions[index]);
|
|
1530
989
|
const r = height / 1e5;
|
|
1531
990
|
const distance = r * Math.PI / 180 / 1e3;
|
|
1532
991
|
cartographic.latitude += distance * Math.cos(newHeading);
|
|
1533
992
|
cartographic.longitude += distance * Math.sin(newHeading);
|
|
1534
|
-
positions[index] =
|
|
993
|
+
positions[index] = vesium.toCartesian3(cartographic);
|
|
1535
994
|
sampled.setSample({
|
|
1536
995
|
time: packable.time,
|
|
1537
996
|
derivative: packable.derivative,
|
|
@@ -1575,7 +1034,7 @@ function interval() {
|
|
|
1575
1034
|
},
|
|
1576
1035
|
onDrag({ viewer, sampled, packable, event, index, lockCamera, dragging }) {
|
|
1577
1036
|
lockCamera();
|
|
1578
|
-
const position =
|
|
1037
|
+
const position = vesium.canvasCoordToCartesian(event.endPosition, viewer.scene);
|
|
1579
1038
|
if (!position) {
|
|
1580
1039
|
return;
|
|
1581
1040
|
}
|
|
@@ -1636,7 +1095,7 @@ function intervalNonclosed() {
|
|
|
1636
1095
|
},
|
|
1637
1096
|
onDrag({ viewer, sampled, packable, event, index, lockCamera, dragging }) {
|
|
1638
1097
|
lockCamera();
|
|
1639
|
-
const position =
|
|
1098
|
+
const position = vesium.canvasCoordToCartesian(event.endPosition, viewer.scene);
|
|
1640
1099
|
if (!position) {
|
|
1641
1100
|
return;
|
|
1642
1101
|
}
|
|
@@ -1691,13 +1150,13 @@ function moved() {
|
|
|
1691
1150
|
return [positions[0]];
|
|
1692
1151
|
} else {
|
|
1693
1152
|
const center = cesium.Rectangle.center(cesium.Rectangle.fromCartesianArray(positions));
|
|
1694
|
-
return [
|
|
1153
|
+
return [vesium.toCartesian3(center)];
|
|
1695
1154
|
}
|
|
1696
1155
|
},
|
|
1697
1156
|
onDrag({ viewer, sampled, packable, event, lockCamera, dragging }) {
|
|
1698
1157
|
dragging && lockCamera();
|
|
1699
|
-
const startPosition =
|
|
1700
|
-
const endPosition =
|
|
1158
|
+
const startPosition = vesium.canvasCoordToCartesian(event.startPosition, viewer.scene);
|
|
1159
|
+
const endPosition = vesium.canvasCoordToCartesian(event.endPosition, viewer.scene);
|
|
1701
1160
|
if (!startPosition || !endPosition) {
|
|
1702
1161
|
return;
|
|
1703
1162
|
}
|
|
@@ -1833,7 +1292,7 @@ const schemeMeasureArea = new PlotScheme({
|
|
|
1833
1292
|
} else if (positions.length >= 3) {
|
|
1834
1293
|
positions.push(positions[0]);
|
|
1835
1294
|
entity.position = new cesium.ConstantPositionProperty(
|
|
1836
|
-
|
|
1295
|
+
vesium.toCartesian3(
|
|
1837
1296
|
cesium.Rectangle.center(cesium.Rectangle.fromCartesianArray(positions))
|
|
1838
1297
|
)
|
|
1839
1298
|
);
|