|
@@ -98,7 +98,6 @@ export default {
|
|
|
|
|
|
var positions = [];
|
|
|
for (var i = 0, len = array.length; i < len; i++) {
|
|
|
- debugger
|
|
|
var cartographic = Cesium.Cartographic.fromCartesian(array[i]);
|
|
|
var longitude = Cesium.Math.toDegrees(cartographic.longitude);
|
|
|
var latitude = Cesium.Math.toDegrees(cartographic.latitude);
|
|
@@ -109,11 +108,22 @@ export default {
|
|
|
positions.push(h);
|
|
|
}
|
|
|
}
|
|
|
+ let threeArray = null;
|
|
|
+ if (positions.length % 2 == 0) {
|
|
|
+ console.log(positions, positions.length % 3);
|
|
|
+ threeArray = positions;
|
|
|
+
|
|
|
+
|
|
|
+ } else {
|
|
|
+
|
|
|
+ threeArray = that.appendLastThree(positions);
|
|
|
+
|
|
|
+ }
|
|
|
|
|
|
viewer.scene.globe.removeAllExcavationRegion();
|
|
|
viewer.scene.globe.addExcavationRegion({
|
|
|
name: 'ggg',
|
|
|
- position: positions,
|
|
|
+ position: threeArray,
|
|
|
height: Number(that.height),
|
|
|
transparent: false
|
|
|
});
|
|
@@ -143,6 +153,19 @@ export default {
|
|
|
that.result = null;
|
|
|
}
|
|
|
|
|
|
+ },
|
|
|
+ appendLastThree(arr) {
|
|
|
+ // 创建一个新数组来存储结果
|
|
|
+ let result = [...arr]; // 使用扩展运算符复制原始数组
|
|
|
+
|
|
|
+ // 检查数组长度是否至少有三个元素
|
|
|
+ // if (arr.length >= 3) {
|
|
|
+ // 获取后三个元素并添加到结果数组末尾
|
|
|
+ result.push(...arr.slice(-3));
|
|
|
+ // }
|
|
|
+
|
|
|
+ // 返回结果数组
|
|
|
+ return result;
|
|
|
}
|
|
|
},
|
|
|
beforeCreate() { }, //生命周期 - 创建之前
|