@vesium/plot 1.0.1-beta.42 → 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.cjs
CHANGED
|
@@ -4,550 +4,10 @@ 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 core$1 = require("@vesium/core");
|
|
8
|
+
const shared = require("@vesium/shared");
|
|
7
9
|
const core = require("@vueuse/core");
|
|
8
10
|
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
11
|
const _PlotScheme = class _PlotScheme {
|
|
552
12
|
constructor(options) {
|
|
553
13
|
__publicField(this, "type");
|
|
@@ -1034,15 +494,15 @@ class PlotSkeletonEntity extends cesium.Entity {
|
|
|
1034
494
|
}
|
|
1035
495
|
}
|
|
1036
496
|
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 });
|
|
497
|
+
const viewer = core$1.useViewer();
|
|
498
|
+
const primitiveCollection = core$1.usePrimitive(new cesium.PrimitiveCollection());
|
|
499
|
+
const groundPrimitiveCollection = core$1.usePrimitive(new cesium.PrimitiveCollection(), { collection: "ground" });
|
|
500
|
+
const dataSource = core$1.useDataSource(new cesium.CustomDataSource());
|
|
501
|
+
const entityScope = core$1.useEntityScope({ collection: () => dataSource.value.entities });
|
|
502
|
+
const primitiveScope = core$1.usePrimitiveScope({ collection: () => primitiveCollection.value });
|
|
503
|
+
const groundPrimitiveScope = core$1.usePrimitiveScope({ collection: () => groundPrimitiveCollection.value });
|
|
1044
504
|
const mouseCartesian = vue.shallowRef();
|
|
1045
|
-
useScreenSpaceEventHandler(
|
|
505
|
+
core$1.useScreenSpaceEventHandler(
|
|
1046
506
|
cesium.ScreenSpaceEventType.MOUSE_MOVE,
|
|
1047
507
|
(event) => {
|
|
1048
508
|
mouseCartesian.value = shared.canvasCoordToCartesian(event == null ? void 0 : event.endPosition, viewer.value.scene);
|
|
@@ -1063,7 +523,7 @@ function useRender(plots, current, getCurrentTime) {
|
|
|
1063
523
|
immediate: true,
|
|
1064
524
|
flush: "post"
|
|
1065
525
|
});
|
|
1066
|
-
useCesiumEventListener(
|
|
526
|
+
core$1.useCesiumEventListener(
|
|
1067
527
|
() => plots.value.map((item) => item.definitionChanged),
|
|
1068
528
|
(_scope, key, newValue, oldValue) => {
|
|
1069
529
|
if (key === "entities") {
|
|
@@ -1100,7 +560,7 @@ function useRender(plots, current, getCurrentTime) {
|
|
|
1100
560
|
vue.watch(current, (plot, previous) => {
|
|
1101
561
|
previous && update(previous);
|
|
1102
562
|
});
|
|
1103
|
-
useCesiumEventListener(
|
|
563
|
+
core$1.useCesiumEventListener(
|
|
1104
564
|
() => plots.value.map((item) => item.definitionChanged),
|
|
1105
565
|
(plot, key) => {
|
|
1106
566
|
if (["disabled", "defining", "scheme", "sampled", "time"].includes(key)) {
|
|
@@ -1118,13 +578,13 @@ function useRender(plots, current, getCurrentTime) {
|
|
|
1118
578
|
};
|
|
1119
579
|
}
|
|
1120
580
|
function useSampled(current, getCurrentTime) {
|
|
1121
|
-
const viewer = useViewer();
|
|
581
|
+
const viewer = core$1.useViewer();
|
|
1122
582
|
const doubleClicking = vue.ref(false);
|
|
1123
583
|
const packable = vue.computed(() => {
|
|
1124
584
|
var _a;
|
|
1125
585
|
return (_a = current.value) == null ? void 0 : _a.sampled.getValue(getCurrentTime());
|
|
1126
586
|
});
|
|
1127
|
-
useScreenSpaceEventHandler(
|
|
587
|
+
core$1.useScreenSpaceEventHandler(
|
|
1128
588
|
cesium.ScreenSpaceEventType.LEFT_CLICK,
|
|
1129
589
|
async (ctx) => {
|
|
1130
590
|
var _a, _b;
|
|
@@ -1150,7 +610,7 @@ function useSampled(current, getCurrentTime) {
|
|
|
1150
610
|
completed && PlotFeature.setDefining(current.value, false);
|
|
1151
611
|
}
|
|
1152
612
|
);
|
|
1153
|
-
useScreenSpaceEventHandler(
|
|
613
|
+
core$1.useScreenSpaceEventHandler(
|
|
1154
614
|
cesium.ScreenSpaceEventType.LEFT_DOUBLE_CLICK,
|
|
1155
615
|
async (ctx) => {
|
|
1156
616
|
var _a;
|
|
@@ -1172,7 +632,7 @@ function useSampled(current, getCurrentTime) {
|
|
|
1172
632
|
completed && PlotFeature.setDefining(current.value, false);
|
|
1173
633
|
}
|
|
1174
634
|
);
|
|
1175
|
-
useScreenSpaceEventHandler(
|
|
635
|
+
core$1.useScreenSpaceEventHandler(
|
|
1176
636
|
cesium.ScreenSpaceEventType.RIGHT_CLICK,
|
|
1177
637
|
async () => {
|
|
1178
638
|
var _a;
|
|
@@ -1207,7 +667,7 @@ function useSampled(current, getCurrentTime) {
|
|
|
1207
667
|
}
|
|
1208
668
|
}
|
|
1209
669
|
};
|
|
1210
|
-
useCesiumEventListener(() => {
|
|
670
|
+
core$1.useCesiumEventListener(() => {
|
|
1211
671
|
var _a;
|
|
1212
672
|
return (_a = current.value) == null ? void 0 : _a.definitionChanged;
|
|
1213
673
|
}, (plot, key) => {
|
|
@@ -1218,9 +678,9 @@ function useSampled(current, getCurrentTime) {
|
|
|
1218
678
|
vue.watch(current, () => setDefiningCursorCss());
|
|
1219
679
|
}
|
|
1220
680
|
function useSkeleton(plots, current, getCurrentTime) {
|
|
1221
|
-
const viewer = useViewer();
|
|
1222
|
-
const dataSource = useDataSource(new cesium.CustomDataSource());
|
|
1223
|
-
const entityScope = useEntityScope({ collection: () => dataSource.value.entities });
|
|
681
|
+
const viewer = core$1.useViewer();
|
|
682
|
+
const dataSource = core$1.useDataSource(new cesium.CustomDataSource());
|
|
683
|
+
const entityScope = core$1.useEntityScope({ collection: () => dataSource.value.entities });
|
|
1224
684
|
const hoverEntity = vue.shallowRef();
|
|
1225
685
|
const activeEntity = vue.shallowRef();
|
|
1226
686
|
const getPointAction = (entity) => {
|
|
@@ -1278,7 +738,7 @@ function useSkeleton(plots, current, getCurrentTime) {
|
|
|
1278
738
|
}
|
|
1279
739
|
plot.skeletons = entities;
|
|
1280
740
|
};
|
|
1281
|
-
const { addGraphicEvent } = useGraphicEvent();
|
|
741
|
+
const { addGraphicEvent } = core$1.useGraphicEvent();
|
|
1282
742
|
vue.watchEffect((onCleanup) => {
|
|
1283
743
|
const remove = addGraphicEvent("global", "DRAG", ({ event, pick, dragging, lockCamera }) => {
|
|
1284
744
|
var _a;
|
|
@@ -1380,7 +840,7 @@ function useSkeleton(plots, current, getCurrentTime) {
|
|
|
1380
840
|
added.forEach((plot) => update(plot));
|
|
1381
841
|
removed.forEach((plot) => update(plot, true));
|
|
1382
842
|
});
|
|
1383
|
-
useCesiumEventListener(
|
|
843
|
+
core$1.useCesiumEventListener(
|
|
1384
844
|
() => plots.value.map((plot) => plot.definitionChanged),
|
|
1385
845
|
(plot, key, newValue, oldValue) => {
|
|
1386
846
|
if (["disabled", "defining", "scheme", "sampled", "time"].includes(key)) {
|
|
@@ -1402,7 +862,7 @@ function useSkeleton(plots, current, getCurrentTime) {
|
|
|
1402
862
|
}
|
|
1403
863
|
function usePlot(options) {
|
|
1404
864
|
const time = (options == null ? void 0 : options.time) || vue.shallowRef();
|
|
1405
|
-
const viewer = useViewer();
|
|
865
|
+
const viewer = core$1.useViewer();
|
|
1406
866
|
const getCurrentTime = () => {
|
|
1407
867
|
var _a, _b, _c;
|
|
1408
868
|
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 +871,7 @@ function usePlot(options) {
|
|
|
1411
871
|
const plots = vue.computed(() => Array.from(collection));
|
|
1412
872
|
const current = vue.shallowRef();
|
|
1413
873
|
const packable = vue.shallowRef();
|
|
1414
|
-
useCesiumEventListener([
|
|
874
|
+
core$1.useCesiumEventListener([
|
|
1415
875
|
() => {
|
|
1416
876
|
var _a;
|
|
1417
877
|
return (_a = current.value) == null ? void 0 : _a.sampled.definitionChanged;
|
|
@@ -1423,7 +883,7 @@ function usePlot(options) {
|
|
|
1423
883
|
useSampled(current, getCurrentTime);
|
|
1424
884
|
useRender(plots, current, getCurrentTime);
|
|
1425
885
|
useSkeleton(plots, current, getCurrentTime);
|
|
1426
|
-
useScreenSpaceEventHandler(cesium.ScreenSpaceEventType.LEFT_CLICK, (data) => {
|
|
886
|
+
core$1.useScreenSpaceEventHandler(cesium.ScreenSpaceEventType.LEFT_CLICK, (data) => {
|
|
1427
887
|
var _a, _b, _c;
|
|
1428
888
|
if ((_a = current.value) == null ? void 0 : _a.defining) {
|
|
1429
889
|
return;
|
|
@@ -1833,7 +1293,7 @@ const schemeMeasureArea = new PlotScheme({
|
|
|
1833
1293
|
} else if (positions.length >= 3) {
|
|
1834
1294
|
positions.push(positions[0]);
|
|
1835
1295
|
entity.position = new cesium.ConstantPositionProperty(
|
|
1836
|
-
|
|
1296
|
+
core$1.toCartesian3(
|
|
1837
1297
|
cesium.Rectangle.center(cesium.Rectangle.fromCartesianArray(positions))
|
|
1838
1298
|
)
|
|
1839
1299
|
);
|