vesium 1.0.1-beta.64 → 1.0.1-beta.68
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 +50 -56
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +8 -6
- package/dist/index.d.cts.map +1 -1
- package/dist/index.d.mts +8 -6
- package/dist/index.d.mts.map +1 -1
- package/dist/index.iife.js +50 -56
- 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 +51 -57
- package/dist/index.mjs.map +1 -1
- package/package.json +6 -6
package/dist/index.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { computedAsync, refThrottled, tryOnScopeDispose, useElementBounding, useElementSize, useMutationObserver, watchImmediate, watchThrottled } from "@vueuse/core";
|
|
1
|
+
import { computedAsync, refThrottled, tryOnScopeDispose, unrefElement, useElementBounding, useElementSize, useMutationObserver, watchImmediate, watchThrottled } from "@vueuse/core";
|
|
2
2
|
import { Cartesian2, EllipsoidGeodesic, ScreenSpaceEventHandler, ScreenSpaceEventType, Viewer } from "cesium";
|
|
3
3
|
import { computed, getCurrentScope, inject, markRaw, nextTick, provide, readonly, ref, shallowReactive, shallowReadonly, shallowRef, toRaw, toRef, toValue, watch, watchEffect } from "vue";
|
|
4
4
|
import { cartesianToCanvasCoord, isDef, isFunction, isPromise, resolvePick, throttle, toCartesian3, tryRun } from "@vesium/shared";
|
|
@@ -101,8 +101,8 @@ function useCesiumEventListener(event, listener, options = {}) {
|
|
|
101
101
|
const events = Array.isArray(_event) ? _event : [_event];
|
|
102
102
|
if (events) {
|
|
103
103
|
if (events.length && isActive.value) {
|
|
104
|
-
const stopFns = events.map((event
|
|
105
|
-
const e = toValue(event
|
|
104
|
+
const stopFns = events.map((event) => {
|
|
105
|
+
const e = toValue(event);
|
|
106
106
|
return e?.addEventListener(listener, e);
|
|
107
107
|
});
|
|
108
108
|
onCleanup(() => stopFns.forEach((stop) => stop?.()));
|
|
@@ -343,49 +343,42 @@ function useElementOverlay(target, position, options = {}) {
|
|
|
343
343
|
}
|
|
344
344
|
});
|
|
345
345
|
const canvasBounding = useElementBounding(() => viewer.value?.canvas.parentElement);
|
|
346
|
-
const
|
|
346
|
+
const targetSize = useElementSize(target, void 0, { box: "border-box" });
|
|
347
347
|
const finalOffset = computed(() => {
|
|
348
348
|
const _offset = toValue(offset);
|
|
349
|
-
let x
|
|
349
|
+
let x = _offset?.x ?? 0;
|
|
350
350
|
const _horizontal = toValue(horizontal);
|
|
351
|
-
if (_horizontal === "center") x
|
|
352
|
-
else if (_horizontal === "right") x
|
|
353
|
-
let y
|
|
351
|
+
if (_horizontal === "center") x -= targetSize.width.value / 2;
|
|
352
|
+
else if (_horizontal === "right") x -= targetSize.width.value;
|
|
353
|
+
let y = _offset?.y ?? 0;
|
|
354
354
|
const _vertical = toValue(vertical);
|
|
355
|
-
if (_vertical === "center") y
|
|
356
|
-
else if (_vertical === "bottom") y
|
|
355
|
+
if (_vertical === "center") y -= targetSize.height.value / 2;
|
|
356
|
+
else if (_vertical === "bottom") y -= targetSize.height.value;
|
|
357
357
|
return {
|
|
358
|
-
x
|
|
359
|
-
y
|
|
358
|
+
x,
|
|
359
|
+
y
|
|
360
360
|
};
|
|
361
361
|
});
|
|
362
|
-
const
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
};
|
|
367
|
-
if (toValue(referenceWindow)) {
|
|
368
|
-
data.x += canvasBounding.x.value;
|
|
369
|
-
data.y += canvasBounding.y.value;
|
|
370
|
-
}
|
|
371
|
-
return {
|
|
372
|
-
x: finalOffset.value.x + data.x,
|
|
373
|
-
y: finalOffset.value.y + data.y
|
|
374
|
-
};
|
|
362
|
+
const x = computed(() => {
|
|
363
|
+
let v = coord.value?.x ?? 0;
|
|
364
|
+
if (toValue(referenceWindow)) v += canvasBounding.x.value;
|
|
365
|
+
return +(v + finalOffset.value.x).toFixed(1);
|
|
375
366
|
});
|
|
376
|
-
const
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
})
|
|
367
|
+
const y = computed(() => {
|
|
368
|
+
let v = coord.value?.y ?? 0;
|
|
369
|
+
if (toValue(referenceWindow)) v += canvasBounding.y.value;
|
|
370
|
+
return +(v + finalOffset.value.y).toFixed(1);
|
|
371
|
+
});
|
|
372
|
+
const style = computed(() => `left:${x.value}px;top:${y.value}px;`);
|
|
382
373
|
watchEffect(() => {
|
|
383
|
-
const
|
|
384
|
-
if (
|
|
385
|
-
|
|
386
|
-
|
|
374
|
+
const applyStyle = toValue(options.applyStyle ?? true);
|
|
375
|
+
if (!applyStyle) return;
|
|
376
|
+
const element = unrefElement(target);
|
|
377
|
+
if (element && applyStyle) {
|
|
378
|
+
element.style?.setProperty?.("left", `${x.value}px`);
|
|
379
|
+
element.style?.setProperty?.("top", `${y.value}px`);
|
|
387
380
|
}
|
|
388
|
-
});
|
|
381
|
+
}, { flush: "post" });
|
|
389
382
|
return {
|
|
390
383
|
x,
|
|
391
384
|
y,
|
|
@@ -523,19 +516,19 @@ function useDrag(listener) {
|
|
|
523
516
|
const dragging = ref(false);
|
|
524
517
|
const viewer = useViewer();
|
|
525
518
|
const cameraLocked = ref(false);
|
|
526
|
-
watch(cameraLocked, (cameraLocked
|
|
527
|
-
viewer.value && (viewer.value.scene.screenSpaceCameraController.enableRotate = !cameraLocked
|
|
519
|
+
watch(cameraLocked, (cameraLocked) => {
|
|
520
|
+
viewer.value && (viewer.value.scene.screenSpaceCameraController.enableRotate = !cameraLocked);
|
|
528
521
|
});
|
|
529
522
|
const lockCamera = () => {
|
|
530
523
|
cameraLocked.value = true;
|
|
531
524
|
};
|
|
532
|
-
const execute = (pick
|
|
525
|
+
const execute = (pick, startPosition, endPosition) => {
|
|
533
526
|
listener({
|
|
534
527
|
event: {
|
|
535
528
|
startPosition: startPosition.clone(),
|
|
536
529
|
endPosition: endPosition.clone()
|
|
537
530
|
},
|
|
538
|
-
pick
|
|
531
|
+
pick,
|
|
539
532
|
dragging: dragging.value,
|
|
540
533
|
lockCamera
|
|
541
534
|
});
|
|
@@ -553,10 +546,10 @@ function useDrag(listener) {
|
|
|
553
546
|
endPosition: endPosition.clone()
|
|
554
547
|
};
|
|
555
548
|
}, 8, false, true));
|
|
556
|
-
watch([pick, motionEvent], ([pick
|
|
557
|
-
if (pick
|
|
558
|
-
const { startPosition, endPosition } = motionEvent
|
|
559
|
-
dragging.value && execute(pick
|
|
549
|
+
watch([pick, motionEvent], ([pick, motionEvent]) => {
|
|
550
|
+
if (pick && motionEvent) {
|
|
551
|
+
const { startPosition, endPosition } = motionEvent;
|
|
552
|
+
dragging.value && execute(pick, startPosition, endPosition);
|
|
560
553
|
}
|
|
561
554
|
});
|
|
562
555
|
const stopLeftUpWatch = useScreenSpaceEventHandler(ScreenSpaceEventType.LEFT_UP, (event) => {
|
|
@@ -582,13 +575,13 @@ function useDrag(listener) {
|
|
|
582
575
|
function useHover(listener) {
|
|
583
576
|
const motionEvent = shallowRef();
|
|
584
577
|
const pick = useScenePick(() => motionEvent.value?.endPosition);
|
|
585
|
-
const execute = (pick
|
|
578
|
+
const execute = (pick, startPosition, endPosition, hovering) => {
|
|
586
579
|
listener({
|
|
587
580
|
event: {
|
|
588
581
|
startPosition: startPosition.clone(),
|
|
589
582
|
endPosition: endPosition.clone()
|
|
590
583
|
},
|
|
591
|
-
pick
|
|
584
|
+
pick,
|
|
592
585
|
hovering
|
|
593
586
|
});
|
|
594
587
|
};
|
|
@@ -598,13 +591,13 @@ function useHover(listener) {
|
|
|
598
591
|
endPosition: endPosition.clone()
|
|
599
592
|
};
|
|
600
593
|
});
|
|
601
|
-
watch([pick, motionEvent], ([pick
|
|
602
|
-
if (pick
|
|
603
|
-
const { startPosition, endPosition } = motionEvent
|
|
604
|
-
execute(pick
|
|
594
|
+
watch([pick, motionEvent], ([pick, motionEvent]) => {
|
|
595
|
+
if (pick && motionEvent) {
|
|
596
|
+
const { startPosition, endPosition } = motionEvent;
|
|
597
|
+
execute(pick, startPosition, endPosition, true);
|
|
605
598
|
}
|
|
606
599
|
});
|
|
607
|
-
watch(pick, (pick
|
|
600
|
+
watch(pick, (pick, prevPick) => {
|
|
608
601
|
if (prevPick && motionEvent.value) {
|
|
609
602
|
const { startPosition, endPosition } = motionEvent.value;
|
|
610
603
|
execute(prevPick, startPosition, endPosition, false);
|
|
@@ -756,13 +749,14 @@ function useGraphicEvent() {
|
|
|
756
749
|
//#endregion
|
|
757
750
|
//#region useImageryLayer/index.ts
|
|
758
751
|
function useImageryLayer(data, options = {}) {
|
|
759
|
-
const { destroyOnRemove, collection, isActive = true, evaluating } = options;
|
|
752
|
+
const { destroyOnRemove, collection, isActive = true, evaluating, index } = options;
|
|
760
753
|
const result = computedAsync(() => toPromiseValue(data), [], { evaluating });
|
|
761
754
|
const viewer = useViewer();
|
|
762
755
|
watchEffect((onCleanup) => {
|
|
763
756
|
if (toValue(isActive)) {
|
|
764
757
|
const list = Array.isArray(result.value) ? [...result.value] : [result.value];
|
|
765
758
|
const _collection = collection ?? viewer.value?.imageryLayers;
|
|
759
|
+
const _index = toValue(index);
|
|
766
760
|
if (collection?.isDestroyed()) return;
|
|
767
761
|
list.forEach((item) => {
|
|
768
762
|
if (!item) {
|
|
@@ -773,7 +767,7 @@ function useImageryLayer(data, options = {}) {
|
|
|
773
767
|
console.warn("ImageryLayer is destroyed");
|
|
774
768
|
return;
|
|
775
769
|
}
|
|
776
|
-
_collection?.add(item);
|
|
770
|
+
_collection?.add(item, _index);
|
|
777
771
|
});
|
|
778
772
|
onCleanup(() => {
|
|
779
773
|
const destroy = toValue(destroyOnRemove);
|
|
@@ -853,9 +847,9 @@ function usePostProcessStageScope(options = {}) {
|
|
|
853
847
|
addEffect(instance) {
|
|
854
848
|
if (!collection.value) throw new Error("collection is not defined");
|
|
855
849
|
if (isPromise(instance)) return new Promise((resolve, reject) => {
|
|
856
|
-
instance.then((instance
|
|
857
|
-
collection.value.add(instance
|
|
858
|
-
resolve(instance
|
|
850
|
+
instance.then((instance) => {
|
|
851
|
+
collection.value.add(instance);
|
|
852
|
+
resolve(instance);
|
|
859
853
|
}).catch((error) => reject(error));
|
|
860
854
|
});
|
|
861
855
|
else return collection.value.add(instance);
|
|
@@ -903,7 +897,7 @@ function usePrimitiveScope(options = {}) {
|
|
|
903
897
|
addEffect(instance, ...args) {
|
|
904
898
|
if (!collection.value) throw new Error("collection is not defined");
|
|
905
899
|
if (isPromise(instance)) return new Promise((resolve, reject) => {
|
|
906
|
-
instance.then((instance
|
|
900
|
+
instance.then((instance) => resolve(collection.value.add(instance, ...args))).catch((error) => reject(error));
|
|
907
901
|
});
|
|
908
902
|
else return collection.value.add(instance, ...args);
|
|
909
903
|
},
|