deeptwins-engine-3d 0.1.63 → 0.1.65
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/assets/Build/DeepTwins/Workers/MvtVector.worker.js +1 -0
- package/dist/esm/{plot/utils/Algorithm.js → drawer/algorithm.js} +1 -3
- package/dist/esm/drawer/common.d.ts +61 -0
- package/dist/esm/{plot/utils/PlotCommon.js → drawer/common.js} +104 -551
- package/dist/esm/{plot/utils/Coordinate.d.ts → drawer/coordinate.d.ts} +1 -1
- package/dist/esm/drawer/index.d.ts +11 -18
- package/dist/esm/drawer/index.js +329 -80
- package/dist/esm/{plot/utils → drawer}/plotUtil.js +1 -3
- package/dist/esm/drawer/shape/Assemble.d.ts +34 -0
- package/dist/esm/drawer/shape/Assemble.js +415 -0
- package/dist/esm/drawer/shape/AttackArrow.d.ts +32 -0
- package/dist/esm/drawer/shape/AttackArrow.js +442 -0
- package/dist/esm/drawer/shape/BaseShape.d.ts +14 -4
- package/dist/esm/drawer/shape/BaseShape.js +175 -20
- package/dist/esm/drawer/shape/Bow.d.ts +31 -0
- package/dist/esm/drawer/shape/Bow.js +375 -0
- package/dist/esm/drawer/shape/Circle.d.ts +37 -0
- package/dist/esm/drawer/shape/Circle.js +461 -0
- package/dist/esm/drawer/shape/Curve.d.ts +29 -0
- package/dist/esm/drawer/shape/Curve.js +386 -0
- package/dist/esm/drawer/shape/DragPoint.d.ts +32 -0
- package/dist/esm/drawer/shape/DragPoint.js +211 -0
- package/dist/esm/drawer/shape/Elliptic.d.ts +38 -0
- package/dist/esm/drawer/shape/Elliptic.js +491 -0
- package/dist/esm/drawer/shape/Formation.d.ts +33 -0
- package/dist/esm/drawer/shape/Formation.js +395 -0
- package/dist/esm/drawer/shape/PincerArrow.d.ts +32 -0
- package/dist/esm/drawer/shape/PincerArrow.js +445 -0
- package/dist/esm/drawer/shape/Point.d.ts +2 -31
- package/dist/esm/drawer/shape/Point.js +7 -201
- package/dist/esm/drawer/shape/Polygon.d.ts +1 -1
- package/dist/esm/drawer/shape/Polygon.js +10 -81
- package/dist/esm/drawer/shape/Polyline.d.ts +1 -1
- package/dist/esm/drawer/shape/Polyline.js +10 -81
- package/dist/esm/drawer/shape/RegularPolygon.d.ts +37 -0
- package/dist/esm/drawer/shape/RegularPolygon.js +468 -0
- package/dist/esm/drawer/shape/RightAngleArrow.d.ts +34 -0
- package/dist/esm/drawer/shape/RightAngleArrow.js +423 -0
- package/dist/esm/drawer/shape/Sector.d.ts +37 -0
- package/dist/esm/drawer/shape/Sector.js +568 -0
- package/dist/esm/drawer/shape/StraightArrow.d.ts +34 -0
- package/dist/esm/drawer/shape/StraightArrow.js +422 -0
- package/dist/esm/drawer/shape/SwallowtailArrow.d.ts +36 -0
- package/dist/esm/drawer/shape/SwallowtailArrow.js +438 -0
- package/dist/esm/drawer/types.d.ts +23 -0
- package/dist/esm/drawer/types.js +11 -0
- package/dist/esm/drawer/utils.d.ts +14 -0
- package/dist/esm/drawer/utils.js +320 -2
- package/dist/esm/graphicLayer/BaseSource.d.ts +1 -1
- package/dist/esm/index.d.ts +1 -0
- package/dist/esm/index.js +5 -3
- package/dist/esm/measure/Area.d.ts +17 -17
- package/dist/esm/measure/Area.js +95 -63
- package/dist/esm/measure/BaseDraw.d.ts +9 -4
- package/dist/esm/measure/BaseDraw.js +37 -2
- package/dist/esm/measure/Distance.d.ts +9 -9
- package/dist/esm/measure/Distance.js +52 -68
- package/dist/esm/measure/index.d.ts +16 -26
- package/dist/esm/measure/index.js +72 -84
- package/dist/esm/measure/types.d.ts +94 -0
- package/dist/esm/measure/types.js +17 -0
- package/dist/esm/measure/utils.d.ts +7 -7
- package/dist/esm/measure/utils.js +43 -24
- package/dist/esm/tileLayer/MvtVectorLoad.d.ts +241 -0
- package/dist/esm/tileLayer/MvtVectorLoad.js +1353 -0
- package/dist/esm/tileLayer/MvtVectorWorkerClient.d.ts +25 -0
- package/dist/esm/tileLayer/MvtVectorWorkerClient.js +126 -0
- package/dist/esm/tool/utils.js +1 -1
- package/dist/umd/deeptwins-engine-3d.min.js +1 -1
- package/package.json +2 -1
- package/dist/assets/Build/DeepTwins/Image/compass/pointer-white.png +0 -0
- package/dist/esm/plot/create/CreateAssemble.d.ts +0 -2
- package/dist/esm/plot/create/CreateAssemble.js +0 -63
- package/dist/esm/plot/create/CreateAttackArrow.d.ts +0 -5
- package/dist/esm/plot/create/CreateAttackArrow.js +0 -75
- package/dist/esm/plot/create/CreateBillboard.d.ts +0 -2
- package/dist/esm/plot/create/CreateBillboard.js +0 -47
- package/dist/esm/plot/create/CreateBow.d.ts +0 -2
- package/dist/esm/plot/create/CreateBow.js +0 -63
- package/dist/esm/plot/create/CreateCircle.d.ts +0 -2
- package/dist/esm/plot/create/CreateCircle.js +0 -68
- package/dist/esm/plot/create/CreateCurve.d.ts +0 -2
- package/dist/esm/plot/create/CreateCurve.js +0 -76
- package/dist/esm/plot/create/CreateElliptic.d.ts +0 -2
- package/dist/esm/plot/create/CreateElliptic.js +0 -69
- package/dist/esm/plot/create/CreateFlag.d.ts +0 -2
- package/dist/esm/plot/create/CreateFlag.js +0 -80
- package/dist/esm/plot/create/CreateFormation.d.ts +0 -2
- package/dist/esm/plot/create/CreateFormation.js +0 -65
- package/dist/esm/plot/create/CreateFreeLine.d.ts +0 -2
- package/dist/esm/plot/create/CreateFreeLine.js +0 -69
- package/dist/esm/plot/create/CreateFreePolygon.d.ts +0 -2
- package/dist/esm/plot/create/CreateFreePolygon.js +0 -65
- package/dist/esm/plot/create/CreateLabel.d.ts +0 -2
- package/dist/esm/plot/create/CreateLabel.js +0 -55
- package/dist/esm/plot/create/CreateLineArrow.d.ts +0 -2
- package/dist/esm/plot/create/CreateLineArrow.js +0 -79
- package/dist/esm/plot/create/CreatePincerArrow.d.ts +0 -5
- package/dist/esm/plot/create/CreatePincerArrow.js +0 -73
- package/dist/esm/plot/create/CreatePoint.d.ts +0 -2
- package/dist/esm/plot/create/CreatePoint.js +0 -47
- package/dist/esm/plot/create/CreatePolygon.d.ts +0 -2
- package/dist/esm/plot/create/CreatePolygon.js +0 -80
- package/dist/esm/plot/create/CreatePolyline.d.ts +0 -2
- package/dist/esm/plot/create/CreatePolyline.js +0 -70
- package/dist/esm/plot/create/CreateRectangle.d.ts +0 -2
- package/dist/esm/plot/create/CreateRectangle.js +0 -60
- package/dist/esm/plot/create/CreateRegularPolygon.d.ts +0 -2
- package/dist/esm/plot/create/CreateRegularPolygon.js +0 -75
- package/dist/esm/plot/create/CreateRightAngleArrow.d.ts +0 -5
- package/dist/esm/plot/create/CreateRightAngleArrow.js +0 -73
- package/dist/esm/plot/create/CreateRoundRectangle.d.ts +0 -2
- package/dist/esm/plot/create/CreateRoundRectangle.js +0 -63
- package/dist/esm/plot/create/CreateSector.d.ts +0 -2
- package/dist/esm/plot/create/CreateSector.js +0 -65
- package/dist/esm/plot/create/CreateStraightArrow.d.ts +0 -5
- package/dist/esm/plot/create/CreateStraightArrow.js +0 -65
- package/dist/esm/plot/create/CreateSwallowtailArrow.d.ts +0 -5
- package/dist/esm/plot/create/CreateSwallowtailArrow.js +0 -67
- package/dist/esm/plot/create/index.d.ts +0 -25
- package/dist/esm/plot/create/index.js +0 -25
- package/dist/esm/plot/edit/EditAssemble.d.ts +0 -8
- package/dist/esm/plot/edit/EditAssemble.js +0 -120
- package/dist/esm/plot/edit/EditAttackArrow.d.ts +0 -8
- package/dist/esm/plot/edit/EditAttackArrow.js +0 -182
- package/dist/esm/plot/edit/EditBillboard.d.ts +0 -7
- package/dist/esm/plot/edit/EditBillboard.js +0 -70
- package/dist/esm/plot/edit/EditBow.d.ts +0 -8
- package/dist/esm/plot/edit/EditBow.js +0 -119
- package/dist/esm/plot/edit/EditCircle.d.ts +0 -8
- package/dist/esm/plot/edit/EditCircle.js +0 -133
- package/dist/esm/plot/edit/EditCurve.d.ts +0 -8
- package/dist/esm/plot/edit/EditCurve.js +0 -180
- package/dist/esm/plot/edit/EditElliptic.d.ts +0 -8
- package/dist/esm/plot/edit/EditElliptic.js +0 -144
- package/dist/esm/plot/edit/EditFlag.d.ts +0 -8
- package/dist/esm/plot/edit/EditFlag.js +0 -121
- package/dist/esm/plot/edit/EditFormation.d.ts +0 -8
- package/dist/esm/plot/edit/EditFormation.js +0 -120
- package/dist/esm/plot/edit/EditLabel.d.ts +0 -7
- package/dist/esm/plot/edit/EditLabel.js +0 -100
- package/dist/esm/plot/edit/EditLineArrow.d.ts +0 -8
- package/dist/esm/plot/edit/EditLineArrow.js +0 -180
- package/dist/esm/plot/edit/EditPincerArrow.d.ts +0 -8
- package/dist/esm/plot/edit/EditPincerArrow.js +0 -121
- package/dist/esm/plot/edit/EditPoint.d.ts +0 -7
- package/dist/esm/plot/edit/EditPoint.js +0 -70
- package/dist/esm/plot/edit/EditPolygon.d.ts +0 -8
- package/dist/esm/plot/edit/EditPolygon.js +0 -181
- package/dist/esm/plot/edit/EditPolyline.d.ts +0 -8
- package/dist/esm/plot/edit/EditPolyline.js +0 -179
- package/dist/esm/plot/edit/EditRectangle.d.ts +0 -8
- package/dist/esm/plot/edit/EditRectangle.js +0 -119
- package/dist/esm/plot/edit/EditRegularPolygon.d.ts +0 -8
- package/dist/esm/plot/edit/EditRegularPolygon.js +0 -170
- package/dist/esm/plot/edit/EditRightAngleArrow.d.ts +0 -8
- package/dist/esm/plot/edit/EditRightAngleArrow.js +0 -143
- package/dist/esm/plot/edit/EditRoundRectangle.d.ts +0 -8
- package/dist/esm/plot/edit/EditRoundRectangle.js +0 -119
- package/dist/esm/plot/edit/EditSector.d.ts +0 -8
- package/dist/esm/plot/edit/EditSector.js +0 -120
- package/dist/esm/plot/edit/EditStraightArrow.d.ts +0 -8
- package/dist/esm/plot/edit/EditStraightArrow.js +0 -120
- package/dist/esm/plot/edit/EditSwallowtailArrow.d.ts +0 -8
- package/dist/esm/plot/edit/EditSwallowtailArrow.js +0 -121
- package/dist/esm/plot/edit/index.d.ts +0 -23
- package/dist/esm/plot/edit/index.js +0 -23
- package/dist/esm/plot/utils/DomUtil.d.ts +0 -34
- package/dist/esm/plot/utils/DomUtil.js +0 -100
- package/dist/esm/plot/utils/PlotCommon.d.ts +0 -101
- package/dist/esm/plot/utils/ReminderTip.d.ts +0 -10
- package/dist/esm/plot/utils/ReminderTip.js +0 -67
- package/dist/esm/plot/utils/Tooltip.d.ts +0 -3
- package/dist/esm/plot/utils/Tooltip.js +0 -97
- /package/dist/esm/{plot/utils/Algorithm.d.ts → drawer/algorithm.d.ts} +0 -0
- /package/dist/esm/{plot/utils/Coordinate.js → drawer/coordinate.js} +0 -0
- /package/dist/esm/{plot/utils → drawer}/plotUtil.d.ts +0 -0
|
@@ -0,0 +1,468 @@
|
|
|
1
|
+
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
|
2
|
+
function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
|
|
3
|
+
function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
4
|
+
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
5
|
+
function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
|
|
6
|
+
function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
|
|
7
|
+
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
|
|
8
|
+
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
9
|
+
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } }
|
|
10
|
+
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
|
|
11
|
+
function _get() { if (typeof Reflect !== "undefined" && Reflect.get) { _get = Reflect.get.bind(); } else { _get = function _get(target, property, receiver) { var base = _superPropBase(target, property); if (!base) return; var desc = Object.getOwnPropertyDescriptor(base, property); if (desc.get) { return desc.get.call(arguments.length < 3 ? target : receiver); } return desc.value; }; } return _get.apply(this, arguments); }
|
|
12
|
+
function _superPropBase(object, property) { while (!Object.prototype.hasOwnProperty.call(object, property)) { object = _getPrototypeOf(object); if (object === null) break; } return object; }
|
|
13
|
+
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); Object.defineProperty(subClass, "prototype", { writable: false }); if (superClass) _setPrototypeOf(subClass, superClass); }
|
|
14
|
+
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
|
|
15
|
+
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
|
|
16
|
+
function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } else if (call !== void 0) { throw new TypeError("Derived constructors may only return object or undefined"); } return _assertThisInitialized(self); }
|
|
17
|
+
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
|
|
18
|
+
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
|
|
19
|
+
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
|
|
20
|
+
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
21
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
|
|
22
|
+
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
23
|
+
import * as Cesium from 'deeptwins-cesium';
|
|
24
|
+
import { isNil } from 'lodash';
|
|
25
|
+
import * as utils from "../../tool/utils";
|
|
26
|
+
import { STATUS } from "../types";
|
|
27
|
+
import { getPolygonRestoreHandlePosition, normalizePolygonPositions } from "../utils";
|
|
28
|
+
import BaseShape from "./BaseShape";
|
|
29
|
+
import DragPoint from "./DragPoint";
|
|
30
|
+
import { ShapePolygon } from "./Polygon";
|
|
31
|
+
import { ShapePolyline } from "./Polyline";
|
|
32
|
+
|
|
33
|
+
// 正多边形默认最少 3 条边。
|
|
34
|
+
var DEFAULT_REGULAR_POLYGON_SIDES = 3;
|
|
35
|
+
// 半径过小时不创建几何,避免生成退化图形。
|
|
36
|
+
var REGULAR_POLYGON_MIN_RADIUS = 0.01;
|
|
37
|
+
var RegularPolygon = /*#__PURE__*/function (_BaseShape) {
|
|
38
|
+
_inherits(RegularPolygon, _BaseShape);
|
|
39
|
+
var _super = _createSuper(RegularPolygon);
|
|
40
|
+
function RegularPolygon(drawContext, config) {
|
|
41
|
+
var _this;
|
|
42
|
+
_classCallCheck(this, RegularPolygon);
|
|
43
|
+
_this = _super.call(this, drawContext);
|
|
44
|
+
_defineProperty(_assertThisInitialized(_this), "type", 'regularPolygon');
|
|
45
|
+
// 正多边形外框图层。
|
|
46
|
+
_defineProperty(_assertThisInitialized(_this), "shapePolylineLayer", void 0);
|
|
47
|
+
// 正多边形面图层。
|
|
48
|
+
_defineProperty(_assertThisInitialized(_this), "shapePolygonLayer", void 0);
|
|
49
|
+
// 正多边形边数。
|
|
50
|
+
_defineProperty(_assertThisInitialized(_this), "_sides", void 0);
|
|
51
|
+
// 绘制和编辑时统一维护中心点。
|
|
52
|
+
_defineProperty(_assertThisInitialized(_this), "_centerPosition", void 0);
|
|
53
|
+
// 半径控制点,同时决定半径和初始朝向。
|
|
54
|
+
_defineProperty(_assertThisInitialized(_this), "_handlePosition", void 0);
|
|
55
|
+
_this._sides = _this._normalizeSides(config === null || config === void 0 ? void 0 : config.sides);
|
|
56
|
+
_this._centerPosition = null;
|
|
57
|
+
_this._handlePosition = null;
|
|
58
|
+
_this.clampToGround = isNil(config === null || config === void 0 ? void 0 : config.clampToGround) ? _this.clampToGround : config.clampToGround;
|
|
59
|
+
_this.pointStyle.heightReference = _this.clampToGround ? Cesium.HeightReference.CLAMP_TO_GROUND : Cesium.HeightReference.NONE;
|
|
60
|
+
_this.polylineStyle.clampToGround = _this.clampToGround;
|
|
61
|
+
if (_this.clampToGround) {
|
|
62
|
+
_this.polygonStyle.heightReference = Cesium.HeightReference.CLAMP_TO_GROUND;
|
|
63
|
+
_this.polygonStyle.perPositionHeight = false;
|
|
64
|
+
} else {
|
|
65
|
+
_this.polygonStyle.heightReference = Cesium.HeightReference.NONE;
|
|
66
|
+
_this.polygonStyle.perPositionHeight = true;
|
|
67
|
+
}
|
|
68
|
+
return _this;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
// 统一收敛边数,避免外部传入无效值。
|
|
72
|
+
_createClass(RegularPolygon, [{
|
|
73
|
+
key: "_normalizeSides",
|
|
74
|
+
value: function _normalizeSides(sides) {
|
|
75
|
+
var numericSides = Number(sides);
|
|
76
|
+
if (!Number.isFinite(numericSides)) {
|
|
77
|
+
return DEFAULT_REGULAR_POLYGON_SIDES;
|
|
78
|
+
}
|
|
79
|
+
return Math.max(DEFAULT_REGULAR_POLYGON_SIDES, Math.floor(numericSides));
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
// 鼠标事件位置统一转成内部经纬高三元组。
|
|
83
|
+
}, {
|
|
84
|
+
key: "_toPositionTuple",
|
|
85
|
+
value: function _toPositionTuple(position) {
|
|
86
|
+
var lng = position.lng,
|
|
87
|
+
lat = position.lat,
|
|
88
|
+
_position$alt = position.alt,
|
|
89
|
+
alt = _position$alt === void 0 ? 0 : _position$alt;
|
|
90
|
+
return [lng, lat, alt];
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
// 线框渲染始终闭合,方便在绘制阶段实时预览边界。
|
|
94
|
+
}, {
|
|
95
|
+
key: "_getDrawPolylinePositions",
|
|
96
|
+
value: function _getDrawPolylinePositions() {
|
|
97
|
+
if (!this.positions.length) {
|
|
98
|
+
return [];
|
|
99
|
+
}
|
|
100
|
+
return [].concat(_toConsumableArray(this.positions), [this.positions[0]]);
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
// 面渲染和普通 polygon 一致,末尾补首点闭环。
|
|
104
|
+
}, {
|
|
105
|
+
key: "_getDrawPolygonPositions",
|
|
106
|
+
value: function _getDrawPolygonPositions() {
|
|
107
|
+
if (!this.positions.length) {
|
|
108
|
+
return [];
|
|
109
|
+
}
|
|
110
|
+
return [].concat(_toConsumableArray(this.positions), [this.positions[0]]);
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
// 统一释放线框和面图层,避免绘制中断后残留几何。
|
|
114
|
+
}, {
|
|
115
|
+
key: "_destroyShapeLayers",
|
|
116
|
+
value: function _destroyShapeLayers() {
|
|
117
|
+
this.shapePolylineLayer && this.shapePolylineLayer.destroy();
|
|
118
|
+
this.shapePolylineLayer = null;
|
|
119
|
+
this.shapePolygonLayer && this.shapePolygonLayer.destroy();
|
|
120
|
+
this.shapePolygonLayer = null;
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
// 根据当前顶点数组同步线框和面图层。
|
|
124
|
+
}, {
|
|
125
|
+
key: "_syncShapeLayers",
|
|
126
|
+
value: function _syncShapeLayers() {
|
|
127
|
+
if (!this.positions.length) {
|
|
128
|
+
this._destroyShapeLayers();
|
|
129
|
+
return;
|
|
130
|
+
}
|
|
131
|
+
var polylinePositions = this._getDrawPolylinePositions();
|
|
132
|
+
var polygonPositions = this._getDrawPolygonPositions();
|
|
133
|
+
if (!this.shapePolylineLayer) {
|
|
134
|
+
this.shapePolylineLayer = new ShapePolyline(this.getMap(), {
|
|
135
|
+
positions: polylinePositions,
|
|
136
|
+
style: this.polylineStyle
|
|
137
|
+
});
|
|
138
|
+
} else {
|
|
139
|
+
this.shapePolylineLayer.update(polylinePositions);
|
|
140
|
+
}
|
|
141
|
+
if (!this.shapePolygonLayer) {
|
|
142
|
+
this.shapePolygonLayer = new ShapePolygon(this.getMap(), {
|
|
143
|
+
positions: polygonPositions,
|
|
144
|
+
style: this.polygonStyle
|
|
145
|
+
});
|
|
146
|
+
return;
|
|
147
|
+
}
|
|
148
|
+
this.shapePolygonLayer.update(polygonPositions);
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
// 通过中心点和控制点,按等角度生成整圈正多边形顶点。
|
|
152
|
+
}, {
|
|
153
|
+
key: "_buildRegularPolygonPositions",
|
|
154
|
+
value: function _buildRegularPolygonPositions(centerPosition, handlePosition) {
|
|
155
|
+
var centerCartesian = this._toCartesian3(centerPosition);
|
|
156
|
+
var handleCartesian = this._toCartesian3(handlePosition);
|
|
157
|
+
if (!centerCartesian || !handleCartesian) {
|
|
158
|
+
return [];
|
|
159
|
+
}
|
|
160
|
+
var transform = Cesium.Transforms.eastNorthUpToFixedFrame(centerCartesian);
|
|
161
|
+
var inverseTransform = Cesium.Matrix4.inverseTransformation(transform, new Cesium.Matrix4());
|
|
162
|
+
var localHandle = Cesium.Matrix4.multiplyByPoint(inverseTransform, handleCartesian, new Cesium.Cartesian3());
|
|
163
|
+
var radius = Math.hypot(localHandle.x, localHandle.y);
|
|
164
|
+
if (!Number.isFinite(radius) || radius <= REGULAR_POLYGON_MIN_RADIUS) {
|
|
165
|
+
return [];
|
|
166
|
+
}
|
|
167
|
+
var startAngle = Math.atan2(localHandle.y, localHandle.x);
|
|
168
|
+
var localZ = this.clampToGround ? 0 : localHandle.z;
|
|
169
|
+
var positions = [];
|
|
170
|
+
var angleStep = Cesium.Math.TWO_PI / this._sides;
|
|
171
|
+
for (var index = 0; index < this._sides; index += 1) {
|
|
172
|
+
var angle = startAngle + angleStep * index;
|
|
173
|
+
var localPoint = new Cesium.Cartesian3(radius * Math.cos(angle), radius * Math.sin(angle), localZ);
|
|
174
|
+
var worldPoint = Cesium.Matrix4.multiplyByPoint(transform, localPoint, new Cesium.Cartesian3());
|
|
175
|
+
var _utils$cartesian3ToLn = utils.cartesian3ToLngLatAlt(worldPoint),
|
|
176
|
+
lng = _utils$cartesian3ToLn.lng,
|
|
177
|
+
lat = _utils$cartesian3ToLn.lat,
|
|
178
|
+
alt = _utils$cartesian3ToLn.alt;
|
|
179
|
+
positions.push([lng, lat, alt]);
|
|
180
|
+
}
|
|
181
|
+
return positions;
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
// 计算控制点相对于中心点的局部 ENU 向量,用于平移时保持半径和朝向。
|
|
185
|
+
}, {
|
|
186
|
+
key: "_getLocalHandleVector",
|
|
187
|
+
value: function _getLocalHandleVector(centerPosition, handlePosition) {
|
|
188
|
+
var centerCartesian = this._toCartesian3(centerPosition);
|
|
189
|
+
var handleCartesian = this._toCartesian3(handlePosition);
|
|
190
|
+
if (!centerCartesian || !handleCartesian) {
|
|
191
|
+
return null;
|
|
192
|
+
}
|
|
193
|
+
var transform = Cesium.Transforms.eastNorthUpToFixedFrame(centerCartesian);
|
|
194
|
+
var inverseTransform = Cesium.Matrix4.inverseTransformation(transform, new Cesium.Matrix4());
|
|
195
|
+
return Cesium.Matrix4.multiplyByPoint(inverseTransform, handleCartesian, new Cesium.Cartesian3());
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
// 把局部 ENU 向量重新投回新的中心点,得到新的控制点位置。
|
|
199
|
+
}, {
|
|
200
|
+
key: "_getPositionByLocalVector",
|
|
201
|
+
value: function _getPositionByLocalVector(centerPosition, localVector) {
|
|
202
|
+
var centerCartesian = this._toCartesian3(centerPosition);
|
|
203
|
+
if (!centerCartesian) {
|
|
204
|
+
return null;
|
|
205
|
+
}
|
|
206
|
+
var transform = Cesium.Transforms.eastNorthUpToFixedFrame(centerCartesian);
|
|
207
|
+
var worldPoint = Cesium.Matrix4.multiplyByPoint(transform, localVector, new Cesium.Cartesian3());
|
|
208
|
+
var _utils$cartesian3ToLn2 = utils.cartesian3ToLngLatAlt(worldPoint),
|
|
209
|
+
lng = _utils$cartesian3ToLn2.lng,
|
|
210
|
+
lat = _utils$cartesian3ToLn2.lat,
|
|
211
|
+
alt = _utils$cartesian3ToLn2.alt;
|
|
212
|
+
return [lng, lat, alt];
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
// 统一更新中心点、控制点、顶点数组和渲染图层。
|
|
216
|
+
}, {
|
|
217
|
+
key: "_applyGeometry",
|
|
218
|
+
value: function _applyGeometry(centerPosition, handlePosition) {
|
|
219
|
+
var positions = this._buildRegularPolygonPositions(centerPosition, handlePosition);
|
|
220
|
+
if (positions.length !== this._sides) {
|
|
221
|
+
return false;
|
|
222
|
+
}
|
|
223
|
+
this._centerPosition = centerPosition ? _toConsumableArray(centerPosition) : null;
|
|
224
|
+
this._handlePosition = _toConsumableArray(positions[0]);
|
|
225
|
+
this.positions = positions;
|
|
226
|
+
this._syncShapeLayers();
|
|
227
|
+
return true;
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
// 编辑结束或销毁时统一释放两个控制点。
|
|
231
|
+
}, {
|
|
232
|
+
key: "_destroyEditHandles",
|
|
233
|
+
value: function _destroyEditHandles() {
|
|
234
|
+
this.dragPoints.forEach(function (point) {
|
|
235
|
+
return point.destroy();
|
|
236
|
+
});
|
|
237
|
+
this.dragPoints = [];
|
|
238
|
+
this.dragLayer = null;
|
|
239
|
+
this.dragging = false;
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
// 创建编辑控制点:中心点负责平移,顶点负责半径和旋转。
|
|
243
|
+
}, {
|
|
244
|
+
key: "_createEditHandle",
|
|
245
|
+
value: function _createEditHandle(position, role) {
|
|
246
|
+
var handle = new DragPoint(this.getMap(), {
|
|
247
|
+
positions: position,
|
|
248
|
+
style: this.pointStyle
|
|
249
|
+
});
|
|
250
|
+
handle.handleRole = role;
|
|
251
|
+
handle.startEdit();
|
|
252
|
+
return handle;
|
|
253
|
+
}
|
|
254
|
+
|
|
255
|
+
// 几何更新后把两个控制点同步到最新位置。
|
|
256
|
+
}, {
|
|
257
|
+
key: "_syncEditHandles",
|
|
258
|
+
value: function _syncEditHandles() {
|
|
259
|
+
var centerHandle = this.dragPoints.find(function (point) {
|
|
260
|
+
return point.handleRole === 'center';
|
|
261
|
+
});
|
|
262
|
+
var radiusHandle = this.dragPoints.find(function (point) {
|
|
263
|
+
return point.handleRole === 'radius';
|
|
264
|
+
});
|
|
265
|
+
if (centerHandle && this._centerPosition) {
|
|
266
|
+
centerHandle.mouseDragChange({
|
|
267
|
+
lng: this._centerPosition[0],
|
|
268
|
+
lat: this._centerPosition[1],
|
|
269
|
+
alt: this._centerPosition[2]
|
|
270
|
+
});
|
|
271
|
+
}
|
|
272
|
+
if (radiusHandle && this._handlePosition) {
|
|
273
|
+
radiusHandle.mouseDragChange({
|
|
274
|
+
lng: this._handlePosition[0],
|
|
275
|
+
lat: this._handlePosition[1],
|
|
276
|
+
alt: this._handlePosition[2]
|
|
277
|
+
});
|
|
278
|
+
}
|
|
279
|
+
}
|
|
280
|
+
|
|
281
|
+
// 绘制预览阶段透出当前顶点数组。
|
|
282
|
+
}, {
|
|
283
|
+
key: "_emitMouseMoveChange",
|
|
284
|
+
value: function _emitMouseMoveChange() {
|
|
285
|
+
this._drawContext.options.onMouseMoveChange && this._drawContext.options.onMouseMoveChange({
|
|
286
|
+
layer: this,
|
|
287
|
+
positions: this.positions
|
|
288
|
+
});
|
|
289
|
+
}
|
|
290
|
+
|
|
291
|
+
// 编辑态拖拽时透出最新顶点数组。
|
|
292
|
+
}, {
|
|
293
|
+
key: "_emitPointsChange",
|
|
294
|
+
value: function _emitPointsChange() {
|
|
295
|
+
var _this$_drawContext$op, _this$_drawContext$op2;
|
|
296
|
+
((_this$_drawContext$op = this._drawContext.options) === null || _this$_drawContext$op === void 0 ? void 0 : _this$_drawContext$op.onPointsChange) && ((_this$_drawContext$op2 = this._drawContext.options) === null || _this$_drawContext$op2 === void 0 ? void 0 : _this$_drawContext$op2.onPointsChange({
|
|
297
|
+
layer: this,
|
|
298
|
+
positions: this.positions
|
|
299
|
+
}));
|
|
300
|
+
}
|
|
301
|
+
|
|
302
|
+
// 统一完成绘制:入库、回调并进入编辑态。
|
|
303
|
+
}, {
|
|
304
|
+
key: "_finishDraw",
|
|
305
|
+
value: function _finishDraw() {
|
|
306
|
+
if (!this.positions.length) {
|
|
307
|
+
return;
|
|
308
|
+
}
|
|
309
|
+
this._drawContext.setDrawerLayer(this.id, this);
|
|
310
|
+
this.drawEnd(this);
|
|
311
|
+
this.startEdit();
|
|
312
|
+
}
|
|
313
|
+
|
|
314
|
+
// 根据传入 polygon 顶点恢复 regularPolygon shape,并回到正多边形编辑模型。
|
|
315
|
+
}, {
|
|
316
|
+
key: "transformData",
|
|
317
|
+
value: function transformData(positions) {
|
|
318
|
+
var config = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
319
|
+
var normalizedPositions = normalizePolygonPositions(positions);
|
|
320
|
+
var centerPosition = Array.isArray(config === null || config === void 0 ? void 0 : config.center) && config.center.length >= 2 ? [config.center[0], config.center[1], config.center[2] || 0] : null;
|
|
321
|
+
var handlePosition = getPolygonRestoreHandlePosition(normalizedPositions);
|
|
322
|
+
var restoreSides = Number(config === null || config === void 0 ? void 0 : config.sides);
|
|
323
|
+
if (!Number.isFinite(restoreSides)) {
|
|
324
|
+
return false;
|
|
325
|
+
}
|
|
326
|
+
this._sides = this._normalizeSides(restoreSides);
|
|
327
|
+
if (!centerPosition || !handlePosition) {
|
|
328
|
+
return false;
|
|
329
|
+
}
|
|
330
|
+
if (!this._applyGeometry(centerPosition, handlePosition)) {
|
|
331
|
+
return false;
|
|
332
|
+
}
|
|
333
|
+
this._drawContext.setDrawerLayer(this.id, this);
|
|
334
|
+
return true;
|
|
335
|
+
}
|
|
336
|
+
|
|
337
|
+
// 第一次点击记录中心点,第二次点击根据半径控制点完成绘制。
|
|
338
|
+
}, {
|
|
339
|
+
key: "addPoint",
|
|
340
|
+
value: function addPoint(position) {
|
|
341
|
+
var nextPosition = this._toPositionTuple(position);
|
|
342
|
+
if (!this._centerPosition) {
|
|
343
|
+
this._centerPosition = nextPosition;
|
|
344
|
+
this._handlePosition = null;
|
|
345
|
+
this.positions = [];
|
|
346
|
+
this._drawContext._changeStatus(STATUS.DRAWING);
|
|
347
|
+
this._drawContext._updateTooltip();
|
|
348
|
+
return;
|
|
349
|
+
}
|
|
350
|
+
if (!this._applyGeometry(this._centerPosition, nextPosition)) {
|
|
351
|
+
return;
|
|
352
|
+
}
|
|
353
|
+
this.drawing(this);
|
|
354
|
+
this._finishDraw();
|
|
355
|
+
}
|
|
356
|
+
|
|
357
|
+
// 鼠标移动时根据当前半径和朝向实时预览正多边形。
|
|
358
|
+
}, {
|
|
359
|
+
key: "updateTempPosition",
|
|
360
|
+
value: function updateTempPosition(position) {
|
|
361
|
+
if (!this._centerPosition) {
|
|
362
|
+
return;
|
|
363
|
+
}
|
|
364
|
+
var nextPosition = this._toPositionTuple(position);
|
|
365
|
+
if (!this._applyGeometry(this._centerPosition, nextPosition)) {
|
|
366
|
+
this.positions = [];
|
|
367
|
+
this._destroyShapeLayers();
|
|
368
|
+
return;
|
|
369
|
+
}
|
|
370
|
+
this._emitMouseMoveChange();
|
|
371
|
+
}
|
|
372
|
+
|
|
373
|
+
// 兼容外部显式结束绘制的调用,按当前控制点收敛最终 geometry。
|
|
374
|
+
}, {
|
|
375
|
+
key: "endDraw",
|
|
376
|
+
value: function endDraw() {
|
|
377
|
+
if (!this._centerPosition || !this._handlePosition) {
|
|
378
|
+
return;
|
|
379
|
+
}
|
|
380
|
+
if (!this._applyGeometry(this._centerPosition, this._handlePosition)) {
|
|
381
|
+
return;
|
|
382
|
+
}
|
|
383
|
+
this._finishDraw();
|
|
384
|
+
}
|
|
385
|
+
|
|
386
|
+
// 编辑态只保留两个控制点,不退化为普通 polygon 的逐点编辑。
|
|
387
|
+
}, {
|
|
388
|
+
key: "startEdit",
|
|
389
|
+
value: function startEdit() {
|
|
390
|
+
if (!this._centerPosition || !this._handlePosition) {
|
|
391
|
+
return;
|
|
392
|
+
}
|
|
393
|
+
_get(_getPrototypeOf(RegularPolygon.prototype), "startEdit", this).call(this);
|
|
394
|
+
this._destroyEditHandles();
|
|
395
|
+
this.dragPoints = [this._createEditHandle(this._centerPosition, 'center'), this._createEditHandle(this._handlePosition, 'radius')];
|
|
396
|
+
}
|
|
397
|
+
|
|
398
|
+
// 记录当前拖拽的控制点。
|
|
399
|
+
}, {
|
|
400
|
+
key: "mouseDragStart",
|
|
401
|
+
value: function mouseDragStart(position, dragLayer) {
|
|
402
|
+
var _this$dragLayer;
|
|
403
|
+
this.dragging = true;
|
|
404
|
+
this.dragLayer = dragLayer;
|
|
405
|
+
(_this$dragLayer = this.dragLayer) === null || _this$dragLayer === void 0 || _this$dragLayer.mouseDragStart();
|
|
406
|
+
}
|
|
407
|
+
|
|
408
|
+
// 拖中心时整体平移,拖顶点时同步调整半径和旋转。
|
|
409
|
+
}, {
|
|
410
|
+
key: "mouseDragChange",
|
|
411
|
+
value: function mouseDragChange(position) {
|
|
412
|
+
if (!this.dragging || !this.dragLayer) {
|
|
413
|
+
return;
|
|
414
|
+
}
|
|
415
|
+
if (!this._centerPosition || !this._handlePosition) {
|
|
416
|
+
return;
|
|
417
|
+
}
|
|
418
|
+
var nextPosition = this._toPositionTuple(position);
|
|
419
|
+
var nextCenterPosition = _toConsumableArray(this._centerPosition);
|
|
420
|
+
var nextHandlePosition = _toConsumableArray(this._handlePosition);
|
|
421
|
+
if (this.dragLayer.handleRole === 'center') {
|
|
422
|
+
var localHandleVector = this._getLocalHandleVector(nextCenterPosition, nextHandlePosition);
|
|
423
|
+
nextCenterPosition = nextPosition;
|
|
424
|
+
var translatedHandlePosition = localHandleVector && this._getPositionByLocalVector(nextCenterPosition, localHandleVector);
|
|
425
|
+
if (!translatedHandlePosition) {
|
|
426
|
+
return;
|
|
427
|
+
}
|
|
428
|
+
nextHandlePosition = translatedHandlePosition;
|
|
429
|
+
} else {
|
|
430
|
+
nextHandlePosition = nextPosition;
|
|
431
|
+
}
|
|
432
|
+
if (!this._applyGeometry(nextCenterPosition, nextHandlePosition)) {
|
|
433
|
+
return;
|
|
434
|
+
}
|
|
435
|
+
this._syncEditHandles();
|
|
436
|
+
this._emitPointsChange();
|
|
437
|
+
}
|
|
438
|
+
|
|
439
|
+
// 结束拖拽时只清理状态,不生成额外中间点。
|
|
440
|
+
}, {
|
|
441
|
+
key: "mouseDragEnd",
|
|
442
|
+
value: function mouseDragEnd() {
|
|
443
|
+
this.dragging = false;
|
|
444
|
+
this.dragLayer = null;
|
|
445
|
+
}
|
|
446
|
+
|
|
447
|
+
// 结束编辑后销毁两个控制点。
|
|
448
|
+
}, {
|
|
449
|
+
key: "endEdit",
|
|
450
|
+
value: function endEdit(layer) {
|
|
451
|
+
var emitComplete = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
|
|
452
|
+
_get(_getPrototypeOf(RegularPolygon.prototype), "endEdit", this).call(this, layer, emitComplete);
|
|
453
|
+
this._destroyEditHandles();
|
|
454
|
+
}
|
|
455
|
+
|
|
456
|
+
// 销毁时同时清理渲染图层和内部几何状态。
|
|
457
|
+
}, {
|
|
458
|
+
key: "destroy",
|
|
459
|
+
value: function destroy() {
|
|
460
|
+
_get(_getPrototypeOf(RegularPolygon.prototype), "destroy", this).call(this);
|
|
461
|
+
this._destroyShapeLayers();
|
|
462
|
+
this._centerPosition = null;
|
|
463
|
+
this._handlePosition = null;
|
|
464
|
+
}
|
|
465
|
+
}]);
|
|
466
|
+
return RegularPolygon;
|
|
467
|
+
}(BaseShape);
|
|
468
|
+
export default RegularPolygon;
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import BaseShape from './BaseShape';
|
|
2
|
+
declare class RightAngleArrow extends BaseShape {
|
|
3
|
+
readonly type: string;
|
|
4
|
+
shapePolylineLayer: any;
|
|
5
|
+
shapePolygonLayer: any;
|
|
6
|
+
private _startPosition;
|
|
7
|
+
private _endPosition;
|
|
8
|
+
constructor(drawContext: any, config: any);
|
|
9
|
+
private _toPositionTuple;
|
|
10
|
+
private _getAltitudeBase;
|
|
11
|
+
private _getDrawPolylinePositions;
|
|
12
|
+
private _getDrawPolygonPositions;
|
|
13
|
+
private _destroyShapeLayers;
|
|
14
|
+
private _syncShapeLayers;
|
|
15
|
+
private _buildRightAngleArrowPositions;
|
|
16
|
+
private _applyGeometry;
|
|
17
|
+
private _destroyEditHandles;
|
|
18
|
+
private _createEditHandle;
|
|
19
|
+
private _syncEditHandles;
|
|
20
|
+
private _emitMouseMoveChange;
|
|
21
|
+
private _emitPointsChange;
|
|
22
|
+
private _finishDraw;
|
|
23
|
+
transformData(_: any[], config?: any): boolean;
|
|
24
|
+
addPoint(position: any): void;
|
|
25
|
+
updateTempPosition(position: any): void;
|
|
26
|
+
endDraw(): void;
|
|
27
|
+
startEdit(): void;
|
|
28
|
+
mouseDragStart(position: any, dragLayer: any): void;
|
|
29
|
+
mouseDragChange(position: any): void;
|
|
30
|
+
mouseDragEnd(): void;
|
|
31
|
+
endEdit(layer: any, emitComplete?: boolean): void;
|
|
32
|
+
destroy(): void;
|
|
33
|
+
}
|
|
34
|
+
export default RightAngleArrow;
|