@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.mjs
CHANGED
|
@@ -1,551 +1,10 @@
|
|
|
1
1
|
var __defProp = Object.defineProperty;
|
|
2
2
|
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
3
3
|
var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
const CREATE_VIEWER_INJECTION_KEY = Symbol("CREATE_VIEWER_INJECTION_KEY");
|
|
9
|
-
const CREATE_VIEWER_COLLECTION = /* @__PURE__ */ new WeakMap();
|
|
10
|
-
async function toPromiseValue(source, options = {}) {
|
|
11
|
-
try {
|
|
12
|
-
const { raw = true } = options;
|
|
13
|
-
let value;
|
|
14
|
-
if (isFunction(source)) {
|
|
15
|
-
value = await source();
|
|
16
|
-
} else {
|
|
17
|
-
const result = toValue(source);
|
|
18
|
-
value = isPromise(result) ? await result : result;
|
|
19
|
-
}
|
|
20
|
-
return raw ? toRaw(value) : value;
|
|
21
|
-
} catch (error) {
|
|
22
|
-
console.error(error);
|
|
23
|
-
throw error;
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
function useCesiumEventListener(event, listener, options = {}) {
|
|
27
|
-
const isActive = toRef(options.isActive ?? true);
|
|
28
|
-
const cleanup = watchEffect((onCleanup) => {
|
|
29
|
-
const _event = toValue(event);
|
|
30
|
-
const events = Array.isArray(_event) ? _event : [_event];
|
|
31
|
-
if (events) {
|
|
32
|
-
if (events.length && isActive.value) {
|
|
33
|
-
const stopFns = events.map((event2) => {
|
|
34
|
-
const e = toValue(event2);
|
|
35
|
-
return e == null ? void 0 : e.addEventListener(listener, e);
|
|
36
|
-
});
|
|
37
|
-
onCleanup(() => stopFns.forEach((stop) => stop == null ? void 0 : stop()));
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
});
|
|
41
|
-
tryOnScopeDispose(cleanup.stop);
|
|
42
|
-
return cleanup.stop;
|
|
43
|
-
}
|
|
44
|
-
function useViewer() {
|
|
45
|
-
const scope = getCurrentScope();
|
|
46
|
-
const instanceViewer = scope ? CREATE_VIEWER_COLLECTION.get(scope) : void 0;
|
|
47
|
-
if (instanceViewer) {
|
|
48
|
-
return instanceViewer;
|
|
49
|
-
} else {
|
|
50
|
-
const injectViewer = inject(CREATE_VIEWER_INJECTION_KEY);
|
|
51
|
-
if (!injectViewer) {
|
|
52
|
-
throw new Error(
|
|
53
|
-
"The `Viewer` instance injected by `createViewer` was not found in the current component or its ancestor components. Have you called `createViewer`?"
|
|
54
|
-
);
|
|
55
|
-
}
|
|
56
|
-
return injectViewer;
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
|
-
function useCollectionScope(addFn, removeFn, removeScopeArgs) {
|
|
60
|
-
const scope = shallowReactive(/* @__PURE__ */ new Set());
|
|
61
|
-
const add = (instance, ...args) => {
|
|
62
|
-
const result = addFn(instance, ...args);
|
|
63
|
-
if (isPromise(result)) {
|
|
64
|
-
return new Promise((resolve, reject) => {
|
|
65
|
-
result.then((i) => {
|
|
66
|
-
scope.add(i);
|
|
67
|
-
resolve(i);
|
|
68
|
-
}).catch((error) => reject(error));
|
|
69
|
-
});
|
|
70
|
-
} else {
|
|
71
|
-
scope.add(result);
|
|
72
|
-
return result;
|
|
73
|
-
}
|
|
74
|
-
};
|
|
75
|
-
const remove = (instance, ...args) => {
|
|
76
|
-
scope.delete(instance);
|
|
77
|
-
return removeFn(instance, ...args);
|
|
78
|
-
};
|
|
79
|
-
const removeWhere = (predicate, ...args) => {
|
|
80
|
-
scope.forEach((instance) => {
|
|
81
|
-
if (predicate(instance)) {
|
|
82
|
-
remove(instance, ...args);
|
|
83
|
-
}
|
|
84
|
-
});
|
|
85
|
-
};
|
|
86
|
-
const removeScope = (...args) => {
|
|
87
|
-
scope.forEach((instance) => {
|
|
88
|
-
remove(instance, ...args);
|
|
89
|
-
});
|
|
90
|
-
};
|
|
91
|
-
tryOnScopeDispose(() => removeScope(...removeScopeArgs));
|
|
92
|
-
return {
|
|
93
|
-
scope: shallowReadonly(scope),
|
|
94
|
-
add,
|
|
95
|
-
remove,
|
|
96
|
-
removeWhere,
|
|
97
|
-
removeScope
|
|
98
|
-
};
|
|
99
|
-
}
|
|
100
|
-
function useDataSource(dataSources, options = {}) {
|
|
101
|
-
const {
|
|
102
|
-
destroyOnRemove,
|
|
103
|
-
collection,
|
|
104
|
-
isActive = true,
|
|
105
|
-
evaluating
|
|
106
|
-
} = options;
|
|
107
|
-
const result = computedAsync(
|
|
108
|
-
() => toPromiseValue(dataSources),
|
|
109
|
-
void 0,
|
|
110
|
-
{
|
|
111
|
-
evaluating
|
|
112
|
-
}
|
|
113
|
-
);
|
|
114
|
-
const viewer = useViewer();
|
|
115
|
-
watchEffect((onCleanup) => {
|
|
116
|
-
var _a;
|
|
117
|
-
const _isActive = toValue(isActive);
|
|
118
|
-
if (_isActive) {
|
|
119
|
-
const list = Array.isArray(result.value) ? [...result.value] : [result.value];
|
|
120
|
-
const _collection = collection ?? ((_a = viewer.value) == null ? void 0 : _a.dataSources);
|
|
121
|
-
list.forEach((item) => item && (_collection == null ? void 0 : _collection.add(item)));
|
|
122
|
-
onCleanup(() => {
|
|
123
|
-
const destroy = toValue(destroyOnRemove);
|
|
124
|
-
!(_collection == null ? void 0 : _collection.isDestroyed()) && list.forEach((dataSource) => dataSource && (_collection == null ? void 0 : _collection.remove(dataSource, destroy)));
|
|
125
|
-
});
|
|
126
|
-
}
|
|
127
|
-
});
|
|
128
|
-
return result;
|
|
129
|
-
}
|
|
130
|
-
function useEntityScope(options = {}) {
|
|
131
|
-
const { collection: _collection } = options;
|
|
132
|
-
const viewer = useViewer();
|
|
133
|
-
const collection = computed(() => {
|
|
134
|
-
var _a;
|
|
135
|
-
return toValue(_collection) ?? ((_a = viewer.value) == null ? void 0 : _a.entities);
|
|
136
|
-
});
|
|
137
|
-
const addFn = (entity) => {
|
|
138
|
-
if (!collection.value) {
|
|
139
|
-
throw new Error("collection is not defined");
|
|
140
|
-
}
|
|
141
|
-
if (!collection.value.contains(entity)) {
|
|
142
|
-
collection.value.add(entity);
|
|
143
|
-
}
|
|
144
|
-
return entity;
|
|
145
|
-
};
|
|
146
|
-
const removeFn = (entity) => {
|
|
147
|
-
var _a;
|
|
148
|
-
return !!((_a = collection.value) == null ? void 0 : _a.remove(entity));
|
|
149
|
-
};
|
|
150
|
-
const { scope, add, remove, removeWhere, removeScope } = useCollectionScope(addFn, removeFn, []);
|
|
151
|
-
return {
|
|
152
|
-
scope,
|
|
153
|
-
add,
|
|
154
|
-
remove,
|
|
155
|
-
removeWhere,
|
|
156
|
-
removeScope
|
|
157
|
-
};
|
|
158
|
-
}
|
|
159
|
-
const pickCache = /* @__PURE__ */ new WeakMap();
|
|
160
|
-
function useScenePick(windowPosition, options = {}) {
|
|
161
|
-
const { width = 3, height = 3, throttled = 8 } = options;
|
|
162
|
-
const isActive = toRef(options.isActive ?? true);
|
|
163
|
-
const viewer = useViewer();
|
|
164
|
-
const position = refThrottled(computed(() => {
|
|
165
|
-
var _a;
|
|
166
|
-
return (_a = toValue(windowPosition)) == null ? void 0 : _a.clone();
|
|
167
|
-
}), throttled, false, true);
|
|
168
|
-
const pick = shallowRef();
|
|
169
|
-
watchEffect(() => {
|
|
170
|
-
var _a;
|
|
171
|
-
if (viewer.value && position.value && isActive.value) {
|
|
172
|
-
const cache = pickCache.get(viewer.value);
|
|
173
|
-
if (cache && cache[0].equals(position.value)) {
|
|
174
|
-
pick.value = cache[1];
|
|
175
|
-
} else {
|
|
176
|
-
pickCache.set(viewer.value, [position.value.clone(), pick.value]);
|
|
177
|
-
pick.value = (_a = viewer.value) == null ? void 0 : _a.scene.pick(
|
|
178
|
-
position.value,
|
|
179
|
-
toValue(width),
|
|
180
|
-
toValue(height)
|
|
181
|
-
);
|
|
182
|
-
}
|
|
183
|
-
}
|
|
184
|
-
});
|
|
185
|
-
return pick;
|
|
186
|
-
}
|
|
187
|
-
function useScreenSpaceEventHandler(type, inputAction, options = {}) {
|
|
188
|
-
const { modifier } = options;
|
|
189
|
-
const viewer = useViewer();
|
|
190
|
-
const isActive = toRef(options.isActive ?? true);
|
|
191
|
-
const handler = computed(() => {
|
|
192
|
-
var _a, _b;
|
|
193
|
-
if ((_b = (_a = viewer.value) == null ? void 0 : _a.cesiumWidget) == null ? void 0 : _b.canvas) {
|
|
194
|
-
return new ScreenSpaceEventHandler(viewer.value.cesiumWidget.canvas);
|
|
195
|
-
}
|
|
196
|
-
});
|
|
197
|
-
const cleanup1 = watch(handler, (_value, previous) => {
|
|
198
|
-
var _a;
|
|
199
|
-
((_a = viewer.value) == null ? void 0 : _a.cesiumWidget) && (previous == null ? void 0 : previous.destroy());
|
|
200
|
-
});
|
|
201
|
-
const cleanup2 = watchEffect((onCleanup) => {
|
|
202
|
-
const typeValue = toValue(type);
|
|
203
|
-
const modifierValue = toValue(modifier);
|
|
204
|
-
const handlerValue = toValue(handler);
|
|
205
|
-
if (!handlerValue || !isActive.value || !inputAction) {
|
|
206
|
-
return;
|
|
207
|
-
}
|
|
208
|
-
if (isDef(typeValue)) {
|
|
209
|
-
handlerValue.setInputAction(inputAction, typeValue, modifierValue);
|
|
210
|
-
onCleanup(() => handlerValue.removeInputAction(typeValue, modifierValue));
|
|
211
|
-
}
|
|
212
|
-
});
|
|
213
|
-
const stop = () => {
|
|
214
|
-
cleanup1();
|
|
215
|
-
cleanup2();
|
|
216
|
-
};
|
|
217
|
-
tryOnScopeDispose(stop);
|
|
218
|
-
return stop;
|
|
219
|
-
}
|
|
220
|
-
function useDrag(listener) {
|
|
221
|
-
const position = shallowRef();
|
|
222
|
-
const pick = useScenePick(position);
|
|
223
|
-
const motionEvent = shallowRef();
|
|
224
|
-
const dragging = ref(false);
|
|
225
|
-
const viewer = useViewer();
|
|
226
|
-
const cameraLocked = ref(false);
|
|
227
|
-
watch(cameraLocked, (cameraLocked2) => {
|
|
228
|
-
viewer.value && (viewer.value.scene.screenSpaceCameraController.enableRotate = !cameraLocked2);
|
|
229
|
-
});
|
|
230
|
-
const lockCamera = () => {
|
|
231
|
-
cameraLocked.value = true;
|
|
232
|
-
};
|
|
233
|
-
const execute = (pick2, startPosition, endPosition) => {
|
|
234
|
-
listener({
|
|
235
|
-
event: {
|
|
236
|
-
startPosition: startPosition.clone(),
|
|
237
|
-
endPosition: endPosition.clone()
|
|
238
|
-
},
|
|
239
|
-
pick: pick2,
|
|
240
|
-
dragging: dragging.value,
|
|
241
|
-
lockCamera
|
|
242
|
-
});
|
|
243
|
-
nextTick(() => {
|
|
244
|
-
if (!dragging.value && cameraLocked.value) {
|
|
245
|
-
cameraLocked.value = false;
|
|
246
|
-
}
|
|
247
|
-
});
|
|
248
|
-
};
|
|
249
|
-
const stopLeftDownWatch = useScreenSpaceEventHandler(
|
|
250
|
-
ScreenSpaceEventType.LEFT_DOWN,
|
|
251
|
-
(event) => {
|
|
252
|
-
dragging.value = true;
|
|
253
|
-
position.value = event.position.clone();
|
|
254
|
-
}
|
|
255
|
-
);
|
|
256
|
-
const stopMouseMoveWatch = useScreenSpaceEventHandler(
|
|
257
|
-
ScreenSpaceEventType.MOUSE_MOVE,
|
|
258
|
-
throttle(({ startPosition, endPosition }) => {
|
|
259
|
-
var _a;
|
|
260
|
-
motionEvent.value = {
|
|
261
|
-
startPosition: ((_a = motionEvent.value) == null ? void 0 : _a.endPosition.clone()) || startPosition.clone(),
|
|
262
|
-
endPosition: endPosition.clone()
|
|
263
|
-
};
|
|
264
|
-
}, 8, false, true)
|
|
265
|
-
);
|
|
266
|
-
watch([pick, motionEvent], ([pick2, motionEvent2]) => {
|
|
267
|
-
if (pick2 && motionEvent2) {
|
|
268
|
-
const { startPosition, endPosition } = motionEvent2;
|
|
269
|
-
dragging.value && execute(pick2, startPosition, endPosition);
|
|
270
|
-
}
|
|
271
|
-
});
|
|
272
|
-
const stopLeftUpWatch = useScreenSpaceEventHandler(
|
|
273
|
-
ScreenSpaceEventType.LEFT_UP,
|
|
274
|
-
(event) => {
|
|
275
|
-
dragging.value = false;
|
|
276
|
-
if (pick.value && motionEvent.value) {
|
|
277
|
-
execute(pick.value, motionEvent.value.endPosition, event.position);
|
|
278
|
-
}
|
|
279
|
-
position.value = void 0;
|
|
280
|
-
motionEvent.value = void 0;
|
|
281
|
-
}
|
|
282
|
-
);
|
|
283
|
-
const stop = () => {
|
|
284
|
-
stopLeftDownWatch();
|
|
285
|
-
stopMouseMoveWatch();
|
|
286
|
-
stopLeftUpWatch();
|
|
287
|
-
};
|
|
288
|
-
tryOnScopeDispose(stop);
|
|
289
|
-
return stop;
|
|
290
|
-
}
|
|
291
|
-
function useHover(listener) {
|
|
292
|
-
const motionEvent = shallowRef();
|
|
293
|
-
const pick = useScenePick(() => {
|
|
294
|
-
var _a;
|
|
295
|
-
return (_a = motionEvent.value) == null ? void 0 : _a.endPosition;
|
|
296
|
-
});
|
|
297
|
-
const execute = (pick2, startPosition, endPosition, hovering) => {
|
|
298
|
-
listener({
|
|
299
|
-
event: {
|
|
300
|
-
startPosition: startPosition.clone(),
|
|
301
|
-
endPosition: endPosition.clone()
|
|
302
|
-
},
|
|
303
|
-
pick: pick2,
|
|
304
|
-
hovering
|
|
305
|
-
});
|
|
306
|
-
};
|
|
307
|
-
useScreenSpaceEventHandler(
|
|
308
|
-
ScreenSpaceEventType.MOUSE_MOVE,
|
|
309
|
-
({ startPosition, endPosition }) => {
|
|
310
|
-
var _a, _b;
|
|
311
|
-
if (!startPosition.equals((_a = motionEvent.value) == null ? void 0 : _a.startPosition) || !endPosition.equals((_b = motionEvent.value) == null ? void 0 : _b.endPosition)) {
|
|
312
|
-
motionEvent.value = { startPosition: startPosition.clone(), endPosition: endPosition.clone() };
|
|
313
|
-
}
|
|
314
|
-
}
|
|
315
|
-
);
|
|
316
|
-
watch([pick, motionEvent], ([pick2, motionEvent2]) => {
|
|
317
|
-
if (pick2 && motionEvent2) {
|
|
318
|
-
const { startPosition, endPosition } = motionEvent2;
|
|
319
|
-
execute(pick2, startPosition, endPosition, true);
|
|
320
|
-
}
|
|
321
|
-
});
|
|
322
|
-
watch(pick, (pick2, prevPick) => {
|
|
323
|
-
if (prevPick && motionEvent.value) {
|
|
324
|
-
const { startPosition, endPosition } = motionEvent.value;
|
|
325
|
-
execute(prevPick, startPosition, endPosition, false);
|
|
326
|
-
}
|
|
327
|
-
});
|
|
328
|
-
}
|
|
329
|
-
const EVENT_TYPE_RECORD = {
|
|
330
|
-
LEFT_DOWN: ScreenSpaceEventType.LEFT_DOWN,
|
|
331
|
-
LEFT_UP: ScreenSpaceEventType.LEFT_UP,
|
|
332
|
-
LEFT_CLICK: ScreenSpaceEventType.LEFT_CLICK,
|
|
333
|
-
LEFT_DOUBLE_CLICK: ScreenSpaceEventType.LEFT_DOUBLE_CLICK,
|
|
334
|
-
RIGHT_DOWN: ScreenSpaceEventType.RIGHT_DOWN,
|
|
335
|
-
RIGHT_UP: ScreenSpaceEventType.RIGHT_UP,
|
|
336
|
-
RIGHT_CLICK: ScreenSpaceEventType.RIGHT_CLICK,
|
|
337
|
-
MIDDLE_DOWN: ScreenSpaceEventType.MIDDLE_DOWN,
|
|
338
|
-
MIDDLE_UP: ScreenSpaceEventType.MIDDLE_UP,
|
|
339
|
-
MIDDLE_CLICK: ScreenSpaceEventType.MIDDLE_CLICK
|
|
340
|
-
};
|
|
341
|
-
function usePositioned(type, listener) {
|
|
342
|
-
const screenEvent = EVENT_TYPE_RECORD[type];
|
|
343
|
-
const viewer = useViewer();
|
|
344
|
-
useScreenSpaceEventHandler(screenEvent, (event) => {
|
|
345
|
-
var _a;
|
|
346
|
-
const position = event.position;
|
|
347
|
-
const pick = (_a = viewer.value) == null ? void 0 : _a.scene.pick(position);
|
|
348
|
-
pick && position && listener({ event: { position }, pick });
|
|
349
|
-
});
|
|
350
|
-
}
|
|
351
|
-
const GLOBAL_GRAPHIC_SYMBOL = Symbol("GLOBAL_GRAPHIC_SYMBOL");
|
|
352
|
-
const POSITIONED_EVENT_TYPES = [
|
|
353
|
-
"LEFT_DOWN",
|
|
354
|
-
"LEFT_UP",
|
|
355
|
-
"LEFT_CLICK",
|
|
356
|
-
"LEFT_DOUBLE_CLICK",
|
|
357
|
-
"RIGHT_DOWN",
|
|
358
|
-
"RIGHT_UP",
|
|
359
|
-
"RIGHT_CLICK",
|
|
360
|
-
"MIDDLE_DOWN",
|
|
361
|
-
"MIDDLE_UP",
|
|
362
|
-
"MIDDLE_CLICK"
|
|
363
|
-
];
|
|
364
|
-
function useGraphicEvent() {
|
|
365
|
-
const collection = /* @__PURE__ */ new WeakMap();
|
|
366
|
-
const cursorCollection = /* @__PURE__ */ new WeakMap();
|
|
367
|
-
const dragCursorCollection = /* @__PURE__ */ new WeakMap();
|
|
368
|
-
const removeGraphicEvent = (graphic, type, listener) => {
|
|
369
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s;
|
|
370
|
-
const _graphic = graphic === "global" ? GLOBAL_GRAPHIC_SYMBOL : graphic;
|
|
371
|
-
(_b = (_a = collection == null ? void 0 : collection.get(_graphic)) == null ? void 0 : _a.get(type)) == null ? void 0 : _b.delete(listener);
|
|
372
|
-
(_d = (_c = cursorCollection == null ? void 0 : cursorCollection.get(_graphic)) == null ? void 0 : _c.get(type)) == null ? void 0 : _d.delete(listener);
|
|
373
|
-
if (((_f = (_e = collection == null ? void 0 : collection.get(_graphic)) == null ? void 0 : _e.get(type)) == null ? void 0 : _f.size) === 0) {
|
|
374
|
-
collection.get(_graphic).delete(type);
|
|
375
|
-
}
|
|
376
|
-
if (((_g = collection.get(_graphic)) == null ? void 0 : _g.size) === 0) {
|
|
377
|
-
collection.delete(_graphic);
|
|
378
|
-
}
|
|
379
|
-
(_i = (_h = cursorCollection == null ? void 0 : cursorCollection.get(_graphic)) == null ? void 0 : _h.get(type)) == null ? void 0 : _i.delete(listener);
|
|
380
|
-
if (((_k = (_j = cursorCollection == null ? void 0 : cursorCollection.get(_graphic)) == null ? void 0 : _j.get(type)) == null ? void 0 : _k.size) === 0) {
|
|
381
|
-
(_l = cursorCollection == null ? void 0 : cursorCollection.get(_graphic)) == null ? void 0 : _l.delete(type);
|
|
382
|
-
}
|
|
383
|
-
if (((_m = cursorCollection == null ? void 0 : cursorCollection.get(_graphic)) == null ? void 0 : _m.size) === 0) {
|
|
384
|
-
cursorCollection == null ? void 0 : cursorCollection.delete(_graphic);
|
|
385
|
-
}
|
|
386
|
-
(_o = (_n = dragCursorCollection == null ? void 0 : dragCursorCollection.get(_graphic)) == null ? void 0 : _n.get(type)) == null ? void 0 : _o.delete(listener);
|
|
387
|
-
if (((_q = (_p = dragCursorCollection == null ? void 0 : dragCursorCollection.get(_graphic)) == null ? void 0 : _p.get(type)) == null ? void 0 : _q.size) === 0) {
|
|
388
|
-
(_r = dragCursorCollection == null ? void 0 : dragCursorCollection.get(_graphic)) == null ? void 0 : _r.delete(type);
|
|
389
|
-
}
|
|
390
|
-
if (((_s = dragCursorCollection == null ? void 0 : dragCursorCollection.get(_graphic)) == null ? void 0 : _s.size) === 0) {
|
|
391
|
-
dragCursorCollection == null ? void 0 : dragCursorCollection.delete(_graphic);
|
|
392
|
-
}
|
|
393
|
-
};
|
|
394
|
-
const addGraphicEvent = (graphic, type, listener, options = {}) => {
|
|
395
|
-
const _graphic = graphic === "global" ? GLOBAL_GRAPHIC_SYMBOL : graphic;
|
|
396
|
-
collection.get(_graphic) ?? collection.set(_graphic, /* @__PURE__ */ new Map());
|
|
397
|
-
const eventTypeMap = collection.get(_graphic);
|
|
398
|
-
eventTypeMap.get(type) ?? eventTypeMap.set(type, /* @__PURE__ */ new Set());
|
|
399
|
-
const listeners = eventTypeMap.get(type);
|
|
400
|
-
listeners.add(listener);
|
|
401
|
-
let { cursor = "pointer", dragCursor } = options;
|
|
402
|
-
if (isDef(cursor)) {
|
|
403
|
-
const _cursor = isFunction(cursor) ? cursor : () => cursor;
|
|
404
|
-
cursorCollection.get(_graphic) ?? cursorCollection.set(_graphic, /* @__PURE__ */ new Map());
|
|
405
|
-
cursorCollection.get(_graphic).get(type) ?? cursorCollection.get(_graphic).set(type, /* @__PURE__ */ new Map());
|
|
406
|
-
cursorCollection.get(_graphic).get(type).set(listener, _cursor);
|
|
407
|
-
}
|
|
408
|
-
if (type === "DRAG") {
|
|
409
|
-
dragCursor ?? (dragCursor = (event) => (event == null ? void 0 : event.dragging) ? "crosshair" : void 0);
|
|
410
|
-
}
|
|
411
|
-
if (isDef(dragCursor)) {
|
|
412
|
-
const _dragCursor = isFunction(dragCursor) ? dragCursor : () => dragCursor;
|
|
413
|
-
dragCursorCollection.get(_graphic) ?? dragCursorCollection.set(_graphic, /* @__PURE__ */ new Map());
|
|
414
|
-
dragCursorCollection.get(_graphic).get(type) ?? dragCursorCollection.get(_graphic).set(type, /* @__PURE__ */ new Map());
|
|
415
|
-
dragCursorCollection.get(_graphic).get(type).set(listener, _dragCursor);
|
|
416
|
-
}
|
|
417
|
-
return () => removeGraphicEvent(graphic, type, listener);
|
|
418
|
-
};
|
|
419
|
-
const clearGraphicEvent = (graphic, type) => {
|
|
420
|
-
var _a, _b, _c, _d, _e, _f;
|
|
421
|
-
const _graphic = graphic === "global" ? GLOBAL_GRAPHIC_SYMBOL : graphic;
|
|
422
|
-
if (type === "all") {
|
|
423
|
-
collection.delete(_graphic);
|
|
424
|
-
cursorCollection.delete(_graphic);
|
|
425
|
-
dragCursorCollection.delete(_graphic);
|
|
426
|
-
return;
|
|
427
|
-
}
|
|
428
|
-
(_a = collection.get(_graphic)) == null ? void 0 : _a.delete(type);
|
|
429
|
-
if (((_b = collection.get(_graphic)) == null ? void 0 : _b.size) === 0) {
|
|
430
|
-
collection.delete(_graphic);
|
|
431
|
-
}
|
|
432
|
-
(_c = cursorCollection == null ? void 0 : cursorCollection.get(_graphic)) == null ? void 0 : _c.delete(type);
|
|
433
|
-
(_d = dragCursorCollection == null ? void 0 : dragCursorCollection.get(_graphic)) == null ? void 0 : _d.delete(type);
|
|
434
|
-
if (((_e = cursorCollection == null ? void 0 : cursorCollection.get(_graphic)) == null ? void 0 : _e.size) === 0) {
|
|
435
|
-
cursorCollection == null ? void 0 : cursorCollection.delete(_graphic);
|
|
436
|
-
}
|
|
437
|
-
if (((_f = dragCursorCollection == null ? void 0 : dragCursorCollection.get(_graphic)) == null ? void 0 : _f.size) === 0) {
|
|
438
|
-
dragCursorCollection == null ? void 0 : dragCursorCollection.delete(_graphic);
|
|
439
|
-
}
|
|
440
|
-
};
|
|
441
|
-
for (const type of POSITIONED_EVENT_TYPES) {
|
|
442
|
-
usePositioned(type, (event) => {
|
|
443
|
-
const graphics = resolvePick(event.pick);
|
|
444
|
-
graphics.concat(GLOBAL_GRAPHIC_SYMBOL).forEach((graphic) => {
|
|
445
|
-
var _a, _b;
|
|
446
|
-
(_b = (_a = collection.get(graphic)) == null ? void 0 : _a.get(type)) == null ? void 0 : _b.forEach((fn) => {
|
|
447
|
-
var _a2;
|
|
448
|
-
return (_a2 = tryRun(fn)) == null ? void 0 : _a2(event);
|
|
449
|
-
});
|
|
450
|
-
});
|
|
451
|
-
});
|
|
452
|
-
}
|
|
453
|
-
const dragging = ref(false);
|
|
454
|
-
const viewer = useViewer();
|
|
455
|
-
useHover((event) => {
|
|
456
|
-
const graphics = resolvePick(event.pick).concat(GLOBAL_GRAPHIC_SYMBOL);
|
|
457
|
-
graphics.forEach((graphic) => {
|
|
458
|
-
var _a, _b, _c;
|
|
459
|
-
(_b = (_a = collection.get(graphic)) == null ? void 0 : _a.get("HOVER")) == null ? void 0 : _b.forEach((fn) => {
|
|
460
|
-
var _a2;
|
|
461
|
-
return (_a2 = tryRun(fn)) == null ? void 0 : _a2(event);
|
|
462
|
-
});
|
|
463
|
-
if (!dragging.value) {
|
|
464
|
-
(_c = cursorCollection.get(graphic)) == null ? void 0 : _c.forEach((map) => {
|
|
465
|
-
map.forEach((fn) => {
|
|
466
|
-
var _a2, _b2;
|
|
467
|
-
const cursor = event.hovering ? tryRun(fn)(event) : "";
|
|
468
|
-
(_b2 = (_a2 = viewer.value) == null ? void 0 : _a2.canvas.style) == null ? void 0 : _b2.setProperty("cursor", cursor);
|
|
469
|
-
});
|
|
470
|
-
});
|
|
471
|
-
}
|
|
472
|
-
});
|
|
473
|
-
});
|
|
474
|
-
useDrag((event) => {
|
|
475
|
-
const graphics = resolvePick(event.pick).concat(GLOBAL_GRAPHIC_SYMBOL);
|
|
476
|
-
dragging.value = event.dragging;
|
|
477
|
-
graphics.forEach((graphic) => {
|
|
478
|
-
var _a, _b, _c;
|
|
479
|
-
(_b = (_a = collection.get(graphic)) == null ? void 0 : _a.get("DRAG")) == null ? void 0 : _b.forEach((fn) => tryRun(fn)(event));
|
|
480
|
-
(_c = dragCursorCollection.get(graphic)) == null ? void 0 : _c.forEach((map) => {
|
|
481
|
-
map.forEach((fn) => {
|
|
482
|
-
var _a2, _b2;
|
|
483
|
-
const cursor = event.dragging ? tryRun(fn)(event) : "";
|
|
484
|
-
(_b2 = (_a2 = viewer.value) == null ? void 0 : _a2.canvas.style) == null ? void 0 : _b2.setProperty("cursor", cursor);
|
|
485
|
-
});
|
|
486
|
-
});
|
|
487
|
-
});
|
|
488
|
-
});
|
|
489
|
-
return {
|
|
490
|
-
addGraphicEvent,
|
|
491
|
-
removeGraphicEvent,
|
|
492
|
-
clearGraphicEvent
|
|
493
|
-
};
|
|
494
|
-
}
|
|
495
|
-
function usePrimitive(data, options = {}) {
|
|
496
|
-
const {
|
|
497
|
-
collection,
|
|
498
|
-
isActive = true,
|
|
499
|
-
evaluating
|
|
500
|
-
} = options;
|
|
501
|
-
const result = computedAsync(
|
|
502
|
-
() => toPromiseValue(data),
|
|
503
|
-
void 0,
|
|
504
|
-
{
|
|
505
|
-
evaluating
|
|
506
|
-
}
|
|
507
|
-
);
|
|
508
|
-
const viewer = useViewer();
|
|
509
|
-
watchEffect((onCleanup) => {
|
|
510
|
-
var _a, _b;
|
|
511
|
-
const _isActive = toValue(isActive);
|
|
512
|
-
if (_isActive) {
|
|
513
|
-
const list = Array.isArray(result.value) ? [...result.value] : [result.value];
|
|
514
|
-
const _collection = collection === "ground" ? (_a = viewer.value) == null ? void 0 : _a.scene.groundPrimitives : collection ?? ((_b = viewer.value) == null ? void 0 : _b.scene.primitives);
|
|
515
|
-
list.forEach((item) => item && (_collection == null ? void 0 : _collection.add(item)));
|
|
516
|
-
onCleanup(() => {
|
|
517
|
-
!(_collection == null ? void 0 : _collection.isDestroyed()) && list.forEach((item) => item && (_collection == null ? void 0 : _collection.remove(item)));
|
|
518
|
-
});
|
|
519
|
-
}
|
|
520
|
-
});
|
|
521
|
-
return result;
|
|
522
|
-
}
|
|
523
|
-
function usePrimitiveScope(options = {}) {
|
|
524
|
-
const { collection: _collection } = options;
|
|
525
|
-
const viewer = useViewer();
|
|
526
|
-
const collection = computed(() => {
|
|
527
|
-
var _a;
|
|
528
|
-
return toValue(_collection) ?? ((_a = viewer.value) == null ? void 0 : _a.scene.primitives);
|
|
529
|
-
});
|
|
530
|
-
const addFn = (primitive) => {
|
|
531
|
-
if (!collection.value) {
|
|
532
|
-
throw new Error("collection is not defined");
|
|
533
|
-
}
|
|
534
|
-
return collection.value.add(primitive);
|
|
535
|
-
};
|
|
536
|
-
const removeFn = (primitive) => {
|
|
537
|
-
var _a;
|
|
538
|
-
return !!((_a = collection.value) == null ? void 0 : _a.remove(primitive));
|
|
539
|
-
};
|
|
540
|
-
const { scope, add, remove, removeWhere, removeScope } = useCollectionScope(addFn, removeFn, []);
|
|
541
|
-
return {
|
|
542
|
-
scope,
|
|
543
|
-
add,
|
|
544
|
-
remove,
|
|
545
|
-
removeWhere,
|
|
546
|
-
removeScope
|
|
547
|
-
};
|
|
548
|
-
}
|
|
4
|
+
import { JulianDate, Event, TimeInterval, Cartesian3, createGuid, Entity, PrimitiveCollection, CustomDataSource, ScreenSpaceEventType, Color, VerticalOrigin, HorizontalOrigin, Rectangle, CoplanarPolygonGeometry, VertexFormat, ClassificationType, CallbackProperty, ConstantPositionProperty, ConstantProperty, PolygonHierarchy, CallbackPositionProperty } from "cesium";
|
|
5
|
+
import { assertError, useViewer, usePrimitive, useDataSource, useEntityScope, usePrimitiveScope, useScreenSpaceEventHandler, canvasCoordToCartesian, useCesiumEventListener, arrayDiff, isFunction, useGraphicEvent, pickHitGraphic, toCartographic, toCartesian3 } from "vesium";
|
|
6
|
+
import { assert, watchArray, promiseTimeout, onKeyStroke } from "@vueuse/core";
|
|
7
|
+
import { shallowRef, watch, computed, ref, watchEffect, toValue, nextTick, shallowReactive } from "vue";
|
|
549
8
|
const _PlotScheme = class _PlotScheme {
|
|
550
9
|
constructor(options) {
|
|
551
10
|
__publicField(this, "type");
|