vesium 1.0.1-beta.54 → 1.0.1-beta.59
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/README.md +1 -1
- package/dist/index.cjs +58 -76
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +4 -0
- package/dist/index.d.cts.map +1 -1
- package/dist/index.d.mts +4 -0
- package/dist/index.d.mts.map +1 -1
- package/dist/index.iife.js +57 -75
- 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 +12 -3
- package/dist/index.mjs.map +1 -1
- package/package.json +6 -6
package/README.md
CHANGED
|
@@ -32,7 +32,7 @@
|
|
|
32
32
|
|
|
33
33
|
## Documentation
|
|
34
34
|
|
|
35
|
-
To view the documentation, visit <a href="https://vesium.
|
|
35
|
+
To view the documentation, visit <a href="https://vesium.js.org" target="__blank">vesium.js.org</a>
|
|
36
36
|
|
|
37
37
|
## Features
|
|
38
38
|
|
package/dist/index.cjs
CHANGED
|
@@ -1,34 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
var __create = Object.create;
|
|
3
|
-
var __defProp = Object.defineProperty;
|
|
4
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
-
var __copyProps = (to, from, except, desc) => {
|
|
9
|
-
if (from && typeof from === "object" || typeof from === "function") for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
|
|
10
|
-
key = keys[i];
|
|
11
|
-
if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
|
|
12
|
-
get: ((k) => from[k]).bind(null, key),
|
|
13
|
-
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
14
|
-
});
|
|
15
|
-
}
|
|
16
|
-
return to;
|
|
17
|
-
};
|
|
18
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
|
|
19
|
-
value: mod,
|
|
20
|
-
enumerable: true
|
|
21
|
-
}) : target, mod));
|
|
22
|
-
|
|
23
|
-
//#endregion
|
|
24
|
-
let __vueuse_core = require("@vueuse/core");
|
|
25
|
-
__vueuse_core = __toESM(__vueuse_core);
|
|
1
|
+
let _vueuse_core = require("@vueuse/core");
|
|
26
2
|
let cesium = require("cesium");
|
|
27
|
-
cesium = __toESM(cesium);
|
|
28
3
|
let vue = require("vue");
|
|
29
|
-
|
|
30
|
-
let __vesium_shared = require("@vesium/shared");
|
|
31
|
-
__vesium_shared = __toESM(__vesium_shared);
|
|
4
|
+
let _vesium_shared = require("@vesium/shared");
|
|
32
5
|
|
|
33
6
|
//#region createViewer/index.ts
|
|
34
7
|
/**
|
|
@@ -48,7 +21,7 @@ function createViewer(...args) {
|
|
|
48
21
|
const scope = (0, vue.getCurrentScope)();
|
|
49
22
|
if (scope) CREATE_VIEWER_COLLECTION.set(scope, readonlyViewer);
|
|
50
23
|
const canvas = (0, vue.computed)(() => viewer.value?.canvas);
|
|
51
|
-
(0,
|
|
24
|
+
(0, _vueuse_core.useMutationObserver)(document?.body, () => {
|
|
52
25
|
if (canvas.value && !document?.body.contains(canvas.value)) viewer.value = void 0;
|
|
53
26
|
}, {
|
|
54
27
|
childList: true,
|
|
@@ -63,7 +36,7 @@ function createViewer(...args) {
|
|
|
63
36
|
onCleanup(() => !viewer.value?.isDestroyed() && viewer.value?.destroy());
|
|
64
37
|
} else viewer.value = void 0;
|
|
65
38
|
});
|
|
66
|
-
(0,
|
|
39
|
+
(0, _vueuse_core.tryOnScopeDispose)(() => {
|
|
67
40
|
viewer.value = void 0;
|
|
68
41
|
});
|
|
69
42
|
return (0, vue.computed)(() => {
|
|
@@ -95,10 +68,10 @@ async function toPromiseValue(source, options = {}) {
|
|
|
95
68
|
try {
|
|
96
69
|
const { raw = true } = options;
|
|
97
70
|
let value;
|
|
98
|
-
if ((0,
|
|
71
|
+
if ((0, _vesium_shared.isFunction)(source)) value = await source();
|
|
99
72
|
else {
|
|
100
73
|
const result = (0, vue.toValue)(source);
|
|
101
|
-
value = (0,
|
|
74
|
+
value = (0, _vesium_shared.isPromise)(result) ? await result : result;
|
|
102
75
|
}
|
|
103
76
|
return raw ? (0, vue.toRaw)(value) : value;
|
|
104
77
|
} catch (error) {
|
|
@@ -134,7 +107,7 @@ function useCesiumEventListener(event, listener, options = {}) {
|
|
|
134
107
|
}
|
|
135
108
|
}
|
|
136
109
|
});
|
|
137
|
-
(0,
|
|
110
|
+
(0, _vueuse_core.tryOnScopeDispose)(cleanup.stop);
|
|
138
111
|
return cleanup.stop;
|
|
139
112
|
}
|
|
140
113
|
|
|
@@ -176,7 +149,7 @@ function useCameraState(options = {}) {
|
|
|
176
149
|
const eventField = (0, vue.toValue)(options.event) || "changed";
|
|
177
150
|
return camera.value?.[eventField];
|
|
178
151
|
});
|
|
179
|
-
const changedSymbol = (0,
|
|
152
|
+
const changedSymbol = (0, _vueuse_core.refThrottled)((0, vue.shallowRef)(Symbol("camera change")), options.delay ?? 8, true, false);
|
|
180
153
|
const setChangedSymbol = () => {
|
|
181
154
|
changedSymbol.value = Symbol("camera change");
|
|
182
155
|
};
|
|
@@ -224,7 +197,7 @@ function useCesiumFps(options = {}) {
|
|
|
224
197
|
const p = (0, vue.shallowRef)(performance.now());
|
|
225
198
|
useCesiumEventListener(() => viewer.value?.scene.postRender, () => p.value = performance.now());
|
|
226
199
|
const interval = (0, vue.ref)(0);
|
|
227
|
-
(0,
|
|
200
|
+
(0, _vueuse_core.watchThrottled)(p, (value, oldValue) => {
|
|
228
201
|
interval.value = value - oldValue;
|
|
229
202
|
}, { throttle: delay });
|
|
230
203
|
const fps = (0, vue.computed)(() => {
|
|
@@ -248,7 +221,7 @@ function useCollectionScope(options) {
|
|
|
248
221
|
const scope = (0, vue.shallowReactive)(/* @__PURE__ */ new Set());
|
|
249
222
|
const add = (instance, ...args) => {
|
|
250
223
|
const result = addEffect(instance, ...args);
|
|
251
|
-
if ((0,
|
|
224
|
+
if ((0, _vesium_shared.isPromise)(result)) return new Promise((resolve, reject) => {
|
|
252
225
|
result.then((i) => {
|
|
253
226
|
scope.add(i);
|
|
254
227
|
resolve(i);
|
|
@@ -273,7 +246,7 @@ function useCollectionScope(options) {
|
|
|
273
246
|
remove(instance, ...args);
|
|
274
247
|
});
|
|
275
248
|
};
|
|
276
|
-
(0,
|
|
249
|
+
(0, _vueuse_core.tryOnScopeDispose)(() => removeScope(...removeScopeArgs));
|
|
277
250
|
return {
|
|
278
251
|
scope: (0, vue.shallowReadonly)(scope),
|
|
279
252
|
add,
|
|
@@ -287,7 +260,7 @@ function useCollectionScope(options) {
|
|
|
287
260
|
//#region useDataSource/index.ts
|
|
288
261
|
function useDataSource(dataSources, options = {}) {
|
|
289
262
|
const { destroyOnRemove, collection, isActive = true, evaluating } = options;
|
|
290
|
-
const result = (0,
|
|
263
|
+
const result = (0, _vueuse_core.computedAsync)(() => toPromiseValue(dataSources), void 0, { evaluating });
|
|
291
264
|
const viewer = useViewer();
|
|
292
265
|
(0, vue.watchEffect)((onCleanup) => {
|
|
293
266
|
if ((0, vue.toValue)(isActive)) {
|
|
@@ -317,7 +290,7 @@ function useDataSourceScope(options = {}) {
|
|
|
317
290
|
return useCollectionScope({
|
|
318
291
|
addEffect(instance) {
|
|
319
292
|
if (!collection.value) throw new Error("collection is not defined");
|
|
320
|
-
if ((0,
|
|
293
|
+
if ((0, _vesium_shared.isPromise)(instance)) return new Promise((resolve, reject) => {
|
|
321
294
|
instance.then((i) => {
|
|
322
295
|
collection.value.add(i);
|
|
323
296
|
resolve(i);
|
|
@@ -341,23 +314,32 @@ function useDataSourceScope(options = {}) {
|
|
|
341
314
|
* Cesium HtmlElement Overlay
|
|
342
315
|
*/
|
|
343
316
|
function useElementOverlay(target, position, options = {}) {
|
|
344
|
-
const { referenceWindow, horizontal = "center", vertical = "bottom", offset = {
|
|
317
|
+
const { referenceWindow, horizontal = "center", vertical = "bottom", clampToGround, offset = {
|
|
345
318
|
x: 0,
|
|
346
319
|
y: 0
|
|
347
320
|
} } = options;
|
|
348
|
-
const cartesian3 = (0, vue.computed)(() => (0, __vesium_shared.toCartesian3)((0, vue.toValue)(position)));
|
|
349
321
|
const viewer = useViewer();
|
|
322
|
+
const cartesian3 = (0, vue.computed)(() => {
|
|
323
|
+
const positionValue = (0, vue.toValue)(position);
|
|
324
|
+
if (!positionValue) return;
|
|
325
|
+
else if (!(0, vue.toValue)(clampToGround)) return (0, _vesium_shared.toCartesian3)(positionValue);
|
|
326
|
+
else {
|
|
327
|
+
const cartographic = (0, _vesium_shared.toCartographic)((0, vue.toValue)(positionValue));
|
|
328
|
+
cartographic.height = +(viewer.value?.scene.globe.getHeight(cartographic) || 0).toFixed(2);
|
|
329
|
+
return (0, _vesium_shared.toCartesian3)(cartographic);
|
|
330
|
+
}
|
|
331
|
+
});
|
|
350
332
|
const coord = (0, vue.shallowRef)();
|
|
351
333
|
useCesiumEventListener(() => viewer.value?.scene.postRender, () => {
|
|
352
334
|
if (!viewer.value?.scene) return;
|
|
353
335
|
if (!cartesian3.value) coord.value = void 0;
|
|
354
336
|
else {
|
|
355
|
-
const result = (0,
|
|
337
|
+
const result = (0, _vesium_shared.cartesianToCanvasCoord)(cartesian3.value, viewer.value.scene);
|
|
356
338
|
coord.value = !cesium.Cartesian2.equals(result, coord.value) ? result : coord.value;
|
|
357
339
|
}
|
|
358
340
|
});
|
|
359
|
-
const canvasBounding = (0,
|
|
360
|
-
const targetBounding = (0,
|
|
341
|
+
const canvasBounding = (0, _vueuse_core.useElementBounding)(() => viewer.value?.canvas.parentElement);
|
|
342
|
+
const targetBounding = (0, _vueuse_core.useElementBounding)(target);
|
|
361
343
|
const finalOffset = (0, vue.computed)(() => {
|
|
362
344
|
const _offset = (0, vue.toValue)(offset);
|
|
363
345
|
let x$1 = _offset?.x ?? 0;
|
|
@@ -411,7 +393,7 @@ function useElementOverlay(target, position, options = {}) {
|
|
|
411
393
|
//#region useEntity/index.ts
|
|
412
394
|
function useEntity(data, options = {}) {
|
|
413
395
|
const { collection, isActive = true, evaluating } = options;
|
|
414
|
-
const result = (0,
|
|
396
|
+
const result = (0, _vueuse_core.computedAsync)(() => toPromiseValue(data), [], { evaluating });
|
|
415
397
|
const viewer = useViewer();
|
|
416
398
|
(0, vue.watchEffect)((onCleanup) => {
|
|
417
399
|
if ((0, vue.toValue)(isActive)) {
|
|
@@ -441,7 +423,7 @@ function useEntityScope(options = {}) {
|
|
|
441
423
|
return useCollectionScope({
|
|
442
424
|
addEffect(instance) {
|
|
443
425
|
if (!collection.value) throw new Error("collection is not defined");
|
|
444
|
-
if ((0,
|
|
426
|
+
if ((0, _vesium_shared.isPromise)(instance)) return new Promise((resolve, reject) => {
|
|
445
427
|
instance.then((i) => {
|
|
446
428
|
collection.value.add(i);
|
|
447
429
|
resolve(i);
|
|
@@ -472,7 +454,7 @@ function useScenePick(windowPosition, options = {}) {
|
|
|
472
454
|
const { width = 3, height = 3, throttled = 8 } = options;
|
|
473
455
|
const isActive = (0, vue.toRef)(options.isActive ?? true);
|
|
474
456
|
const viewer = useViewer();
|
|
475
|
-
const position = (0,
|
|
457
|
+
const position = (0, _vueuse_core.refThrottled)((0, vue.computed)(() => (0, vue.toValue)(windowPosition)?.clone()), throttled, false, true);
|
|
476
458
|
const pick = (0, vue.shallowRef)();
|
|
477
459
|
(0, vue.watchEffect)(() => {
|
|
478
460
|
if (viewer.value && position.value && isActive.value) {
|
|
@@ -512,7 +494,7 @@ function useScreenSpaceEventHandler(type, inputAction, options = {}) {
|
|
|
512
494
|
const modifierValue = (0, vue.toValue)(modifier);
|
|
513
495
|
const handlerValue = (0, vue.toValue)(handler);
|
|
514
496
|
if (!handlerValue || !isActive.value || !inputAction) return;
|
|
515
|
-
if ((0,
|
|
497
|
+
if ((0, _vesium_shared.isDef)(typeValue)) {
|
|
516
498
|
handlerValue.setInputAction(inputAction, typeValue, modifierValue);
|
|
517
499
|
onCleanup(() => handlerValue.removeInputAction(typeValue, modifierValue));
|
|
518
500
|
}
|
|
@@ -521,7 +503,7 @@ function useScreenSpaceEventHandler(type, inputAction, options = {}) {
|
|
|
521
503
|
cleanup1();
|
|
522
504
|
cleanup2();
|
|
523
505
|
};
|
|
524
|
-
(0,
|
|
506
|
+
(0, _vueuse_core.tryOnScopeDispose)(stop);
|
|
525
507
|
return stop;
|
|
526
508
|
}
|
|
527
509
|
|
|
@@ -561,7 +543,7 @@ function useDrag(listener) {
|
|
|
561
543
|
dragging.value = true;
|
|
562
544
|
position.value = event.position.clone();
|
|
563
545
|
});
|
|
564
|
-
const stopMouseMoveWatch = useScreenSpaceEventHandler(cesium.ScreenSpaceEventType.MOUSE_MOVE, (0,
|
|
546
|
+
const stopMouseMoveWatch = useScreenSpaceEventHandler(cesium.ScreenSpaceEventType.MOUSE_MOVE, (0, _vesium_shared.throttle)(({ startPosition, endPosition }) => {
|
|
565
547
|
motionEvent.value = {
|
|
566
548
|
startPosition: motionEvent.value?.endPosition.clone() || startPosition.clone(),
|
|
567
549
|
endPosition: endPosition.clone()
|
|
@@ -584,7 +566,7 @@ function useDrag(listener) {
|
|
|
584
566
|
stopMouseMoveWatch();
|
|
585
567
|
stopLeftUpWatch();
|
|
586
568
|
};
|
|
587
|
-
(0,
|
|
569
|
+
(0, _vueuse_core.tryOnScopeDispose)(stop);
|
|
588
570
|
return stop;
|
|
589
571
|
}
|
|
590
572
|
|
|
@@ -699,15 +681,15 @@ function useGraphicEvent() {
|
|
|
699
681
|
eventTypeMap.get(type) ?? eventTypeMap.set(type, /* @__PURE__ */ new Set());
|
|
700
682
|
eventTypeMap.get(type).add(listener);
|
|
701
683
|
let { cursor = "pointer", dragCursor } = options;
|
|
702
|
-
if ((0,
|
|
703
|
-
const _cursor = (0,
|
|
684
|
+
if ((0, _vesium_shared.isDef)(cursor)) {
|
|
685
|
+
const _cursor = (0, _vesium_shared.isFunction)(cursor) ? cursor : () => cursor;
|
|
704
686
|
cursorCollection.get(_graphic) ?? cursorCollection.set(_graphic, /* @__PURE__ */ new Map());
|
|
705
687
|
cursorCollection.get(_graphic).get(type) ?? cursorCollection.get(_graphic).set(type, /* @__PURE__ */ new Map());
|
|
706
688
|
cursorCollection.get(_graphic).get(type).set(listener, _cursor);
|
|
707
689
|
}
|
|
708
690
|
if (type === "DRAG") dragCursor ??= ((event) => event?.dragging ? "crosshair" : void 0);
|
|
709
|
-
if ((0,
|
|
710
|
-
const _dragCursor = (0,
|
|
691
|
+
if ((0, _vesium_shared.isDef)(dragCursor)) {
|
|
692
|
+
const _dragCursor = (0, _vesium_shared.isFunction)(dragCursor) ? dragCursor : () => dragCursor;
|
|
711
693
|
dragCursorCollection.get(_graphic) ?? dragCursorCollection.set(_graphic, /* @__PURE__ */ new Map());
|
|
712
694
|
dragCursorCollection.get(_graphic).get(type) ?? dragCursorCollection.get(_graphic).set(type, /* @__PURE__ */ new Map());
|
|
713
695
|
dragCursorCollection.get(_graphic).get(type).set(listener, _dragCursor);
|
|
@@ -730,31 +712,31 @@ function useGraphicEvent() {
|
|
|
730
712
|
if (dragCursorCollection?.get(_graphic)?.size === 0) dragCursorCollection?.delete(_graphic);
|
|
731
713
|
};
|
|
732
714
|
for (const type of POSITIONED_EVENT_TYPES) usePositioned(type, (event) => {
|
|
733
|
-
(0,
|
|
734
|
-
collection.get(graphic)?.get(type)?.forEach((fn) => (0,
|
|
715
|
+
(0, _vesium_shared.resolvePick)(event.pick).concat(GLOBAL_GRAPHIC_SYMBOL).forEach((graphic) => {
|
|
716
|
+
collection.get(graphic)?.get(type)?.forEach((fn) => (0, _vesium_shared.tryRun)(fn)?.(event));
|
|
735
717
|
});
|
|
736
718
|
});
|
|
737
719
|
const dragging = (0, vue.ref)(false);
|
|
738
720
|
const viewer = useViewer();
|
|
739
721
|
useHover((event) => {
|
|
740
|
-
(0,
|
|
741
|
-
collection.get(graphic)?.get("HOVER")?.forEach((fn) => (0,
|
|
722
|
+
(0, _vesium_shared.resolvePick)(event.pick).concat(GLOBAL_GRAPHIC_SYMBOL).forEach((graphic) => {
|
|
723
|
+
collection.get(graphic)?.get("HOVER")?.forEach((fn) => (0, _vesium_shared.tryRun)(fn)?.(event));
|
|
742
724
|
if (!dragging.value) cursorCollection.get(graphic)?.forEach((map) => {
|
|
743
725
|
map.forEach((fn) => {
|
|
744
|
-
const cursor = event.hovering ? (0,
|
|
726
|
+
const cursor = event.hovering ? (0, _vesium_shared.tryRun)(fn)(event) : "";
|
|
745
727
|
viewer.value?.canvas.style?.setProperty("cursor", cursor);
|
|
746
728
|
});
|
|
747
729
|
});
|
|
748
730
|
});
|
|
749
731
|
});
|
|
750
732
|
useDrag((event) => {
|
|
751
|
-
const graphics = (0,
|
|
733
|
+
const graphics = (0, _vesium_shared.resolvePick)(event.pick).concat(GLOBAL_GRAPHIC_SYMBOL);
|
|
752
734
|
dragging.value = event.dragging;
|
|
753
735
|
graphics.forEach((graphic) => {
|
|
754
|
-
collection.get(graphic)?.get("DRAG")?.forEach((fn) => (0,
|
|
736
|
+
collection.get(graphic)?.get("DRAG")?.forEach((fn) => (0, _vesium_shared.tryRun)(fn)(event));
|
|
755
737
|
dragCursorCollection.get(graphic)?.forEach((map) => {
|
|
756
738
|
map.forEach((fn) => {
|
|
757
|
-
const cursor = event.dragging ? (0,
|
|
739
|
+
const cursor = event.dragging ? (0, _vesium_shared.tryRun)(fn)(event) : "";
|
|
758
740
|
viewer.value?.canvas.style?.setProperty("cursor", cursor);
|
|
759
741
|
});
|
|
760
742
|
});
|
|
@@ -771,7 +753,7 @@ function useGraphicEvent() {
|
|
|
771
753
|
//#region useImageryLayer/index.ts
|
|
772
754
|
function useImageryLayer(data, options = {}) {
|
|
773
755
|
const { destroyOnRemove, collection, isActive = true, evaluating } = options;
|
|
774
|
-
const result = (0,
|
|
756
|
+
const result = (0, _vueuse_core.computedAsync)(() => toPromiseValue(data), [], { evaluating });
|
|
775
757
|
const viewer = useViewer();
|
|
776
758
|
(0, vue.watchEffect)((onCleanup) => {
|
|
777
759
|
if ((0, vue.toValue)(isActive)) {
|
|
@@ -813,7 +795,7 @@ function useImageryLayerScope(options = {}) {
|
|
|
813
795
|
return useCollectionScope({
|
|
814
796
|
addEffect(instance, index) {
|
|
815
797
|
if (!collection.value) throw new Error("collection is not defined");
|
|
816
|
-
if ((0,
|
|
798
|
+
if ((0, _vesium_shared.isPromise)(instance)) return new Promise((resolve, reject) => {
|
|
817
799
|
instance.then((i) => {
|
|
818
800
|
collection.value.add(i, index);
|
|
819
801
|
resolve(i);
|
|
@@ -835,7 +817,7 @@ function useImageryLayerScope(options = {}) {
|
|
|
835
817
|
//#region usePostProcessStage/index.ts
|
|
836
818
|
function usePostProcessStage(data, options = {}) {
|
|
837
819
|
const { collection, isActive = true, evaluating } = options;
|
|
838
|
-
const result = (0,
|
|
820
|
+
const result = (0, _vueuse_core.computedAsync)(() => toPromiseValue(data), void 0, { evaluating });
|
|
839
821
|
const viewer = useViewer();
|
|
840
822
|
(0, vue.watchEffect)((onCleanup) => {
|
|
841
823
|
if (!viewer.value) return;
|
|
@@ -866,7 +848,7 @@ function usePostProcessStageScope(options = {}) {
|
|
|
866
848
|
return useCollectionScope({
|
|
867
849
|
addEffect(instance) {
|
|
868
850
|
if (!collection.value) throw new Error("collection is not defined");
|
|
869
|
-
if ((0,
|
|
851
|
+
if ((0, _vesium_shared.isPromise)(instance)) return new Promise((resolve, reject) => {
|
|
870
852
|
instance.then((instance$1) => {
|
|
871
853
|
collection.value.add(instance$1);
|
|
872
854
|
resolve(instance$1);
|
|
@@ -885,7 +867,7 @@ function usePostProcessStageScope(options = {}) {
|
|
|
885
867
|
//#region usePrimitive/index.ts
|
|
886
868
|
function usePrimitive(data, options = {}) {
|
|
887
869
|
const { collection, isActive = true, evaluating } = options;
|
|
888
|
-
const result = (0,
|
|
870
|
+
const result = (0, _vueuse_core.computedAsync)(() => toPromiseValue(data), void 0, { evaluating });
|
|
889
871
|
const viewer = useViewer();
|
|
890
872
|
(0, vue.watchEffect)((onCleanup) => {
|
|
891
873
|
if ((0, vue.toValue)(isActive)) {
|
|
@@ -916,7 +898,7 @@ function usePrimitiveScope(options = {}) {
|
|
|
916
898
|
const { scope, add, remove, removeWhere, removeScope } = useCollectionScope({
|
|
917
899
|
addEffect(instance, ...args) {
|
|
918
900
|
if (!collection.value) throw new Error("collection is not defined");
|
|
919
|
-
if ((0,
|
|
901
|
+
if ((0, _vesium_shared.isPromise)(instance)) return new Promise((resolve, reject) => {
|
|
920
902
|
instance.then((instance$1) => resolve(collection.value.add(instance$1, ...args))).catch((error) => reject(error));
|
|
921
903
|
});
|
|
922
904
|
else return collection.value.add(instance, ...args);
|
|
@@ -982,7 +964,7 @@ function useScaleBar(options = {}) {
|
|
|
982
964
|
const { maxPixel = 80, delay = 8 } = options;
|
|
983
965
|
const maxPixelRef = (0, vue.computed)(() => (0, vue.toValue)(maxPixel));
|
|
984
966
|
const viewer = useViewer();
|
|
985
|
-
const canvasSize = (0,
|
|
967
|
+
const canvasSize = (0, _vueuse_core.useElementSize)(() => viewer.value?.canvas);
|
|
986
968
|
const pixelDistance = (0, vue.ref)();
|
|
987
969
|
const setPixelDistance = async () => {
|
|
988
970
|
await (0, vue.nextTick)();
|
|
@@ -996,8 +978,8 @@ function useScaleBar(options = {}) {
|
|
|
996
978
|
if (!leftPosition || !rightPosition) return;
|
|
997
979
|
pixelDistance.value = new cesium.EllipsoidGeodesic(scene.globe.ellipsoid.cartesianToCartographic(leftPosition), scene.globe.ellipsoid.cartesianToCartographic(rightPosition)).surfaceDistance;
|
|
998
980
|
};
|
|
999
|
-
(0,
|
|
1000
|
-
useCesiumEventListener(() => viewer.value?.camera.changed, (0,
|
|
981
|
+
(0, _vueuse_core.watchImmediate)(viewer, () => setPixelDistance());
|
|
982
|
+
useCesiumEventListener(() => viewer.value?.camera.changed, (0, _vesium_shared.throttle)(setPixelDistance, delay));
|
|
1001
983
|
const distance = (0, vue.computed)(() => {
|
|
1002
984
|
if (pixelDistance.value) return distances.find((item) => pixelDistance.value * maxPixelRef.value > item);
|
|
1003
985
|
});
|
|
@@ -1027,7 +1009,7 @@ function useScaleBar(options = {}) {
|
|
|
1027
1009
|
function useSceneDrillPick(windowPosition, options = {}) {
|
|
1028
1010
|
const { width = 3, height = 3, limit, throttled = 8, isActive = true } = options;
|
|
1029
1011
|
const viewer = useViewer();
|
|
1030
|
-
const position = (0,
|
|
1012
|
+
const position = (0, _vueuse_core.refThrottled)((0, vue.computed)(() => (0, vue.toValue)(windowPosition)), throttled, false, true);
|
|
1031
1013
|
return (0, vue.computed)(() => {
|
|
1032
1014
|
if (position.value && (0, vue.toValue)(isActive)) return viewer.value?.scene.drillPick(position.value, (0, vue.toValue)(limit), (0, vue.toValue)(width), (0, vue.toValue)(height));
|
|
1033
1015
|
});
|
|
@@ -1059,10 +1041,10 @@ exports.useSceneDrillPick = useSceneDrillPick;
|
|
|
1059
1041
|
exports.useScenePick = useScenePick;
|
|
1060
1042
|
exports.useScreenSpaceEventHandler = useScreenSpaceEventHandler;
|
|
1061
1043
|
exports.useViewer = useViewer;
|
|
1062
|
-
Object.keys(
|
|
1044
|
+
Object.keys(_vesium_shared).forEach(function (k) {
|
|
1063
1045
|
if (k !== 'default' && !Object.prototype.hasOwnProperty.call(exports, k)) Object.defineProperty(exports, k, {
|
|
1064
1046
|
enumerable: true,
|
|
1065
|
-
get: function () { return
|
|
1047
|
+
get: function () { return _vesium_shared[k]; }
|
|
1066
1048
|
});
|
|
1067
1049
|
});
|
|
1068
1050
|
|