@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.cjs
CHANGED
|
@@ -4,8 +4,7 @@ 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
|
|
8
|
-
const shared = require("@vesium/shared");
|
|
7
|
+
const vesium = require("vesium");
|
|
9
8
|
const core = require("@vueuse/core");
|
|
10
9
|
const vue = require("vue");
|
|
11
10
|
const _PlotScheme = class _PlotScheme {
|
|
@@ -48,7 +47,7 @@ const _PlotScheme = class _PlotScheme {
|
|
|
48
47
|
return _PlotScheme._record.get(type);
|
|
49
48
|
}
|
|
50
49
|
static setCache(scheme) {
|
|
51
|
-
|
|
50
|
+
vesium.assertError(!scheme.type, "`scheme.type` is required");
|
|
52
51
|
_PlotScheme._record.set(scheme.type, scheme);
|
|
53
52
|
}
|
|
54
53
|
static resolve(maybeScheme) {
|
|
@@ -494,18 +493,18 @@ class PlotSkeletonEntity extends cesium.Entity {
|
|
|
494
493
|
}
|
|
495
494
|
}
|
|
496
495
|
function useRender(plots, current, getCurrentTime) {
|
|
497
|
-
const viewer =
|
|
498
|
-
const primitiveCollection =
|
|
499
|
-
const groundPrimitiveCollection =
|
|
500
|
-
const dataSource =
|
|
501
|
-
const entityScope =
|
|
502
|
-
const primitiveScope =
|
|
503
|
-
const groundPrimitiveScope =
|
|
496
|
+
const viewer = vesium.useViewer();
|
|
497
|
+
const primitiveCollection = vesium.usePrimitive(new cesium.PrimitiveCollection());
|
|
498
|
+
const groundPrimitiveCollection = vesium.usePrimitive(new cesium.PrimitiveCollection(), { collection: "ground" });
|
|
499
|
+
const dataSource = vesium.useDataSource(new cesium.CustomDataSource());
|
|
500
|
+
const entityScope = vesium.useEntityScope({ collection: () => dataSource.value.entities });
|
|
501
|
+
const primitiveScope = vesium.usePrimitiveScope({ collection: () => primitiveCollection.value });
|
|
502
|
+
const groundPrimitiveScope = vesium.usePrimitiveScope({ collection: () => groundPrimitiveCollection.value });
|
|
504
503
|
const mouseCartesian = vue.shallowRef();
|
|
505
|
-
|
|
504
|
+
vesium.useScreenSpaceEventHandler(
|
|
506
505
|
cesium.ScreenSpaceEventType.MOUSE_MOVE,
|
|
507
506
|
(event) => {
|
|
508
|
-
mouseCartesian.value =
|
|
507
|
+
mouseCartesian.value = vesium.canvasCoordToCartesian(event == null ? void 0 : event.endPosition, viewer.value.scene);
|
|
509
508
|
}
|
|
510
509
|
);
|
|
511
510
|
core.watchArray(plots, (_value, _oldValue, added, removed = []) => {
|
|
@@ -523,19 +522,19 @@ function useRender(plots, current, getCurrentTime) {
|
|
|
523
522
|
immediate: true,
|
|
524
523
|
flush: "post"
|
|
525
524
|
});
|
|
526
|
-
|
|
525
|
+
vesium.useCesiumEventListener(
|
|
527
526
|
() => plots.value.map((item) => item.definitionChanged),
|
|
528
527
|
(_scope, key, newValue, oldValue) => {
|
|
529
528
|
if (key === "entities") {
|
|
530
|
-
const { added, removed } =
|
|
529
|
+
const { added, removed } = vesium.arrayDiff(newValue, oldValue);
|
|
531
530
|
added.forEach((item) => entityScope.add(item));
|
|
532
531
|
removed.forEach((item) => entityScope.remove(item));
|
|
533
532
|
} else if (key === "primitives") {
|
|
534
|
-
const { added, removed } =
|
|
533
|
+
const { added, removed } = vesium.arrayDiff(newValue, oldValue);
|
|
535
534
|
added.forEach((item) => primitiveScope.add(item));
|
|
536
535
|
removed.forEach((item) => primitiveScope.remove(item));
|
|
537
536
|
} else if (key === "groundPrimitives") {
|
|
538
|
-
const { added, removed } =
|
|
537
|
+
const { added, removed } = vesium.arrayDiff(newValue, oldValue);
|
|
539
538
|
added.forEach((item) => groundPrimitiveScope.add(item));
|
|
540
539
|
removed.forEach((item) => groundPrimitiveScope.remove(item));
|
|
541
540
|
}
|
|
@@ -560,7 +559,7 @@ function useRender(plots, current, getCurrentTime) {
|
|
|
560
559
|
vue.watch(current, (plot, previous) => {
|
|
561
560
|
previous && update(previous);
|
|
562
561
|
});
|
|
563
|
-
|
|
562
|
+
vesium.useCesiumEventListener(
|
|
564
563
|
() => plots.value.map((item) => item.definitionChanged),
|
|
565
564
|
(plot, key) => {
|
|
566
565
|
if (["disabled", "defining", "scheme", "sampled", "time"].includes(key)) {
|
|
@@ -578,13 +577,13 @@ function useRender(plots, current, getCurrentTime) {
|
|
|
578
577
|
};
|
|
579
578
|
}
|
|
580
579
|
function useSampled(current, getCurrentTime) {
|
|
581
|
-
const viewer =
|
|
580
|
+
const viewer = vesium.useViewer();
|
|
582
581
|
const doubleClicking = vue.ref(false);
|
|
583
582
|
const packable = vue.computed(() => {
|
|
584
583
|
var _a;
|
|
585
584
|
return (_a = current.value) == null ? void 0 : _a.sampled.getValue(getCurrentTime());
|
|
586
585
|
});
|
|
587
|
-
|
|
586
|
+
vesium.useScreenSpaceEventHandler(
|
|
588
587
|
cesium.ScreenSpaceEventType.LEFT_CLICK,
|
|
589
588
|
async (ctx) => {
|
|
590
589
|
var _a, _b;
|
|
@@ -599,7 +598,7 @@ function useSampled(current, getCurrentTime) {
|
|
|
599
598
|
if (!defining) {
|
|
600
599
|
return;
|
|
601
600
|
}
|
|
602
|
-
const position =
|
|
601
|
+
const position = vesium.canvasCoordToCartesian(ctx.position, viewer.value.scene);
|
|
603
602
|
if (!position) {
|
|
604
603
|
return;
|
|
605
604
|
}
|
|
@@ -610,7 +609,7 @@ function useSampled(current, getCurrentTime) {
|
|
|
610
609
|
completed && PlotFeature.setDefining(current.value, false);
|
|
611
610
|
}
|
|
612
611
|
);
|
|
613
|
-
|
|
612
|
+
vesium.useScreenSpaceEventHandler(
|
|
614
613
|
cesium.ScreenSpaceEventType.LEFT_DOUBLE_CLICK,
|
|
615
614
|
async (ctx) => {
|
|
616
615
|
var _a;
|
|
@@ -624,7 +623,7 @@ function useSampled(current, getCurrentTime) {
|
|
|
624
623
|
if (!defining) {
|
|
625
624
|
return;
|
|
626
625
|
}
|
|
627
|
-
const position =
|
|
626
|
+
const position = vesium.canvasCoordToCartesian(ctx.position, viewer.value.scene);
|
|
628
627
|
if (!position) {
|
|
629
628
|
return;
|
|
630
629
|
}
|
|
@@ -632,7 +631,7 @@ function useSampled(current, getCurrentTime) {
|
|
|
632
631
|
completed && PlotFeature.setDefining(current.value, false);
|
|
633
632
|
}
|
|
634
633
|
);
|
|
635
|
-
|
|
634
|
+
vesium.useScreenSpaceEventHandler(
|
|
636
635
|
cesium.ScreenSpaceEventType.RIGHT_CLICK,
|
|
637
636
|
async () => {
|
|
638
637
|
var _a;
|
|
@@ -661,13 +660,13 @@ function useSampled(current, getCurrentTime) {
|
|
|
661
660
|
}
|
|
662
661
|
} else {
|
|
663
662
|
const definingCursor = current.value.scheme.definingCursor;
|
|
664
|
-
definingCursorCss.value =
|
|
663
|
+
definingCursorCss.value = vesium.isFunction(definingCursor) ? definingCursor(packable.value) : definingCursor;
|
|
665
664
|
if (definingCursorCss.value) {
|
|
666
665
|
(_b = viewer.value) == null ? void 0 : _b.container.parentElement.style.setProperty("cursor", definingCursorCss.value);
|
|
667
666
|
}
|
|
668
667
|
}
|
|
669
668
|
};
|
|
670
|
-
|
|
669
|
+
vesium.useCesiumEventListener(() => {
|
|
671
670
|
var _a;
|
|
672
671
|
return (_a = current.value) == null ? void 0 : _a.definitionChanged;
|
|
673
672
|
}, (plot, key) => {
|
|
@@ -678,9 +677,9 @@ function useSampled(current, getCurrentTime) {
|
|
|
678
677
|
vue.watch(current, () => setDefiningCursorCss());
|
|
679
678
|
}
|
|
680
679
|
function useSkeleton(plots, current, getCurrentTime) {
|
|
681
|
-
const viewer =
|
|
682
|
-
const dataSource =
|
|
683
|
-
const entityScope =
|
|
680
|
+
const viewer = vesium.useViewer();
|
|
681
|
+
const dataSource = vesium.useDataSource(new cesium.CustomDataSource());
|
|
682
|
+
const entityScope = vesium.useEntityScope({ collection: () => dataSource.value.entities });
|
|
684
683
|
const hoverEntity = vue.shallowRef();
|
|
685
684
|
const activeEntity = vue.shallowRef();
|
|
686
685
|
const getPointAction = (entity) => {
|
|
@@ -702,7 +701,7 @@ function useSkeleton(plots, current, getCurrentTime) {
|
|
|
702
701
|
const skeletons = plot.scheme.skeletons;
|
|
703
702
|
skeletons.forEach((skeleton) => {
|
|
704
703
|
var _a;
|
|
705
|
-
const disabled =
|
|
704
|
+
const disabled = vesium.isFunction(skeleton.disabled) ? skeleton.disabled({ active, defining }) : skeleton.disabled;
|
|
706
705
|
if (disabled) {
|
|
707
706
|
return;
|
|
708
707
|
}
|
|
@@ -738,7 +737,7 @@ function useSkeleton(plots, current, getCurrentTime) {
|
|
|
738
737
|
}
|
|
739
738
|
plot.skeletons = entities;
|
|
740
739
|
};
|
|
741
|
-
const { addGraphicEvent } =
|
|
740
|
+
const { addGraphicEvent } = vesium.useGraphicEvent();
|
|
742
741
|
vue.watchEffect((onCleanup) => {
|
|
743
742
|
const remove = addGraphicEvent("global", "DRAG", ({ event, pick, dragging, lockCamera }) => {
|
|
744
743
|
var _a;
|
|
@@ -770,14 +769,14 @@ function useSkeleton(plots, current, getCurrentTime) {
|
|
|
770
769
|
var _a;
|
|
771
770
|
if (!((_a = current.value) == null ? void 0 : _a.defining) && entityScope.scope.has(pick.id)) {
|
|
772
771
|
const skeleton = pick.id.skeleton;
|
|
773
|
-
return
|
|
772
|
+
return vesium.isFunction(skeleton == null ? void 0 : skeleton.cursor) ? skeleton.cursor(pick) : vue.toValue(skeleton == null ? void 0 : skeleton.cursor);
|
|
774
773
|
}
|
|
775
774
|
},
|
|
776
775
|
dragCursor: ({ pick }) => {
|
|
777
776
|
var _a;
|
|
778
777
|
if (!((_a = current.value) == null ? void 0 : _a.defining) && entityScope.scope.has(pick.id)) {
|
|
779
778
|
const skeleton = pick.id.skeleton;
|
|
780
|
-
return
|
|
779
|
+
return vesium.isFunction(skeleton == null ? void 0 : skeleton.dragCursor) ? skeleton.dragCursor(pick) : vue.toValue(skeleton == null ? void 0 : skeleton.dragCursor);
|
|
781
780
|
}
|
|
782
781
|
}
|
|
783
782
|
});
|
|
@@ -840,13 +839,13 @@ function useSkeleton(plots, current, getCurrentTime) {
|
|
|
840
839
|
added.forEach((plot) => update(plot));
|
|
841
840
|
removed.forEach((plot) => update(plot, true));
|
|
842
841
|
});
|
|
843
|
-
|
|
842
|
+
vesium.useCesiumEventListener(
|
|
844
843
|
() => plots.value.map((plot) => plot.definitionChanged),
|
|
845
844
|
(plot, key, newValue, oldValue) => {
|
|
846
845
|
if (["disabled", "defining", "scheme", "sampled", "time"].includes(key)) {
|
|
847
846
|
vue.nextTick(() => update(plot));
|
|
848
847
|
} else if (key === "skeletons") {
|
|
849
|
-
const { added, removed } =
|
|
848
|
+
const { added, removed } = vesium.arrayDiff(newValue, oldValue);
|
|
850
849
|
added.forEach((item) => entityScope.add(item));
|
|
851
850
|
removed.forEach((item) => entityScope.remove(item));
|
|
852
851
|
}
|
|
@@ -862,7 +861,7 @@ function useSkeleton(plots, current, getCurrentTime) {
|
|
|
862
861
|
}
|
|
863
862
|
function usePlot(options) {
|
|
864
863
|
const time = (options == null ? void 0 : options.time) || vue.shallowRef();
|
|
865
|
-
const viewer =
|
|
864
|
+
const viewer = vesium.useViewer();
|
|
866
865
|
const getCurrentTime = () => {
|
|
867
866
|
var _a, _b, _c;
|
|
868
867
|
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();
|
|
@@ -871,7 +870,7 @@ function usePlot(options) {
|
|
|
871
870
|
const plots = vue.computed(() => Array.from(collection));
|
|
872
871
|
const current = vue.shallowRef();
|
|
873
872
|
const packable = vue.shallowRef();
|
|
874
|
-
|
|
873
|
+
vesium.useCesiumEventListener([
|
|
875
874
|
() => {
|
|
876
875
|
var _a;
|
|
877
876
|
return (_a = current.value) == null ? void 0 : _a.sampled.definitionChanged;
|
|
@@ -883,7 +882,7 @@ function usePlot(options) {
|
|
|
883
882
|
useSampled(current, getCurrentTime);
|
|
884
883
|
useRender(plots, current, getCurrentTime);
|
|
885
884
|
useSkeleton(plots, current, getCurrentTime);
|
|
886
|
-
|
|
885
|
+
vesium.useScreenSpaceEventHandler(cesium.ScreenSpaceEventType.LEFT_CLICK, (data) => {
|
|
887
886
|
var _a, _b, _c;
|
|
888
887
|
if ((_a = current.value) == null ? void 0 : _a.defining) {
|
|
889
888
|
return;
|
|
@@ -896,7 +895,7 @@ function usePlot(options) {
|
|
|
896
895
|
current.value = void 0;
|
|
897
896
|
return;
|
|
898
897
|
}
|
|
899
|
-
current.value = plots.value.find((plot) =>
|
|
898
|
+
current.value = plots.value.find((plot) => vesium.pickHitGraphic(pick, [...plot.entities, ...plot.primitives, ...plot.groundPrimitives]));
|
|
900
899
|
});
|
|
901
900
|
let operateResolve;
|
|
902
901
|
let operateReject;
|
|
@@ -952,7 +951,7 @@ function control() {
|
|
|
952
951
|
dragCursor: "crosshair",
|
|
953
952
|
onDrag({ viewer, sampled, packable, event, index, lockCamera }) {
|
|
954
953
|
lockCamera();
|
|
955
|
-
const position =
|
|
954
|
+
const position = vesium.canvasCoordToCartesian(event.endPosition, viewer.scene);
|
|
956
955
|
if (position) {
|
|
957
956
|
const positions = [...packable.positions ?? []];
|
|
958
957
|
positions[index] = position;
|
|
@@ -965,7 +964,7 @@ function control() {
|
|
|
965
964
|
},
|
|
966
965
|
onKeyPressed({ viewer, keyEvent, sampled, packable, index }) {
|
|
967
966
|
var _a;
|
|
968
|
-
const height = (_a =
|
|
967
|
+
const height = (_a = vesium.toCartographic(viewer.camera.position)) == null ? void 0 : _a.height;
|
|
969
968
|
if (!height || !["ArrowUp", "ArrowRight", "ArrowDown", "ArrowLeft"].includes(keyEvent.key))
|
|
970
969
|
return;
|
|
971
970
|
keyEvent.preventDefault();
|
|
@@ -986,12 +985,12 @@ function control() {
|
|
|
986
985
|
}
|
|
987
986
|
const newHeading = (viewer.camera.heading + headingAdjust) % (2 * Math.PI);
|
|
988
987
|
const positions = [...packable.positions ?? []];
|
|
989
|
-
const cartographic =
|
|
988
|
+
const cartographic = vesium.toCartographic(positions[index]);
|
|
990
989
|
const r = height / 1e5;
|
|
991
990
|
const distance = r * Math.PI / 180 / 1e3;
|
|
992
991
|
cartographic.latitude += distance * Math.cos(newHeading);
|
|
993
992
|
cartographic.longitude += distance * Math.sin(newHeading);
|
|
994
|
-
positions[index] =
|
|
993
|
+
positions[index] = vesium.toCartesian3(cartographic);
|
|
995
994
|
sampled.setSample({
|
|
996
995
|
time: packable.time,
|
|
997
996
|
derivative: packable.derivative,
|
|
@@ -1035,7 +1034,7 @@ function interval() {
|
|
|
1035
1034
|
},
|
|
1036
1035
|
onDrag({ viewer, sampled, packable, event, index, lockCamera, dragging }) {
|
|
1037
1036
|
lockCamera();
|
|
1038
|
-
const position =
|
|
1037
|
+
const position = vesium.canvasCoordToCartesian(event.endPosition, viewer.scene);
|
|
1039
1038
|
if (!position) {
|
|
1040
1039
|
return;
|
|
1041
1040
|
}
|
|
@@ -1096,7 +1095,7 @@ function intervalNonclosed() {
|
|
|
1096
1095
|
},
|
|
1097
1096
|
onDrag({ viewer, sampled, packable, event, index, lockCamera, dragging }) {
|
|
1098
1097
|
lockCamera();
|
|
1099
|
-
const position =
|
|
1098
|
+
const position = vesium.canvasCoordToCartesian(event.endPosition, viewer.scene);
|
|
1100
1099
|
if (!position) {
|
|
1101
1100
|
return;
|
|
1102
1101
|
}
|
|
@@ -1151,13 +1150,13 @@ function moved() {
|
|
|
1151
1150
|
return [positions[0]];
|
|
1152
1151
|
} else {
|
|
1153
1152
|
const center = cesium.Rectangle.center(cesium.Rectangle.fromCartesianArray(positions));
|
|
1154
|
-
return [
|
|
1153
|
+
return [vesium.toCartesian3(center)];
|
|
1155
1154
|
}
|
|
1156
1155
|
},
|
|
1157
1156
|
onDrag({ viewer, sampled, packable, event, lockCamera, dragging }) {
|
|
1158
1157
|
dragging && lockCamera();
|
|
1159
|
-
const startPosition =
|
|
1160
|
-
const endPosition =
|
|
1158
|
+
const startPosition = vesium.canvasCoordToCartesian(event.startPosition, viewer.scene);
|
|
1159
|
+
const endPosition = vesium.canvasCoordToCartesian(event.endPosition, viewer.scene);
|
|
1161
1160
|
if (!startPosition || !endPosition) {
|
|
1162
1161
|
return;
|
|
1163
1162
|
}
|
|
@@ -1293,7 +1292,7 @@ const schemeMeasureArea = new PlotScheme({
|
|
|
1293
1292
|
} else if (positions.length >= 3) {
|
|
1294
1293
|
positions.push(positions[0]);
|
|
1295
1294
|
entity.position = new cesium.ConstantPositionProperty(
|
|
1296
|
-
|
|
1295
|
+
vesium.toCartesian3(
|
|
1297
1296
|
cesium.Rectangle.center(cesium.Rectangle.fromCartesianArray(positions))
|
|
1298
1297
|
)
|
|
1299
1298
|
);
|