deeptwins-engine-3d 0.1.64 → 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.
Files changed (169) hide show
  1. package/dist/esm/{plot/utils/Algorithm.js → drawer/algorithm.js} +1 -3
  2. package/dist/esm/drawer/common.d.ts +61 -0
  3. package/dist/esm/{plot/utils/PlotCommon.js → drawer/common.js} +104 -551
  4. package/dist/esm/drawer/index.d.ts +11 -18
  5. package/dist/esm/drawer/index.js +329 -80
  6. package/dist/esm/{plot/utils → drawer}/plotUtil.js +1 -3
  7. package/dist/esm/drawer/shape/Assemble.d.ts +34 -0
  8. package/dist/esm/drawer/shape/Assemble.js +415 -0
  9. package/dist/esm/drawer/shape/AttackArrow.d.ts +32 -0
  10. package/dist/esm/drawer/shape/AttackArrow.js +442 -0
  11. package/dist/esm/drawer/shape/BaseShape.d.ts +14 -4
  12. package/dist/esm/drawer/shape/BaseShape.js +175 -20
  13. package/dist/esm/drawer/shape/Bow.d.ts +31 -0
  14. package/dist/esm/drawer/shape/Bow.js +375 -0
  15. package/dist/esm/drawer/shape/Circle.d.ts +37 -0
  16. package/dist/esm/drawer/shape/Circle.js +461 -0
  17. package/dist/esm/drawer/shape/Curve.d.ts +29 -0
  18. package/dist/esm/drawer/shape/Curve.js +386 -0
  19. package/dist/esm/drawer/shape/DragPoint.d.ts +32 -0
  20. package/dist/esm/drawer/shape/DragPoint.js +211 -0
  21. package/dist/esm/drawer/shape/Elliptic.d.ts +38 -0
  22. package/dist/esm/drawer/shape/Elliptic.js +491 -0
  23. package/dist/esm/drawer/shape/Formation.d.ts +33 -0
  24. package/dist/esm/drawer/shape/Formation.js +395 -0
  25. package/dist/esm/drawer/shape/PincerArrow.d.ts +32 -0
  26. package/dist/esm/drawer/shape/PincerArrow.js +445 -0
  27. package/dist/esm/drawer/shape/Point.d.ts +2 -31
  28. package/dist/esm/drawer/shape/Point.js +7 -201
  29. package/dist/esm/drawer/shape/Polygon.d.ts +1 -1
  30. package/dist/esm/drawer/shape/Polygon.js +10 -81
  31. package/dist/esm/drawer/shape/Polyline.d.ts +1 -1
  32. package/dist/esm/drawer/shape/Polyline.js +10 -81
  33. package/dist/esm/drawer/shape/RegularPolygon.d.ts +37 -0
  34. package/dist/esm/drawer/shape/RegularPolygon.js +468 -0
  35. package/dist/esm/drawer/shape/RightAngleArrow.d.ts +34 -0
  36. package/dist/esm/drawer/shape/RightAngleArrow.js +423 -0
  37. package/dist/esm/drawer/shape/Sector.d.ts +37 -0
  38. package/dist/esm/drawer/shape/Sector.js +568 -0
  39. package/dist/esm/drawer/shape/StraightArrow.d.ts +34 -0
  40. package/dist/esm/drawer/shape/StraightArrow.js +422 -0
  41. package/dist/esm/drawer/shape/SwallowtailArrow.d.ts +36 -0
  42. package/dist/esm/drawer/shape/SwallowtailArrow.js +438 -0
  43. package/dist/esm/drawer/types.d.ts +23 -0
  44. package/dist/esm/drawer/types.js +11 -0
  45. package/dist/esm/drawer/utils.d.ts +14 -0
  46. package/dist/esm/drawer/utils.js +320 -2
  47. package/dist/esm/index.js +2 -2
  48. package/dist/esm/measure/Area.d.ts +17 -17
  49. package/dist/esm/measure/Area.js +95 -63
  50. package/dist/esm/measure/BaseDraw.d.ts +9 -4
  51. package/dist/esm/measure/BaseDraw.js +37 -2
  52. package/dist/esm/measure/Distance.d.ts +9 -9
  53. package/dist/esm/measure/Distance.js +52 -68
  54. package/dist/esm/measure/index.d.ts +16 -26
  55. package/dist/esm/measure/index.js +72 -84
  56. package/dist/esm/measure/types.d.ts +94 -0
  57. package/dist/esm/measure/types.js +17 -0
  58. package/dist/esm/measure/utils.d.ts +7 -7
  59. package/dist/esm/measure/utils.js +43 -24
  60. package/dist/esm/tool/utils.js +1 -1
  61. package/dist/umd/deeptwins-engine-3d.min.js +1 -1
  62. package/package.json +1 -1
  63. package/dist/esm/plot/create/CreateAssemble.d.ts +0 -2
  64. package/dist/esm/plot/create/CreateAssemble.js +0 -63
  65. package/dist/esm/plot/create/CreateAttackArrow.d.ts +0 -5
  66. package/dist/esm/plot/create/CreateAttackArrow.js +0 -75
  67. package/dist/esm/plot/create/CreateBillboard.d.ts +0 -2
  68. package/dist/esm/plot/create/CreateBillboard.js +0 -47
  69. package/dist/esm/plot/create/CreateBow.d.ts +0 -2
  70. package/dist/esm/plot/create/CreateBow.js +0 -63
  71. package/dist/esm/plot/create/CreateCircle.d.ts +0 -2
  72. package/dist/esm/plot/create/CreateCircle.js +0 -68
  73. package/dist/esm/plot/create/CreateCurve.d.ts +0 -2
  74. package/dist/esm/plot/create/CreateCurve.js +0 -76
  75. package/dist/esm/plot/create/CreateElliptic.d.ts +0 -2
  76. package/dist/esm/plot/create/CreateElliptic.js +0 -69
  77. package/dist/esm/plot/create/CreateFlag.d.ts +0 -2
  78. package/dist/esm/plot/create/CreateFlag.js +0 -80
  79. package/dist/esm/plot/create/CreateFormation.d.ts +0 -2
  80. package/dist/esm/plot/create/CreateFormation.js +0 -65
  81. package/dist/esm/plot/create/CreateFreeLine.d.ts +0 -2
  82. package/dist/esm/plot/create/CreateFreeLine.js +0 -69
  83. package/dist/esm/plot/create/CreateFreePolygon.d.ts +0 -2
  84. package/dist/esm/plot/create/CreateFreePolygon.js +0 -65
  85. package/dist/esm/plot/create/CreateLabel.d.ts +0 -2
  86. package/dist/esm/plot/create/CreateLabel.js +0 -55
  87. package/dist/esm/plot/create/CreateLineArrow.d.ts +0 -2
  88. package/dist/esm/plot/create/CreateLineArrow.js +0 -79
  89. package/dist/esm/plot/create/CreatePincerArrow.d.ts +0 -5
  90. package/dist/esm/plot/create/CreatePincerArrow.js +0 -73
  91. package/dist/esm/plot/create/CreatePoint.d.ts +0 -2
  92. package/dist/esm/plot/create/CreatePoint.js +0 -47
  93. package/dist/esm/plot/create/CreatePolygon.d.ts +0 -2
  94. package/dist/esm/plot/create/CreatePolygon.js +0 -80
  95. package/dist/esm/plot/create/CreatePolyline.d.ts +0 -2
  96. package/dist/esm/plot/create/CreatePolyline.js +0 -70
  97. package/dist/esm/plot/create/CreateRectangle.d.ts +0 -2
  98. package/dist/esm/plot/create/CreateRectangle.js +0 -60
  99. package/dist/esm/plot/create/CreateRegularPolygon.d.ts +0 -2
  100. package/dist/esm/plot/create/CreateRegularPolygon.js +0 -75
  101. package/dist/esm/plot/create/CreateRightAngleArrow.d.ts +0 -5
  102. package/dist/esm/plot/create/CreateRightAngleArrow.js +0 -73
  103. package/dist/esm/plot/create/CreateRoundRectangle.d.ts +0 -2
  104. package/dist/esm/plot/create/CreateRoundRectangle.js +0 -63
  105. package/dist/esm/plot/create/CreateSector.d.ts +0 -2
  106. package/dist/esm/plot/create/CreateSector.js +0 -65
  107. package/dist/esm/plot/create/CreateStraightArrow.d.ts +0 -5
  108. package/dist/esm/plot/create/CreateStraightArrow.js +0 -65
  109. package/dist/esm/plot/create/CreateSwallowtailArrow.d.ts +0 -5
  110. package/dist/esm/plot/create/CreateSwallowtailArrow.js +0 -67
  111. package/dist/esm/plot/create/index.d.ts +0 -25
  112. package/dist/esm/plot/create/index.js +0 -25
  113. package/dist/esm/plot/edit/EditAssemble.d.ts +0 -8
  114. package/dist/esm/plot/edit/EditAssemble.js +0 -120
  115. package/dist/esm/plot/edit/EditAttackArrow.d.ts +0 -8
  116. package/dist/esm/plot/edit/EditAttackArrow.js +0 -182
  117. package/dist/esm/plot/edit/EditBillboard.d.ts +0 -7
  118. package/dist/esm/plot/edit/EditBillboard.js +0 -70
  119. package/dist/esm/plot/edit/EditBow.d.ts +0 -8
  120. package/dist/esm/plot/edit/EditBow.js +0 -119
  121. package/dist/esm/plot/edit/EditCircle.d.ts +0 -8
  122. package/dist/esm/plot/edit/EditCircle.js +0 -133
  123. package/dist/esm/plot/edit/EditCurve.d.ts +0 -8
  124. package/dist/esm/plot/edit/EditCurve.js +0 -180
  125. package/dist/esm/plot/edit/EditElliptic.d.ts +0 -8
  126. package/dist/esm/plot/edit/EditElliptic.js +0 -144
  127. package/dist/esm/plot/edit/EditFlag.d.ts +0 -8
  128. package/dist/esm/plot/edit/EditFlag.js +0 -121
  129. package/dist/esm/plot/edit/EditFormation.d.ts +0 -8
  130. package/dist/esm/plot/edit/EditFormation.js +0 -120
  131. package/dist/esm/plot/edit/EditLabel.d.ts +0 -7
  132. package/dist/esm/plot/edit/EditLabel.js +0 -100
  133. package/dist/esm/plot/edit/EditLineArrow.d.ts +0 -8
  134. package/dist/esm/plot/edit/EditLineArrow.js +0 -180
  135. package/dist/esm/plot/edit/EditPincerArrow.d.ts +0 -8
  136. package/dist/esm/plot/edit/EditPincerArrow.js +0 -121
  137. package/dist/esm/plot/edit/EditPoint.d.ts +0 -7
  138. package/dist/esm/plot/edit/EditPoint.js +0 -70
  139. package/dist/esm/plot/edit/EditPolygon.d.ts +0 -8
  140. package/dist/esm/plot/edit/EditPolygon.js +0 -181
  141. package/dist/esm/plot/edit/EditPolyline.d.ts +0 -8
  142. package/dist/esm/plot/edit/EditPolyline.js +0 -179
  143. package/dist/esm/plot/edit/EditRectangle.d.ts +0 -8
  144. package/dist/esm/plot/edit/EditRectangle.js +0 -119
  145. package/dist/esm/plot/edit/EditRegularPolygon.d.ts +0 -8
  146. package/dist/esm/plot/edit/EditRegularPolygon.js +0 -170
  147. package/dist/esm/plot/edit/EditRightAngleArrow.d.ts +0 -8
  148. package/dist/esm/plot/edit/EditRightAngleArrow.js +0 -143
  149. package/dist/esm/plot/edit/EditRoundRectangle.d.ts +0 -8
  150. package/dist/esm/plot/edit/EditRoundRectangle.js +0 -119
  151. package/dist/esm/plot/edit/EditSector.d.ts +0 -8
  152. package/dist/esm/plot/edit/EditSector.js +0 -120
  153. package/dist/esm/plot/edit/EditStraightArrow.d.ts +0 -8
  154. package/dist/esm/plot/edit/EditStraightArrow.js +0 -120
  155. package/dist/esm/plot/edit/EditSwallowtailArrow.d.ts +0 -8
  156. package/dist/esm/plot/edit/EditSwallowtailArrow.js +0 -121
  157. package/dist/esm/plot/edit/index.d.ts +0 -23
  158. package/dist/esm/plot/edit/index.js +0 -23
  159. package/dist/esm/plot/utils/DomUtil.d.ts +0 -34
  160. package/dist/esm/plot/utils/DomUtil.js +0 -100
  161. package/dist/esm/plot/utils/PlotCommon.d.ts +0 -101
  162. package/dist/esm/plot/utils/ReminderTip.d.ts +0 -10
  163. package/dist/esm/plot/utils/ReminderTip.js +0 -67
  164. package/dist/esm/plot/utils/Tooltip.d.ts +0 -3
  165. package/dist/esm/plot/utils/Tooltip.js +0 -97
  166. /package/dist/esm/{plot/utils/Algorithm.d.ts → drawer/algorithm.d.ts} +0 -0
  167. /package/dist/esm/{plot/utils/Coordinate.d.ts → drawer/coordinate.d.ts} +0 -0
  168. /package/dist/esm/{plot/utils/Coordinate.js → drawer/coordinate.js} +0 -0
  169. /package/dist/esm/{plot/utils → drawer}/plotUtil.d.ts +0 -0
