@vesium/plot 1.0.1-beta.52 → 1.0.1-beta.57
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 +137 -1122
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +9 -53
- package/dist/index.d.cts.map +1 -1
- package/dist/index.d.mts +9 -53
- package/dist/index.d.mts.map +1 -1
- package/dist/index.iife.js +1842 -2833
- 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 +123 -1111
- package/dist/index.mjs.map +1 -1
- package/package.json +7 -6
package/dist/index.cjs
CHANGED
|
@@ -6,12 +6,16 @@ var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
|
6
6
|
var __getProtoOf = Object.getPrototypeOf;
|
|
7
7
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
8
|
var __copyProps = (to, from, except, desc) => {
|
|
9
|
-
if (from && typeof from === "object" || typeof from === "function")
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
9
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
10
|
+
for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
|
|
11
|
+
key = keys[i];
|
|
12
|
+
if (!__hasOwnProp.call(to, key) && key !== except) {
|
|
13
|
+
__defProp(to, key, {
|
|
14
|
+
get: ((k) => from[k]).bind(null, key),
|
|
15
|
+
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
16
|
+
});
|
|
17
|
+
}
|
|
18
|
+
}
|
|
15
19
|
}
|
|
16
20
|
return to;
|
|
17
21
|
};
|
|
@@ -21,11 +25,13 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
21
25
|
}) : target, mod));
|
|
22
26
|
|
|
23
27
|
//#endregion
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
28
|
+
let cesium = require("cesium");
|
|
29
|
+
let vesium = require("vesium");
|
|
30
|
+
let __vueuse_core = require("@vueuse/core");
|
|
31
|
+
let vue = require("vue");
|
|
32
|
+
let __vesium_geometry = require("@vesium/geometry");
|
|
33
|
+
let __turf_turf = require("@turf/turf");
|
|
34
|
+
__turf_turf = __toESM(__turf_turf);
|
|
29
35
|
|
|
30
36
|
//#region usePlot/PlotScheme.ts
|
|
31
37
|
var PlotScheme = class PlotScheme {
|
|
@@ -204,16 +210,13 @@ var SampledPlotProperty = class SampledPlotProperty {
|
|
|
204
210
|
const end = this._times[this._times.length - 1];
|
|
205
211
|
if (cesium.JulianDate.lessThan(time, start) || cesium.JulianDate.greaterThan(time, end)) switch (this.strategy) {
|
|
206
212
|
case SampledPlotStrategy.STRICT: return;
|
|
207
|
-
case SampledPlotStrategy.NEAR:
|
|
213
|
+
case SampledPlotStrategy.NEAR:
|
|
208
214
|
time = cesium.JulianDate.lessThan(time, this._times[0]) ? this._times[0].clone() : this._times[this._times.length - 1].clone();
|
|
209
215
|
break;
|
|
210
|
-
}
|
|
211
216
|
case SampledPlotStrategy.CYCLE: {
|
|
212
217
|
const startMS = cesium.JulianDate.toDate(this._times[0]).getTime();
|
|
213
|
-
const
|
|
214
|
-
const
|
|
215
|
-
const timeMS = cesium.JulianDate.toDate(time).getTime();
|
|
216
|
-
const diff = (timeMS - startMS) % duration;
|
|
218
|
+
const duration = cesium.JulianDate.toDate(this._times[this._times.length - 1]).getTime() - startMS;
|
|
219
|
+
const diff = (cesium.JulianDate.toDate(time).getTime() - startMS) % duration;
|
|
217
220
|
const dete = new Date(startMS + diff);
|
|
218
221
|
time = cesium.JulianDate.fromDate(dete);
|
|
219
222
|
break;
|
|
@@ -223,11 +226,10 @@ var SampledPlotProperty = class SampledPlotProperty {
|
|
|
223
226
|
const nextIndex = Math.min(prevIndex, this._times.length - 1);
|
|
224
227
|
const prevMs = cesium.JulianDate.toDate(this._times[prevIndex]).getTime();
|
|
225
228
|
const nextMs = cesium.JulianDate.toDate(this._times[nextIndex]).getTime();
|
|
226
|
-
const ms = cesium.JulianDate.toDate(time).getTime();
|
|
227
229
|
return {
|
|
228
230
|
prevIndex,
|
|
229
231
|
nextIndex,
|
|
230
|
-
proportion: (
|
|
232
|
+
proportion: (cesium.JulianDate.toDate(time).getTime() - prevMs) / (nextMs - prevMs) || 0
|
|
231
233
|
};
|
|
232
234
|
}
|
|
233
235
|
/**
|
|
@@ -319,8 +321,7 @@ var SampledPlotProperty = class SampledPlotProperty {
|
|
|
319
321
|
if (index !== -1) {
|
|
320
322
|
this._sampleds.splice(index, 1);
|
|
321
323
|
this._derivatives.splice(index, 1);
|
|
322
|
-
|
|
323
|
-
if (removed.length) {
|
|
324
|
+
if (this._times.splice(index, 1).length) {
|
|
324
325
|
this._definitionChanged.raiseEvent(this);
|
|
325
326
|
return true;
|
|
326
327
|
}
|
|
@@ -550,19 +551,27 @@ function useRender(plots, current, getCurrentTime) {
|
|
|
550
551
|
}
|
|
551
552
|
});
|
|
552
553
|
const update = async (plot) => {
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
554
|
+
await (0, vue.nextTick)();
|
|
555
|
+
const packable = plot.sampled.getValue(getCurrentTime());
|
|
556
|
+
const mouse = plot.defining ? mouseCartesian.value : void 0;
|
|
557
|
+
const result = await plot.scheme.render?.({
|
|
558
|
+
packable,
|
|
559
|
+
mouse,
|
|
556
560
|
defining: plot.defining,
|
|
557
561
|
previous: {
|
|
558
562
|
entities: plot.entities,
|
|
559
563
|
primitives: plot.primitives,
|
|
560
564
|
groundPrimitives: plot.groundPrimitives
|
|
565
|
+
},
|
|
566
|
+
getPositions() {
|
|
567
|
+
const points = packable.positions;
|
|
568
|
+
mouse && points.push(mouse);
|
|
569
|
+
return points;
|
|
561
570
|
}
|
|
562
571
|
});
|
|
563
|
-
plot.entities =
|
|
564
|
-
plot.primitives =
|
|
565
|
-
plot.groundPrimitives =
|
|
572
|
+
plot.entities = result?.entities ?? [];
|
|
573
|
+
plot.primitives = result?.primitives ?? [];
|
|
574
|
+
plot.groundPrimitives = result?.groundPrimitives ?? [];
|
|
566
575
|
};
|
|
567
576
|
(0, vue.watch)(current, (plot, previous) => {
|
|
568
577
|
previous && update(previous);
|
|
@@ -605,8 +614,7 @@ function useSampled(current, getCurrentTime) {
|
|
|
605
614
|
packable.value.positions ??= [];
|
|
606
615
|
packable.value.positions.push(position);
|
|
607
616
|
sampled.setSample(packable.value);
|
|
608
|
-
|
|
609
|
-
completed && PlotFeature.setDefining(current.value, false);
|
|
617
|
+
scheme.complete?.(packable.value) && PlotFeature.setDefining(current.value, false);
|
|
610
618
|
});
|
|
611
619
|
(0, vesium.useScreenSpaceEventHandler)(cesium.ScreenSpaceEventType.LEFT_DOUBLE_CLICK, async (ctx) => {
|
|
612
620
|
if (!current.value || !packable.value) return;
|
|
@@ -615,10 +623,8 @@ function useSampled(current, getCurrentTime) {
|
|
|
615
623
|
doubleClicking.value = false;
|
|
616
624
|
const { scheme, defining } = current.value;
|
|
617
625
|
if (!defining) return;
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
const completed = scheme.allowManualComplete?.(packable.value);
|
|
621
|
-
completed && PlotFeature.setDefining(current.value, false);
|
|
626
|
+
if (!(0, vesium.canvasCoordToCartesian)(ctx.position, viewer.value.scene)) return;
|
|
627
|
+
scheme.allowManualComplete?.(packable.value) && PlotFeature.setDefining(current.value, false);
|
|
622
628
|
});
|
|
623
629
|
(0, vesium.useScreenSpaceEventHandler)(cesium.ScreenSpaceEventType.RIGHT_CLICK, async () => {
|
|
624
630
|
if (!current.value || !packable.value) return;
|
|
@@ -668,13 +674,11 @@ function useSkeleton(plots, current, getCurrentTime) {
|
|
|
668
674
|
const packable = plot.sampled.getValue(getCurrentTime());
|
|
669
675
|
const defining = plot.defining;
|
|
670
676
|
const active = current.value === plot;
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
const disabled = (0, vesium.isFunction)(skeleton.disabled) ? skeleton.disabled({
|
|
677
|
+
plot.scheme.skeletons.forEach((skeleton) => {
|
|
678
|
+
if ((0, vesium.isFunction)(skeleton.disabled) ? skeleton.disabled({
|
|
674
679
|
active,
|
|
675
680
|
defining
|
|
676
|
-
}) : skeleton.disabled;
|
|
677
|
-
if (disabled) return;
|
|
681
|
+
}) : skeleton.disabled) return;
|
|
678
682
|
const positions = skeleton.format?.(packable) ?? packable?.positions ?? [];
|
|
679
683
|
positions.forEach((position, index) => {
|
|
680
684
|
let entity = oldEntities.find((item) => item.index === index && item.skeleton === skeleton);
|
|
@@ -701,9 +705,9 @@ function useSkeleton(plots, current, getCurrentTime) {
|
|
|
701
705
|
}
|
|
702
706
|
plot.skeletons = entities;
|
|
703
707
|
};
|
|
704
|
-
const
|
|
708
|
+
const graphicEvent = (0, vesium.useGraphicEvent)();
|
|
705
709
|
(0, vue.watchEffect)((onCleanup) => {
|
|
706
|
-
|
|
710
|
+
onCleanup(graphicEvent.add("global", "DRAG", ({ event, pick, dragging, lockCamera }) => {
|
|
707
711
|
if (pick.id instanceof PlotSkeletonEntity && entityScope.scope.has(pick.id)) {
|
|
708
712
|
const entity = pick.id;
|
|
709
713
|
const plot = entity.plot;
|
|
@@ -736,8 +740,7 @@ function useSkeleton(plots, current, getCurrentTime) {
|
|
|
736
740
|
return (0, vesium.isFunction)(skeleton?.dragCursor) ? skeleton.dragCursor(pick) : (0, vue.toValue)(skeleton?.dragCursor);
|
|
737
741
|
}
|
|
738
742
|
}
|
|
739
|
-
});
|
|
740
|
-
onCleanup(remove);
|
|
743
|
+
}));
|
|
741
744
|
});
|
|
742
745
|
(0, __vueuse_core.onKeyStroke)((keyEvent) => {
|
|
743
746
|
if (activeEntity.value) {
|
|
@@ -756,16 +759,13 @@ function useSkeleton(plots, current, getCurrentTime) {
|
|
|
756
759
|
}
|
|
757
760
|
});
|
|
758
761
|
(0, vue.watchEffect)((onCleanup) => {
|
|
759
|
-
|
|
760
|
-
if (hovering && pick.id instanceof PlotSkeletonEntity && entityScope.scope.has(pick.id))
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
} else hoverEntity.value = void 0;
|
|
764
|
-
});
|
|
765
|
-
onCleanup(remove);
|
|
762
|
+
onCleanup(graphicEvent.add("global", "HOVER", ({ hovering, pick }) => {
|
|
763
|
+
if (hovering && pick.id instanceof PlotSkeletonEntity && entityScope.scope.has(pick.id)) hoverEntity.value = pick.id;
|
|
764
|
+
else hoverEntity.value = void 0;
|
|
765
|
+
}));
|
|
766
766
|
});
|
|
767
767
|
(0, vue.watchEffect)((onCleanup) => {
|
|
768
|
-
|
|
768
|
+
onCleanup(graphicEvent.add("global", "LEFT_CLICK", ({ event, pick }) => {
|
|
769
769
|
if (pick.id instanceof PlotSkeletonEntity && entityScope.scope.has(pick.id)) {
|
|
770
770
|
const entity = pick.id;
|
|
771
771
|
activeEntity.value = entity;
|
|
@@ -783,8 +783,7 @@ function useSkeleton(plots, current, getCurrentTime) {
|
|
|
783
783
|
event
|
|
784
784
|
});
|
|
785
785
|
} else activeEntity.value = void 0;
|
|
786
|
-
});
|
|
787
|
-
onCleanup(remove);
|
|
786
|
+
}));
|
|
788
787
|
});
|
|
789
788
|
(0, __vueuse_core.watchArray)(plots, (value, oldValue, added, removed = []) => {
|
|
790
789
|
added.forEach((plot) => update(plot));
|
|
@@ -849,8 +848,7 @@ function usePlot(options) {
|
|
|
849
848
|
if (previous) {
|
|
850
849
|
if (previous.defining) {
|
|
851
850
|
const packable$1 = previous.sampled.getValue(getCurrentTime());
|
|
852
|
-
|
|
853
|
-
if (completed) {
|
|
851
|
+
if (previous.scheme.allowManualComplete?.(packable$1)) {
|
|
854
852
|
PlotFeature.setDefining(previous, false);
|
|
855
853
|
operateResolve?.(previous);
|
|
856
854
|
} else collection.delete(previous);
|
|
@@ -934,8 +932,7 @@ function control() {
|
|
|
934
932
|
const newHeading = (viewer.camera.heading + headingAdjust) % (2 * Math.PI);
|
|
935
933
|
const positions = [...packable.positions ?? []];
|
|
936
934
|
const cartographic = (0, vesium.toCartographic)(positions[index]);
|
|
937
|
-
const
|
|
938
|
-
const distance$1 = r * Math.PI / 180 / 1e3;
|
|
935
|
+
const distance$1 = height / 1e5 * Math.PI / 180 / 1e3;
|
|
939
936
|
cartographic.latitude += distance$1 * Math.cos(newHeading);
|
|
940
937
|
cartographic.longitude += distance$1 * Math.sin(newHeading);
|
|
941
938
|
positions[index] = (0, vesium.toCartesian3)(cartographic);
|
|
@@ -946,16 +943,15 @@ function control() {
|
|
|
946
943
|
});
|
|
947
944
|
},
|
|
948
945
|
render: ({ position, action }) => {
|
|
949
|
-
const colors = {
|
|
950
|
-
[PlotAction.IDLE]: cesium.Color.BLUE.withAlpha(.4),
|
|
951
|
-
[PlotAction.HOVER]: cesium.Color.BLUE.withAlpha(.6),
|
|
952
|
-
[PlotAction.ACTIVE]: cesium.Color.AQUA.withAlpha(1)
|
|
953
|
-
};
|
|
954
946
|
return {
|
|
955
947
|
position,
|
|
956
948
|
point: {
|
|
957
949
|
pixelSize: 8,
|
|
958
|
-
color:
|
|
950
|
+
color: {
|
|
951
|
+
[PlotAction.IDLE]: cesium.Color.BLUE.withAlpha(.4),
|
|
952
|
+
[PlotAction.HOVER]: cesium.Color.BLUE.withAlpha(.6),
|
|
953
|
+
[PlotAction.ACTIVE]: cesium.Color.AQUA.withAlpha(1)
|
|
954
|
+
}[action],
|
|
959
955
|
disableDepthTestDistance: Number.POSITIVE_INFINITY,
|
|
960
956
|
outlineWidth: 1,
|
|
961
957
|
outlineColor: cesium.Color.WHITE.withAlpha(.4)
|
|
@@ -1002,16 +998,15 @@ function interval() {
|
|
|
1002
998
|
},
|
|
1003
999
|
render: ({ position, action, active }) => {
|
|
1004
1000
|
if (!active) return;
|
|
1005
|
-
const colors = {
|
|
1006
|
-
[PlotAction.IDLE]: cesium.Color.GREEN.withAlpha(.4),
|
|
1007
|
-
[PlotAction.HOVER]: cesium.Color.GREEN.withAlpha(.6),
|
|
1008
|
-
[PlotAction.ACTIVE]: cesium.Color.GREEN.withAlpha(1)
|
|
1009
|
-
};
|
|
1010
1001
|
return {
|
|
1011
1002
|
position,
|
|
1012
1003
|
point: {
|
|
1013
1004
|
pixelSize: 6,
|
|
1014
|
-
color:
|
|
1005
|
+
color: {
|
|
1006
|
+
[PlotAction.IDLE]: cesium.Color.GREEN.withAlpha(.4),
|
|
1007
|
+
[PlotAction.HOVER]: cesium.Color.GREEN.withAlpha(.6),
|
|
1008
|
+
[PlotAction.ACTIVE]: cesium.Color.GREEN.withAlpha(1)
|
|
1009
|
+
}[action],
|
|
1015
1010
|
disableDepthTestDistance: Number.POSITIVE_INFINITY,
|
|
1016
1011
|
outlineWidth: 1,
|
|
1017
1012
|
outlineColor: cesium.Color.WHITE.withAlpha(.4)
|
|
@@ -1056,16 +1051,15 @@ function intervalNonclosed() {
|
|
|
1056
1051
|
});
|
|
1057
1052
|
},
|
|
1058
1053
|
render: ({ position, action }) => {
|
|
1059
|
-
const colors = {
|
|
1060
|
-
[PlotAction.IDLE]: cesium.Color.GREEN.withAlpha(.4),
|
|
1061
|
-
[PlotAction.HOVER]: cesium.Color.GREEN.withAlpha(.6),
|
|
1062
|
-
[PlotAction.ACTIVE]: cesium.Color.GREEN.withAlpha(1)
|
|
1063
|
-
};
|
|
1064
1054
|
return {
|
|
1065
1055
|
position,
|
|
1066
1056
|
point: {
|
|
1067
1057
|
pixelSize: 6,
|
|
1068
|
-
color:
|
|
1058
|
+
color: {
|
|
1059
|
+
[PlotAction.IDLE]: cesium.Color.GREEN.withAlpha(.4),
|
|
1060
|
+
[PlotAction.HOVER]: cesium.Color.GREEN.withAlpha(.6),
|
|
1061
|
+
[PlotAction.ACTIVE]: cesium.Color.GREEN.withAlpha(1)
|
|
1062
|
+
}[action],
|
|
1069
1063
|
disableDepthTestDistance: Number.POSITIVE_INFINITY,
|
|
1070
1064
|
outlineWidth: 1,
|
|
1071
1065
|
outlineColor: cesium.Color.WHITE.withAlpha(.4)
|
|
@@ -1090,10 +1084,7 @@ function moved() {
|
|
|
1090
1084
|
const positions = packable.positions ?? [];
|
|
1091
1085
|
if (positions.length === 0) return [];
|
|
1092
1086
|
else if (positions.length === 1) return [positions[0]];
|
|
1093
|
-
else
|
|
1094
|
-
const center = cesium.Rectangle.center(cesium.Rectangle.fromCartesianArray(positions));
|
|
1095
|
-
return [(0, vesium.toCartesian3)(center)];
|
|
1096
|
-
}
|
|
1087
|
+
else return [(0, vesium.toCartesian3)(cesium.Rectangle.center(cesium.Rectangle.fromCartesianArray(positions)))];
|
|
1097
1088
|
},
|
|
1098
1089
|
onDrag({ viewer, sampled, packable, event, lockCamera, dragging }) {
|
|
1099
1090
|
dragging && lockCamera();
|
|
@@ -1109,18 +1100,17 @@ function moved() {
|
|
|
1109
1100
|
});
|
|
1110
1101
|
},
|
|
1111
1102
|
render: ({ position, action }) => {
|
|
1112
|
-
const colors = {
|
|
1113
|
-
[PlotAction.IDLE]: cesium.Color.WHITE,
|
|
1114
|
-
[PlotAction.HOVER]: cesium.Color.WHITE,
|
|
1115
|
-
[PlotAction.ACTIVE]: cesium.Color.AQUA.withAlpha(1)
|
|
1116
|
-
};
|
|
1117
1103
|
return {
|
|
1118
1104
|
position,
|
|
1119
1105
|
billboard: {
|
|
1120
1106
|
image: svg,
|
|
1121
1107
|
width: 20,
|
|
1122
1108
|
height: 20,
|
|
1123
|
-
color:
|
|
1109
|
+
color: {
|
|
1110
|
+
[PlotAction.IDLE]: cesium.Color.WHITE,
|
|
1111
|
+
[PlotAction.HOVER]: cesium.Color.WHITE,
|
|
1112
|
+
[PlotAction.ACTIVE]: cesium.Color.AQUA.withAlpha(1)
|
|
1113
|
+
}[action],
|
|
1124
1114
|
pixelOffset: new cesium.Cartesian3(0, -20),
|
|
1125
1115
|
horizontalOrigin: cesium.HorizontalOrigin.CENTER,
|
|
1126
1116
|
verticalOrigin: cesium.VerticalOrigin.BOTTOM,
|
|
@@ -1190,12 +1180,12 @@ async function clampToHeightMostDetailedByTilesetOrTerrain(options) {
|
|
|
1190
1180
|
else resolve([]);
|
|
1191
1181
|
});
|
|
1192
1182
|
const [tilesetPositions, terrainPositions] = await Promise.all([tilesetPromise, terrainPromise]);
|
|
1193
|
-
const
|
|
1183
|
+
const results = [];
|
|
1194
1184
|
positions.forEach((item, index) => {
|
|
1195
1185
|
const position = tilesetPositions[index] || terrainPositions[index] ? cesium.Ellipsoid.WGS84.cartographicToCartesian(terrainPositions[index]) : item.clone();
|
|
1196
|
-
|
|
1186
|
+
results.push(position);
|
|
1197
1187
|
});
|
|
1198
|
-
return
|
|
1188
|
+
return results;
|
|
1199
1189
|
}
|
|
1200
1190
|
|
|
1201
1191
|
//#endregion
|
|
@@ -1224,8 +1214,7 @@ async function triangleGrid(positions, options) {
|
|
|
1224
1214
|
const bbox = cesium.Rectangle.fromCartesianArray(positions);
|
|
1225
1215
|
const vertical = bbox.north - bbox.south;
|
|
1226
1216
|
const horizontal = bbox.east - bbox.west;
|
|
1227
|
-
const
|
|
1228
|
-
const granularity = max / density;
|
|
1217
|
+
const granularity = Math.max(horizontal, vertical) / density;
|
|
1229
1218
|
const polygonGeometry = cesium.PolygonGeometry.fromPositions({
|
|
1230
1219
|
positions,
|
|
1231
1220
|
vertexFormat: cesium.PerInstanceColorAppearance.FLAT_VERTEX_FORMAT,
|
|
@@ -1244,13 +1233,12 @@ async function triangleGrid(positions, options) {
|
|
|
1244
1233
|
}
|
|
1245
1234
|
if (clampToGround) {
|
|
1246
1235
|
if (!scene) throw new Error("scene is required on `clampToGround == true`.");
|
|
1247
|
-
|
|
1236
|
+
cartesian3List = await clampToHeightMostDetailedByTilesetOrTerrain({
|
|
1248
1237
|
scene,
|
|
1249
1238
|
terrainProvider,
|
|
1250
1239
|
positions: cartesian3List,
|
|
1251
1240
|
classificationType
|
|
1252
1241
|
});
|
|
1253
|
-
cartesian3List = detaileds;
|
|
1254
1242
|
}
|
|
1255
1243
|
const grid = [];
|
|
1256
1244
|
while (cartesian3List?.length) {
|
|
@@ -1298,18 +1286,14 @@ async function area(positions, options) {
|
|
|
1298
1286
|
if (positions.length < 2) throw new Error("positions.length must >= 2");
|
|
1299
1287
|
const { density, scene, clampToGround, classificationType, terrainProvider } = defaultOptions$1(options);
|
|
1300
1288
|
if (density <= 0) throw new Error("options.density must > 0");
|
|
1301
|
-
if (!clampToGround)
|
|
1302
|
-
|
|
1303
|
-
return triangles$1.reduce((count, current) => count += triangleArea(...current), 0);
|
|
1304
|
-
}
|
|
1305
|
-
const triangles = await triangleGrid(positions, {
|
|
1289
|
+
if (!clampToGround) return tesselate(positions).reduce((count, current) => count += triangleArea(...current), 0);
|
|
1290
|
+
return (await triangleGrid(positions, {
|
|
1306
1291
|
density,
|
|
1307
1292
|
scene,
|
|
1308
1293
|
clampToGround,
|
|
1309
1294
|
classificationType,
|
|
1310
1295
|
terrainProvider
|
|
1311
|
-
});
|
|
1312
|
-
return triangles.reduce((count, current) => count += triangleArea(...current), 0);
|
|
1296
|
+
})).reduce((count, current) => count += triangleArea(...current), 0);
|
|
1313
1297
|
}
|
|
1314
1298
|
|
|
1315
1299
|
//#endregion
|
|
@@ -1327,13 +1311,12 @@ async function lerpArray(options) {
|
|
|
1327
1311
|
result.push(end.clone());
|
|
1328
1312
|
if (!clampToGround) return result;
|
|
1329
1313
|
if (!scene) throw new Error("scene is required on `clampToGround == true`.");
|
|
1330
|
-
|
|
1314
|
+
return await clampToHeightMostDetailedByTilesetOrTerrain({
|
|
1331
1315
|
scene,
|
|
1332
1316
|
terrainProvider,
|
|
1333
1317
|
positions: result,
|
|
1334
1318
|
classificationType
|
|
1335
1319
|
});
|
|
1336
|
-
return detaileds;
|
|
1337
1320
|
}
|
|
1338
1321
|
|
|
1339
1322
|
//#endregion
|
|
@@ -1389,8 +1372,7 @@ async function distance(positions, options) {
|
|
|
1389
1372
|
terrainProvider: _options.terrainProvider
|
|
1390
1373
|
});
|
|
1391
1374
|
});
|
|
1392
|
-
const
|
|
1393
|
-
const stagePromises = detaileds.map(async (positions$1) => {
|
|
1375
|
+
const stagePromises = (await Promise.all(positionListPromises)).map(async (positions$1) => {
|
|
1394
1376
|
const { count: count$1 } = await distance(positions$1);
|
|
1395
1377
|
return count$1;
|
|
1396
1378
|
});
|
|
@@ -1460,7 +1442,7 @@ const schemeMeasureDistance = new PlotScheme({
|
|
|
1460
1442
|
} })] };
|
|
1461
1443
|
},
|
|
1462
1444
|
render(context) {
|
|
1463
|
-
|
|
1445
|
+
context.previous.entities[0];
|
|
1464
1446
|
const { mouse, packable, previous } = context;
|
|
1465
1447
|
const entities = previous.entities;
|
|
1466
1448
|
const positions = [...packable.positions ?? []];
|
|
@@ -1498,6 +1480,9 @@ const schemeMeasureDistance = new PlotScheme({
|
|
|
1498
1480
|
|
|
1499
1481
|
//#endregion
|
|
1500
1482
|
//#region scheme/Billboard.ts
|
|
1483
|
+
/**
|
|
1484
|
+
* billboard标绘配置
|
|
1485
|
+
*/
|
|
1501
1486
|
const PlotSchemeBillboard = new PlotScheme({
|
|
1502
1487
|
type: "Billboard",
|
|
1503
1488
|
complete: (packable) => packable.positions.length >= 1,
|
|
@@ -1520,6 +1505,9 @@ const PlotSchemeBillboard = new PlotScheme({
|
|
|
1520
1505
|
|
|
1521
1506
|
//#endregion
|
|
1522
1507
|
//#region scheme/BillboardPinBuilder.ts
|
|
1508
|
+
/**
|
|
1509
|
+
* billboard-pin-builder标绘配置
|
|
1510
|
+
*/
|
|
1523
1511
|
const PlotSchemeBillboardPinBuilder = new PlotScheme({
|
|
1524
1512
|
type: "BillboardPinBuilder",
|
|
1525
1513
|
complete: (packable) => packable.positions.length >= 1,
|
|
@@ -1537,6 +1525,9 @@ const PlotSchemeBillboardPinBuilder = new PlotScheme({
|
|
|
1537
1525
|
|
|
1538
1526
|
//#endregion
|
|
1539
1527
|
//#region scheme/Cylinder.ts
|
|
1528
|
+
/**
|
|
1529
|
+
* cylinder标绘配置
|
|
1530
|
+
*/
|
|
1540
1531
|
const PlotSchemeCylinder = new PlotScheme({
|
|
1541
1532
|
type: "Cylinder",
|
|
1542
1533
|
complete: (packable) => packable.positions.length >= 2,
|
|
@@ -1563,6 +1554,9 @@ const PlotSchemeCylinder = new PlotScheme({
|
|
|
1563
1554
|
|
|
1564
1555
|
//#endregion
|
|
1565
1556
|
//#region scheme/Ellipse.ts
|
|
1557
|
+
/**
|
|
1558
|
+
* ellipse标绘配置 圆形扩散波
|
|
1559
|
+
*/
|
|
1566
1560
|
const PlotSchemeEllipse = new PlotScheme({
|
|
1567
1561
|
type: "Ellipse",
|
|
1568
1562
|
complete: (packable) => packable.positions.length >= 2,
|
|
@@ -1589,6 +1583,9 @@ const PlotSchemeEllipse = new PlotScheme({
|
|
|
1589
1583
|
|
|
1590
1584
|
//#endregion
|
|
1591
1585
|
//#region scheme/Label.ts
|
|
1586
|
+
/**
|
|
1587
|
+
* 基础label标绘配置
|
|
1588
|
+
*/
|
|
1592
1589
|
const PlotSchemeLabel = new PlotScheme({
|
|
1593
1590
|
type: "Label",
|
|
1594
1591
|
complete: (packable) => packable.positions.length >= 1,
|
|
@@ -1606,6 +1603,9 @@ const PlotSchemeLabel = new PlotScheme({
|
|
|
1606
1603
|
|
|
1607
1604
|
//#endregion
|
|
1608
1605
|
//#region scheme/Point.ts
|
|
1606
|
+
/**
|
|
1607
|
+
* 基础point标绘配置
|
|
1608
|
+
*/
|
|
1609
1609
|
const PlotSchemePoint = new PlotScheme({
|
|
1610
1610
|
type: "Point",
|
|
1611
1611
|
complete: (packable) => packable.positions.length >= 1,
|
|
@@ -1626,6 +1626,9 @@ const PlotSchemePoint = new PlotScheme({
|
|
|
1626
1626
|
|
|
1627
1627
|
//#endregion
|
|
1628
1628
|
//#region scheme/Polygon.ts
|
|
1629
|
+
/**
|
|
1630
|
+
* 基础Polygon标绘配置
|
|
1631
|
+
*/
|
|
1629
1632
|
const PlotSchemePolygon = new PlotScheme({
|
|
1630
1633
|
type: "Polygon",
|
|
1631
1634
|
allowManualComplete: (packable) => packable.positions.length >= 2,
|
|
@@ -1663,930 +1666,10 @@ const PlotSchemePolygon = new PlotScheme({
|
|
|
1663
1666
|
});
|
|
1664
1667
|
|
|
1665
1668
|
//#endregion
|
|
1666
|
-
//#region
|
|
1667
|
-
const FITTING_COUNT = 100;
|
|
1668
|
-
const HALF_PI = Math.PI / 2;
|
|
1669
|
-
const ZERO_TOLERANCE = 1e-4;
|
|
1670
|
-
const TWO_PI = Math.PI * 2;
|
|
1671
|
-
/**
|
|
1672
|
-
* 计算两个坐标之间的距离
|
|
1673
|
-
* @param coord1
|
|
1674
|
-
* @param coord2
|
|
1675
|
-
*/
|
|
1676
|
-
function mathDistance(coord1, coord2) {
|
|
1677
|
-
return Math.hypot(coord1[0] - coord2[0], coord1[1] - coord2[1]);
|
|
1678
|
-
}
|
|
1679
|
-
/**
|
|
1680
|
-
* 计算点集合的总距离
|
|
1681
|
-
* @param points
|
|
1682
|
-
*/
|
|
1683
|
-
function wholeDistance(points) {
|
|
1684
|
-
let distance$1 = 0;
|
|
1685
|
-
if (points && Array.isArray(points) && points.length > 0) points.forEach((item, index) => {
|
|
1686
|
-
if (index < points.length - 1) distance$1 += mathDistance(item, points[index + 1]);
|
|
1687
|
-
});
|
|
1688
|
-
return distance$1;
|
|
1689
|
-
}
|
|
1690
|
-
/**
|
|
1691
|
-
* 获取基础长度
|
|
1692
|
-
* @param points
|
|
1693
|
-
*/
|
|
1694
|
-
const getBaseLength = (points) => wholeDistance(points) ** .99;
|
|
1695
|
-
/**
|
|
1696
|
-
* 求取两个坐标的中间坐标
|
|
1697
|
-
* @param coord1
|
|
1698
|
-
* @param coord2
|
|
1699
|
-
*/
|
|
1700
|
-
function mid(coord1, coord2) {
|
|
1701
|
-
return [(coord1[0] + coord2[0]) / 2, (coord1[1] + coord2[1]) / 2];
|
|
1702
|
-
}
|
|
1703
|
-
/**
|
|
1704
|
-
* 通过三个点确定一个圆的中心点
|
|
1705
|
-
* @param coord1
|
|
1706
|
-
* @param coord2
|
|
1707
|
-
* @param coord3
|
|
1708
|
-
*/
|
|
1709
|
-
function getCircleCenterOfThreeCoords(coord1, coord2, coord3) {
|
|
1710
|
-
const coordA = [(coord1[0] + coord2[0]) / 2, (coord1[1] + coord2[1]) / 2];
|
|
1711
|
-
const coordB = [coordA[0] - coord1[1] + coord2[1], coordA[1] + coord1[0] - coord2[0]];
|
|
1712
|
-
const coordC = [(coord1[0] + coord3[0]) / 2, (coord1[1] + coord3[1]) / 2];
|
|
1713
|
-
const coordD = [coordC[0] - coord1[1] + coord3[1], coordC[1] + coord1[0] - coord3[0]];
|
|
1714
|
-
return getIntersectCoord(coordA, coordB, coordC, coordD);
|
|
1715
|
-
}
|
|
1716
|
-
/**
|
|
1717
|
-
* 获取交集的点
|
|
1718
|
-
* @param coordA
|
|
1719
|
-
* @param coordB
|
|
1720
|
-
* @param coordC
|
|
1721
|
-
* @param coordD
|
|
1722
|
-
*/
|
|
1723
|
-
function getIntersectCoord(coordA, coordB, coordC, coordD) {
|
|
1724
|
-
if (coordA[1] === coordB[1]) {
|
|
1725
|
-
const f$1 = (coordD[0] - coordC[0]) / (coordD[1] - coordC[1]);
|
|
1726
|
-
const x$1 = f$1 * (coordA[1] - coordC[1]) + coordC[0];
|
|
1727
|
-
const y$1 = coordA[1];
|
|
1728
|
-
return [x$1, y$1];
|
|
1729
|
-
}
|
|
1730
|
-
if (coordC[1] === coordD[1]) {
|
|
1731
|
-
const e$1 = (coordB[0] - coordA[0]) / (coordB[1] - coordA[1]);
|
|
1732
|
-
const x$1 = e$1 * (coordC[1] - coordA[1]) + coordA[0];
|
|
1733
|
-
const y$1 = coordC[1];
|
|
1734
|
-
return [x$1, y$1];
|
|
1735
|
-
}
|
|
1736
|
-
const e = (coordB[0] - coordA[0]) / (coordB[1] - coordA[1]);
|
|
1737
|
-
const f = (coordD[0] - coordC[0]) / (coordD[1] - coordC[1]);
|
|
1738
|
-
const y = (e * coordA[1] - coordA[0] - f * coordC[1] + coordC[0]) / (e - f);
|
|
1739
|
-
const x = e * y - e * coordA[1] + coordA[0];
|
|
1740
|
-
return [x, y];
|
|
1741
|
-
}
|
|
1742
|
-
/**
|
|
1743
|
-
* 获取方位角(地平经度)
|
|
1744
|
-
* @param startCoord
|
|
1745
|
-
* @param endCoord
|
|
1746
|
-
*/
|
|
1747
|
-
function getAzimuth(startCoord, endCoord) {
|
|
1748
|
-
let azimuth = 0;
|
|
1749
|
-
const angle = Math.asin(Math.abs(endCoord[1] - startCoord[1]) / mathDistance(startCoord, endCoord));
|
|
1750
|
-
if (endCoord[1] >= startCoord[1] && endCoord[0] >= startCoord[0]) azimuth = angle + Math.PI;
|
|
1751
|
-
else if (endCoord[1] >= startCoord[1] && endCoord[0] < startCoord[0]) azimuth = Math.PI * 2 - angle;
|
|
1752
|
-
else if (endCoord[1] < startCoord[1] && endCoord[0] < startCoord[0]) azimuth = angle;
|
|
1753
|
-
else if (endCoord[1] < startCoord[1] && endCoord[0] >= startCoord[0]) azimuth = Math.PI - angle;
|
|
1754
|
-
return azimuth;
|
|
1755
|
-
}
|
|
1756
|
-
/**
|
|
1757
|
-
* 通过三个点获取方位角
|
|
1758
|
-
* @param coordA
|
|
1759
|
-
* @param coordB
|
|
1760
|
-
* @param coordC
|
|
1761
|
-
*/
|
|
1762
|
-
function getAngleOfThreeCoords(coordA, coordB, coordC) {
|
|
1763
|
-
const angle = getAzimuth(coordB, coordA) - getAzimuth(coordB, coordC);
|
|
1764
|
-
return angle < 0 ? angle + Math.PI * 2 : angle;
|
|
1765
|
-
}
|
|
1766
|
-
/**
|
|
1767
|
-
* 判断是否是顺时针
|
|
1768
|
-
* @param coord1
|
|
1769
|
-
* @param coord2
|
|
1770
|
-
* @param coord3
|
|
1771
|
-
*/
|
|
1772
|
-
function isClockWise(coord1, coord2, coord3) {
|
|
1773
|
-
return (coord3[1] - coord1[1]) * (coord2[0] - coord1[0]) > (coord2[1] - coord1[1]) * (coord3[0] - coord1[0]);
|
|
1774
|
-
}
|
|
1775
|
-
/**
|
|
1776
|
-
* 获取立方值
|
|
1777
|
-
*/
|
|
1778
|
-
function getCubicValue(t, startCoord, coord1, coord2, endCoord) {
|
|
1779
|
-
t = Math.max(Math.min(t, 1), 0);
|
|
1780
|
-
const [tp, t2] = [1 - t, t * t];
|
|
1781
|
-
const t3 = t2 * t;
|
|
1782
|
-
const tp2 = tp * tp;
|
|
1783
|
-
const tp3 = tp2 * tp;
|
|
1784
|
-
const x = tp3 * startCoord[0] + 3 * tp2 * t * coord1[0] + 3 * tp * t2 * coord2[0] + t3 * endCoord[0];
|
|
1785
|
-
const y = tp3 * startCoord[1] + 3 * tp2 * t * coord1[1] + 3 * tp * t2 * coord2[1] + t3 * endCoord[1];
|
|
1786
|
-
return [x, y];
|
|
1787
|
-
}
|
|
1788
|
-
/**
|
|
1789
|
-
* 根据起止点和旋转方向求取第三个点
|
|
1790
|
-
* @param startCoord
|
|
1791
|
-
* @param endCoord
|
|
1792
|
-
* @param angle
|
|
1793
|
-
* @param distance
|
|
1794
|
-
* @param clockWise
|
|
1795
|
-
*/
|
|
1796
|
-
function getThirdCoord(startCoord, endCoord, angle, distance$1, clockWise) {
|
|
1797
|
-
const azimuth = getAzimuth(startCoord, endCoord);
|
|
1798
|
-
const alpha = clockWise ? azimuth + angle : azimuth - angle;
|
|
1799
|
-
const dx = distance$1 * Math.cos(alpha);
|
|
1800
|
-
const dy = distance$1 * Math.sin(alpha);
|
|
1801
|
-
return [endCoord[0] + dx, endCoord[1] + dy];
|
|
1802
|
-
}
|
|
1803
|
-
/**
|
|
1804
|
-
* 插值弓形线段点
|
|
1805
|
-
* @param center
|
|
1806
|
-
* @param radius
|
|
1807
|
-
* @param startAngle
|
|
1808
|
-
* @param endAngle
|
|
1809
|
-
*/
|
|
1810
|
-
function getArcCoords(center, radius, startAngle, endAngle) {
|
|
1811
|
-
let [x, y, coords, angleDiff] = [
|
|
1812
|
-
0,
|
|
1813
|
-
0,
|
|
1814
|
-
[],
|
|
1815
|
-
endAngle - startAngle
|
|
1816
|
-
];
|
|
1817
|
-
angleDiff = angleDiff < 0 ? angleDiff + Math.PI * 2 : angleDiff;
|
|
1818
|
-
for (let i = 0; i <= 100; i++) {
|
|
1819
|
-
const angle = startAngle + angleDiff * i / 100;
|
|
1820
|
-
x = center[0] + radius * Math.cos(angle);
|
|
1821
|
-
y = center[1] + radius * Math.sin(angle);
|
|
1822
|
-
coords.push([x, y]);
|
|
1823
|
-
}
|
|
1824
|
-
return coords;
|
|
1825
|
-
}
|
|
1826
|
-
/**
|
|
1827
|
-
* getBisectorNormals
|
|
1828
|
-
* @param t
|
|
1829
|
-
* @param coord1
|
|
1830
|
-
* @param coord2
|
|
1831
|
-
* @param coord3
|
|
1832
|
-
*/
|
|
1833
|
-
function getBisectorNormals(t, coord1, coord2, coord3) {
|
|
1834
|
-
const normal = getNormal(coord1, coord2, coord3);
|
|
1835
|
-
let [bisectorNormalRight, bisectorNormalLeft, dt, x, y] = [
|
|
1836
|
-
[0, 0],
|
|
1837
|
-
[0, 0],
|
|
1838
|
-
0,
|
|
1839
|
-
0,
|
|
1840
|
-
0
|
|
1841
|
-
];
|
|
1842
|
-
const dist = Math.hypot(normal[0], normal[1]);
|
|
1843
|
-
const uX = normal[0] / dist;
|
|
1844
|
-
const uY = normal[1] / dist;
|
|
1845
|
-
const d1 = mathDistance(coord1, coord2);
|
|
1846
|
-
const d2 = mathDistance(coord2, coord3);
|
|
1847
|
-
if (dist > ZERO_TOLERANCE) if (isClockWise(coord1, coord2, coord3)) {
|
|
1848
|
-
dt = t * d1;
|
|
1849
|
-
x = coord2[0] - dt * uY;
|
|
1850
|
-
y = coord2[1] + dt * uX;
|
|
1851
|
-
bisectorNormalRight = [x, y];
|
|
1852
|
-
dt = t * d2;
|
|
1853
|
-
x = coord2[0] + dt * uY;
|
|
1854
|
-
y = coord2[1] - dt * uX;
|
|
1855
|
-
bisectorNormalLeft = [x, y];
|
|
1856
|
-
} else {
|
|
1857
|
-
dt = t * d1;
|
|
1858
|
-
x = coord2[0] + dt * uY;
|
|
1859
|
-
y = coord2[1] - dt * uX;
|
|
1860
|
-
bisectorNormalRight = [x, y];
|
|
1861
|
-
dt = t * d2;
|
|
1862
|
-
x = coord2[0] - dt * uY;
|
|
1863
|
-
y = coord2[1] + dt * uX;
|
|
1864
|
-
bisectorNormalLeft = [x, y];
|
|
1865
|
-
}
|
|
1866
|
-
else {
|
|
1867
|
-
x = coord2[0] + t * (coord1[0] - coord2[0]);
|
|
1868
|
-
y = coord2[1] + t * (coord1[1] - coord2[1]);
|
|
1869
|
-
bisectorNormalRight = [x, y];
|
|
1870
|
-
x = coord2[0] + t * (coord3[0] - coord2[0]);
|
|
1871
|
-
y = coord2[1] + t * (coord3[1] - coord2[1]);
|
|
1872
|
-
bisectorNormalLeft = [x, y];
|
|
1873
|
-
}
|
|
1874
|
-
return [bisectorNormalRight, bisectorNormalLeft];
|
|
1875
|
-
}
|
|
1876
|
-
/**
|
|
1877
|
-
* 获取默认三点的内切圆
|
|
1878
|
-
* @param coord1
|
|
1879
|
-
* @param coord2
|
|
1880
|
-
* @param coord3
|
|
1881
|
-
*/
|
|
1882
|
-
function getNormal(coord1, coord2, coord3) {
|
|
1883
|
-
let dX1 = coord1[0] - coord2[0];
|
|
1884
|
-
let dY1 = coord1[1] - coord2[1];
|
|
1885
|
-
const d1 = Math.hypot(dX1, dY1);
|
|
1886
|
-
dX1 /= d1;
|
|
1887
|
-
dY1 /= d1;
|
|
1888
|
-
let dX2 = coord3[0] - coord2[0];
|
|
1889
|
-
let dY2 = coord3[1] - coord2[1];
|
|
1890
|
-
const d2 = Math.hypot(dX2, dY2);
|
|
1891
|
-
dX2 /= d2;
|
|
1892
|
-
dY2 /= d2;
|
|
1893
|
-
const uX = dX1 + dX2;
|
|
1894
|
-
const uY = dY1 + dY2;
|
|
1895
|
-
return [uX, uY];
|
|
1896
|
-
}
|
|
1897
|
-
/**
|
|
1898
|
-
* 贝塞尔曲线
|
|
1899
|
-
* @param points
|
|
1900
|
-
*/
|
|
1901
|
-
function getBezierCoords(points) {
|
|
1902
|
-
if (points.length <= 2) return points;
|
|
1903
|
-
const bezierCoords = [];
|
|
1904
|
-
const n = points.length - 1;
|
|
1905
|
-
for (let t = 0; t <= 1; t += .01) {
|
|
1906
|
-
let [x, y] = [0, 0];
|
|
1907
|
-
for (let index = 0; index <= n; index++) {
|
|
1908
|
-
const factor = getBinomialFactor(n, index);
|
|
1909
|
-
const a = t ** index;
|
|
1910
|
-
const b = (1 - t) ** (n - index);
|
|
1911
|
-
x += factor * a * b * points[index][0];
|
|
1912
|
-
y += factor * a * b * points[index][1];
|
|
1913
|
-
}
|
|
1914
|
-
bezierCoords.push([x, y]);
|
|
1915
|
-
}
|
|
1916
|
-
bezierCoords.push(points[n]);
|
|
1917
|
-
return bezierCoords;
|
|
1918
|
-
}
|
|
1919
|
-
/**
|
|
1920
|
-
* 获取阶乘数据
|
|
1921
|
-
* @param n
|
|
1922
|
-
*/
|
|
1923
|
-
function getFactorial(n) {
|
|
1924
|
-
let result = 1;
|
|
1925
|
-
switch (true) {
|
|
1926
|
-
case n <= 1:
|
|
1927
|
-
result = 1;
|
|
1928
|
-
break;
|
|
1929
|
-
case n === 2:
|
|
1930
|
-
result = 2;
|
|
1931
|
-
break;
|
|
1932
|
-
case n === 3:
|
|
1933
|
-
result = 6;
|
|
1934
|
-
break;
|
|
1935
|
-
case n === 24:
|
|
1936
|
-
result = 24;
|
|
1937
|
-
break;
|
|
1938
|
-
case n === 5:
|
|
1939
|
-
result = 120;
|
|
1940
|
-
break;
|
|
1941
|
-
default:
|
|
1942
|
-
for (let i = 1; i <= n; i++) result *= i;
|
|
1943
|
-
break;
|
|
1944
|
-
}
|
|
1945
|
-
return result;
|
|
1946
|
-
}
|
|
1947
|
-
/**
|
|
1948
|
-
* 获取二项分布
|
|
1949
|
-
* @param n
|
|
1950
|
-
* @param index
|
|
1951
|
-
*/
|
|
1952
|
-
function getBinomialFactor(n, index) {
|
|
1953
|
-
return getFactorial(n) / (getFactorial(index) * getFactorial(n - index));
|
|
1954
|
-
}
|
|
1955
|
-
/**
|
|
1956
|
-
* 插值线性点
|
|
1957
|
-
* @param points
|
|
1958
|
-
*/
|
|
1959
|
-
function getQBSplineCoords(points) {
|
|
1960
|
-
if (points.length <= 2) return points;
|
|
1961
|
-
const [n, bSplineCoords] = [2, []];
|
|
1962
|
-
const m = points.length - n - 1;
|
|
1963
|
-
bSplineCoords.push(points[0]);
|
|
1964
|
-
for (let i = 0; i <= m; i++) for (let t = 0; t <= 1; t += .05) {
|
|
1965
|
-
let [x, y] = [0, 0];
|
|
1966
|
-
for (let k = 0; k <= n; k++) {
|
|
1967
|
-
const factor = getQuadricBSplineFactor(k, t);
|
|
1968
|
-
x += factor * points[i + k][0];
|
|
1969
|
-
y += factor * points[i + k][1];
|
|
1970
|
-
}
|
|
1971
|
-
bSplineCoords.push([x, y]);
|
|
1972
|
-
}
|
|
1973
|
-
bSplineCoords.push(points.at(-1));
|
|
1974
|
-
return bSplineCoords;
|
|
1975
|
-
}
|
|
1976
|
-
/**
|
|
1977
|
-
* 得到二次线性因子
|
|
1978
|
-
* @param k
|
|
1979
|
-
* @param t
|
|
1980
|
-
*/
|
|
1981
|
-
function getQuadricBSplineFactor(k, t) {
|
|
1982
|
-
let res = 0;
|
|
1983
|
-
if (k === 0) res = (t - 1) ** 2 / 2;
|
|
1984
|
-
else if (k === 1) res = (-2 * t ** 2 + 2 * t + 1) / 2;
|
|
1985
|
-
else if (k === 2) res = t ** 2 / 2;
|
|
1986
|
-
return res;
|
|
1987
|
-
}
|
|
1988
|
-
|
|
1989
|
-
//#endregion
|
|
1990
|
-
//#region geom/arc.ts
|
|
1991
|
-
/**
|
|
1992
|
-
* 标绘画弓形算法,继承线要素相关方法和属性
|
|
1993
|
-
*/
|
|
1994
|
-
function arc(coords) {
|
|
1995
|
-
const coordlength = coords.length;
|
|
1996
|
-
if (coordlength <= 2) throw new Error("coords.length must >= 3");
|
|
1997
|
-
else {
|
|
1998
|
-
let [coord1, coord2, coord3, startAngle, endAngle] = [
|
|
1999
|
-
coords[0],
|
|
2000
|
-
coords[1],
|
|
2001
|
-
coords[2],
|
|
2002
|
-
0,
|
|
2003
|
-
0
|
|
2004
|
-
];
|
|
2005
|
-
const center = getCircleCenterOfThreeCoords(coord1, coord2, coord3);
|
|
2006
|
-
const radius = mathDistance(coord1, center);
|
|
2007
|
-
const angle1 = getAzimuth(coord1, center);
|
|
2008
|
-
const angle2 = getAzimuth(coord2, center);
|
|
2009
|
-
if (isClockWise(coord1, coord2, coord3)) {
|
|
2010
|
-
startAngle = angle2;
|
|
2011
|
-
endAngle = angle1;
|
|
2012
|
-
} else {
|
|
2013
|
-
startAngle = angle1;
|
|
2014
|
-
endAngle = angle2;
|
|
2015
|
-
}
|
|
2016
|
-
return getArcCoords(center, radius, startAngle, endAngle);
|
|
2017
|
-
}
|
|
2018
|
-
}
|
|
2019
|
-
|
|
2020
|
-
//#endregion
|
|
2021
|
-
//#region geom/arrowAttackDirection.ts
|
|
2022
|
-
/**
|
|
2023
|
-
* 尖曲箭头
|
|
2024
|
-
*/
|
|
2025
|
-
function arrowAttackDirection(coords, options = {}) {
|
|
2026
|
-
const coordLength = coords.length;
|
|
2027
|
-
if (coordLength < 3) throw new Error("coords.length must >= 3");
|
|
2028
|
-
else {
|
|
2029
|
-
let [tailLeft, tailRight] = [coords[0], coords[1]];
|
|
2030
|
-
if (isClockWise(coords[0], coords[1], coords[2])) {
|
|
2031
|
-
tailLeft = coords[1];
|
|
2032
|
-
tailRight = coords[0];
|
|
2033
|
-
}
|
|
2034
|
-
const midTail = mid(tailLeft, tailRight);
|
|
2035
|
-
const boneCoords = [midTail].concat(coords.slice(2));
|
|
2036
|
-
const headCoords = getArrowHeadCoords(boneCoords, {
|
|
2037
|
-
tailLeft,
|
|
2038
|
-
tailRight,
|
|
2039
|
-
...options
|
|
2040
|
-
});
|
|
2041
|
-
if (headCoords && headCoords.length > 4) {
|
|
2042
|
-
const [neckLeft, neckRight] = [headCoords[0], headCoords[4]];
|
|
2043
|
-
const tailWidthFactor = mathDistance(tailLeft, tailRight) / getBaseLength(boneCoords);
|
|
2044
|
-
const bodyCoords = getArrowBodyCoords(boneCoords, neckLeft, neckRight, tailWidthFactor);
|
|
2045
|
-
const coordlength = bodyCoords.length;
|
|
2046
|
-
let leftCoords = [tailLeft].concat(bodyCoords.slice(0, coordlength / 2));
|
|
2047
|
-
leftCoords.push(neckLeft);
|
|
2048
|
-
let rightCoords = [tailRight].concat(bodyCoords.slice(coordlength / 2, coordlength));
|
|
2049
|
-
rightCoords.push(neckRight);
|
|
2050
|
-
leftCoords = getQBSplineCoords(leftCoords);
|
|
2051
|
-
rightCoords = getQBSplineCoords(rightCoords);
|
|
2052
|
-
return leftCoords.concat(headCoords, rightCoords.reverse());
|
|
2053
|
-
} else return [];
|
|
2054
|
-
}
|
|
2055
|
-
}
|
|
2056
|
-
/**
|
|
2057
|
-
* 插值头部点
|
|
2058
|
-
*/
|
|
2059
|
-
function getArrowHeadCoords(points, options) {
|
|
2060
|
-
const { tailLeft, tailRight, headHeightFactor = .18, headWidthFactor = .3, neckHeightFactor = .85, neckWidthFactor = .15, headTailFactor = .8 } = options;
|
|
2061
|
-
let len = getBaseLength(points);
|
|
2062
|
-
let headHeight = len * headHeightFactor;
|
|
2063
|
-
const headCoord = points.at(-1);
|
|
2064
|
-
len = mathDistance(headCoord, points.at(-2));
|
|
2065
|
-
let tailWidth = 0;
|
|
2066
|
-
if (tailLeft && tailRight) tailWidth = mathDistance(tailLeft, tailRight);
|
|
2067
|
-
if (headHeight > tailWidth * headTailFactor) headHeight = tailWidth * headTailFactor;
|
|
2068
|
-
const headWidth = headHeight * headWidthFactor;
|
|
2069
|
-
const neckWidth = headHeight * neckWidthFactor;
|
|
2070
|
-
headHeight = Math.min(headHeight, len);
|
|
2071
|
-
const neckHeight = headHeight * neckHeightFactor;
|
|
2072
|
-
const headEndCoord = getThirdCoord(points.at(-2), headCoord, 0, headHeight, true);
|
|
2073
|
-
const neckEndCoord = getThirdCoord(points.at(-2), headCoord, 0, neckHeight, true);
|
|
2074
|
-
const headLeft = getThirdCoord(headCoord, headEndCoord, HALF_PI, headWidth, false);
|
|
2075
|
-
const headRight = getThirdCoord(headCoord, headEndCoord, HALF_PI, headWidth, true);
|
|
2076
|
-
const neckLeft = getThirdCoord(headCoord, neckEndCoord, HALF_PI, neckWidth, false);
|
|
2077
|
-
const neckRight = getThirdCoord(headCoord, neckEndCoord, HALF_PI, neckWidth, true);
|
|
2078
|
-
return [
|
|
2079
|
-
neckLeft,
|
|
2080
|
-
headLeft,
|
|
2081
|
-
headCoord,
|
|
2082
|
-
headRight,
|
|
2083
|
-
neckRight
|
|
2084
|
-
];
|
|
2085
|
-
}
|
|
2086
|
-
/**
|
|
2087
|
-
* 插值面部分数据
|
|
2088
|
-
* @param points
|
|
2089
|
-
* @param neckLeft
|
|
2090
|
-
* @param neckRight
|
|
2091
|
-
* @param tailWidthFactor
|
|
2092
|
-
*/
|
|
2093
|
-
function getArrowBodyCoords(points, neckLeft, neckRight, tailWidthFactor) {
|
|
2094
|
-
const allLen = wholeDistance(points);
|
|
2095
|
-
const len = getBaseLength(points);
|
|
2096
|
-
const tailWidth = len * tailWidthFactor;
|
|
2097
|
-
const neckWidth = mathDistance(neckLeft, neckRight);
|
|
2098
|
-
const widthDif = (tailWidth - neckWidth) / 2;
|
|
2099
|
-
let tempLen = 0;
|
|
2100
|
-
const leftBodyCoords = [];
|
|
2101
|
-
const rightBodyCoords = [];
|
|
2102
|
-
for (let i = 1; i < points.length - 1; i++) {
|
|
2103
|
-
const angle = getAngleOfThreeCoords(points[i - 1], points[i], points[i + 1]) / 2;
|
|
2104
|
-
tempLen += mathDistance(points[i - 1], points[i]);
|
|
2105
|
-
const w = (tailWidth / 2 - tempLen / allLen * widthDif) / Math.sin(angle);
|
|
2106
|
-
const left = getThirdCoord(points[i - 1], points[i], Math.PI - angle, w, true);
|
|
2107
|
-
const right = getThirdCoord(points[i - 1], points[i], angle, w, false);
|
|
2108
|
-
leftBodyCoords.push(left);
|
|
2109
|
-
rightBodyCoords.push(right);
|
|
2110
|
-
}
|
|
2111
|
-
return leftBodyCoords.concat(rightBodyCoords);
|
|
2112
|
-
}
|
|
2113
|
-
|
|
2114
|
-
//#endregion
|
|
2115
|
-
//#region geom/arrowAttackDirectionTailed.ts
|
|
2116
|
-
/**
|
|
2117
|
-
* 燕尾尖曲箭头
|
|
2118
|
-
*/
|
|
2119
|
-
function arrowAttackDirectionTailed(coords, options = {}) {
|
|
2120
|
-
const { headHeightFactor = .18, headWidthFactor = .3, neckHeightFactor = .85, neckWidthFactor = .15, tailWidthFactor = .1, swallowTailFactor = 1 } = options;
|
|
2121
|
-
const coordLength = coords.length;
|
|
2122
|
-
if (coordLength < 3) throw new Error("coords.length must >= 3");
|
|
2123
|
-
let [tailLeft, tailRight] = [coords[0], coords[1]];
|
|
2124
|
-
if (isClockWise(coords[0], coords[1], coords[2])) {
|
|
2125
|
-
tailLeft = coords[1];
|
|
2126
|
-
tailRight = coords[0];
|
|
2127
|
-
}
|
|
2128
|
-
const midTail = mid(tailLeft, tailRight);
|
|
2129
|
-
const boneCoords = [midTail].concat(coords.slice(2));
|
|
2130
|
-
const headCoords = getArrowHeadCoords(boneCoords, {
|
|
2131
|
-
tailLeft,
|
|
2132
|
-
tailRight,
|
|
2133
|
-
headHeightFactor,
|
|
2134
|
-
headWidthFactor,
|
|
2135
|
-
neckWidthFactor,
|
|
2136
|
-
neckHeightFactor
|
|
2137
|
-
});
|
|
2138
|
-
if (headCoords && headCoords.length > 4) {
|
|
2139
|
-
const [neckLeft, neckRight] = [headCoords[0], headCoords[4]];
|
|
2140
|
-
const tailWidth = mathDistance(tailLeft, tailRight);
|
|
2141
|
-
const allLen = getBaseLength(boneCoords);
|
|
2142
|
-
const len = allLen * tailWidthFactor * swallowTailFactor;
|
|
2143
|
-
const swallowTailCoord = getThirdCoord(boneCoords[1], boneCoords[0], 0, len, true);
|
|
2144
|
-
const factor = tailWidth / allLen;
|
|
2145
|
-
const bodyCoords = getArrowBodyCoords(boneCoords, neckLeft, neckRight, factor);
|
|
2146
|
-
const coordlength = bodyCoords.length;
|
|
2147
|
-
let leftCoords = [tailLeft].concat(bodyCoords.slice(0, coordlength / 2));
|
|
2148
|
-
leftCoords.push(neckLeft);
|
|
2149
|
-
let rightCoords = [tailRight].concat(bodyCoords.slice(coordlength / 2, coordlength));
|
|
2150
|
-
rightCoords.push(neckRight);
|
|
2151
|
-
leftCoords = getQBSplineCoords(leftCoords);
|
|
2152
|
-
rightCoords = getQBSplineCoords(rightCoords);
|
|
2153
|
-
return leftCoords.concat(headCoords, rightCoords.reverse(), [swallowTailCoord, leftCoords[0]]);
|
|
2154
|
-
} else return [];
|
|
2155
|
-
}
|
|
2156
|
-
|
|
2157
|
-
//#endregion
|
|
2158
|
-
//#region geom/arrowClamped.ts
|
|
2159
|
-
/**
|
|
2160
|
-
* 钳击箭头 有效点位长度3,4,5
|
|
2161
|
-
*/
|
|
2162
|
-
function arrowClamped(coords) {
|
|
2163
|
-
const options = {
|
|
2164
|
-
headHeightFactor: .25,
|
|
2165
|
-
headWidthFactor: .3,
|
|
2166
|
-
neckHeightFactor: .85,
|
|
2167
|
-
neckWidthFactor: .15
|
|
2168
|
-
};
|
|
2169
|
-
if (coords.length < 3) throw new Error(`coords.length must >= 3`);
|
|
2170
|
-
const [coord1, coord2, coord3] = coords;
|
|
2171
|
-
let tempCoord4, connCoord;
|
|
2172
|
-
if (coords.length === 3) {
|
|
2173
|
-
tempCoord4 = getTempCoord4(coord1, coord2, coord3);
|
|
2174
|
-
connCoord = mid(coord1, coord2);
|
|
2175
|
-
} else if (coords.length === 4) {
|
|
2176
|
-
tempCoord4 = coords[3];
|
|
2177
|
-
connCoord = mid(coord1, coord2);
|
|
2178
|
-
} else {
|
|
2179
|
-
tempCoord4 = coords[3];
|
|
2180
|
-
connCoord = coords[4];
|
|
2181
|
-
}
|
|
2182
|
-
let leftArrowCoords;
|
|
2183
|
-
let rightArrowCoords;
|
|
2184
|
-
if (isClockWise(coord1, coord2, coord3)) {
|
|
2185
|
-
leftArrowCoords = getArrowCoords(coord1, connCoord, tempCoord4, false, options);
|
|
2186
|
-
rightArrowCoords = getArrowCoords(connCoord, coord2, coord3, true, options);
|
|
2187
|
-
} else {
|
|
2188
|
-
leftArrowCoords = getArrowCoords(coord2, connCoord, coord3, false, options);
|
|
2189
|
-
rightArrowCoords = getArrowCoords(connCoord, coord1, tempCoord4, true, options);
|
|
2190
|
-
}
|
|
2191
|
-
const m = leftArrowCoords.length;
|
|
2192
|
-
const t = (m - 5) / 2;
|
|
2193
|
-
const llBodyCoords = leftArrowCoords.slice(0, t);
|
|
2194
|
-
const lArrowCoords = leftArrowCoords.slice(t, t + 5);
|
|
2195
|
-
let lrBodyCoords = leftArrowCoords.slice(t + 5, m);
|
|
2196
|
-
let rlBodyCoords = rightArrowCoords.slice(0, t);
|
|
2197
|
-
const rArrowCoords = rightArrowCoords.slice(t, t + 5);
|
|
2198
|
-
const rrBodyCoords = rightArrowCoords.slice(t + 5, m);
|
|
2199
|
-
rlBodyCoords = getBezierCoords(rlBodyCoords);
|
|
2200
|
-
const bodyCoords = getBezierCoords(rrBodyCoords.concat(llBodyCoords.slice(1)));
|
|
2201
|
-
lrBodyCoords = getBezierCoords(lrBodyCoords);
|
|
2202
|
-
return rlBodyCoords.concat(rArrowCoords, bodyCoords, lArrowCoords, lrBodyCoords);
|
|
2203
|
-
}
|
|
2204
|
-
/**
|
|
2205
|
-
* 插值箭形上的点
|
|
2206
|
-
* @param coord1 - Wgs84坐标
|
|
2207
|
-
* @param coord2 - Wgs84坐标
|
|
2208
|
-
* @param coord3 - Wgs84坐标
|
|
2209
|
-
* @param clockWise - 是否顺时针
|
|
2210
|
-
*/
|
|
2211
|
-
function getArrowCoords(coord1, coord2, coord3, clockWise, options) {
|
|
2212
|
-
const midCoord = mid(coord1, coord2);
|
|
2213
|
-
const len = mathDistance(midCoord, coord3);
|
|
2214
|
-
let midCoord1 = getThirdCoord(coord3, midCoord, 0, len * .3, true);
|
|
2215
|
-
let midCoord2 = getThirdCoord(coord3, midCoord, 0, len * .5, true);
|
|
2216
|
-
midCoord1 = getThirdCoord(midCoord, midCoord1, HALF_PI, len / 5, clockWise);
|
|
2217
|
-
midCoord2 = getThirdCoord(midCoord, midCoord2, HALF_PI, len / 4, clockWise);
|
|
2218
|
-
const coords = [
|
|
2219
|
-
midCoord,
|
|
2220
|
-
midCoord1,
|
|
2221
|
-
midCoord2,
|
|
2222
|
-
coord3
|
|
2223
|
-
];
|
|
2224
|
-
const arrowCoords = getArrowHeadCoords$1(coords, options);
|
|
2225
|
-
if (arrowCoords && Array.isArray(arrowCoords) && arrowCoords.length > 0) {
|
|
2226
|
-
const [neckLeftCoord, neckRightCoord] = [arrowCoords[0], arrowCoords[4]];
|
|
2227
|
-
const tailWidthFactor = mathDistance(coord1, coord2) / getBaseLength(coords) / 2;
|
|
2228
|
-
const bodyCoords = getArrowBodyCoords$1(coords, neckLeftCoord, neckRightCoord, tailWidthFactor);
|
|
2229
|
-
const n = bodyCoords.length;
|
|
2230
|
-
let lCoords = bodyCoords.slice(0, n / 2);
|
|
2231
|
-
let rCoords = bodyCoords.slice(n / 2, n);
|
|
2232
|
-
lCoords.push(neckLeftCoord);
|
|
2233
|
-
rCoords.push(neckRightCoord);
|
|
2234
|
-
lCoords = lCoords.reverse();
|
|
2235
|
-
lCoords.push(coord2);
|
|
2236
|
-
rCoords = rCoords.reverse();
|
|
2237
|
-
rCoords.push(coord1);
|
|
2238
|
-
return lCoords.reverse().concat(arrowCoords, rCoords);
|
|
2239
|
-
} else throw new Error("插值出错");
|
|
2240
|
-
}
|
|
2241
|
-
/**
|
|
2242
|
-
* 插值头部点
|
|
2243
|
-
* @param coords
|
|
2244
|
-
*/
|
|
2245
|
-
function getArrowHeadCoords$1(coords, options) {
|
|
2246
|
-
const { headHeightFactor, headWidthFactor, neckWidthFactor, neckHeightFactor } = options;
|
|
2247
|
-
const len = getBaseLength(coords);
|
|
2248
|
-
const headHeight = len * headHeightFactor;
|
|
2249
|
-
const headCoord = coords.at(-1);
|
|
2250
|
-
const headWidth = headHeight * headWidthFactor;
|
|
2251
|
-
const neckWidth = headHeight * neckWidthFactor;
|
|
2252
|
-
const neckHeight = headHeight * neckHeightFactor;
|
|
2253
|
-
const headEndCoord = getThirdCoord(coords.at(-2), headCoord, 0, headHeight, true);
|
|
2254
|
-
const neckEndCoord = getThirdCoord(coords.at(-2), headCoord, 0, neckHeight, true);
|
|
2255
|
-
const headLeft = getThirdCoord(headCoord, headEndCoord, HALF_PI, headWidth, false);
|
|
2256
|
-
const headRight = getThirdCoord(headCoord, headEndCoord, HALF_PI, headWidth, true);
|
|
2257
|
-
const neckLeft = getThirdCoord(headCoord, neckEndCoord, HALF_PI, neckWidth, false);
|
|
2258
|
-
const neckRight = getThirdCoord(headCoord, neckEndCoord, HALF_PI, neckWidth, true);
|
|
2259
|
-
return [
|
|
2260
|
-
neckLeft,
|
|
2261
|
-
headLeft,
|
|
2262
|
-
headCoord,
|
|
2263
|
-
headRight,
|
|
2264
|
-
neckRight
|
|
2265
|
-
];
|
|
2266
|
-
}
|
|
2267
|
-
/**
|
|
2268
|
-
* 插值面部分数据
|
|
2269
|
-
* @param coords
|
|
2270
|
-
* @param neckLeft
|
|
2271
|
-
* @param neckRight
|
|
2272
|
-
* @param tailWidthFactor
|
|
2273
|
-
*/
|
|
2274
|
-
function getArrowBodyCoords$1(coords, neckLeft, neckRight, tailWidthFactor) {
|
|
2275
|
-
const allLen = wholeDistance(coords);
|
|
2276
|
-
const len = getBaseLength(coords);
|
|
2277
|
-
const tailWidth = len * tailWidthFactor;
|
|
2278
|
-
const neckWidth = mathDistance(neckLeft, neckRight);
|
|
2279
|
-
const widthDif = (tailWidth - neckWidth) / 2;
|
|
2280
|
-
let tempLen = 0;
|
|
2281
|
-
const leftBodyCoords = [];
|
|
2282
|
-
const rightBodyCoords = [];
|
|
2283
|
-
for (let i = 1; i < coords.length - 1; i++) {
|
|
2284
|
-
const angle = getAngleOfThreeCoords(coords[i - 1], coords[i], coords[i + 1]) / 2;
|
|
2285
|
-
tempLen += mathDistance(coords[i - 1], coords[i]);
|
|
2286
|
-
const w = (tailWidth / 2 - tempLen / allLen * widthDif) / Math.sin(angle);
|
|
2287
|
-
const left = getThirdCoord(coords[i - 1], coords[i], Math.PI - angle, w, true);
|
|
2288
|
-
const right = getThirdCoord(coords[i - 1], coords[i], angle, w, false);
|
|
2289
|
-
leftBodyCoords.push(left);
|
|
2290
|
-
rightBodyCoords.push(right);
|
|
2291
|
-
}
|
|
2292
|
-
return leftBodyCoords.concat(rightBodyCoords);
|
|
2293
|
-
}
|
|
2294
|
-
/**
|
|
2295
|
-
* 获取对称点
|
|
2296
|
-
* @param lineCoord1
|
|
2297
|
-
* @param lineCoord2
|
|
2298
|
-
* @param coord
|
|
2299
|
-
*/
|
|
2300
|
-
function getTempCoord4(lineCoord1, lineCoord2, coord) {
|
|
2301
|
-
const midCoord = mid(lineCoord1, lineCoord2);
|
|
2302
|
-
const len = mathDistance(midCoord, coord);
|
|
2303
|
-
const angle = getAngleOfThreeCoords(lineCoord1, midCoord, coord);
|
|
2304
|
-
if (angle < HALF_PI) {
|
|
2305
|
-
const distance1 = len * Math.sin(angle);
|
|
2306
|
-
const distance2 = len * Math.cos(angle);
|
|
2307
|
-
const mid$1 = getThirdCoord(lineCoord1, midCoord, HALF_PI, distance1, false);
|
|
2308
|
-
return getThirdCoord(midCoord, mid$1, HALF_PI, distance2, true);
|
|
2309
|
-
} else if (angle >= HALF_PI && angle < Math.PI) {
|
|
2310
|
-
const distance1 = len * Math.sin(Math.PI - angle);
|
|
2311
|
-
const distance2 = len * Math.cos(Math.PI - angle);
|
|
2312
|
-
const mid$1 = getThirdCoord(lineCoord1, midCoord, HALF_PI, distance1, false);
|
|
2313
|
-
return getThirdCoord(midCoord, mid$1, HALF_PI, distance2, false);
|
|
2314
|
-
} else if (angle >= Math.PI && angle < Math.PI * 1.5) {
|
|
2315
|
-
const distance1 = len * Math.sin(angle - Math.PI);
|
|
2316
|
-
const distance2 = len * Math.cos(angle - Math.PI);
|
|
2317
|
-
const mid$1 = getThirdCoord(lineCoord1, midCoord, HALF_PI, distance1, true);
|
|
2318
|
-
return getThirdCoord(midCoord, mid$1, HALF_PI, distance2, true);
|
|
2319
|
-
} else {
|
|
2320
|
-
const distance1 = len * Math.sin(Math.PI * 2 - angle);
|
|
2321
|
-
const distance2 = len * Math.cos(Math.PI * 2 - angle);
|
|
2322
|
-
const mid$1 = getThirdCoord(lineCoord1, midCoord, HALF_PI, distance1, true);
|
|
2323
|
-
return getThirdCoord(midCoord, mid$1, HALF_PI, distance2, false);
|
|
2324
|
-
}
|
|
2325
|
-
}
|
|
2326
|
-
|
|
2327
|
-
//#endregion
|
|
2328
|
-
//#region geom/arrowStraightSharp.ts
|
|
2329
|
-
/**
|
|
2330
|
-
* 尖箭头
|
|
2331
|
-
*
|
|
2332
|
-
*/
|
|
2333
|
-
function arrowStraightSharp(coords, options = {}) {
|
|
2334
|
-
const { tailWidthFactor = .1, neckWidthFactor = .2, headWidthFactor = .25, headAngle = Math.PI / 8.5, neckAngle = Math.PI / 13 } = options;
|
|
2335
|
-
const coordlength = coords.length;
|
|
2336
|
-
if (coordlength < 2) throw new Error("coords.length must >= 2");
|
|
2337
|
-
const [coord1, coord2] = [coords[0], coords[1]];
|
|
2338
|
-
const len = getBaseLength(coords);
|
|
2339
|
-
const tailWidth = len * tailWidthFactor;
|
|
2340
|
-
const neckWidth = len * neckWidthFactor;
|
|
2341
|
-
const headWidth = len * headWidthFactor;
|
|
2342
|
-
const tailLeft = getThirdCoord(coord2, coord1, HALF_PI, tailWidth, true);
|
|
2343
|
-
const tailRight = getThirdCoord(coord2, coord1, HALF_PI, tailWidth, false);
|
|
2344
|
-
const headLeft = getThirdCoord(coord1, coord2, headAngle, headWidth, false);
|
|
2345
|
-
const headRight = getThirdCoord(coord1, coord2, headAngle, headWidth, true);
|
|
2346
|
-
const neckLeft = getThirdCoord(coord1, coord2, neckAngle, neckWidth, false);
|
|
2347
|
-
const neckRight = getThirdCoord(coord1, coord2, neckAngle, neckWidth, true);
|
|
2348
|
-
const pList = [
|
|
2349
|
-
tailLeft,
|
|
2350
|
-
neckLeft,
|
|
2351
|
-
headLeft,
|
|
2352
|
-
coord2,
|
|
2353
|
-
headRight,
|
|
2354
|
-
neckRight,
|
|
2355
|
-
tailRight
|
|
2356
|
-
];
|
|
2357
|
-
return pList;
|
|
2358
|
-
}
|
|
2359
|
-
|
|
2360
|
-
//#endregion
|
|
2361
|
-
//#region geom/arrowStraight.ts
|
|
2362
|
-
/**
|
|
2363
|
-
* 直箭头
|
|
2364
|
-
*/
|
|
2365
|
-
function arrowStraight(coords) {
|
|
2366
|
-
const tailWidthFactor = .05;
|
|
2367
|
-
const neckWidthFactor = .1;
|
|
2368
|
-
const headWidthFactor = .15;
|
|
2369
|
-
const headAngle = Math.PI / 4;
|
|
2370
|
-
const neckAngle = Math.PI * .17741;
|
|
2371
|
-
return arrowStraightSharp(coords, {
|
|
2372
|
-
tailWidthFactor,
|
|
2373
|
-
neckWidthFactor,
|
|
2374
|
-
headWidthFactor,
|
|
2375
|
-
headAngle,
|
|
2376
|
-
neckAngle
|
|
2377
|
-
});
|
|
2378
|
-
}
|
|
2379
|
-
|
|
2380
|
-
//#endregion
|
|
2381
|
-
//#region geom/arrowUnitCombatOperation.ts
|
|
2382
|
-
/**
|
|
2383
|
-
* 分队战斗行动(尖曲箭头)
|
|
2384
|
-
*/
|
|
2385
|
-
function arrowUnitCombatOperation(coords, options = {}) {
|
|
2386
|
-
const { headHeightFactor = .18, headWidthFactor = .3, neckHeightFactor = .85, neckWidthFactor = .15, tailWidthFactor = .1 } = options;
|
|
2387
|
-
const coordlength = coords.length;
|
|
2388
|
-
if (coordlength < 2) throw new Error("coords.length must >= 2");
|
|
2389
|
-
else {
|
|
2390
|
-
const allLen = getBaseLength(coords);
|
|
2391
|
-
const tailWidth = allLen * tailWidthFactor;
|
|
2392
|
-
const tailLeft = getThirdCoord(coords[1], coords[0], HALF_PI, tailWidth, false);
|
|
2393
|
-
const tailRight = getThirdCoord(coords[1], coords[0], HALF_PI, tailWidth, true);
|
|
2394
|
-
const headCoords = getArrowHeadCoords(coords, {
|
|
2395
|
-
tailLeft,
|
|
2396
|
-
tailRight,
|
|
2397
|
-
headHeightFactor,
|
|
2398
|
-
headWidthFactor,
|
|
2399
|
-
neckWidthFactor,
|
|
2400
|
-
neckHeightFactor
|
|
2401
|
-
});
|
|
2402
|
-
if (headCoords && headCoords.length > 4) {
|
|
2403
|
-
const neckLeft = headCoords[0];
|
|
2404
|
-
const neckRight = headCoords[4];
|
|
2405
|
-
const bodyCoords = getArrowBodyCoords(coords, neckLeft, neckRight, tailWidthFactor);
|
|
2406
|
-
const coordlength$1 = bodyCoords.length;
|
|
2407
|
-
let leftCoords = [tailLeft].concat(bodyCoords.slice(0, coordlength$1 / 2));
|
|
2408
|
-
leftCoords.push(neckLeft);
|
|
2409
|
-
let rightCoords = [tailRight].concat(bodyCoords.slice(coordlength$1 / 2, coordlength$1));
|
|
2410
|
-
rightCoords.push(neckRight);
|
|
2411
|
-
leftCoords = getQBSplineCoords(leftCoords);
|
|
2412
|
-
rightCoords = getQBSplineCoords(rightCoords);
|
|
2413
|
-
return leftCoords.concat(headCoords, rightCoords.reverse());
|
|
2414
|
-
} else return [];
|
|
2415
|
-
}
|
|
2416
|
-
}
|
|
2417
|
-
|
|
2418
|
-
//#endregion
|
|
2419
|
-
//#region geom/arrowUnitCombatOperationTailed.ts
|
|
2420
|
-
/**
|
|
2421
|
-
* 燕尾尖箭头
|
|
2422
|
-
*/
|
|
2423
|
-
function arrowUnitCombatOperationTailed(coords, options = {}) {
|
|
2424
|
-
const { headHeightFactor = .18, headWidthFactor = .3, neckHeightFactor = .85, neckWidthFactor = .15, tailWidthFactor = .1, swallowTailFactor = 1 } = options;
|
|
2425
|
-
const coordlength = coords.length;
|
|
2426
|
-
if (coordlength < 2) throw new Error("coords.length must >= 2");
|
|
2427
|
-
const allLen = getBaseLength(coords);
|
|
2428
|
-
const tailWidth = allLen * tailWidthFactor;
|
|
2429
|
-
const tailLeft = getThirdCoord(coords[1], coords[0], HALF_PI, tailWidth, false);
|
|
2430
|
-
const tailRight = getThirdCoord(coords[1], coords[0], HALF_PI, tailWidth, true);
|
|
2431
|
-
const len = tailWidth * swallowTailFactor;
|
|
2432
|
-
const swallowTailCoord = getThirdCoord(coords[1], coords[0], 0, len, true);
|
|
2433
|
-
const tailCoords = [
|
|
2434
|
-
tailLeft,
|
|
2435
|
-
swallowTailCoord,
|
|
2436
|
-
tailRight
|
|
2437
|
-
];
|
|
2438
|
-
const headCoords = getArrowHeadCoords(coords, {
|
|
2439
|
-
tailLeft: tailCoords[0],
|
|
2440
|
-
tailRight: tailCoords[2],
|
|
2441
|
-
headHeightFactor,
|
|
2442
|
-
headWidthFactor,
|
|
2443
|
-
neckWidthFactor,
|
|
2444
|
-
neckHeightFactor
|
|
2445
|
-
});
|
|
2446
|
-
if (headCoords && headCoords.length > 4) {
|
|
2447
|
-
const neckLeft = headCoords[0];
|
|
2448
|
-
const neckRight = headCoords[4];
|
|
2449
|
-
const bodyCoords = getArrowBodyCoords(coords, neckLeft, neckRight, tailWidthFactor);
|
|
2450
|
-
const coordlength$1 = bodyCoords.length;
|
|
2451
|
-
let leftCoords = [tailCoords[0]].concat(bodyCoords.slice(0, coordlength$1 / 2));
|
|
2452
|
-
leftCoords.push(neckLeft);
|
|
2453
|
-
let rightCoords = [tailCoords[2]].concat(bodyCoords.slice(coordlength$1 / 2, coordlength$1));
|
|
2454
|
-
rightCoords.push(neckRight);
|
|
2455
|
-
leftCoords = getQBSplineCoords(leftCoords);
|
|
2456
|
-
rightCoords = getQBSplineCoords(rightCoords);
|
|
2457
|
-
return leftCoords.concat(headCoords, rightCoords.reverse(), [tailCoords[1], leftCoords[0]]);
|
|
2458
|
-
}
|
|
2459
|
-
return [];
|
|
2460
|
-
}
|
|
2461
|
-
|
|
2462
|
-
//#endregion
|
|
2463
|
-
//#region geom/assemblingPlace.ts
|
|
2464
|
-
/**
|
|
2465
|
-
* 集结地
|
|
2466
|
-
*
|
|
2467
|
-
*/
|
|
2468
|
-
function assemblingPlace(coords) {
|
|
2469
|
-
if (coords.length < 3) throw new Error(`coords.length must >= 3`);
|
|
2470
|
-
const t = .4;
|
|
2471
|
-
const midCoord = mid(coords[0], coords[2]);
|
|
2472
|
-
coords.push(midCoord, coords[0], coords[1]);
|
|
2473
|
-
let normals = [];
|
|
2474
|
-
const pList = [];
|
|
2475
|
-
for (let i = 0; i < coords.length - 2; i++) {
|
|
2476
|
-
const coord1 = coords[i];
|
|
2477
|
-
const coord2 = coords[i + 1];
|
|
2478
|
-
const coord3 = coords[i + 2];
|
|
2479
|
-
const normalCoords = getBisectorNormals(t, coord1, coord2, coord3);
|
|
2480
|
-
normals = normals.concat(normalCoords);
|
|
2481
|
-
}
|
|
2482
|
-
const count = normals.length;
|
|
2483
|
-
normals = [normals[count - 1]].concat(normals.slice(0, count - 1));
|
|
2484
|
-
for (let i = 0; i < coords.length - 2; i++) {
|
|
2485
|
-
const coord1 = coords[i];
|
|
2486
|
-
const coord2 = coords[i + 1];
|
|
2487
|
-
pList.push(coord1);
|
|
2488
|
-
for (let t$1 = 0; t$1 <= FITTING_COUNT; t$1++) {
|
|
2489
|
-
const coord = getCubicValue(t$1 / FITTING_COUNT, coord1, normals[i * 2], normals[i * 2 + 1], coord2);
|
|
2490
|
-
pList.push(coord);
|
|
2491
|
-
}
|
|
2492
|
-
pList.push(coord2);
|
|
2493
|
-
}
|
|
2494
|
-
return pList;
|
|
2495
|
-
}
|
|
2496
|
-
|
|
2497
|
-
//#endregion
|
|
2498
|
-
//#region geom/flagCurve.ts
|
|
2499
|
-
/**
|
|
2500
|
-
* 曲线旗标
|
|
2501
|
-
*/
|
|
2502
|
-
function flagCurve(coords) {
|
|
2503
|
-
const coordlength = coords.length;
|
|
2504
|
-
if (coordlength < 2) throw new Error("coords.length must >= 2");
|
|
2505
|
-
return calculatePonits(coords);
|
|
2506
|
-
}
|
|
2507
|
-
/**
|
|
2508
|
-
* 插值点数据
|
|
2509
|
-
* @param coords
|
|
2510
|
-
*/
|
|
2511
|
-
function calculatePonits(coords) {
|
|
2512
|
-
let components = [];
|
|
2513
|
-
if (coords.length > 1) {
|
|
2514
|
-
const startCoord = coords[0];
|
|
2515
|
-
const endCoord = coords.at(-1);
|
|
2516
|
-
const coord1 = startCoord;
|
|
2517
|
-
const coord2 = [(endCoord[0] - startCoord[0]) / 4 + startCoord[0], (endCoord[1] - startCoord[1]) / 8 + startCoord[1]];
|
|
2518
|
-
const coord3 = [(startCoord[0] + endCoord[0]) / 2, startCoord[1]];
|
|
2519
|
-
const coord4 = [(endCoord[0] - startCoord[0]) * 3 / 4 + startCoord[0], -(endCoord[1] - startCoord[1]) / 8 + startCoord[1]];
|
|
2520
|
-
const coord5 = [endCoord[0], startCoord[1]];
|
|
2521
|
-
const coord6 = [endCoord[0], (startCoord[1] + endCoord[1]) / 2];
|
|
2522
|
-
const coord7 = [(endCoord[0] - startCoord[0]) * 3 / 4 + startCoord[0], (endCoord[1] - startCoord[1]) * 3 / 8 + startCoord[1]];
|
|
2523
|
-
const coord8 = [(startCoord[0] + endCoord[0]) / 2, (startCoord[1] + endCoord[1]) / 2];
|
|
2524
|
-
const coord9 = [(endCoord[0] - startCoord[0]) / 4 + startCoord[0], (endCoord[1] - startCoord[1]) * 5 / 8 + startCoord[1]];
|
|
2525
|
-
const coord10 = [startCoord[0], (startCoord[1] + endCoord[1]) / 2];
|
|
2526
|
-
const coord11 = [startCoord[0], endCoord[1]];
|
|
2527
|
-
const curve1 = getBezierCoords([
|
|
2528
|
-
coord1,
|
|
2529
|
-
coord2,
|
|
2530
|
-
coord3,
|
|
2531
|
-
coord4,
|
|
2532
|
-
coord5
|
|
2533
|
-
]);
|
|
2534
|
-
const curve2 = getBezierCoords([
|
|
2535
|
-
coord6,
|
|
2536
|
-
coord7,
|
|
2537
|
-
coord8,
|
|
2538
|
-
coord9,
|
|
2539
|
-
coord10
|
|
2540
|
-
]);
|
|
2541
|
-
components = curve1.concat(curve2);
|
|
2542
|
-
components.push(coord11);
|
|
2543
|
-
}
|
|
2544
|
-
return components;
|
|
2545
|
-
}
|
|
2546
|
-
|
|
2547
|
-
//#endregion
|
|
2548
|
-
//#region geom/flagRect.ts
|
|
2549
|
-
/**
|
|
2550
|
-
* 直角旗标(使用两个控制点直接创建直角旗标)
|
|
2551
|
-
*/
|
|
2552
|
-
function flagRect(coords) {
|
|
2553
|
-
if (coords.length < 2) throw new Error("coords.length must >= 2");
|
|
2554
|
-
const [startCoord, endCoord] = coords;
|
|
2555
|
-
const coord1 = [endCoord[0], startCoord[1]];
|
|
2556
|
-
const coord2 = [endCoord[0], (startCoord[1] + endCoord[1]) / 2];
|
|
2557
|
-
const coord3 = [startCoord[0], (startCoord[1] + endCoord[1]) / 2];
|
|
2558
|
-
const coord4 = [startCoord[0], endCoord[1]];
|
|
2559
|
-
return [
|
|
2560
|
-
startCoord,
|
|
2561
|
-
coord1,
|
|
2562
|
-
coord2,
|
|
2563
|
-
coord3,
|
|
2564
|
-
coord4
|
|
2565
|
-
];
|
|
2566
|
-
}
|
|
2567
|
-
|
|
2568
|
-
//#endregion
|
|
2569
|
-
//#region geom/flagTriangle.ts
|
|
1669
|
+
//#region scheme/PolygonArc.ts
|
|
2570
1670
|
/**
|
|
2571
|
-
*
|
|
1671
|
+
* 弓形
|
|
2572
1672
|
*/
|
|
2573
|
-
function flagTriangle(coords) {
|
|
2574
|
-
const coordlength = coords.length;
|
|
2575
|
-
if (coordlength < 2) throw new Error("coords.length must >= 2");
|
|
2576
|
-
const [startCoord, endCoord] = coords;
|
|
2577
|
-
const coord1 = [endCoord[0], (startCoord[1] + endCoord[1]) / 2];
|
|
2578
|
-
const coord2 = [startCoord[0], (startCoord[1] + endCoord[1]) / 2];
|
|
2579
|
-
const coord3 = [startCoord[0], endCoord[1]];
|
|
2580
|
-
return [
|
|
2581
|
-
startCoord,
|
|
2582
|
-
coord1,
|
|
2583
|
-
coord2,
|
|
2584
|
-
coord3
|
|
2585
|
-
];
|
|
2586
|
-
}
|
|
2587
|
-
|
|
2588
|
-
//#endregion
|
|
2589
|
-
//#region scheme/PolygonArc.ts
|
|
2590
1673
|
const PlotSchemePolygonArc = new PlotScheme({
|
|
2591
1674
|
type: "PolygonArc",
|
|
2592
1675
|
complete: (packable) => packable.positions.length >= 3,
|
|
@@ -2603,8 +1686,7 @@ const PlotSchemePolygonArc = new PlotScheme({
|
|
|
2603
1686
|
entity.polygon.hierarchy = void 0;
|
|
2604
1687
|
return context.previous;
|
|
2605
1688
|
}
|
|
2606
|
-
const
|
|
2607
|
-
const hierarchy = new cesium.PolygonHierarchy(positions);
|
|
1689
|
+
const hierarchy = new cesium.PolygonHierarchy((0, __vesium_geometry.arc)(coords).map((item) => (0, vesium.toCartesian3)(item)));
|
|
2608
1690
|
entity.polygon.hierarchy = new cesium.CallbackProperty(() => hierarchy, false);
|
|
2609
1691
|
return { entities: [entity] };
|
|
2610
1692
|
}
|
|
@@ -2632,8 +1714,7 @@ const PlotSchemePolygonArrowAttackDirection = new PlotScheme({
|
|
|
2632
1714
|
entity.polygon.hierarchy = void 0;
|
|
2633
1715
|
return context.previous;
|
|
2634
1716
|
}
|
|
2635
|
-
const
|
|
2636
|
-
const hierarchy = new cesium.PolygonHierarchy(positions);
|
|
1717
|
+
const hierarchy = new cesium.PolygonHierarchy((0, __vesium_geometry.arrowAttackDirection)(coords).map((item) => (0, vesium.toCartesian3)(item)));
|
|
2637
1718
|
entity.polygon.hierarchy = new cesium.CallbackProperty(() => hierarchy, false);
|
|
2638
1719
|
return { entities: [entity] };
|
|
2639
1720
|
}
|
|
@@ -2661,8 +1742,7 @@ const PlotSchemePolygonArrowAttackDirectionTailed = new PlotScheme({
|
|
|
2661
1742
|
entity.polygon.hierarchy = void 0;
|
|
2662
1743
|
return context.previous;
|
|
2663
1744
|
}
|
|
2664
|
-
const
|
|
2665
|
-
const hierarchy = new cesium.PolygonHierarchy(positions);
|
|
1745
|
+
const hierarchy = new cesium.PolygonHierarchy((0, __vesium_geometry.arrowAttackDirectionTailed)(coords).map((item) => (0, vesium.toCartesian3)(item)));
|
|
2666
1746
|
entity.polygon.hierarchy = new cesium.CallbackProperty(() => hierarchy, false);
|
|
2667
1747
|
return { entities: [entity] };
|
|
2668
1748
|
}
|
|
@@ -2686,8 +1766,7 @@ const PlotSchemePolygonArrowClamped = new PlotScheme({
|
|
|
2686
1766
|
}
|
|
2687
1767
|
const coords = points.map((e) => (0, vesium.toCoord)(e));
|
|
2688
1768
|
if (coords.length >= 3) {
|
|
2689
|
-
const
|
|
2690
|
-
const hierarchy = new cesium.PolygonHierarchy(positions.map((item) => (0, vesium.toCartesian3)(item)));
|
|
1769
|
+
const hierarchy = new cesium.PolygonHierarchy((0, __vesium_geometry.arrowClamped)(coords).map((item) => (0, vesium.toCartesian3)(item)));
|
|
2691
1770
|
entity.polygon.hierarchy = new cesium.CallbackProperty(() => hierarchy, false);
|
|
2692
1771
|
} else entity.polygon.hierarchy = void 0;
|
|
2693
1772
|
return { entities: [entity] };
|
|
@@ -2712,8 +1791,7 @@ const PlotSchemePolygonArrowStraight = new PlotScheme({
|
|
|
2712
1791
|
}
|
|
2713
1792
|
const coords = points.map((e) => (0, vesium.toCoord)(e));
|
|
2714
1793
|
if (coords.length >= 2) {
|
|
2715
|
-
const
|
|
2716
|
-
const hierarchy = new cesium.PolygonHierarchy(positions.map((item) => (0, vesium.toCartesian3)(item)));
|
|
1794
|
+
const hierarchy = new cesium.PolygonHierarchy((0, __vesium_geometry.arrowStraight)(coords).map((item) => (0, vesium.toCartesian3)(item)));
|
|
2717
1795
|
entity.polygon.hierarchy = new cesium.CallbackProperty(() => hierarchy, false);
|
|
2718
1796
|
} else entity.polygon.hierarchy = void 0;
|
|
2719
1797
|
return { entities: [entity] };
|
|
@@ -2738,8 +1816,7 @@ const PlotSchemePolygonArrowStraightSharp = new PlotScheme({
|
|
|
2738
1816
|
}
|
|
2739
1817
|
const coords = points.map((e) => (0, vesium.toCoord)(e));
|
|
2740
1818
|
if (coords.length >= 2) {
|
|
2741
|
-
const
|
|
2742
|
-
const hierarchy = new cesium.PolygonHierarchy(positions.map((item) => (0, vesium.toCartesian3)(item)));
|
|
1819
|
+
const hierarchy = new cesium.PolygonHierarchy((0, __vesium_geometry.arrowStraightSharp)(coords).map((item) => (0, vesium.toCartesian3)(item)));
|
|
2743
1820
|
entity.polygon.hierarchy = new cesium.CallbackProperty(() => hierarchy, false);
|
|
2744
1821
|
} else entity.polygon.hierarchy = void 0;
|
|
2745
1822
|
return { entities: [entity] };
|
|
@@ -2768,8 +1845,7 @@ const PlotSchemePolygonArrowUnitCombatOperation = new PlotScheme({
|
|
|
2768
1845
|
entity.polygon.hierarchy = void 0;
|
|
2769
1846
|
return context.previous;
|
|
2770
1847
|
}
|
|
2771
|
-
const
|
|
2772
|
-
const hierarchy = new cesium.PolygonHierarchy(positions);
|
|
1848
|
+
const hierarchy = new cesium.PolygonHierarchy((0, __vesium_geometry.arrowUnitCombatOperation)(coords).map((item) => (0, vesium.toCartesian3)(item)));
|
|
2773
1849
|
entity.polygon.hierarchy = new cesium.CallbackProperty(() => hierarchy, false);
|
|
2774
1850
|
return { entities: [entity] };
|
|
2775
1851
|
}
|
|
@@ -2797,8 +1873,7 @@ const PlotSchemePolygonArrowUnitCombatOperationTailed = new PlotScheme({
|
|
|
2797
1873
|
entity.polygon.hierarchy = void 0;
|
|
2798
1874
|
return context.previous;
|
|
2799
1875
|
}
|
|
2800
|
-
const
|
|
2801
|
-
const hierarchy = new cesium.PolygonHierarchy(positions);
|
|
1876
|
+
const hierarchy = new cesium.PolygonHierarchy((0, __vesium_geometry.arrowUnitCombatOperationTailed)(coords).map((item) => (0, vesium.toCartesian3)(item)));
|
|
2802
1877
|
entity.polygon.hierarchy = new cesium.CallbackProperty(() => hierarchy, false);
|
|
2803
1878
|
return { entities: [entity] };
|
|
2804
1879
|
}
|
|
@@ -2826,83 +1901,15 @@ const PlotSchemePolygonAssemblingPlace = new PlotScheme({
|
|
|
2826
1901
|
entity.polygon.hierarchy = void 0;
|
|
2827
1902
|
return context.previous;
|
|
2828
1903
|
}
|
|
2829
|
-
|
|
2830
|
-
|
|
2831
|
-
|
|
2832
|
-
|
|
2833
|
-
|
|
2834
|
-
|
|
2835
|
-
|
|
2836
|
-
//#endregion
|
|
2837
|
-
//#region scheme/PolygonFlagCurve.ts
|
|
2838
|
-
const PlotSchemePolygonFlagCurve = new PlotScheme({
|
|
2839
|
-
type: "PolygonFlagCurve",
|
|
2840
|
-
complete: (packable) => packable.positions.length >= 2,
|
|
2841
|
-
skeletons: [moved, control],
|
|
2842
|
-
initRender() {
|
|
2843
|
-
return { entities: [new cesium.Entity({ polygon: {} })] };
|
|
2844
|
-
},
|
|
2845
|
-
render(context) {
|
|
2846
|
-
const entity = context.previous.entities[0];
|
|
2847
|
-
const points = context.packable.positions;
|
|
2848
|
-
context.mouse && points.push(context.mouse.clone());
|
|
2849
|
-
const coords = points.map((e) => (0, vesium.toCoord)(e));
|
|
2850
|
-
if (coords.length < 2) {
|
|
2851
|
-
entity.polygon.hierarchy = void 0;
|
|
2852
|
-
return context.previous;
|
|
1904
|
+
if (coords.length === 2) {
|
|
1905
|
+
const c0 = (0, vesium.toCartographic)(coords[0]);
|
|
1906
|
+
const c1 = (0, vesium.toCartographic)(coords[1]);
|
|
1907
|
+
const latitude = c0.latitude;
|
|
1908
|
+
const height = c0.height;
|
|
1909
|
+
const longitude = c1.longitude - (c0.longitude - c1.longitude);
|
|
1910
|
+
coords.push((0, vesium.toCoord)(new cesium.Cartographic(longitude, latitude, height)));
|
|
2853
1911
|
}
|
|
2854
|
-
const
|
|
2855
|
-
const hierarchy = new cesium.PolygonHierarchy(positions);
|
|
2856
|
-
entity.polygon.hierarchy = new cesium.CallbackProperty(() => hierarchy, false);
|
|
2857
|
-
return { entities: [entity] };
|
|
2858
|
-
}
|
|
2859
|
-
});
|
|
2860
|
-
|
|
2861
|
-
//#endregion
|
|
2862
|
-
//#region scheme/PolygonFlagRect.ts
|
|
2863
|
-
const PlotSchemePolygonFlagRect = new PlotScheme({
|
|
2864
|
-
type: "PolygonFlagRect",
|
|
2865
|
-
complete: (packable) => packable.positions.length >= 2,
|
|
2866
|
-
skeletons: [moved, control],
|
|
2867
|
-
initRender() {
|
|
2868
|
-
return { entities: [new cesium.Entity({ polygon: {} })] };
|
|
2869
|
-
},
|
|
2870
|
-
render(context) {
|
|
2871
|
-
const entity = context.previous.entities[0];
|
|
2872
|
-
const points = context.packable.positions;
|
|
2873
|
-
context.mouse && points.push(context.mouse.clone());
|
|
2874
|
-
const coords = points.map((e) => (0, vesium.toCoord)(e));
|
|
2875
|
-
if (coords.length < 2) {
|
|
2876
|
-
entity.polygon.hierarchy = void 0;
|
|
2877
|
-
return context.previous;
|
|
2878
|
-
}
|
|
2879
|
-
const positions = flagRect(coords).map((item) => (0, vesium.toCartesian3)(item));
|
|
2880
|
-
const hierarchy = new cesium.PolygonHierarchy(positions);
|
|
2881
|
-
entity.polygon.hierarchy = new cesium.CallbackProperty(() => hierarchy, false);
|
|
2882
|
-
return { entities: [entity] };
|
|
2883
|
-
}
|
|
2884
|
-
});
|
|
2885
|
-
|
|
2886
|
-
//#endregion
|
|
2887
|
-
//#region scheme/PolygonFlagTriangle.ts
|
|
2888
|
-
const PlotSchemePolygonFlagTriangle = new PlotScheme({
|
|
2889
|
-
type: "PolygonFlagTriangle",
|
|
2890
|
-
complete: (packable) => packable.positions.length >= 2,
|
|
2891
|
-
skeletons: [moved, control],
|
|
2892
|
-
initRender() {
|
|
2893
|
-
return { entities: [new cesium.Entity({ polygon: {} })] };
|
|
2894
|
-
},
|
|
2895
|
-
render(context) {
|
|
2896
|
-
const entity = context.previous.entities[0];
|
|
2897
|
-
const points = context.packable.positions;
|
|
2898
|
-
context.mouse && points.push(context.mouse.clone());
|
|
2899
|
-
const coords = points.map((e) => (0, vesium.toCoord)(e));
|
|
2900
|
-
if (coords.length < 2) {
|
|
2901
|
-
entity.polygon.hierarchy = void 0;
|
|
2902
|
-
return context.previous;
|
|
2903
|
-
}
|
|
2904
|
-
const positions = flagTriangle(coords).map((item) => (0, vesium.toCartesian3)(item));
|
|
2905
|
-
const hierarchy = new cesium.PolygonHierarchy(positions);
|
|
1912
|
+
const hierarchy = new cesium.PolygonHierarchy((0, __vesium_geometry.assemblingPlace)(coords).map((item) => (0, vesium.toCartesian3)(item)));
|
|
2906
1913
|
entity.polygon.hierarchy = new cesium.CallbackProperty(() => hierarchy, false);
|
|
2907
1914
|
return { entities: [entity] };
|
|
2908
1915
|
}
|
|
@@ -2910,6 +1917,9 @@ const PlotSchemePolygonFlagTriangle = new PlotScheme({
|
|
|
2910
1917
|
|
|
2911
1918
|
//#endregion
|
|
2912
1919
|
//#region scheme/PolygonSmooth.ts
|
|
1920
|
+
/**
|
|
1921
|
+
* polygon-smooth 标绘配置 平滑闭合面
|
|
1922
|
+
*/
|
|
2913
1923
|
const PlotSchemePolygonSmooth = new PlotScheme({
|
|
2914
1924
|
type: "PolygonSmooth",
|
|
2915
1925
|
allowManualComplete: (packable) => packable.positions.length >= 3,
|
|
@@ -2933,8 +1943,7 @@ const PlotSchemePolygonSmooth = new PlotScheme({
|
|
|
2933
1943
|
const wgs84s = positions.map((e) => (0, vesium.toCoord)(e));
|
|
2934
1944
|
wgs84s.push(wgs84s[0]);
|
|
2935
1945
|
const { features } = __turf_turf.polygonSmooth(__turf_turf.polygon([wgs84s]), { iterations: 3 });
|
|
2936
|
-
const
|
|
2937
|
-
const hierarchy = new cesium.PolygonHierarchy(cartesians);
|
|
1946
|
+
const hierarchy = new cesium.PolygonHierarchy(features[0].geometry.coordinates[0].map((item) => (0, vesium.toCartesian3)(item)).filter((e) => !!e));
|
|
2938
1947
|
entity.polygon.hierarchy = new cesium.CallbackProperty(() => hierarchy, false);
|
|
2939
1948
|
return { entities: [entity] };
|
|
2940
1949
|
}
|
|
@@ -2942,6 +1951,9 @@ const PlotSchemePolygonSmooth = new PlotScheme({
|
|
|
2942
1951
|
|
|
2943
1952
|
//#endregion
|
|
2944
1953
|
//#region scheme/Polyline.ts
|
|
1954
|
+
/**
|
|
1955
|
+
* polyline
|
|
1956
|
+
*/
|
|
2945
1957
|
const PlotSchemePolyline = new PlotScheme({
|
|
2946
1958
|
type: "Polyline",
|
|
2947
1959
|
allowManualComplete: (packable) => packable.positions.length > 1,
|
|
@@ -2969,6 +1981,9 @@ const PlotSchemePolyline = new PlotScheme({
|
|
|
2969
1981
|
|
|
2970
1982
|
//#endregion
|
|
2971
1983
|
//#region scheme/PolylineCurve.ts
|
|
1984
|
+
/**
|
|
1985
|
+
* polyline-Curve
|
|
1986
|
+
*/
|
|
2972
1987
|
const PlotSchemePolylineCurve = new PlotScheme({
|
|
2973
1988
|
type: "PolylineCurve",
|
|
2974
1989
|
allowManualComplete: (packable) => packable.positions.length > 1,
|
|
@@ -3001,6 +2016,9 @@ const PlotSchemePolylineCurve = new PlotScheme({
|
|
|
3001
2016
|
|
|
3002
2017
|
//#endregion
|
|
3003
2018
|
//#region scheme/Rectangle.ts
|
|
2019
|
+
/**
|
|
2020
|
+
* rectangle
|
|
2021
|
+
*/
|
|
3004
2022
|
const PlotSchemeRectangle = new PlotScheme({
|
|
3005
2023
|
type: "Rectangle",
|
|
3006
2024
|
complete: (packable) => packable.positions.length >= 2,
|
|
@@ -3043,9 +2061,6 @@ exports.PlotSchemePolygonArrowStraightSharp = PlotSchemePolygonArrowStraightShar
|
|
|
3043
2061
|
exports.PlotSchemePolygonArrowUnitCombatOperation = PlotSchemePolygonArrowUnitCombatOperation;
|
|
3044
2062
|
exports.PlotSchemePolygonArrowUnitCombatOperationTailed = PlotSchemePolygonArrowUnitCombatOperationTailed;
|
|
3045
2063
|
exports.PlotSchemePolygonAssemblingPlace = PlotSchemePolygonAssemblingPlace;
|
|
3046
|
-
exports.PlotSchemePolygonFlagCurve = PlotSchemePolygonFlagCurve;
|
|
3047
|
-
exports.PlotSchemePolygonFlagRect = PlotSchemePolygonFlagRect;
|
|
3048
|
-
exports.PlotSchemePolygonFlagTriangle = PlotSchemePolygonFlagTriangle;
|
|
3049
2064
|
exports.PlotSchemePolygonSmooth = PlotSchemePolygonSmooth;
|
|
3050
2065
|
exports.PlotSchemePolyline = PlotSchemePolyline;
|
|
3051
2066
|
exports.PlotSchemePolylineCurve = PlotSchemePolylineCurve;
|