@vesium/plot 1.0.1-beta.44 → 1.0.1-beta.46
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 +47 -48
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.iife.js +48 -48
- 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 +2 -3
- package/dist/index.mjs.map +1 -1
- package/package.json +2 -3
package/dist/index.iife.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
var VesiumPlot = function(exports, cesium,
|
|
1
|
+
var VesiumPlot = function(exports, cesium, vesium, 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);
|
|
@@ -43,7 +43,7 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
43
43
|
return _PlotScheme._record.get(type);
|
|
44
44
|
}
|
|
45
45
|
static setCache(scheme) {
|
|
46
|
-
|
|
46
|
+
vesium.assertError(!scheme.type, "`scheme.type` is required");
|
|
47
47
|
_PlotScheme._record.set(scheme.type, scheme);
|
|
48
48
|
}
|
|
49
49
|
static resolve(maybeScheme) {
|
|
@@ -489,18 +489,18 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
489
489
|
}
|
|
490
490
|
}
|
|
491
491
|
function useRender(plots, current, getCurrentTime) {
|
|
492
|
-
const viewer =
|
|
493
|
-
const primitiveCollection =
|
|
494
|
-
const groundPrimitiveCollection =
|
|
495
|
-
const dataSource =
|
|
496
|
-
const entityScope =
|
|
497
|
-
const primitiveScope =
|
|
498
|
-
const groundPrimitiveScope =
|
|
492
|
+
const viewer = vesium.useViewer();
|
|
493
|
+
const primitiveCollection = vesium.usePrimitive(new cesium.PrimitiveCollection());
|
|
494
|
+
const groundPrimitiveCollection = vesium.usePrimitive(new cesium.PrimitiveCollection(), { collection: "ground" });
|
|
495
|
+
const dataSource = vesium.useDataSource(new cesium.CustomDataSource());
|
|
496
|
+
const entityScope = vesium.useEntityScope({ collection: () => dataSource.value.entities });
|
|
497
|
+
const primitiveScope = vesium.usePrimitiveScope({ collection: () => primitiveCollection.value });
|
|
498
|
+
const groundPrimitiveScope = vesium.usePrimitiveScope({ collection: () => groundPrimitiveCollection.value });
|
|
499
499
|
const mouseCartesian = vue.shallowRef();
|
|
500
|
-
|
|
500
|
+
vesium.useScreenSpaceEventHandler(
|
|
501
501
|
cesium.ScreenSpaceEventType.MOUSE_MOVE,
|
|
502
502
|
(event) => {
|
|
503
|
-
mouseCartesian.value =
|
|
503
|
+
mouseCartesian.value = vesium.canvasCoordToCartesian(event == null ? void 0 : event.endPosition, viewer.value.scene);
|
|
504
504
|
}
|
|
505
505
|
);
|
|
506
506
|
core.watchArray(plots, (_value, _oldValue, added, removed = []) => {
|
|
@@ -518,19 +518,19 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
518
518
|
immediate: true,
|
|
519
519
|
flush: "post"
|
|
520
520
|
});
|
|
521
|
-
|
|
521
|
+
vesium.useCesiumEventListener(
|
|
522
522
|
() => plots.value.map((item) => item.definitionChanged),
|
|
523
523
|
(_scope, key, newValue, oldValue) => {
|
|
524
524
|
if (key === "entities") {
|
|
525
|
-
const { added, removed } =
|
|
525
|
+
const { added, removed } = vesium.arrayDiff(newValue, oldValue);
|
|
526
526
|
added.forEach((item) => entityScope.add(item));
|
|
527
527
|
removed.forEach((item) => entityScope.remove(item));
|
|
528
528
|
} else if (key === "primitives") {
|
|
529
|
-
const { added, removed } =
|
|
529
|
+
const { added, removed } = vesium.arrayDiff(newValue, oldValue);
|
|
530
530
|
added.forEach((item) => primitiveScope.add(item));
|
|
531
531
|
removed.forEach((item) => primitiveScope.remove(item));
|
|
532
532
|
} else if (key === "groundPrimitives") {
|
|
533
|
-
const { added, removed } =
|
|
533
|
+
const { added, removed } = vesium.arrayDiff(newValue, oldValue);
|
|
534
534
|
added.forEach((item) => groundPrimitiveScope.add(item));
|
|
535
535
|
removed.forEach((item) => groundPrimitiveScope.remove(item));
|
|
536
536
|
}
|
|
@@ -555,7 +555,7 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
555
555
|
vue.watch(current, (plot, previous) => {
|
|
556
556
|
previous && update(previous);
|
|
557
557
|
});
|
|
558
|
-
|
|
558
|
+
vesium.useCesiumEventListener(
|
|
559
559
|
() => plots.value.map((item) => item.definitionChanged),
|
|
560
560
|
(plot, key) => {
|
|
561
561
|
if (["disabled", "defining", "scheme", "sampled", "time"].includes(key)) {
|
|
@@ -573,13 +573,13 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
573
573
|
};
|
|
574
574
|
}
|
|
575
575
|
function useSampled(current, getCurrentTime) {
|
|
576
|
-
const viewer =
|
|
576
|
+
const viewer = vesium.useViewer();
|
|
577
577
|
const doubleClicking = vue.ref(false);
|
|
578
578
|
const packable = vue.computed(() => {
|
|
579
579
|
var _a;
|
|
580
580
|
return (_a = current.value) == null ? void 0 : _a.sampled.getValue(getCurrentTime());
|
|
581
581
|
});
|
|
582
|
-
|
|
582
|
+
vesium.useScreenSpaceEventHandler(
|
|
583
583
|
cesium.ScreenSpaceEventType.LEFT_CLICK,
|
|
584
584
|
async (ctx) => {
|
|
585
585
|
var _a, _b;
|
|
@@ -594,7 +594,7 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
594
594
|
if (!defining) {
|
|
595
595
|
return;
|
|
596
596
|
}
|
|
597
|
-
const position =
|
|
597
|
+
const position = vesium.canvasCoordToCartesian(ctx.position, viewer.value.scene);
|
|
598
598
|
if (!position) {
|
|
599
599
|
return;
|
|
600
600
|
}
|
|
@@ -605,7 +605,7 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
605
605
|
completed && PlotFeature.setDefining(current.value, false);
|
|
606
606
|
}
|
|
607
607
|
);
|
|
608
|
-
|
|
608
|
+
vesium.useScreenSpaceEventHandler(
|
|
609
609
|
cesium.ScreenSpaceEventType.LEFT_DOUBLE_CLICK,
|
|
610
610
|
async (ctx) => {
|
|
611
611
|
var _a;
|
|
@@ -619,7 +619,7 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
619
619
|
if (!defining) {
|
|
620
620
|
return;
|
|
621
621
|
}
|
|
622
|
-
const position =
|
|
622
|
+
const position = vesium.canvasCoordToCartesian(ctx.position, viewer.value.scene);
|
|
623
623
|
if (!position) {
|
|
624
624
|
return;
|
|
625
625
|
}
|
|
@@ -627,7 +627,7 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
627
627
|
completed && PlotFeature.setDefining(current.value, false);
|
|
628
628
|
}
|
|
629
629
|
);
|
|
630
|
-
|
|
630
|
+
vesium.useScreenSpaceEventHandler(
|
|
631
631
|
cesium.ScreenSpaceEventType.RIGHT_CLICK,
|
|
632
632
|
async () => {
|
|
633
633
|
var _a;
|
|
@@ -656,13 +656,13 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
656
656
|
}
|
|
657
657
|
} else {
|
|
658
658
|
const definingCursor = current.value.scheme.definingCursor;
|
|
659
|
-
definingCursorCss.value =
|
|
659
|
+
definingCursorCss.value = vesium.isFunction(definingCursor) ? definingCursor(packable.value) : definingCursor;
|
|
660
660
|
if (definingCursorCss.value) {
|
|
661
661
|
(_b = viewer.value) == null ? void 0 : _b.container.parentElement.style.setProperty("cursor", definingCursorCss.value);
|
|
662
662
|
}
|
|
663
663
|
}
|
|
664
664
|
};
|
|
665
|
-
|
|
665
|
+
vesium.useCesiumEventListener(() => {
|
|
666
666
|
var _a;
|
|
667
667
|
return (_a = current.value) == null ? void 0 : _a.definitionChanged;
|
|
668
668
|
}, (plot, key) => {
|
|
@@ -673,9 +673,9 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
673
673
|
vue.watch(current, () => setDefiningCursorCss());
|
|
674
674
|
}
|
|
675
675
|
function useSkeleton(plots, current, getCurrentTime) {
|
|
676
|
-
const viewer =
|
|
677
|
-
const dataSource =
|
|
678
|
-
const entityScope =
|
|
676
|
+
const viewer = vesium.useViewer();
|
|
677
|
+
const dataSource = vesium.useDataSource(new cesium.CustomDataSource());
|
|
678
|
+
const entityScope = vesium.useEntityScope({ collection: () => dataSource.value.entities });
|
|
679
679
|
const hoverEntity = vue.shallowRef();
|
|
680
680
|
const activeEntity = vue.shallowRef();
|
|
681
681
|
const getPointAction = (entity) => {
|
|
@@ -697,7 +697,7 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
697
697
|
const skeletons = plot.scheme.skeletons;
|
|
698
698
|
skeletons.forEach((skeleton) => {
|
|
699
699
|
var _a;
|
|
700
|
-
const disabled =
|
|
700
|
+
const disabled = vesium.isFunction(skeleton.disabled) ? skeleton.disabled({ active, defining }) : skeleton.disabled;
|
|
701
701
|
if (disabled) {
|
|
702
702
|
return;
|
|
703
703
|
}
|
|
@@ -733,7 +733,7 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
733
733
|
}
|
|
734
734
|
plot.skeletons = entities;
|
|
735
735
|
};
|
|
736
|
-
const { addGraphicEvent } =
|
|
736
|
+
const { addGraphicEvent } = vesium.useGraphicEvent();
|
|
737
737
|
vue.watchEffect((onCleanup) => {
|
|
738
738
|
const remove = addGraphicEvent("global", "DRAG", ({ event, pick, dragging, lockCamera }) => {
|
|
739
739
|
var _a;
|
|
@@ -765,14 +765,14 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
765
765
|
var _a;
|
|
766
766
|
if (!((_a = current.value) == null ? void 0 : _a.defining) && entityScope.scope.has(pick.id)) {
|
|
767
767
|
const skeleton = pick.id.skeleton;
|
|
768
|
-
return
|
|
768
|
+
return vesium.isFunction(skeleton == null ? void 0 : skeleton.cursor) ? skeleton.cursor(pick) : vue.toValue(skeleton == null ? void 0 : skeleton.cursor);
|
|
769
769
|
}
|
|
770
770
|
},
|
|
771
771
|
dragCursor: ({ pick }) => {
|
|
772
772
|
var _a;
|
|
773
773
|
if (!((_a = current.value) == null ? void 0 : _a.defining) && entityScope.scope.has(pick.id)) {
|
|
774
774
|
const skeleton = pick.id.skeleton;
|
|
775
|
-
return
|
|
775
|
+
return vesium.isFunction(skeleton == null ? void 0 : skeleton.dragCursor) ? skeleton.dragCursor(pick) : vue.toValue(skeleton == null ? void 0 : skeleton.dragCursor);
|
|
776
776
|
}
|
|
777
777
|
}
|
|
778
778
|
});
|
|
@@ -835,13 +835,13 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
835
835
|
added.forEach((plot) => update(plot));
|
|
836
836
|
removed.forEach((plot) => update(plot, true));
|
|
837
837
|
});
|
|
838
|
-
|
|
838
|
+
vesium.useCesiumEventListener(
|
|
839
839
|
() => plots.value.map((plot) => plot.definitionChanged),
|
|
840
840
|
(plot, key, newValue, oldValue) => {
|
|
841
841
|
if (["disabled", "defining", "scheme", "sampled", "time"].includes(key)) {
|
|
842
842
|
vue.nextTick(() => update(plot));
|
|
843
843
|
} else if (key === "skeletons") {
|
|
844
|
-
const { added, removed } =
|
|
844
|
+
const { added, removed } = vesium.arrayDiff(newValue, oldValue);
|
|
845
845
|
added.forEach((item) => entityScope.add(item));
|
|
846
846
|
removed.forEach((item) => entityScope.remove(item));
|
|
847
847
|
}
|
|
@@ -857,7 +857,7 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
857
857
|
}
|
|
858
858
|
function usePlot(options) {
|
|
859
859
|
const time = (options == null ? void 0 : options.time) || vue.shallowRef();
|
|
860
|
-
const viewer =
|
|
860
|
+
const viewer = vesium.useViewer();
|
|
861
861
|
const getCurrentTime = () => {
|
|
862
862
|
var _a, _b, _c;
|
|
863
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();
|
|
@@ -866,7 +866,7 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
866
866
|
const plots = vue.computed(() => Array.from(collection));
|
|
867
867
|
const current = vue.shallowRef();
|
|
868
868
|
const packable = vue.shallowRef();
|
|
869
|
-
|
|
869
|
+
vesium.useCesiumEventListener([
|
|
870
870
|
() => {
|
|
871
871
|
var _a;
|
|
872
872
|
return (_a = current.value) == null ? void 0 : _a.sampled.definitionChanged;
|
|
@@ -878,7 +878,7 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
878
878
|
useSampled(current, getCurrentTime);
|
|
879
879
|
useRender(plots, current, getCurrentTime);
|
|
880
880
|
useSkeleton(plots, current, getCurrentTime);
|
|
881
|
-
|
|
881
|
+
vesium.useScreenSpaceEventHandler(cesium.ScreenSpaceEventType.LEFT_CLICK, (data) => {
|
|
882
882
|
var _a, _b, _c;
|
|
883
883
|
if ((_a = current.value) == null ? void 0 : _a.defining) {
|
|
884
884
|
return;
|
|
@@ -891,7 +891,7 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
891
891
|
current.value = void 0;
|
|
892
892
|
return;
|
|
893
893
|
}
|
|
894
|
-
current.value = plots.value.find((plot) =>
|
|
894
|
+
current.value = plots.value.find((plot) => vesium.pickHitGraphic(pick, [...plot.entities, ...plot.primitives, ...plot.groundPrimitives]));
|
|
895
895
|
});
|
|
896
896
|
let operateResolve;
|
|
897
897
|
let operateReject;
|
|
@@ -947,7 +947,7 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
947
947
|
dragCursor: "crosshair",
|
|
948
948
|
onDrag({ viewer, sampled, packable, event, index, lockCamera }) {
|
|
949
949
|
lockCamera();
|
|
950
|
-
const position =
|
|
950
|
+
const position = vesium.canvasCoordToCartesian(event.endPosition, viewer.scene);
|
|
951
951
|
if (position) {
|
|
952
952
|
const positions = [...packable.positions ?? []];
|
|
953
953
|
positions[index] = position;
|
|
@@ -960,7 +960,7 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
960
960
|
},
|
|
961
961
|
onKeyPressed({ viewer, keyEvent, sampled, packable, index }) {
|
|
962
962
|
var _a;
|
|
963
|
-
const height = (_a =
|
|
963
|
+
const height = (_a = vesium.toCartographic(viewer.camera.position)) == null ? void 0 : _a.height;
|
|
964
964
|
if (!height || !["ArrowUp", "ArrowRight", "ArrowDown", "ArrowLeft"].includes(keyEvent.key))
|
|
965
965
|
return;
|
|
966
966
|
keyEvent.preventDefault();
|
|
@@ -981,12 +981,12 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
981
981
|
}
|
|
982
982
|
const newHeading = (viewer.camera.heading + headingAdjust) % (2 * Math.PI);
|
|
983
983
|
const positions = [...packable.positions ?? []];
|
|
984
|
-
const cartographic =
|
|
984
|
+
const cartographic = vesium.toCartographic(positions[index]);
|
|
985
985
|
const r = height / 1e5;
|
|
986
986
|
const distance = r * Math.PI / 180 / 1e3;
|
|
987
987
|
cartographic.latitude += distance * Math.cos(newHeading);
|
|
988
988
|
cartographic.longitude += distance * Math.sin(newHeading);
|
|
989
|
-
positions[index] =
|
|
989
|
+
positions[index] = vesium.toCartesian3(cartographic);
|
|
990
990
|
sampled.setSample({
|
|
991
991
|
time: packable.time,
|
|
992
992
|
derivative: packable.derivative,
|
|
@@ -1030,7 +1030,7 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
1030
1030
|
},
|
|
1031
1031
|
onDrag({ viewer, sampled, packable, event, index, lockCamera, dragging }) {
|
|
1032
1032
|
lockCamera();
|
|
1033
|
-
const position =
|
|
1033
|
+
const position = vesium.canvasCoordToCartesian(event.endPosition, viewer.scene);
|
|
1034
1034
|
if (!position) {
|
|
1035
1035
|
return;
|
|
1036
1036
|
}
|
|
@@ -1091,7 +1091,7 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
1091
1091
|
},
|
|
1092
1092
|
onDrag({ viewer, sampled, packable, event, index, lockCamera, dragging }) {
|
|
1093
1093
|
lockCamera();
|
|
1094
|
-
const position =
|
|
1094
|
+
const position = vesium.canvasCoordToCartesian(event.endPosition, viewer.scene);
|
|
1095
1095
|
if (!position) {
|
|
1096
1096
|
return;
|
|
1097
1097
|
}
|
|
@@ -1146,13 +1146,13 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
1146
1146
|
return [positions[0]];
|
|
1147
1147
|
} else {
|
|
1148
1148
|
const center = cesium.Rectangle.center(cesium.Rectangle.fromCartesianArray(positions));
|
|
1149
|
-
return [
|
|
1149
|
+
return [vesium.toCartesian3(center)];
|
|
1150
1150
|
}
|
|
1151
1151
|
},
|
|
1152
1152
|
onDrag({ viewer, sampled, packable, event, lockCamera, dragging }) {
|
|
1153
1153
|
dragging && lockCamera();
|
|
1154
|
-
const startPosition =
|
|
1155
|
-
const endPosition =
|
|
1154
|
+
const startPosition = vesium.canvasCoordToCartesian(event.startPosition, viewer.scene);
|
|
1155
|
+
const endPosition = vesium.canvasCoordToCartesian(event.endPosition, viewer.scene);
|
|
1156
1156
|
if (!startPosition || !endPosition) {
|
|
1157
1157
|
return;
|
|
1158
1158
|
}
|
|
@@ -1288,7 +1288,7 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
1288
1288
|
} else if (positions.length >= 3) {
|
|
1289
1289
|
positions.push(positions[0]);
|
|
1290
1290
|
entity.position = new cesium.ConstantPositionProperty(
|
|
1291
|
-
|
|
1291
|
+
vesium.toCartesian3(
|
|
1292
1292
|
cesium.Rectangle.center(cesium.Rectangle.fromCartesianArray(positions))
|
|
1293
1293
|
)
|
|
1294
1294
|
);
|
|
@@ -1450,5 +1450,5 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
1450
1450
|
exports.usePlot = usePlot;
|
|
1451
1451
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
1452
1452
|
return exports;
|
|
1453
|
-
}({}, Cesium,
|
|
1453
|
+
}({}, Cesium, Vesium, VueUse, Vue);
|
|
1454
1454
|
//# sourceMappingURL=index.iife.js.map
|