@vesium/plot 1.0.1-beta.41 → 1.0.1-beta.44
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 +26 -566
- package/dist/index.cjs.map +1 -1
- package/dist/index.iife.js +26 -567
- 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 +6 -546
- package/dist/index.mjs.map +1 -1
- package/package.json +3 -2
package/dist/index.iife.js
CHANGED
|
@@ -1,549 +1,8 @@
|
|
|
1
|
-
var VesiumPlot = function(exports, cesium, core,
|
|
1
|
+
var VesiumPlot = function(exports, cesium, core$1, shared, core, vue) {
|
|
2
2
|
"use strict";var __defProp = Object.defineProperty;
|
|
3
3
|
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
4
4
|
var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
5
5
|
|
|
6
|
-
const CREATE_VIEWER_INJECTION_KEY = Symbol("CREATE_VIEWER_INJECTION_KEY");
|
|
7
|
-
const CREATE_VIEWER_COLLECTION = /* @__PURE__ */ new WeakMap();
|
|
8
|
-
async function toPromiseValue(source, options = {}) {
|
|
9
|
-
try {
|
|
10
|
-
const { raw = true } = options;
|
|
11
|
-
let value;
|
|
12
|
-
if (shared.isFunction(source)) {
|
|
13
|
-
value = await source();
|
|
14
|
-
} else {
|
|
15
|
-
const result = vue.toValue(source);
|
|
16
|
-
value = shared.isPromise(result) ? await result : result;
|
|
17
|
-
}
|
|
18
|
-
return raw ? vue.toRaw(value) : value;
|
|
19
|
-
} catch (error) {
|
|
20
|
-
console.error(error);
|
|
21
|
-
throw error;
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
function useCesiumEventListener(event, listener, options = {}) {
|
|
25
|
-
const isActive = vue.toRef(options.isActive ?? true);
|
|
26
|
-
const cleanup = vue.watchEffect((onCleanup) => {
|
|
27
|
-
const _event = vue.toValue(event);
|
|
28
|
-
const events = Array.isArray(_event) ? _event : [_event];
|
|
29
|
-
if (events) {
|
|
30
|
-
if (events.length && isActive.value) {
|
|
31
|
-
const stopFns = events.map((event2) => {
|
|
32
|
-
const e = vue.toValue(event2);
|
|
33
|
-
return e == null ? void 0 : e.addEventListener(listener, e);
|
|
34
|
-
});
|
|
35
|
-
onCleanup(() => stopFns.forEach((stop) => stop == null ? void 0 : stop()));
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
});
|
|
39
|
-
core.tryOnScopeDispose(cleanup.stop);
|
|
40
|
-
return cleanup.stop;
|
|
41
|
-
}
|
|
42
|
-
function useViewer() {
|
|
43
|
-
const scope = vue.getCurrentScope();
|
|
44
|
-
const instanceViewer = scope ? CREATE_VIEWER_COLLECTION.get(scope) : void 0;
|
|
45
|
-
if (instanceViewer) {
|
|
46
|
-
return instanceViewer;
|
|
47
|
-
} else {
|
|
48
|
-
const injectViewer = vue.inject(CREATE_VIEWER_INJECTION_KEY);
|
|
49
|
-
if (!injectViewer) {
|
|
50
|
-
throw new Error(
|
|
51
|
-
"The `Viewer` instance injected by `createViewer` was not found in the current component or its ancestor components. Have you called `createViewer`?"
|
|
52
|
-
);
|
|
53
|
-
}
|
|
54
|
-
return injectViewer;
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
function useCollectionScope(addFn, removeFn, removeScopeArgs) {
|
|
58
|
-
const scope = vue.shallowReactive(/* @__PURE__ */ new Set());
|
|
59
|
-
const add = (instance, ...args) => {
|
|
60
|
-
const result = addFn(instance, ...args);
|
|
61
|
-
if (shared.isPromise(result)) {
|
|
62
|
-
return new Promise((resolve, reject) => {
|
|
63
|
-
result.then((i) => {
|
|
64
|
-
scope.add(i);
|
|
65
|
-
resolve(i);
|
|
66
|
-
}).catch((error) => reject(error));
|
|
67
|
-
});
|
|
68
|
-
} else {
|
|
69
|
-
scope.add(result);
|
|
70
|
-
return result;
|
|
71
|
-
}
|
|
72
|
-
};
|
|
73
|
-
const remove = (instance, ...args) => {
|
|
74
|
-
scope.delete(instance);
|
|
75
|
-
return removeFn(instance, ...args);
|
|
76
|
-
};
|
|
77
|
-
const removeWhere = (predicate, ...args) => {
|
|
78
|
-
scope.forEach((instance) => {
|
|
79
|
-
if (predicate(instance)) {
|
|
80
|
-
remove(instance, ...args);
|
|
81
|
-
}
|
|
82
|
-
});
|
|
83
|
-
};
|
|
84
|
-
const removeScope = (...args) => {
|
|
85
|
-
scope.forEach((instance) => {
|
|
86
|
-
remove(instance, ...args);
|
|
87
|
-
});
|
|
88
|
-
};
|
|
89
|
-
core.tryOnScopeDispose(() => removeScope(...removeScopeArgs));
|
|
90
|
-
return {
|
|
91
|
-
scope: vue.shallowReadonly(scope),
|
|
92
|
-
add,
|
|
93
|
-
remove,
|
|
94
|
-
removeWhere,
|
|
95
|
-
removeScope
|
|
96
|
-
};
|
|
97
|
-
}
|
|
98
|
-
function useDataSource(dataSources, options = {}) {
|
|
99
|
-
const {
|
|
100
|
-
destroyOnRemove,
|
|
101
|
-
collection,
|
|
102
|
-
isActive = true,
|
|
103
|
-
evaluating
|
|
104
|
-
} = options;
|
|
105
|
-
const result = core.computedAsync(
|
|
106
|
-
() => toPromiseValue(dataSources),
|
|
107
|
-
void 0,
|
|
108
|
-
{
|
|
109
|
-
evaluating
|
|
110
|
-
}
|
|
111
|
-
);
|
|
112
|
-
const viewer = useViewer();
|
|
113
|
-
vue.watchEffect((onCleanup) => {
|
|
114
|
-
var _a;
|
|
115
|
-
const _isActive = vue.toValue(isActive);
|
|
116
|
-
if (_isActive) {
|
|
117
|
-
const list = Array.isArray(result.value) ? [...result.value] : [result.value];
|
|
118
|
-
const _collection = collection ?? ((_a = viewer.value) == null ? void 0 : _a.dataSources);
|
|
119
|
-
list.forEach((item) => item && (_collection == null ? void 0 : _collection.add(item)));
|
|
120
|
-
onCleanup(() => {
|
|
121
|
-
const destroy = vue.toValue(destroyOnRemove);
|
|
122
|
-
!(_collection == null ? void 0 : _collection.isDestroyed()) && list.forEach((dataSource) => dataSource && (_collection == null ? void 0 : _collection.remove(dataSource, destroy)));
|
|
123
|
-
});
|
|
124
|
-
}
|
|
125
|
-
});
|
|
126
|
-
return result;
|
|
127
|
-
}
|
|
128
|
-
function useEntityScope(options = {}) {
|
|
129
|
-
const { collection: _collection } = options;
|
|
130
|
-
const viewer = useViewer();
|
|
131
|
-
const collection = vue.computed(() => {
|
|
132
|
-
var _a;
|
|
133
|
-
return vue.toValue(_collection) ?? ((_a = viewer.value) == null ? void 0 : _a.entities);
|
|
134
|
-
});
|
|
135
|
-
const addFn = (entity) => {
|
|
136
|
-
if (!collection.value) {
|
|
137
|
-
throw new Error("collection is not defined");
|
|
138
|
-
}
|
|
139
|
-
if (!collection.value.contains(entity)) {
|
|
140
|
-
collection.value.add(entity);
|
|
141
|
-
}
|
|
142
|
-
return entity;
|
|
143
|
-
};
|
|
144
|
-
const removeFn = (entity) => {
|
|
145
|
-
var _a;
|
|
146
|
-
return !!((_a = collection.value) == null ? void 0 : _a.remove(entity));
|
|
147
|
-
};
|
|
148
|
-
const { scope, add, remove, removeWhere, removeScope } = useCollectionScope(addFn, removeFn, []);
|
|
149
|
-
return {
|
|
150
|
-
scope,
|
|
151
|
-
add,
|
|
152
|
-
remove,
|
|
153
|
-
removeWhere,
|
|
154
|
-
removeScope
|
|
155
|
-
};
|
|
156
|
-
}
|
|
157
|
-
const pickCache = /* @__PURE__ */ new WeakMap();
|
|
158
|
-
function useScenePick(windowPosition, options = {}) {
|
|
159
|
-
const { width = 3, height = 3, throttled = 8 } = options;
|
|
160
|
-
const isActive = vue.toRef(options.isActive ?? true);
|
|
161
|
-
const viewer = useViewer();
|
|
162
|
-
const position = core.refThrottled(vue.computed(() => {
|
|
163
|
-
var _a;
|
|
164
|
-
return (_a = vue.toValue(windowPosition)) == null ? void 0 : _a.clone();
|
|
165
|
-
}), throttled, false, true);
|
|
166
|
-
const pick = vue.shallowRef();
|
|
167
|
-
vue.watchEffect(() => {
|
|
168
|
-
var _a;
|
|
169
|
-
if (viewer.value && position.value && isActive.value) {
|
|
170
|
-
const cache = pickCache.get(viewer.value);
|
|
171
|
-
if (cache && cache[0].equals(position.value)) {
|
|
172
|
-
pick.value = cache[1];
|
|
173
|
-
} else {
|
|
174
|
-
pickCache.set(viewer.value, [position.value.clone(), pick.value]);
|
|
175
|
-
pick.value = (_a = viewer.value) == null ? void 0 : _a.scene.pick(
|
|
176
|
-
position.value,
|
|
177
|
-
vue.toValue(width),
|
|
178
|
-
vue.toValue(height)
|
|
179
|
-
);
|
|
180
|
-
}
|
|
181
|
-
}
|
|
182
|
-
});
|
|
183
|
-
return pick;
|
|
184
|
-
}
|
|
185
|
-
function useScreenSpaceEventHandler(type, inputAction, options = {}) {
|
|
186
|
-
const { modifier } = options;
|
|
187
|
-
const viewer = useViewer();
|
|
188
|
-
const isActive = vue.toRef(options.isActive ?? true);
|
|
189
|
-
const handler = vue.computed(() => {
|
|
190
|
-
var _a, _b;
|
|
191
|
-
if ((_b = (_a = viewer.value) == null ? void 0 : _a.cesiumWidget) == null ? void 0 : _b.canvas) {
|
|
192
|
-
return new cesium.ScreenSpaceEventHandler(viewer.value.cesiumWidget.canvas);
|
|
193
|
-
}
|
|
194
|
-
});
|
|
195
|
-
const cleanup1 = vue.watch(handler, (_value, previous) => {
|
|
196
|
-
var _a;
|
|
197
|
-
((_a = viewer.value) == null ? void 0 : _a.cesiumWidget) && (previous == null ? void 0 : previous.destroy());
|
|
198
|
-
});
|
|
199
|
-
const cleanup2 = vue.watchEffect((onCleanup) => {
|
|
200
|
-
const typeValue = vue.toValue(type);
|
|
201
|
-
const modifierValue = vue.toValue(modifier);
|
|
202
|
-
const handlerValue = vue.toValue(handler);
|
|
203
|
-
if (!handlerValue || !isActive.value || !inputAction) {
|
|
204
|
-
return;
|
|
205
|
-
}
|
|
206
|
-
if (shared.isDef(typeValue)) {
|
|
207
|
-
handlerValue.setInputAction(inputAction, typeValue, modifierValue);
|
|
208
|
-
onCleanup(() => handlerValue.removeInputAction(typeValue, modifierValue));
|
|
209
|
-
}
|
|
210
|
-
});
|
|
211
|
-
const stop = () => {
|
|
212
|
-
cleanup1();
|
|
213
|
-
cleanup2();
|
|
214
|
-
};
|
|
215
|
-
core.tryOnScopeDispose(stop);
|
|
216
|
-
return stop;
|
|
217
|
-
}
|
|
218
|
-
function useDrag(listener) {
|
|
219
|
-
const position = vue.shallowRef();
|
|
220
|
-
const pick = useScenePick(position);
|
|
221
|
-
const motionEvent = vue.shallowRef();
|
|
222
|
-
const dragging = vue.ref(false);
|
|
223
|
-
const viewer = useViewer();
|
|
224
|
-
const cameraLocked = vue.ref(false);
|
|
225
|
-
vue.watch(cameraLocked, (cameraLocked2) => {
|
|
226
|
-
viewer.value && (viewer.value.scene.screenSpaceCameraController.enableRotate = !cameraLocked2);
|
|
227
|
-
});
|
|
228
|
-
const lockCamera = () => {
|
|
229
|
-
cameraLocked.value = true;
|
|
230
|
-
};
|
|
231
|
-
const execute = (pick2, startPosition, endPosition) => {
|
|
232
|
-
listener({
|
|
233
|
-
event: {
|
|
234
|
-
startPosition: startPosition.clone(),
|
|
235
|
-
endPosition: endPosition.clone()
|
|
236
|
-
},
|
|
237
|
-
pick: pick2,
|
|
238
|
-
dragging: dragging.value,
|
|
239
|
-
lockCamera
|
|
240
|
-
});
|
|
241
|
-
vue.nextTick(() => {
|
|
242
|
-
if (!dragging.value && cameraLocked.value) {
|
|
243
|
-
cameraLocked.value = false;
|
|
244
|
-
}
|
|
245
|
-
});
|
|
246
|
-
};
|
|
247
|
-
const stopLeftDownWatch = useScreenSpaceEventHandler(
|
|
248
|
-
cesium.ScreenSpaceEventType.LEFT_DOWN,
|
|
249
|
-
(event) => {
|
|
250
|
-
dragging.value = true;
|
|
251
|
-
position.value = event.position.clone();
|
|
252
|
-
}
|
|
253
|
-
);
|
|
254
|
-
const stopMouseMoveWatch = useScreenSpaceEventHandler(
|
|
255
|
-
cesium.ScreenSpaceEventType.MOUSE_MOVE,
|
|
256
|
-
shared.throttle(({ startPosition, endPosition }) => {
|
|
257
|
-
var _a;
|
|
258
|
-
motionEvent.value = {
|
|
259
|
-
startPosition: ((_a = motionEvent.value) == null ? void 0 : _a.endPosition.clone()) || startPosition.clone(),
|
|
260
|
-
endPosition: endPosition.clone()
|
|
261
|
-
};
|
|
262
|
-
}, 8, false, true)
|
|
263
|
-
);
|
|
264
|
-
vue.watch([pick, motionEvent], ([pick2, motionEvent2]) => {
|
|
265
|
-
if (pick2 && motionEvent2) {
|
|
266
|
-
const { startPosition, endPosition } = motionEvent2;
|
|
267
|
-
dragging.value && execute(pick2, startPosition, endPosition);
|
|
268
|
-
}
|
|
269
|
-
});
|
|
270
|
-
const stopLeftUpWatch = useScreenSpaceEventHandler(
|
|
271
|
-
cesium.ScreenSpaceEventType.LEFT_UP,
|
|
272
|
-
(event) => {
|
|
273
|
-
dragging.value = false;
|
|
274
|
-
if (pick.value && motionEvent.value) {
|
|
275
|
-
execute(pick.value, motionEvent.value.endPosition, event.position);
|
|
276
|
-
}
|
|
277
|
-
position.value = void 0;
|
|
278
|
-
motionEvent.value = void 0;
|
|
279
|
-
}
|
|
280
|
-
);
|
|
281
|
-
const stop = () => {
|
|
282
|
-
stopLeftDownWatch();
|
|
283
|
-
stopMouseMoveWatch();
|
|
284
|
-
stopLeftUpWatch();
|
|
285
|
-
};
|
|
286
|
-
core.tryOnScopeDispose(stop);
|
|
287
|
-
return stop;
|
|
288
|
-
}
|
|
289
|
-
function useHover(listener) {
|
|
290
|
-
const motionEvent = vue.shallowRef();
|
|
291
|
-
const pick = useScenePick(() => {
|
|
292
|
-
var _a;
|
|
293
|
-
return (_a = motionEvent.value) == null ? void 0 : _a.endPosition;
|
|
294
|
-
});
|
|
295
|
-
const execute = (pick2, startPosition, endPosition, hovering) => {
|
|
296
|
-
listener({
|
|
297
|
-
event: {
|
|
298
|
-
startPosition: startPosition.clone(),
|
|
299
|
-
endPosition: endPosition.clone()
|
|
300
|
-
},
|
|
301
|
-
pick: pick2,
|
|
302
|
-
hovering
|
|
303
|
-
});
|
|
304
|
-
};
|
|
305
|
-
useScreenSpaceEventHandler(
|
|
306
|
-
cesium.ScreenSpaceEventType.MOUSE_MOVE,
|
|
307
|
-
({ startPosition, endPosition }) => {
|
|
308
|
-
var _a, _b;
|
|
309
|
-
if (!startPosition.equals((_a = motionEvent.value) == null ? void 0 : _a.startPosition) || !endPosition.equals((_b = motionEvent.value) == null ? void 0 : _b.endPosition)) {
|
|
310
|
-
motionEvent.value = { startPosition: startPosition.clone(), endPosition: endPosition.clone() };
|
|
311
|
-
}
|
|
312
|
-
}
|
|
313
|
-
);
|
|
314
|
-
vue.watch([pick, motionEvent], ([pick2, motionEvent2]) => {
|
|
315
|
-
if (pick2 && motionEvent2) {
|
|
316
|
-
const { startPosition, endPosition } = motionEvent2;
|
|
317
|
-
execute(pick2, startPosition, endPosition, true);
|
|
318
|
-
}
|
|
319
|
-
});
|
|
320
|
-
vue.watch(pick, (pick2, prevPick) => {
|
|
321
|
-
if (prevPick && motionEvent.value) {
|
|
322
|
-
const { startPosition, endPosition } = motionEvent.value;
|
|
323
|
-
execute(prevPick, startPosition, endPosition, false);
|
|
324
|
-
}
|
|
325
|
-
});
|
|
326
|
-
}
|
|
327
|
-
const EVENT_TYPE_RECORD = {
|
|
328
|
-
LEFT_DOWN: cesium.ScreenSpaceEventType.LEFT_DOWN,
|
|
329
|
-
LEFT_UP: cesium.ScreenSpaceEventType.LEFT_UP,
|
|
330
|
-
LEFT_CLICK: cesium.ScreenSpaceEventType.LEFT_CLICK,
|
|
331
|
-
LEFT_DOUBLE_CLICK: cesium.ScreenSpaceEventType.LEFT_DOUBLE_CLICK,
|
|
332
|
-
RIGHT_DOWN: cesium.ScreenSpaceEventType.RIGHT_DOWN,
|
|
333
|
-
RIGHT_UP: cesium.ScreenSpaceEventType.RIGHT_UP,
|
|
334
|
-
RIGHT_CLICK: cesium.ScreenSpaceEventType.RIGHT_CLICK,
|
|
335
|
-
MIDDLE_DOWN: cesium.ScreenSpaceEventType.MIDDLE_DOWN,
|
|
336
|
-
MIDDLE_UP: cesium.ScreenSpaceEventType.MIDDLE_UP,
|
|
337
|
-
MIDDLE_CLICK: cesium.ScreenSpaceEventType.MIDDLE_CLICK
|
|
338
|
-
};
|
|
339
|
-
function usePositioned(type, listener) {
|
|
340
|
-
const screenEvent = EVENT_TYPE_RECORD[type];
|
|
341
|
-
const viewer = useViewer();
|
|
342
|
-
useScreenSpaceEventHandler(screenEvent, (event) => {
|
|
343
|
-
var _a;
|
|
344
|
-
const position = event.position;
|
|
345
|
-
const pick = (_a = viewer.value) == null ? void 0 : _a.scene.pick(position);
|
|
346
|
-
pick && position && listener({ event: { position }, pick });
|
|
347
|
-
});
|
|
348
|
-
}
|
|
349
|
-
const GLOBAL_GRAPHIC_SYMBOL = Symbol("GLOBAL_GRAPHIC_SYMBOL");
|
|
350
|
-
const POSITIONED_EVENT_TYPES = [
|
|
351
|
-
"LEFT_DOWN",
|
|
352
|
-
"LEFT_UP",
|
|
353
|
-
"LEFT_CLICK",
|
|
354
|
-
"LEFT_DOUBLE_CLICK",
|
|
355
|
-
"RIGHT_DOWN",
|
|
356
|
-
"RIGHT_UP",
|
|
357
|
-
"RIGHT_CLICK",
|
|
358
|
-
"MIDDLE_DOWN",
|
|
359
|
-
"MIDDLE_UP",
|
|
360
|
-
"MIDDLE_CLICK"
|
|
361
|
-
];
|
|
362
|
-
function useGraphicEvent() {
|
|
363
|
-
const collection = /* @__PURE__ */ new WeakMap();
|
|
364
|
-
const cursorCollection = /* @__PURE__ */ new WeakMap();
|
|
365
|
-
const dragCursorCollection = /* @__PURE__ */ new WeakMap();
|
|
366
|
-
const removeGraphicEvent = (graphic, type, listener) => {
|
|
367
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s;
|
|
368
|
-
const _graphic = graphic === "global" ? GLOBAL_GRAPHIC_SYMBOL : graphic;
|
|
369
|
-
(_b = (_a = collection == null ? void 0 : collection.get(_graphic)) == null ? void 0 : _a.get(type)) == null ? void 0 : _b.delete(listener);
|
|
370
|
-
(_d = (_c = cursorCollection == null ? void 0 : cursorCollection.get(_graphic)) == null ? void 0 : _c.get(type)) == null ? void 0 : _d.delete(listener);
|
|
371
|
-
if (((_f = (_e = collection == null ? void 0 : collection.get(_graphic)) == null ? void 0 : _e.get(type)) == null ? void 0 : _f.size) === 0) {
|
|
372
|
-
collection.get(_graphic).delete(type);
|
|
373
|
-
}
|
|
374
|
-
if (((_g = collection.get(_graphic)) == null ? void 0 : _g.size) === 0) {
|
|
375
|
-
collection.delete(_graphic);
|
|
376
|
-
}
|
|
377
|
-
(_i = (_h = cursorCollection == null ? void 0 : cursorCollection.get(_graphic)) == null ? void 0 : _h.get(type)) == null ? void 0 : _i.delete(listener);
|
|
378
|
-
if (((_k = (_j = cursorCollection == null ? void 0 : cursorCollection.get(_graphic)) == null ? void 0 : _j.get(type)) == null ? void 0 : _k.size) === 0) {
|
|
379
|
-
(_l = cursorCollection == null ? void 0 : cursorCollection.get(_graphic)) == null ? void 0 : _l.delete(type);
|
|
380
|
-
}
|
|
381
|
-
if (((_m = cursorCollection == null ? void 0 : cursorCollection.get(_graphic)) == null ? void 0 : _m.size) === 0) {
|
|
382
|
-
cursorCollection == null ? void 0 : cursorCollection.delete(_graphic);
|
|
383
|
-
}
|
|
384
|
-
(_o = (_n = dragCursorCollection == null ? void 0 : dragCursorCollection.get(_graphic)) == null ? void 0 : _n.get(type)) == null ? void 0 : _o.delete(listener);
|
|
385
|
-
if (((_q = (_p = dragCursorCollection == null ? void 0 : dragCursorCollection.get(_graphic)) == null ? void 0 : _p.get(type)) == null ? void 0 : _q.size) === 0) {
|
|
386
|
-
(_r = dragCursorCollection == null ? void 0 : dragCursorCollection.get(_graphic)) == null ? void 0 : _r.delete(type);
|
|
387
|
-
}
|
|
388
|
-
if (((_s = dragCursorCollection == null ? void 0 : dragCursorCollection.get(_graphic)) == null ? void 0 : _s.size) === 0) {
|
|
389
|
-
dragCursorCollection == null ? void 0 : dragCursorCollection.delete(_graphic);
|
|
390
|
-
}
|
|
391
|
-
};
|
|
392
|
-
const addGraphicEvent = (graphic, type, listener, options = {}) => {
|
|
393
|
-
const _graphic = graphic === "global" ? GLOBAL_GRAPHIC_SYMBOL : graphic;
|
|
394
|
-
collection.get(_graphic) ?? collection.set(_graphic, /* @__PURE__ */ new Map());
|
|
395
|
-
const eventTypeMap = collection.get(_graphic);
|
|
396
|
-
eventTypeMap.get(type) ?? eventTypeMap.set(type, /* @__PURE__ */ new Set());
|
|
397
|
-
const listeners = eventTypeMap.get(type);
|
|
398
|
-
listeners.add(listener);
|
|
399
|
-
let { cursor = "pointer", dragCursor } = options;
|
|
400
|
-
if (shared.isDef(cursor)) {
|
|
401
|
-
const _cursor = shared.isFunction(cursor) ? cursor : () => cursor;
|
|
402
|
-
cursorCollection.get(_graphic) ?? cursorCollection.set(_graphic, /* @__PURE__ */ new Map());
|
|
403
|
-
cursorCollection.get(_graphic).get(type) ?? cursorCollection.get(_graphic).set(type, /* @__PURE__ */ new Map());
|
|
404
|
-
cursorCollection.get(_graphic).get(type).set(listener, _cursor);
|
|
405
|
-
}
|
|
406
|
-
if (type === "DRAG") {
|
|
407
|
-
dragCursor ?? (dragCursor = (event) => (event == null ? void 0 : event.dragging) ? "crosshair" : void 0);
|
|
408
|
-
}
|
|
409
|
-
if (shared.isDef(dragCursor)) {
|
|
410
|
-
const _dragCursor = shared.isFunction(dragCursor) ? dragCursor : () => dragCursor;
|
|
411
|
-
dragCursorCollection.get(_graphic) ?? dragCursorCollection.set(_graphic, /* @__PURE__ */ new Map());
|
|
412
|
-
dragCursorCollection.get(_graphic).get(type) ?? dragCursorCollection.get(_graphic).set(type, /* @__PURE__ */ new Map());
|
|
413
|
-
dragCursorCollection.get(_graphic).get(type).set(listener, _dragCursor);
|
|
414
|
-
}
|
|
415
|
-
return () => removeGraphicEvent(graphic, type, listener);
|
|
416
|
-
};
|
|
417
|
-
const clearGraphicEvent = (graphic, type) => {
|
|
418
|
-
var _a, _b, _c, _d, _e, _f;
|
|
419
|
-
const _graphic = graphic === "global" ? GLOBAL_GRAPHIC_SYMBOL : graphic;
|
|
420
|
-
if (type === "all") {
|
|
421
|
-
collection.delete(_graphic);
|
|
422
|
-
cursorCollection.delete(_graphic);
|
|
423
|
-
dragCursorCollection.delete(_graphic);
|
|
424
|
-
return;
|
|
425
|
-
}
|
|
426
|
-
(_a = collection.get(_graphic)) == null ? void 0 : _a.delete(type);
|
|
427
|
-
if (((_b = collection.get(_graphic)) == null ? void 0 : _b.size) === 0) {
|
|
428
|
-
collection.delete(_graphic);
|
|
429
|
-
}
|
|
430
|
-
(_c = cursorCollection == null ? void 0 : cursorCollection.get(_graphic)) == null ? void 0 : _c.delete(type);
|
|
431
|
-
(_d = dragCursorCollection == null ? void 0 : dragCursorCollection.get(_graphic)) == null ? void 0 : _d.delete(type);
|
|
432
|
-
if (((_e = cursorCollection == null ? void 0 : cursorCollection.get(_graphic)) == null ? void 0 : _e.size) === 0) {
|
|
433
|
-
cursorCollection == null ? void 0 : cursorCollection.delete(_graphic);
|
|
434
|
-
}
|
|
435
|
-
if (((_f = dragCursorCollection == null ? void 0 : dragCursorCollection.get(_graphic)) == null ? void 0 : _f.size) === 0) {
|
|
436
|
-
dragCursorCollection == null ? void 0 : dragCursorCollection.delete(_graphic);
|
|
437
|
-
}
|
|
438
|
-
};
|
|
439
|
-
for (const type of POSITIONED_EVENT_TYPES) {
|
|
440
|
-
usePositioned(type, (event) => {
|
|
441
|
-
const graphics = shared.resolvePick(event.pick);
|
|
442
|
-
graphics.concat(GLOBAL_GRAPHIC_SYMBOL).forEach((graphic) => {
|
|
443
|
-
var _a, _b;
|
|
444
|
-
(_b = (_a = collection.get(graphic)) == null ? void 0 : _a.get(type)) == null ? void 0 : _b.forEach((fn) => {
|
|
445
|
-
var _a2;
|
|
446
|
-
return (_a2 = shared.tryRun(fn)) == null ? void 0 : _a2(event);
|
|
447
|
-
});
|
|
448
|
-
});
|
|
449
|
-
});
|
|
450
|
-
}
|
|
451
|
-
const dragging = vue.ref(false);
|
|
452
|
-
const viewer = useViewer();
|
|
453
|
-
useHover((event) => {
|
|
454
|
-
const graphics = shared.resolvePick(event.pick).concat(GLOBAL_GRAPHIC_SYMBOL);
|
|
455
|
-
graphics.forEach((graphic) => {
|
|
456
|
-
var _a, _b, _c;
|
|
457
|
-
(_b = (_a = collection.get(graphic)) == null ? void 0 : _a.get("HOVER")) == null ? void 0 : _b.forEach((fn) => {
|
|
458
|
-
var _a2;
|
|
459
|
-
return (_a2 = shared.tryRun(fn)) == null ? void 0 : _a2(event);
|
|
460
|
-
});
|
|
461
|
-
if (!dragging.value) {
|
|
462
|
-
(_c = cursorCollection.get(graphic)) == null ? void 0 : _c.forEach((map) => {
|
|
463
|
-
map.forEach((fn) => {
|
|
464
|
-
var _a2, _b2;
|
|
465
|
-
const cursor = event.hovering ? shared.tryRun(fn)(event) : "";
|
|
466
|
-
(_b2 = (_a2 = viewer.value) == null ? void 0 : _a2.canvas.style) == null ? void 0 : _b2.setProperty("cursor", cursor);
|
|
467
|
-
});
|
|
468
|
-
});
|
|
469
|
-
}
|
|
470
|
-
});
|
|
471
|
-
});
|
|
472
|
-
useDrag((event) => {
|
|
473
|
-
const graphics = shared.resolvePick(event.pick).concat(GLOBAL_GRAPHIC_SYMBOL);
|
|
474
|
-
dragging.value = event.dragging;
|
|
475
|
-
graphics.forEach((graphic) => {
|
|
476
|
-
var _a, _b, _c;
|
|
477
|
-
(_b = (_a = collection.get(graphic)) == null ? void 0 : _a.get("DRAG")) == null ? void 0 : _b.forEach((fn) => shared.tryRun(fn)(event));
|
|
478
|
-
(_c = dragCursorCollection.get(graphic)) == null ? void 0 : _c.forEach((map) => {
|
|
479
|
-
map.forEach((fn) => {
|
|
480
|
-
var _a2, _b2;
|
|
481
|
-
const cursor = event.dragging ? shared.tryRun(fn)(event) : "";
|
|
482
|
-
(_b2 = (_a2 = viewer.value) == null ? void 0 : _a2.canvas.style) == null ? void 0 : _b2.setProperty("cursor", cursor);
|
|
483
|
-
});
|
|
484
|
-
});
|
|
485
|
-
});
|
|
486
|
-
});
|
|
487
|
-
return {
|
|
488
|
-
addGraphicEvent,
|
|
489
|
-
removeGraphicEvent,
|
|
490
|
-
clearGraphicEvent
|
|
491
|
-
};
|
|
492
|
-
}
|
|
493
|
-
function usePrimitive(data, options = {}) {
|
|
494
|
-
const {
|
|
495
|
-
collection,
|
|
496
|
-
isActive = true,
|
|
497
|
-
evaluating
|
|
498
|
-
} = options;
|
|
499
|
-
const result = core.computedAsync(
|
|
500
|
-
() => toPromiseValue(data),
|
|
501
|
-
void 0,
|
|
502
|
-
{
|
|
503
|
-
evaluating
|
|
504
|
-
}
|
|
505
|
-
);
|
|
506
|
-
const viewer = useViewer();
|
|
507
|
-
vue.watchEffect((onCleanup) => {
|
|
508
|
-
var _a, _b;
|
|
509
|
-
const _isActive = vue.toValue(isActive);
|
|
510
|
-
if (_isActive) {
|
|
511
|
-
const list = Array.isArray(result.value) ? [...result.value] : [result.value];
|
|
512
|
-
const _collection = collection === "ground" ? (_a = viewer.value) == null ? void 0 : _a.scene.groundPrimitives : collection ?? ((_b = viewer.value) == null ? void 0 : _b.scene.primitives);
|
|
513
|
-
list.forEach((item) => item && (_collection == null ? void 0 : _collection.add(item)));
|
|
514
|
-
onCleanup(() => {
|
|
515
|
-
!(_collection == null ? void 0 : _collection.isDestroyed()) && list.forEach((item) => item && (_collection == null ? void 0 : _collection.remove(item)));
|
|
516
|
-
});
|
|
517
|
-
}
|
|
518
|
-
});
|
|
519
|
-
return result;
|
|
520
|
-
}
|
|
521
|
-
function usePrimitiveScope(options = {}) {
|
|
522
|
-
const { collection: _collection } = options;
|
|
523
|
-
const viewer = useViewer();
|
|
524
|
-
const collection = vue.computed(() => {
|
|
525
|
-
var _a;
|
|
526
|
-
return vue.toValue(_collection) ?? ((_a = viewer.value) == null ? void 0 : _a.scene.primitives);
|
|
527
|
-
});
|
|
528
|
-
const addFn = (primitive) => {
|
|
529
|
-
if (!collection.value) {
|
|
530
|
-
throw new Error("collection is not defined");
|
|
531
|
-
}
|
|
532
|
-
return collection.value.add(primitive);
|
|
533
|
-
};
|
|
534
|
-
const removeFn = (primitive) => {
|
|
535
|
-
var _a;
|
|
536
|
-
return !!((_a = collection.value) == null ? void 0 : _a.remove(primitive));
|
|
537
|
-
};
|
|
538
|
-
const { scope, add, remove, removeWhere, removeScope } = useCollectionScope(addFn, removeFn, []);
|
|
539
|
-
return {
|
|
540
|
-
scope,
|
|
541
|
-
add,
|
|
542
|
-
remove,
|
|
543
|
-
removeWhere,
|
|
544
|
-
removeScope
|
|
545
|
-
};
|
|
546
|
-
}
|
|
547
6
|
const _PlotScheme = class _PlotScheme {
|
|
548
7
|
constructor(options) {
|
|
549
8
|
__publicField(this, "type");
|
|
@@ -1030,15 +489,15 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
1030
489
|
}
|
|
1031
490
|
}
|
|
1032
491
|
function useRender(plots, current, getCurrentTime) {
|
|
1033
|
-
const viewer = useViewer();
|
|
1034
|
-
const primitiveCollection = usePrimitive(new cesium.PrimitiveCollection());
|
|
1035
|
-
const groundPrimitiveCollection = usePrimitive(new cesium.PrimitiveCollection(), { collection: "ground" });
|
|
1036
|
-
const dataSource = useDataSource(new cesium.CustomDataSource());
|
|
1037
|
-
const entityScope = useEntityScope({ collection: () => dataSource.value.entities });
|
|
1038
|
-
const primitiveScope = usePrimitiveScope({ collection: () => primitiveCollection.value });
|
|
1039
|
-
const groundPrimitiveScope = usePrimitiveScope({ collection: () => groundPrimitiveCollection.value });
|
|
492
|
+
const viewer = core$1.useViewer();
|
|
493
|
+
const primitiveCollection = core$1.usePrimitive(new cesium.PrimitiveCollection());
|
|
494
|
+
const groundPrimitiveCollection = core$1.usePrimitive(new cesium.PrimitiveCollection(), { collection: "ground" });
|
|
495
|
+
const dataSource = core$1.useDataSource(new cesium.CustomDataSource());
|
|
496
|
+
const entityScope = core$1.useEntityScope({ collection: () => dataSource.value.entities });
|
|
497
|
+
const primitiveScope = core$1.usePrimitiveScope({ collection: () => primitiveCollection.value });
|
|
498
|
+
const groundPrimitiveScope = core$1.usePrimitiveScope({ collection: () => groundPrimitiveCollection.value });
|
|
1040
499
|
const mouseCartesian = vue.shallowRef();
|
|
1041
|
-
useScreenSpaceEventHandler(
|
|
500
|
+
core$1.useScreenSpaceEventHandler(
|
|
1042
501
|
cesium.ScreenSpaceEventType.MOUSE_MOVE,
|
|
1043
502
|
(event) => {
|
|
1044
503
|
mouseCartesian.value = shared.canvasCoordToCartesian(event == null ? void 0 : event.endPosition, viewer.value.scene);
|
|
@@ -1059,7 +518,7 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
1059
518
|
immediate: true,
|
|
1060
519
|
flush: "post"
|
|
1061
520
|
});
|
|
1062
|
-
useCesiumEventListener(
|
|
521
|
+
core$1.useCesiumEventListener(
|
|
1063
522
|
() => plots.value.map((item) => item.definitionChanged),
|
|
1064
523
|
(_scope, key, newValue, oldValue) => {
|
|
1065
524
|
if (key === "entities") {
|
|
@@ -1096,7 +555,7 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
1096
555
|
vue.watch(current, (plot, previous) => {
|
|
1097
556
|
previous && update(previous);
|
|
1098
557
|
});
|
|
1099
|
-
useCesiumEventListener(
|
|
558
|
+
core$1.useCesiumEventListener(
|
|
1100
559
|
() => plots.value.map((item) => item.definitionChanged),
|
|
1101
560
|
(plot, key) => {
|
|
1102
561
|
if (["disabled", "defining", "scheme", "sampled", "time"].includes(key)) {
|
|
@@ -1114,13 +573,13 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
1114
573
|
};
|
|
1115
574
|
}
|
|
1116
575
|
function useSampled(current, getCurrentTime) {
|
|
1117
|
-
const viewer = useViewer();
|
|
576
|
+
const viewer = core$1.useViewer();
|
|
1118
577
|
const doubleClicking = vue.ref(false);
|
|
1119
578
|
const packable = vue.computed(() => {
|
|
1120
579
|
var _a;
|
|
1121
580
|
return (_a = current.value) == null ? void 0 : _a.sampled.getValue(getCurrentTime());
|
|
1122
581
|
});
|
|
1123
|
-
useScreenSpaceEventHandler(
|
|
582
|
+
core$1.useScreenSpaceEventHandler(
|
|
1124
583
|
cesium.ScreenSpaceEventType.LEFT_CLICK,
|
|
1125
584
|
async (ctx) => {
|
|
1126
585
|
var _a, _b;
|
|
@@ -1146,7 +605,7 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
1146
605
|
completed && PlotFeature.setDefining(current.value, false);
|
|
1147
606
|
}
|
|
1148
607
|
);
|
|
1149
|
-
useScreenSpaceEventHandler(
|
|
608
|
+
core$1.useScreenSpaceEventHandler(
|
|
1150
609
|
cesium.ScreenSpaceEventType.LEFT_DOUBLE_CLICK,
|
|
1151
610
|
async (ctx) => {
|
|
1152
611
|
var _a;
|
|
@@ -1168,7 +627,7 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
1168
627
|
completed && PlotFeature.setDefining(current.value, false);
|
|
1169
628
|
}
|
|
1170
629
|
);
|
|
1171
|
-
useScreenSpaceEventHandler(
|
|
630
|
+
core$1.useScreenSpaceEventHandler(
|
|
1172
631
|
cesium.ScreenSpaceEventType.RIGHT_CLICK,
|
|
1173
632
|
async () => {
|
|
1174
633
|
var _a;
|
|
@@ -1203,7 +662,7 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
1203
662
|
}
|
|
1204
663
|
}
|
|
1205
664
|
};
|
|
1206
|
-
useCesiumEventListener(() => {
|
|
665
|
+
core$1.useCesiumEventListener(() => {
|
|
1207
666
|
var _a;
|
|
1208
667
|
return (_a = current.value) == null ? void 0 : _a.definitionChanged;
|
|
1209
668
|
}, (plot, key) => {
|
|
@@ -1214,9 +673,9 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
1214
673
|
vue.watch(current, () => setDefiningCursorCss());
|
|
1215
674
|
}
|
|
1216
675
|
function useSkeleton(plots, current, getCurrentTime) {
|
|
1217
|
-
const viewer = useViewer();
|
|
1218
|
-
const dataSource = useDataSource(new cesium.CustomDataSource());
|
|
1219
|
-
const entityScope = useEntityScope({ collection: () => dataSource.value.entities });
|
|
676
|
+
const viewer = core$1.useViewer();
|
|
677
|
+
const dataSource = core$1.useDataSource(new cesium.CustomDataSource());
|
|
678
|
+
const entityScope = core$1.useEntityScope({ collection: () => dataSource.value.entities });
|
|
1220
679
|
const hoverEntity = vue.shallowRef();
|
|
1221
680
|
const activeEntity = vue.shallowRef();
|
|
1222
681
|
const getPointAction = (entity) => {
|
|
@@ -1274,7 +733,7 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
1274
733
|
}
|
|
1275
734
|
plot.skeletons = entities;
|
|
1276
735
|
};
|
|
1277
|
-
const { addGraphicEvent } = useGraphicEvent();
|
|
736
|
+
const { addGraphicEvent } = core$1.useGraphicEvent();
|
|
1278
737
|
vue.watchEffect((onCleanup) => {
|
|
1279
738
|
const remove = addGraphicEvent("global", "DRAG", ({ event, pick, dragging, lockCamera }) => {
|
|
1280
739
|
var _a;
|
|
@@ -1376,7 +835,7 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
1376
835
|
added.forEach((plot) => update(plot));
|
|
1377
836
|
removed.forEach((plot) => update(plot, true));
|
|
1378
837
|
});
|
|
1379
|
-
useCesiumEventListener(
|
|
838
|
+
core$1.useCesiumEventListener(
|
|
1380
839
|
() => plots.value.map((plot) => plot.definitionChanged),
|
|
1381
840
|
(plot, key, newValue, oldValue) => {
|
|
1382
841
|
if (["disabled", "defining", "scheme", "sampled", "time"].includes(key)) {
|
|
@@ -1398,7 +857,7 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
1398
857
|
}
|
|
1399
858
|
function usePlot(options) {
|
|
1400
859
|
const time = (options == null ? void 0 : options.time) || vue.shallowRef();
|
|
1401
|
-
const viewer = useViewer();
|
|
860
|
+
const viewer = core$1.useViewer();
|
|
1402
861
|
const getCurrentTime = () => {
|
|
1403
862
|
var _a, _b, _c;
|
|
1404
863
|
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();
|
|
@@ -1407,7 +866,7 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
1407
866
|
const plots = vue.computed(() => Array.from(collection));
|
|
1408
867
|
const current = vue.shallowRef();
|
|
1409
868
|
const packable = vue.shallowRef();
|
|
1410
|
-
useCesiumEventListener([
|
|
869
|
+
core$1.useCesiumEventListener([
|
|
1411
870
|
() => {
|
|
1412
871
|
var _a;
|
|
1413
872
|
return (_a = current.value) == null ? void 0 : _a.sampled.definitionChanged;
|
|
@@ -1419,7 +878,7 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
1419
878
|
useSampled(current, getCurrentTime);
|
|
1420
879
|
useRender(plots, current, getCurrentTime);
|
|
1421
880
|
useSkeleton(plots, current, getCurrentTime);
|
|
1422
|
-
useScreenSpaceEventHandler(cesium.ScreenSpaceEventType.LEFT_CLICK, (data) => {
|
|
881
|
+
core$1.useScreenSpaceEventHandler(cesium.ScreenSpaceEventType.LEFT_CLICK, (data) => {
|
|
1423
882
|
var _a, _b, _c;
|
|
1424
883
|
if ((_a = current.value) == null ? void 0 : _a.defining) {
|
|
1425
884
|
return;
|
|
@@ -1829,7 +1288,7 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
1829
1288
|
} else if (positions.length >= 3) {
|
|
1830
1289
|
positions.push(positions[0]);
|
|
1831
1290
|
entity.position = new cesium.ConstantPositionProperty(
|
|
1832
|
-
|
|
1291
|
+
core$1.toCartesian3(
|
|
1833
1292
|
cesium.Rectangle.center(cesium.Rectangle.fromCartesianArray(positions))
|
|
1834
1293
|
)
|
|
1835
1294
|
);
|
|
@@ -1991,5 +1450,5 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
1991
1450
|
exports.usePlot = usePlot;
|
|
1992
1451
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
1993
1452
|
return exports;
|
|
1994
|
-
}({}, Cesium, VueUse, Vue
|
|
1453
|
+
}({}, Cesium, VesiumCore, VesiumShared, VueUse, Vue);
|
|
1995
1454
|
//# sourceMappingURL=index.iife.js.map
|