@@ -1,12 +1,12 @@
1
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 ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
3
+ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
2
4
  function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
3
5
  function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
4
6
  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
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; }
6
8
  function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
7
9
  function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
8
- function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
9
- function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
10
10
  function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
11
11
  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); } }
12
12
  function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
@@ -17,8 +17,8 @@ import * as Cesium from 'deeptwins-cesium';
17
17
  import { cloneDeep } from 'lodash';
18
18
  import { v4 as uuidV4 } from 'uuid';
19
19
  import * as utils from "../../tool/utils";
20
- import { STATUS } from "../index";
21
- import { DragPoint } from "./Point";
20
+ import { STATUS } from "../types";
21
+ import DragPoint from "./DragPoint";
22
22
  var BaseShape = /*#__PURE__*/function () {
23
23
  function BaseShape(drawContext) {
24
24
  _classCallCheck(this, BaseShape);
@@ -91,14 +91,14 @@ var BaseShape = /*#__PURE__*/function () {
91
91
  value: function drawEnd(layer) {
92
92
  var _this$_drawContext$op3;
93
93
  if (!this._canOperate()) return;
94
+ this._drawContext._changeStatus(STATUS.END_DRAW);
95
+ this._drawContext._updateTooltip();
96
+ this.getMap().canvas.style.cursor = 'default';
94
97
  // 调用绘制完成事件
95
98
  ((_this$_drawContext$op3 = this._drawContext.options) === null || _this$_drawContext$op3 === void 0 ? void 0 : _this$_drawContext$op3.onComplete) && this._drawContext.options.onComplete({
96
99
  layer: layer,
97
100
  positions: this.positions
98
101
  });
99
- this._drawContext._changeStatus(STATUS.END_DRAW);
100
- this._drawContext._updateTooltip();
101
- this.getMap().canvas.style.cursor = 'default';
102
102
  }
103
103
 
104
104
  // 开始编辑
@@ -115,9 +115,12 @@ var BaseShape = /*#__PURE__*/function () {
115
115
  key: "endEdit",
116
116
  value: function endEdit(layer) {
117
117
  var _this$_drawContext$op4;
118
+ var emitComplete = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
118
119
  if (!this._canOperate()) return;
119
120
  this.isEditing = false;
120
- // 调用绘制完成事件
121
+ if (!emitComplete) {
122
+ return;
123
+ }
121
124
  ((_this$_drawContext$op4 = this._drawContext.options) === null || _this$_drawContext$op4 === void 0 ? void 0 : _this$_drawContext$op4.onComplete) && this._drawContext.options.onComplete({
122
125
  layer: layer,
123
126
  positions: this.positions
@@ -129,14 +132,47 @@ var BaseShape = /*#__PURE__*/function () {
129
132
  if (!this._canOperate()) return;
130
133
  this.positions = [];
131
134
  this.isDestroyed = true;
135
+ this.isEditing = false;
136
+ this.dragging = false;
137
+ this.dragLayer = null;
132
138
  this.dragPoints.forEach(function (t) {
133
139
  return t.destroy();
134
140
  });
135
141
  this.dragPoints = [];
136
- this.edges.forEach(function (t) {
137
- return t.middlePoint.destroy();
138
- });
139
- this.edges = [];
142
+ this._destroyMiddlePoints();
143
+ }
144
+
145
+ // DragPoint 对外暴露的是经纬高数组;创建中间点前统一转回 Cartesian3。
146
+ }, {
147
+ key: "_toCartesian3",
148
+ value: function _toCartesian3(position) {
149
+ if (!Array.isArray(position) || position.length < 2) {
150
+ return null;
151
+ }
152
+ var _position = _slicedToArray(position, 3),
153
+ lng = _position[0],
154
+ lat = _position[1],
155
+ _position$ = _position[2],
156
+ alt = _position$ === void 0 ? 0 : _position$;
157
+ if (!Number.isFinite(lng) || !Number.isFinite(lat) || !Number.isFinite(alt)) {
158
+ return null;
159
+ }
160
+ return utils.lngLatAltToCartesian3(lng, lat, alt);
161
+ }
162
+
163
+ // 根据两个拖拽点生成中间点;位置非法时跳过,避免把异常值传给 Cesium。
164
+ }, {
165
+ key: "_createMiddlePointFromDragPoints",
166
+ value: function _createMiddlePointFromDragPoints(source, target) {
167
+ var _source$getPosition, _target$getPosition;
168
+ var sourcePosition = source === null || source === void 0 || (_source$getPosition = source.getPosition) === null || _source$getPosition === void 0 ? void 0 : _source$getPosition.call(source);
169
+ var targetPosition = target === null || target === void 0 || (_target$getPosition = target.getPosition) === null || _target$getPosition === void 0 ? void 0 : _target$getPosition.call(target);
170
+ var p1 = this._toCartesian3(sourcePosition);
171
+ var p2 = this._toCartesian3(targetPosition);
172
+ if (!p1 || !p2) {
173
+ return null;
174
+ }
175
+ return this._createTwoPointMiddle(utils.getMidpoint(p1, p2));
140
176
  }
141
177
 
142
178
  // 根据可拖拽点位创建两个点位中间点和映射关系
@@ -150,9 +186,10 @@ var BaseShape = /*#__PURE__*/function () {
150
186
  item.startEdit();
151
187
  item.show(true);
152
188
  if (itemNext) {
153
- var p1 = item.layer.layers[0].source.positions;
154
- var p2 = itemNext.layer.layers[0].source.positions;
155
- var layer = this._createTwoPointMiddle(utils.getMidpoint(p1, p2));
189
+ var layer = this._createMiddlePointFromDragPoints(item, itemNext);
190
+ if (!layer) {
191
+ continue;
192
+ }
156
193
  layer.startEdit();
157
194
  // 创建映射关系
158
195
  edges.push({
@@ -164,6 +201,123 @@ var BaseShape = /*#__PURE__*/function () {
164
201
  }
165
202
  return edges;
166
203
  }
204
+ }, {
205
+ key: "_destroyMiddlePoints",
206
+ value: function _destroyMiddlePoints() {
207
+ this.edges.forEach(function (t) {
208
+ var _t$middlePoint;
209
+ return (_t$middlePoint = t.middlePoint) === null || _t$middlePoint === void 0 ? void 0 : _t$middlePoint.destroy();
210
+ });
211
+ this.edges = [];
212
+ }
213
+ }, {
214
+ key: "_startEdgeEditing",
215
+ value: function _startEdgeEditing(isPolygon) {
216
+ this._destroyMiddlePoints();
217
+ this.edges = this._createEdgesAndMiddle(this.dragPoints, isPolygon);
218
+ }
219
+ }, {
220
+ key: "_getChangedEdges",
221
+ value: function _getChangedEdges() {
222
+ var dragLayer = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : this.dragLayer;
223
+ if (!dragLayer) {
224
+ return [];
225
+ }
226
+ return this.edges.filter(function (t) {
227
+ var _t$source, _t$target;
228
+ return ((_t$source = t.source) === null || _t$source === void 0 ? void 0 : _t$source.id) === dragLayer.id || ((_t$target = t.target) === null || _t$target === void 0 ? void 0 : _t$target.id) === dragLayer.id;
229
+ });
230
+ }
231
+ }, {
232
+ key: "_handleDragStart",
233
+ value: function _handleDragStart(dragLayer) {
234
+ var _this = this;
235
+ this.dragging = true;
236
+ this.dragLayer = dragLayer;
237
+ if (!this.dragLayer) {
238
+ return;
239
+ }
240
+ if (this.dragLayer.isMiddlePoint) {
241
+ var changeEdges = this.edges.filter(function (t) {
242
+ var _t$middlePoint2;
243
+ return ((_t$middlePoint2 = t.middlePoint) === null || _t$middlePoint2 === void 0 ? void 0 : _t$middlePoint2.id) === _this.dragLayer.id;
244
+ });
245
+ this.edges = this.edges.filter(function (t) {
246
+ var _t$middlePoint3;
247
+ return ((_t$middlePoint3 = t.middlePoint) === null || _t$middlePoint3 === void 0 ? void 0 : _t$middlePoint3.id) !== _this.dragLayer.id;
248
+ });
249
+ var _loop = function _loop() {
250
+ var source = changeEdges[i].source;
251
+ var target = changeEdges[i].target;
252
+ var middlePoint = changeEdges[i].middlePoint;
253
+ middlePoint.isStart = false;
254
+ _this.edges.push({
255
+ source: source,
256
+ target: middlePoint,
257
+ middlePoint: null
258
+ }, {
259
+ source: middlePoint,
260
+ target: target,
261
+ middlePoint: null
262
+ });
263
+ var findIndex = _this.dragPoints.findIndex(function (t) {
264
+ return t.id === source.id;
265
+ });
266
+ if (findIndex > -1) {
267
+ _this.dragPoints.splice(findIndex + 1, 0, middlePoint);
268
+ }
269
+ };
270
+ for (var i = 0; i < changeEdges.length; i++) {
271
+ _loop();
272
+ }
273
+ } else {
274
+ var _changeEdges = this._getChangedEdges();
275
+ for (var _i = 0; _i < _changeEdges.length; _i++) {
276
+ var _changeEdges$_i$middl;
277
+ (_changeEdges$_i$middl = _changeEdges[_i].middlePoint) === null || _changeEdges$_i$middl === void 0 || _changeEdges$_i$middl.destroy();
278
+ _changeEdges[_i].middlePoint = null;
279
+ }
280
+ }
281
+ this.dragLayer.mouseDragStart();
282
+ }
283
+ }, {
284
+ key: "_handleDragChange",
285
+ value: function _handleDragChange(position) {
286
+ if (!this.dragging || !this.dragLayer) {
287
+ return this.positions;
288
+ }
289
+ this.dragLayer.mouseDragChange(position);
290
+ this.positions = this._updatePositionsFromEdges();
291
+ return this.positions;
292
+ }
293
+ }, {
294
+ key: "_handleDragEnd",
295
+ value: function _handleDragEnd() {
296
+ if (!this.dragLayer) {
297
+ this.dragging = false;
298
+ return;
299
+ }
300
+ var changeEdges = this._getChangedEdges();
301
+ for (var i = 0; i < changeEdges.length; i++) {
302
+ var layer = this._createMiddlePointFromDragPoints(changeEdges[i].source, changeEdges[i].target);
303
+ if (!layer) {
304
+ continue;
305
+ }
306
+ layer.startEdit();
307
+ changeEdges[i].middlePoint = layer;
308
+ }
309
+ this.dragging = false;
310
+ this.dragLayer = null;
311
+ }
312
+ }, {
313
+ key: "_stopEdgeEditing",
314
+ value: function _stopEdgeEditing() {
315
+ this.dragPoints.forEach(function (t) {
316
+ t.endEdit();
317
+ t.show(false);
318
+ });
319
+ this._destroyMiddlePoints();
320
+ }
167
321
 
168
322
  // 创建两点间的可拖动点位
169
323
  }, {
@@ -193,17 +347,18 @@ var BaseShape = /*#__PURE__*/function () {
193
347
  return point.isStart;
194
348
  });
195
349
  if (!startPoint) {
196
- return;
350
+ return [];
197
351
  }
198
352
 
199
353
  // 从起点开始,按source->target的顺序构建positions数组
200
354
  var currentPoint = startPoint;
201
355
  while (currentPoint && !visitedIds.has(currentPoint.id)) {
202
356
  // 添加当前点
203
- var _currentPoint$_geoJso = _slicedToArray(currentPoint._geoJson.geometry.coordinates, 3),
204
- lng = _currentPoint$_geoJso[0],
205
- lat = _currentPoint$_geoJso[1],
206
- alt = _currentPoint$_geoJso[2];
357
+ var _currentPoint$getPosi = currentPoint.getPosition(),
358
+ _currentPoint$getPosi2 = _slicedToArray(_currentPoint$getPosi, 3),
359
+ lng = _currentPoint$getPosi2[0],
360
+ lat = _currentPoint$getPosi2[1],
361
+ alt = _currentPoint$getPosi2[2];
207
362
  positions.push([lng, lat, alt]);
208
363
  visitedIds.add(currentPoint.id);
209
364
 
@@ -0,0 +1,31 @@
1
+ import BaseShape from './BaseShape';
2
+ declare class Bow extends BaseShape {
3
+ readonly type: string;
4
+ shapePolylineLayer: any;
5
+ private _startPosition;
6
+ private _endPosition;
7
+ constructor(drawContext: any, config: any);
8
+ private _toPositionTuple;
9
+ private _getAltitudeBase;
10
+ private _destroyShapeLayer;
11
+ private _syncShapeLayer;
12
+ private _buildBowPositions;
13
+ private _applyGeometry;
14
+ private _destroyEditHandles;
15
+ private _createEditHandle;
16
+ private _syncEditHandles;
17
+ private _emitMouseMoveChange;
18
+ private _emitPointsChange;
19
+ private _finishDraw;
20
+ transformData(_: any[], config?: any): boolean;
21
+ addPoint(position: any): void;
22
+ updateTempPosition(position: any): void;
23
+ endDraw(): void;
24
+ startEdit(): void;
25
+ mouseDragStart(position: any, dragLayer: any): void;
26
+ mouseDragChange(position: any): void;
27
+ mouseDragEnd(): void;
28
+ endEdit(layer: any, emitComplete?: boolean): void;
29
+ destroy(): void;
30
+ }
31
+ export default Bow;
@@ -0,0 +1,375 @@
1
+ function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
2
+ 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."); }
3
+ 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); }
4
+ function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
5
+ function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
6
+ 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; }
7
+ 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); }
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 { calculateBowPoints } from "../common";
26
+ import * as utils from "../../tool/utils";
27
+ import { STATUS } from "../types";
28
+ import BaseShape from "./BaseShape";
29
+ import DragPoint from "./DragPoint";
30
+ import { ShapePolyline } from "./Polyline";
31
+ var Bow = /*#__PURE__*/function (_BaseShape) {
32
+ _inherits(Bow, _BaseShape);
33
+ var _super = _createSuper(Bow);
34
+ function Bow(drawContext, config) {
35
+ var _this;
36
+ _classCallCheck(this, Bow);
37
+ _this = _super.call(this, drawContext);
38
+ _defineProperty(_assertThisInitialized(_this), "type", 'bow');
39
+ _defineProperty(_assertThisInitialized(_this), "shapePolylineLayer", void 0);
40
+ _defineProperty(_assertThisInitialized(_this), "_startPosition", void 0);
41
+ _defineProperty(_assertThisInitialized(_this), "_endPosition", void 0);
42
+ _this._startPosition = null;
43
+ _this._endPosition = null;
44
+ _this.clampToGround = isNil(config === null || config === void 0 ? void 0 : config.clampToGround) ? _this.clampToGround : config.clampToGround;
45
+ _this.pointStyle.heightReference = _this.clampToGround ? Cesium.HeightReference.CLAMP_TO_GROUND : Cesium.HeightReference.NONE;
46
+ _this.polylineStyle.clampToGround = _this.clampToGround;
47
+ return _this;
48
+ }
49
+
50
+ // 鼠标事件位置统一转成内部经纬高三元组。
51
+ _createClass(Bow, [{
52
+ key: "_toPositionTuple",
53
+ value: function _toPositionTuple(position) {
54
+ var lng = position.lng,
55
+ lat = position.lat,
56
+ _position$alt = position.alt,
57
+ alt = _position$alt === void 0 ? 0 : _position$alt;
58
+ return [lng, lat, alt];
59
+ }
60
+
61
+ // 贴地时高度统一为 0;非贴地时用两个控制点的平均高度近似。
62
+ }, {
63
+ key: "_getAltitudeBase",
64
+ value: function _getAltitudeBase(startPosition, endPosition) {
65
+ if (this.clampToGround) {
66
+ return 0;
67
+ }
68
+ var altitudes = [startPosition === null || startPosition === void 0 ? void 0 : startPosition[2], endPosition === null || endPosition === void 0 ? void 0 : endPosition[2]].filter(function (altitude) {
69
+ return Number.isFinite(altitude);
70
+ });
71
+ if (!altitudes.length) {
72
+ return 0;
73
+ }
74
+ return altitudes.reduce(function (sum, altitude) {
75
+ return sum + altitude;
76
+ }, 0) / altitudes.length;
77
+ }
78
+
79
+ // 统一释放线图层,避免绘制中断后残留几何。
80
+ }, {
81
+ key: "_destroyShapeLayer",
82
+ value: function _destroyShapeLayer() {
83
+ this.shapePolylineLayer && this.shapePolylineLayer.destroy();
84
+ this.shapePolylineLayer = null;
85
+ }
86
+
87
+ // 根据当前点数组同步线图层。
88
+ }, {
89
+ key: "_syncShapeLayer",
90
+ value: function _syncShapeLayer() {
91
+ if (!this.positions.length) {
92
+ this._destroyShapeLayer();
93
+ return;
94
+ }
95
+ if (!this.shapePolylineLayer) {
96
+ this.shapePolylineLayer = new ShapePolyline(this.getMap(), {
97
+ positions: this.positions,
98
+ style: this.polylineStyle
99
+ });
100
+ return;
101
+ }
102
+ this.shapePolylineLayer.update(this.positions);
103
+ }
104
+
105
+ // 参考 drawer/common.calculateBowPoints:用两个端点计算弓形折线点集。
106
+ }, {
107
+ key: "_buildBowPositions",
108
+ value: function _buildBowPositions(startPosition, endPosition) {
109
+ var startCartesian = this._toCartesian3(startPosition);
110
+ var endCartesian = this._toCartesian3(endPosition);
111
+ if (!startCartesian) {
112
+ return [];
113
+ }
114
+ var anchorCartesians = endCartesian ? [startCartesian, endCartesian] : [startCartesian];
115
+ var cartesianPoints = calculateBowPoints(anchorCartesians);
116
+ if (!Array.isArray(cartesianPoints) || !cartesianPoints.length) {
117
+ return [];
118
+ }
119
+ var altitudeBase = this._getAltitudeBase(startPosition, endPosition);
120
+ return cartesianPoints.map(function (cartesian) {
121
+ if (!cartesian || _typeof(cartesian) !== 'object' || !Number.isFinite(cartesian.x) || !Number.isFinite(cartesian.y) || !Number.isFinite(cartesian.z)) {
122
+ return null;
123
+ }
124
+ var _utils$cartesian3ToLn = utils.cartesian3ToLngLatAlt(cartesian),
125
+ lng = _utils$cartesian3ToLn.lng,
126
+ lat = _utils$cartesian3ToLn.lat;
127
+ return [lng, lat, altitudeBase];
128
+ }).filter(function (position) {
129
+ return Boolean(position);
130
+ });
131
+ }
132
+
133
+ // 统一更新两个控制点、点数组和渲染图层。
134
+ }, {
135
+ key: "_applyGeometry",
136
+ value: function _applyGeometry(startPosition, endPosition) {
137
+ var positions = this._buildBowPositions(startPosition, endPosition);
138
+ if (positions.length < 2) {
139
+ this.positions = [];
140
+ this._destroyShapeLayer();
141
+ return false;
142
+ }
143
+ this._startPosition = startPosition ? _toConsumableArray(startPosition) : null;
144
+ this._endPosition = endPosition ? _toConsumableArray(endPosition) : null;
145
+ this.positions = positions;
146
+ this._syncShapeLayer();
147
+ return true;
148
+ }
149
+
150
+ // 编辑结束或销毁时统一释放两个控制点。
151
+ }, {
152
+ key: "_destroyEditHandles",
153
+ value: function _destroyEditHandles() {
154
+ this.dragPoints.forEach(function (point) {
155
+ return point.destroy();
156
+ });
157
+ this.dragPoints = [];
158
+ this.dragLayer = null;
159
+ this.dragging = false;
160
+ }
161
+
162
+ // 创建编辑控制点:起点/终点负责调整弓形端点。
163
+ }, {
164
+ key: "_createEditHandle",
165
+ value: function _createEditHandle(position, role) {
166
+ var handle = new DragPoint(this.getMap(), {
167
+ positions: position,
168
+ style: this.pointStyle
169
+ });
170
+ handle.handleRole = role;
171
+ handle.startEdit();
172
+ return handle;
173
+ }
174
+
175
+ // 几何变化后把两个控制点同步到最新位置。
176
+ }, {
177
+ key: "_syncEditHandles",
178
+ value: function _syncEditHandles() {
179
+ var startHandle = this.dragPoints.find(function (point) {
180
+ return point.handleRole === 'start';
181
+ });
182
+ var endHandle = this.dragPoints.find(function (point) {
183
+ return point.handleRole === 'end';
184
+ });
185
+ if (startHandle && this._startPosition) {
186
+ startHandle.mouseDragChange({
187
+ lng: this._startPosition[0],
188
+ lat: this._startPosition[1],
189
+ alt: this._startPosition[2]
190
+ });
191
+ }
192
+ if (endHandle && this._endPosition) {
193
+ endHandle.mouseDragChange({
194
+ lng: this._endPosition[0],
195
+ lat: this._endPosition[1],
196
+ alt: this._endPosition[2]
197
+ });
198
+ }
199
+ }
200
+
201
+ // 绘制预览阶段透出当前弓形折线点集。
202
+ }, {
203
+ key: "_emitMouseMoveChange",
204
+ value: function _emitMouseMoveChange() {
205
+ this._drawContext.options.onMouseMoveChange && this._drawContext.options.onMouseMoveChange({
206
+ layer: this,
207
+ positions: this.positions
208
+ });
209
+ }
210
+
211
+ // 编辑态拖拽时透出最新点集。
212
+ }, {
213
+ key: "_emitPointsChange",
214
+ value: function _emitPointsChange() {
215
+ var _this$_drawContext$op, _this$_drawContext$op2;
216
+ ((_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({
217
+ layer: this,
218
+ positions: this.positions
219
+ }));
220
+ }
221
+
222
+ // 统一完成绘制:入库、触发回调并进入编辑态。
223
+ }, {
224
+ key: "_finishDraw",
225
+ value: function _finishDraw() {
226
+ if (!this.positions.length) {
227
+ return;
228
+ }
229
+ this._drawContext.setDrawerLayer(this.id, this);
230
+ this.drawEnd(this);
231
+ this.startEdit();
232
+ }
233
+
234
+ // 基于 anchors 还原弓形;缺少 anchors 时由 Drawer 回退为普通 polyline。
235
+ }, {
236
+ key: "transformData",
237
+ value: function transformData(_) {
238
+ var config = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
239
+ var anchors = config === null || config === void 0 ? void 0 : config.anchors;
240
+ if (!Array.isArray(anchors) || anchors.length < 2) {
241
+ return false;
242
+ }
243
+ var startPosition = [anchors[0][0], anchors[0][1], anchors[0][2] || 0];
244
+ var endPosition = [anchors[1][0], anchors[1][1], anchors[1][2] || 0];
245
+ if (!this._applyGeometry(startPosition, endPosition)) {
246
+ return false;
247
+ }
248
+ this._drawContext.setDrawerLayer(this.id, this);
249
+ return true;
250
+ }
251
+
252
+ // 第一次点击记录起点,第二次点击根据终点完成弓形绘制。
253
+ }, {
254
+ key: "addPoint",
255
+ value: function addPoint(position) {
256
+ var nextPosition = this._toPositionTuple(position);
257
+ if (!this._startPosition) {
258
+ this._startPosition = nextPosition;
259
+ this._endPosition = null;
260
+ this.positions = [];
261
+ this._drawContext._changeStatus(STATUS.DRAWING);
262
+ this._drawContext._updateTooltip();
263
+ return;
264
+ }
265
+ if (!this._applyGeometry(this._startPosition, nextPosition)) {
266
+ return;
267
+ }
268
+ this.drawing(this);
269
+ this._finishDraw();
270
+ }
271
+
272
+ // 鼠标移动时根据当前终点实时预览弓形。
273
+ }, {
274
+ key: "updateTempPosition",
275
+ value: function updateTempPosition(position) {
276
+ if (!this._startPosition) {
277
+ return;
278
+ }
279
+ var nextPosition = this._toPositionTuple(position);
280
+ if (!this._applyGeometry(this._startPosition, nextPosition)) {
281
+ return;
282
+ }
283
+ this._emitMouseMoveChange();
284
+ }
285
+
286
+ // 兼容外部显式结束绘制的调用,按当前控制点收敛最终 geometry。
287
+ }, {
288
+ key: "endDraw",
289
+ value: function endDraw() {
290
+ if (!this._startPosition || !this._endPosition) {
291
+ return;
292
+ }
293
+ if (!this._applyGeometry(this._startPosition, this._endPosition)) {
294
+ return;
295
+ }
296
+ this._finishDraw();
297
+ }
298
+
299
+ // 编辑态只保留两个控制点,避免引入多点编辑导致算法含义不清。
300
+ }, {
301
+ key: "startEdit",
302
+ value: function startEdit() {
303
+ if (!this._startPosition || !this._endPosition) {
304
+ return;
305
+ }
306
+ _get(_getPrototypeOf(Bow.prototype), "startEdit", this).call(this);
307
+ this._destroyEditHandles();
308
+ this.dragPoints = [this._createEditHandle(this._startPosition, 'start'), this._createEditHandle(this._endPosition, 'end')];
309
+ }
310
+
311
+ // 记录当前拖拽的控制点。
312
+ }, {
313
+ key: "mouseDragStart",
314
+ value: function mouseDragStart(position, dragLayer) {
315
+ var _this$dragLayer;
316
+ this.dragging = true;
317
+ this.dragLayer = dragLayer;
318
+ (_this$dragLayer = this.dragLayer) === null || _this$dragLayer === void 0 || _this$dragLayer.mouseDragStart();
319
+ }
320
+
321
+ // 拖拽起点/终点时重新计算弓形折线点集。
322
+ }, {
323
+ key: "mouseDragChange",
324
+ value: function mouseDragChange(position) {
325
+ if (!this.dragging || !this.dragLayer) {
326
+ return;
327
+ }
328
+ if (!this._startPosition || !this._endPosition) {
329
+ return;
330
+ }
331
+ var nextPosition = this._toPositionTuple(position);
332
+ var nextStartPosition = _toConsumableArray(this._startPosition);
333
+ var nextEndPosition = _toConsumableArray(this._endPosition);
334
+ if (this.dragLayer.handleRole === 'start') {
335
+ nextStartPosition = nextPosition;
336
+ } else {
337
+ nextEndPosition = nextPosition;
338
+ }
339
+ if (!this._applyGeometry(nextStartPosition, nextEndPosition)) {
340
+ return;
341
+ }
342
+ this._syncEditHandles();
343
+ this._emitPointsChange();
344
+ }
345
+
346
+ // 结束拖拽时只清理状态。
347
+ }, {
348
+ key: "mouseDragEnd",
349
+ value: function mouseDragEnd() {
350
+ this.dragging = false;
351
+ this.dragLayer = null;
352
+ }
353
+
354
+ // 结束编辑后销毁两个控制点。
355
+ }, {
356
+ key: "endEdit",
357
+ value: function endEdit(layer) {
358
+ var emitComplete = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
359
+ _get(_getPrototypeOf(Bow.prototype), "endEdit", this).call(this, layer, emitComplete);
360
+ this._destroyEditHandles();
361
+ }
362
+
363
+ // 销毁时同时清理渲染图层和内部几何状态。
364
+ }, {
365
+ key: "destroy",
366
+ value: function destroy() {
367
+ _get(_getPrototypeOf(Bow.prototype), "destroy", this).call(this);
368
+ this._destroyShapeLayer();
369
+ this._startPosition = null;
370
+ this._endPosition = null;
371
+ }
372
+ }]);
373
+ return Bow;
374
+ }(BaseShape);
375
+ export default Bow;