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