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.
- 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/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/index.js +2 -2
- 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/tool/utils.js +1 -1
- package/dist/umd/deeptwins-engine-3d.min.js +1 -1
- package/package.json +1 -1
- 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.d.ts → drawer/coordinate.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,37 @@
|
|
|
1
|
+
import BaseShape from './BaseShape';
|
|
2
|
+
declare class Circle extends BaseShape {
|
|
3
|
+
readonly type: string;
|
|
4
|
+
shapePolylineLayer: any;
|
|
5
|
+
shapePolygonLayer: any;
|
|
6
|
+
private _segments;
|
|
7
|
+
private _centerPosition;
|
|
8
|
+
private _handlePosition;
|
|
9
|
+
constructor(drawContext: any, config: any);
|
|
10
|
+
private _normalizeSegments;
|
|
11
|
+
private _toPositionTuple;
|
|
12
|
+
private _getDrawPolylinePositions;
|
|
13
|
+
private _getDrawPolygonPositions;
|
|
14
|
+
private _destroyShapeLayers;
|
|
15
|
+
private _syncShapeLayers;
|
|
16
|
+
private _buildCirclePositions;
|
|
17
|
+
private _getLocalHandleVector;
|
|
18
|
+
private _getPositionByLocalVector;
|
|
19
|
+
private _applyGeometry;
|
|
20
|
+
private _destroyEditHandles;
|
|
21
|
+
private _createEditHandle;
|
|
22
|
+
private _syncEditHandles;
|
|
23
|
+
private _emitMouseMoveChange;
|
|
24
|
+
private _emitPointsChange;
|
|
25
|
+
private _finishDraw;
|
|
26
|
+
transformData(positions: any[], config?: any): boolean;
|
|
27
|
+
addPoint(position: any): void;
|
|
28
|
+
updateTempPosition(position: any): void;
|
|
29
|
+
endDraw(): void;
|
|
30
|
+
startEdit(): void;
|
|
31
|
+
mouseDragStart(position: any, dragLayer: any): void;
|
|
32
|
+
mouseDragChange(position: any): void;
|
|
33
|
+
mouseDragEnd(): void;
|
|
34
|
+
endEdit(layer: any, emitComplete?: boolean): void;
|
|
35
|
+
destroy(): void;
|
|
36
|
+
}
|
|
37
|
+
export default Circle;
|
|
@@ -0,0 +1,461 @@
|
|
|
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
|
+
// 默认使用 64 段近似圆,兼顾渲染效果和顶点数量。
|
|
34
|
+
var DEFAULT_CIRCLE_SEGMENTS = 64;
|
|
35
|
+
// 过低分段会明显退化成多边形,统一收敛到最小值。
|
|
36
|
+
var MIN_CIRCLE_SEGMENTS = 16;
|
|
37
|
+
// 半径过小时不创建几何,避免出现退化图形。
|
|
38
|
+
var CIRCLE_MIN_RADIUS = 0.01;
|
|
39
|
+
var Circle = /*#__PURE__*/function (_BaseShape) {
|
|
40
|
+
_inherits(Circle, _BaseShape);
|
|
41
|
+
var _super = _createSuper(Circle);
|
|
42
|
+
function Circle(drawContext, config) {
|
|
43
|
+
var _this;
|
|
44
|
+
_classCallCheck(this, Circle);
|
|
45
|
+
_this = _super.call(this, drawContext);
|
|
46
|
+
_defineProperty(_assertThisInitialized(_this), "type", 'circle');
|
|
47
|
+
_defineProperty(_assertThisInitialized(_this), "shapePolylineLayer", void 0);
|
|
48
|
+
_defineProperty(_assertThisInitialized(_this), "shapePolygonLayer", void 0);
|
|
49
|
+
_defineProperty(_assertThisInitialized(_this), "_segments", void 0);
|
|
50
|
+
_defineProperty(_assertThisInitialized(_this), "_centerPosition", void 0);
|
|
51
|
+
_defineProperty(_assertThisInitialized(_this), "_handlePosition", void 0);
|
|
52
|
+
_this._segments = _this._normalizeSegments(config === null || config === void 0 ? void 0 : config.segments);
|
|
53
|
+
_this._centerPosition = null;
|
|
54
|
+
_this._handlePosition = null;
|
|
55
|
+
_this.clampToGround = isNil(config === null || config === void 0 ? void 0 : config.clampToGround) ? _this.clampToGround : config.clampToGround;
|
|
56
|
+
_this.pointStyle.heightReference = _this.clampToGround ? Cesium.HeightReference.CLAMP_TO_GROUND : Cesium.HeightReference.NONE;
|
|
57
|
+
_this.polylineStyle.clampToGround = _this.clampToGround;
|
|
58
|
+
if (_this.clampToGround) {
|
|
59
|
+
_this.polygonStyle.heightReference = Cesium.HeightReference.CLAMP_TO_GROUND;
|
|
60
|
+
_this.polygonStyle.perPositionHeight = false;
|
|
61
|
+
} else {
|
|
62
|
+
_this.polygonStyle.heightReference = Cesium.HeightReference.NONE;
|
|
63
|
+
_this.polygonStyle.perPositionHeight = true;
|
|
64
|
+
}
|
|
65
|
+
return _this;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
// 统一收敛外部传入的精度参数,避免非法值直接进入几何计算。
|
|
69
|
+
_createClass(Circle, [{
|
|
70
|
+
key: "_normalizeSegments",
|
|
71
|
+
value: function _normalizeSegments(segments) {
|
|
72
|
+
var numericSegments = Number(segments);
|
|
73
|
+
if (!Number.isFinite(numericSegments)) {
|
|
74
|
+
return DEFAULT_CIRCLE_SEGMENTS;
|
|
75
|
+
}
|
|
76
|
+
return Math.max(MIN_CIRCLE_SEGMENTS, Math.floor(numericSegments));
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
// 鼠标事件位置统一转成内部经纬高三元组。
|
|
80
|
+
}, {
|
|
81
|
+
key: "_toPositionTuple",
|
|
82
|
+
value: function _toPositionTuple(position) {
|
|
83
|
+
var lng = position.lng,
|
|
84
|
+
lat = position.lat,
|
|
85
|
+
_position$alt = position.alt,
|
|
86
|
+
alt = _position$alt === void 0 ? 0 : _position$alt;
|
|
87
|
+
return [lng, lat, alt];
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
// 外框渲染始终闭合,方便绘制和编辑阶段实时预览圆边界。
|
|
91
|
+
}, {
|
|
92
|
+
key: "_getDrawPolylinePositions",
|
|
93
|
+
value: function _getDrawPolylinePositions() {
|
|
94
|
+
if (!this.positions.length) {
|
|
95
|
+
return [];
|
|
96
|
+
}
|
|
97
|
+
return [].concat(_toConsumableArray(this.positions), [this.positions[0]]);
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
// 面渲染和 polygon 一致,末尾补首点形成闭环。
|
|
101
|
+
}, {
|
|
102
|
+
key: "_getDrawPolygonPositions",
|
|
103
|
+
value: function _getDrawPolygonPositions() {
|
|
104
|
+
if (!this.positions.length) {
|
|
105
|
+
return [];
|
|
106
|
+
}
|
|
107
|
+
return [].concat(_toConsumableArray(this.positions), [this.positions[0]]);
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
// 统一释放线框和面图层,避免绘制中断后残留几何。
|
|
111
|
+
}, {
|
|
112
|
+
key: "_destroyShapeLayers",
|
|
113
|
+
value: function _destroyShapeLayers() {
|
|
114
|
+
this.shapePolylineLayer && this.shapePolylineLayer.destroy();
|
|
115
|
+
this.shapePolylineLayer = null;
|
|
116
|
+
this.shapePolygonLayer && this.shapePolygonLayer.destroy();
|
|
117
|
+
this.shapePolygonLayer = null;
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
// 根据当前圆周点数组同步线框和面图层。
|
|
121
|
+
}, {
|
|
122
|
+
key: "_syncShapeLayers",
|
|
123
|
+
value: function _syncShapeLayers() {
|
|
124
|
+
if (!this.positions.length) {
|
|
125
|
+
this._destroyShapeLayers();
|
|
126
|
+
return;
|
|
127
|
+
}
|
|
128
|
+
var polylinePositions = this._getDrawPolylinePositions();
|
|
129
|
+
var polygonPositions = this._getDrawPolygonPositions();
|
|
130
|
+
if (!this.shapePolylineLayer) {
|
|
131
|
+
this.shapePolylineLayer = new ShapePolyline(this.getMap(), {
|
|
132
|
+
positions: polylinePositions,
|
|
133
|
+
style: this.polylineStyle
|
|
134
|
+
});
|
|
135
|
+
} else {
|
|
136
|
+
this.shapePolylineLayer.update(polylinePositions);
|
|
137
|
+
}
|
|
138
|
+
if (!this.shapePolygonLayer) {
|
|
139
|
+
this.shapePolygonLayer = new ShapePolygon(this.getMap(), {
|
|
140
|
+
positions: polygonPositions,
|
|
141
|
+
style: this.polygonStyle
|
|
142
|
+
});
|
|
143
|
+
return;
|
|
144
|
+
}
|
|
145
|
+
this.shapePolygonLayer.update(polygonPositions);
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
// 通过圆心和半径控制点,在局部 ENU 坐标系中生成近似圆顶点。
|
|
149
|
+
}, {
|
|
150
|
+
key: "_buildCirclePositions",
|
|
151
|
+
value: function _buildCirclePositions(centerPosition, handlePosition) {
|
|
152
|
+
var centerCartesian = this._toCartesian3(centerPosition);
|
|
153
|
+
var handleCartesian = this._toCartesian3(handlePosition);
|
|
154
|
+
if (!centerCartesian || !handleCartesian) {
|
|
155
|
+
return [];
|
|
156
|
+
}
|
|
157
|
+
var transform = Cesium.Transforms.eastNorthUpToFixedFrame(centerCartesian);
|
|
158
|
+
var inverseTransform = Cesium.Matrix4.inverseTransformation(transform, new Cesium.Matrix4());
|
|
159
|
+
var localHandle = Cesium.Matrix4.multiplyByPoint(inverseTransform, handleCartesian, new Cesium.Cartesian3());
|
|
160
|
+
var radius = Math.hypot(localHandle.x, localHandle.y);
|
|
161
|
+
if (!Number.isFinite(radius) || radius <= CIRCLE_MIN_RADIUS) {
|
|
162
|
+
return [];
|
|
163
|
+
}
|
|
164
|
+
var startAngle = Math.atan2(localHandle.y, localHandle.x);
|
|
165
|
+
var localZ = this.clampToGround ? 0 : localHandle.z;
|
|
166
|
+
var positions = [];
|
|
167
|
+
var angleStep = Cesium.Math.TWO_PI / this._segments;
|
|
168
|
+
for (var index = 0; index < this._segments; index += 1) {
|
|
169
|
+
var angle = startAngle + angleStep * index;
|
|
170
|
+
var localPoint = new Cesium.Cartesian3(radius * Math.cos(angle), radius * Math.sin(angle), localZ);
|
|
171
|
+
var worldPoint = Cesium.Matrix4.multiplyByPoint(transform, localPoint, new Cesium.Cartesian3());
|
|
172
|
+
var _utils$cartesian3ToLn = utils.cartesian3ToLngLatAlt(worldPoint),
|
|
173
|
+
lng = _utils$cartesian3ToLn.lng,
|
|
174
|
+
lat = _utils$cartesian3ToLn.lat,
|
|
175
|
+
alt = _utils$cartesian3ToLn.alt;
|
|
176
|
+
positions.push([lng, lat, alt]);
|
|
177
|
+
}
|
|
178
|
+
return positions;
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
// 计算半径控制点相对圆心的局部 ENU 向量,用于整体平移时保持半径。
|
|
182
|
+
}, {
|
|
183
|
+
key: "_getLocalHandleVector",
|
|
184
|
+
value: function _getLocalHandleVector(centerPosition, handlePosition) {
|
|
185
|
+
var centerCartesian = this._toCartesian3(centerPosition);
|
|
186
|
+
var handleCartesian = this._toCartesian3(handlePosition);
|
|
187
|
+
if (!centerCartesian || !handleCartesian) {
|
|
188
|
+
return null;
|
|
189
|
+
}
|
|
190
|
+
var transform = Cesium.Transforms.eastNorthUpToFixedFrame(centerCartesian);
|
|
191
|
+
var inverseTransform = Cesium.Matrix4.inverseTransformation(transform, new Cesium.Matrix4());
|
|
192
|
+
return Cesium.Matrix4.multiplyByPoint(inverseTransform, handleCartesian, new Cesium.Cartesian3());
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
// 把局部 ENU 向量重新投回新的圆心,得到新的半径控制点位置。
|
|
196
|
+
}, {
|
|
197
|
+
key: "_getPositionByLocalVector",
|
|
198
|
+
value: function _getPositionByLocalVector(centerPosition, localVector) {
|
|
199
|
+
var centerCartesian = this._toCartesian3(centerPosition);
|
|
200
|
+
if (!centerCartesian) {
|
|
201
|
+
return null;
|
|
202
|
+
}
|
|
203
|
+
var transform = Cesium.Transforms.eastNorthUpToFixedFrame(centerCartesian);
|
|
204
|
+
var worldPoint = Cesium.Matrix4.multiplyByPoint(transform, localVector, new Cesium.Cartesian3());
|
|
205
|
+
var _utils$cartesian3ToLn2 = utils.cartesian3ToLngLatAlt(worldPoint),
|
|
206
|
+
lng = _utils$cartesian3ToLn2.lng,
|
|
207
|
+
lat = _utils$cartesian3ToLn2.lat,
|
|
208
|
+
alt = _utils$cartesian3ToLn2.alt;
|
|
209
|
+
return [lng, lat, alt];
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
// 统一更新圆心、半径控制点、圆周顶点数组和渲染图层。
|
|
213
|
+
}, {
|
|
214
|
+
key: "_applyGeometry",
|
|
215
|
+
value: function _applyGeometry(centerPosition, handlePosition) {
|
|
216
|
+
var positions = this._buildCirclePositions(centerPosition, handlePosition);
|
|
217
|
+
if (positions.length !== this._segments) {
|
|
218
|
+
return false;
|
|
219
|
+
}
|
|
220
|
+
this._centerPosition = centerPosition ? _toConsumableArray(centerPosition) : null;
|
|
221
|
+
this._handlePosition = _toConsumableArray(positions[0]);
|
|
222
|
+
this.positions = positions;
|
|
223
|
+
this._syncShapeLayers();
|
|
224
|
+
return true;
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
// 编辑结束或销毁时统一释放两个控制点。
|
|
228
|
+
}, {
|
|
229
|
+
key: "_destroyEditHandles",
|
|
230
|
+
value: function _destroyEditHandles() {
|
|
231
|
+
this.dragPoints.forEach(function (point) {
|
|
232
|
+
return point.destroy();
|
|
233
|
+
});
|
|
234
|
+
this.dragPoints = [];
|
|
235
|
+
this.dragLayer = null;
|
|
236
|
+
this.dragging = false;
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
// 创建编辑控制点:圆心点负责平移,半径点负责修改半径。
|
|
240
|
+
}, {
|
|
241
|
+
key: "_createEditHandle",
|
|
242
|
+
value: function _createEditHandle(position, role) {
|
|
243
|
+
var handle = new DragPoint(this.getMap(), {
|
|
244
|
+
positions: position,
|
|
245
|
+
style: this.pointStyle
|
|
246
|
+
});
|
|
247
|
+
handle.handleRole = role;
|
|
248
|
+
handle.startEdit();
|
|
249
|
+
return handle;
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
// 几何变化后把两个控制点同步到最新位置。
|
|
253
|
+
}, {
|
|
254
|
+
key: "_syncEditHandles",
|
|
255
|
+
value: function _syncEditHandles() {
|
|
256
|
+
var centerHandle = this.dragPoints.find(function (point) {
|
|
257
|
+
return point.handleRole === 'center';
|
|
258
|
+
});
|
|
259
|
+
var radiusHandle = this.dragPoints.find(function (point) {
|
|
260
|
+
return point.handleRole === 'radius';
|
|
261
|
+
});
|
|
262
|
+
if (centerHandle && this._centerPosition) {
|
|
263
|
+
centerHandle.mouseDragChange({
|
|
264
|
+
lng: this._centerPosition[0],
|
|
265
|
+
lat: this._centerPosition[1],
|
|
266
|
+
alt: this._centerPosition[2]
|
|
267
|
+
});
|
|
268
|
+
}
|
|
269
|
+
if (radiusHandle && this._handlePosition) {
|
|
270
|
+
radiusHandle.mouseDragChange({
|
|
271
|
+
lng: this._handlePosition[0],
|
|
272
|
+
lat: this._handlePosition[1],
|
|
273
|
+
alt: this._handlePosition[2]
|
|
274
|
+
});
|
|
275
|
+
}
|
|
276
|
+
}
|
|
277
|
+
|
|
278
|
+
// 绘制预览阶段透出当前近似圆顶点数组。
|
|
279
|
+
}, {
|
|
280
|
+
key: "_emitMouseMoveChange",
|
|
281
|
+
value: function _emitMouseMoveChange() {
|
|
282
|
+
this._drawContext.options.onMouseMoveChange && this._drawContext.options.onMouseMoveChange({
|
|
283
|
+
layer: this,
|
|
284
|
+
positions: this.positions
|
|
285
|
+
});
|
|
286
|
+
}
|
|
287
|
+
|
|
288
|
+
// 编辑态拖拽时透出最新圆周顶点数组。
|
|
289
|
+
}, {
|
|
290
|
+
key: "_emitPointsChange",
|
|
291
|
+
value: function _emitPointsChange() {
|
|
292
|
+
var _this$_drawContext$op, _this$_drawContext$op2;
|
|
293
|
+
((_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({
|
|
294
|
+
layer: this,
|
|
295
|
+
positions: this.positions
|
|
296
|
+
}));
|
|
297
|
+
}
|
|
298
|
+
|
|
299
|
+
// 统一完成绘制:入库、触发回调并进入编辑态。
|
|
300
|
+
}, {
|
|
301
|
+
key: "_finishDraw",
|
|
302
|
+
value: function _finishDraw() {
|
|
303
|
+
if (!this.positions.length) {
|
|
304
|
+
return;
|
|
305
|
+
}
|
|
306
|
+
this._drawContext.setDrawerLayer(this.id, this);
|
|
307
|
+
this.drawEnd(this);
|
|
308
|
+
this.startEdit();
|
|
309
|
+
}
|
|
310
|
+
|
|
311
|
+
// 根据传入 polygon 顶点恢复 circle shape,并回到圆形编辑模型。
|
|
312
|
+
}, {
|
|
313
|
+
key: "transformData",
|
|
314
|
+
value: function transformData(positions) {
|
|
315
|
+
var config = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
316
|
+
var normalizedPositions = normalizePolygonPositions(positions);
|
|
317
|
+
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;
|
|
318
|
+
var handlePosition = getPolygonRestoreHandlePosition(normalizedPositions);
|
|
319
|
+
this._segments = this._normalizeSegments(config === null || config === void 0 ? void 0 : config.segments);
|
|
320
|
+
if (!centerPosition || !handlePosition) {
|
|
321
|
+
return false;
|
|
322
|
+
}
|
|
323
|
+
if (!this._applyGeometry(centerPosition, handlePosition)) {
|
|
324
|
+
return false;
|
|
325
|
+
}
|
|
326
|
+
this._drawContext.setDrawerLayer(this.id, this);
|
|
327
|
+
return true;
|
|
328
|
+
}
|
|
329
|
+
|
|
330
|
+
// 第一次点击记录圆心,第二次点击根据半径控制点完成圆形绘制。
|
|
331
|
+
}, {
|
|
332
|
+
key: "addPoint",
|
|
333
|
+
value: function addPoint(position) {
|
|
334
|
+
var nextPosition = this._toPositionTuple(position);
|
|
335
|
+
if (!this._centerPosition) {
|
|
336
|
+
this._centerPosition = nextPosition;
|
|
337
|
+
this._handlePosition = null;
|
|
338
|
+
this.positions = [];
|
|
339
|
+
this._drawContext._changeStatus(STATUS.DRAWING);
|
|
340
|
+
this._drawContext._updateTooltip();
|
|
341
|
+
return;
|
|
342
|
+
}
|
|
343
|
+
if (!this._applyGeometry(this._centerPosition, nextPosition)) {
|
|
344
|
+
return;
|
|
345
|
+
}
|
|
346
|
+
this.drawing(this);
|
|
347
|
+
this._finishDraw();
|
|
348
|
+
}
|
|
349
|
+
|
|
350
|
+
// 鼠标移动时根据当前半径实时预览圆形。
|
|
351
|
+
}, {
|
|
352
|
+
key: "updateTempPosition",
|
|
353
|
+
value: function updateTempPosition(position) {
|
|
354
|
+
if (!this._centerPosition) {
|
|
355
|
+
return;
|
|
356
|
+
}
|
|
357
|
+
var nextPosition = this._toPositionTuple(position);
|
|
358
|
+
if (!this._applyGeometry(this._centerPosition, nextPosition)) {
|
|
359
|
+
this.positions = [];
|
|
360
|
+
this._destroyShapeLayers();
|
|
361
|
+
return;
|
|
362
|
+
}
|
|
363
|
+
this._emitMouseMoveChange();
|
|
364
|
+
}
|
|
365
|
+
|
|
366
|
+
// 兼容外部显式结束绘制的调用,按当前控制点收敛最终 geometry。
|
|
367
|
+
}, {
|
|
368
|
+
key: "endDraw",
|
|
369
|
+
value: function endDraw() {
|
|
370
|
+
if (!this._centerPosition || !this._handlePosition) {
|
|
371
|
+
return;
|
|
372
|
+
}
|
|
373
|
+
if (!this._applyGeometry(this._centerPosition, this._handlePosition)) {
|
|
374
|
+
return;
|
|
375
|
+
}
|
|
376
|
+
this._finishDraw();
|
|
377
|
+
}
|
|
378
|
+
|
|
379
|
+
// 编辑态只保留两个控制点,不退化为普通 polygon 的逐点编辑。
|
|
380
|
+
}, {
|
|
381
|
+
key: "startEdit",
|
|
382
|
+
value: function startEdit() {
|
|
383
|
+
if (!this._centerPosition || !this._handlePosition) {
|
|
384
|
+
return;
|
|
385
|
+
}
|
|
386
|
+
_get(_getPrototypeOf(Circle.prototype), "startEdit", this).call(this);
|
|
387
|
+
this._destroyEditHandles();
|
|
388
|
+
this.dragPoints = [this._createEditHandle(this._centerPosition, 'center'), this._createEditHandle(this._handlePosition, 'radius')];
|
|
389
|
+
}
|
|
390
|
+
|
|
391
|
+
// 记录当前拖拽的控制点。
|
|
392
|
+
}, {
|
|
393
|
+
key: "mouseDragStart",
|
|
394
|
+
value: function mouseDragStart(position, dragLayer) {
|
|
395
|
+
var _this$dragLayer;
|
|
396
|
+
this.dragging = true;
|
|
397
|
+
this.dragLayer = dragLayer;
|
|
398
|
+
(_this$dragLayer = this.dragLayer) === null || _this$dragLayer === void 0 || _this$dragLayer.mouseDragStart();
|
|
399
|
+
}
|
|
400
|
+
|
|
401
|
+
// 拖圆心时整体平移,拖半径点时只更新半径。
|
|
402
|
+
}, {
|
|
403
|
+
key: "mouseDragChange",
|
|
404
|
+
value: function mouseDragChange(position) {
|
|
405
|
+
if (!this.dragging || !this.dragLayer) {
|
|
406
|
+
return;
|
|
407
|
+
}
|
|
408
|
+
if (!this._centerPosition || !this._handlePosition) {
|
|
409
|
+
return;
|
|
410
|
+
}
|
|
411
|
+
var nextPosition = this._toPositionTuple(position);
|
|
412
|
+
var nextCenterPosition = _toConsumableArray(this._centerPosition);
|
|
413
|
+
var nextHandlePosition = _toConsumableArray(this._handlePosition);
|
|
414
|
+
if (this.dragLayer.handleRole === 'center') {
|
|
415
|
+
var localHandleVector = this._getLocalHandleVector(nextCenterPosition, nextHandlePosition);
|
|
416
|
+
nextCenterPosition = nextPosition;
|
|
417
|
+
var translatedHandlePosition = localHandleVector && this._getPositionByLocalVector(nextCenterPosition, localHandleVector);
|
|
418
|
+
if (!translatedHandlePosition) {
|
|
419
|
+
return;
|
|
420
|
+
}
|
|
421
|
+
nextHandlePosition = translatedHandlePosition;
|
|
422
|
+
} else {
|
|
423
|
+
nextHandlePosition = nextPosition;
|
|
424
|
+
}
|
|
425
|
+
if (!this._applyGeometry(nextCenterPosition, nextHandlePosition)) {
|
|
426
|
+
return;
|
|
427
|
+
}
|
|
428
|
+
this._syncEditHandles();
|
|
429
|
+
this._emitPointsChange();
|
|
430
|
+
}
|
|
431
|
+
|
|
432
|
+
// 结束拖拽时只清理状态,不生成额外中间点。
|
|
433
|
+
}, {
|
|
434
|
+
key: "mouseDragEnd",
|
|
435
|
+
value: function mouseDragEnd() {
|
|
436
|
+
this.dragging = false;
|
|
437
|
+
this.dragLayer = null;
|
|
438
|
+
}
|
|
439
|
+
|
|
440
|
+
// 结束编辑后销毁两个控制点。
|
|
441
|
+
}, {
|
|
442
|
+
key: "endEdit",
|
|
443
|
+
value: function endEdit(layer) {
|
|
444
|
+
var emitComplete = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
|
|
445
|
+
_get(_getPrototypeOf(Circle.prototype), "endEdit", this).call(this, layer, emitComplete);
|
|
446
|
+
this._destroyEditHandles();
|
|
447
|
+
}
|
|
448
|
+
|
|
449
|
+
// 销毁时同时清理渲染图层和内部几何状态。
|
|
450
|
+
}, {
|
|
451
|
+
key: "destroy",
|
|
452
|
+
value: function destroy() {
|
|
453
|
+
_get(_getPrototypeOf(Circle.prototype), "destroy", this).call(this);
|
|
454
|
+
this._destroyShapeLayers();
|
|
455
|
+
this._centerPosition = null;
|
|
456
|
+
this._handlePosition = null;
|
|
457
|
+
}
|
|
458
|
+
}]);
|
|
459
|
+
return Circle;
|
|
460
|
+
}(BaseShape);
|
|
461
|
+
export default Circle;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import BaseShape from './BaseShape';
|
|
2
|
+
declare class Curve extends BaseShape {
|
|
3
|
+
readonly type: string;
|
|
4
|
+
shapePolylineLayer: any;
|
|
5
|
+
private _anchorPositions;
|
|
6
|
+
private _tempPosition;
|
|
7
|
+
constructor(drawContext: any, config: any);
|
|
8
|
+
private _toPositionTuple;
|
|
9
|
+
private _getAltitudeBase;
|
|
10
|
+
private _destroyShapeLayer;
|
|
11
|
+
private _syncShapeLayer;
|
|
12
|
+
private _buildCurvePositions;
|
|
13
|
+
private _applyGeometry;
|
|
14
|
+
private _emitMouseMoveChange;
|
|
15
|
+
private _emitPointsChange;
|
|
16
|
+
private _finishDraw;
|
|
17
|
+
transformData(_: any[], config?: any): boolean;
|
|
18
|
+
addPoint(position: any): void;
|
|
19
|
+
removePrev(): void;
|
|
20
|
+
updateTempPosition(position: any): void;
|
|
21
|
+
endDraw(): void;
|
|
22
|
+
startEdit(): void;
|
|
23
|
+
mouseDragStart(position: any, dragLayer: any): void;
|
|
24
|
+
mouseDragChange(position: any): void;
|
|
25
|
+
mouseDragEnd(): void;
|
|
26
|
+
endEdit(layer: any, emitComplete?: boolean): void;
|
|
27
|
+
destroy(): void;
|
|
28
|
+
}
|
|
29
|
+
export default Curve;
|