deeptwins-engine-3d 0.1.8 → 0.1.11
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/cameraControl/ModelRoamHistory.d.ts +2 -1
- package/dist/esm/cameraControl/ModelRoamHistory.js +33 -29
- package/dist/esm/cameraControl/ModelRoamRealTime.d.ts +4 -3
- package/dist/esm/cameraControl/ModelRoamRealTime.js +26 -22
- package/dist/esm/cameraControl/Roam.d.ts +3 -1
- package/dist/esm/cameraControl/Roam.js +17 -13
- package/dist/esm/cameraControl/Rotate.d.ts +3 -1
- package/dist/esm/cameraControl/Rotate.js +29 -25
- package/dist/esm/cameraControl/RotateInPlace.d.ts +3 -1
- package/dist/esm/cameraControl/RotateInPlace.js +22 -19
- package/dist/esm/constant.d.ts +12 -0
- package/dist/esm/constant.js +16 -0
- package/dist/esm/graphicLayer/BaseEntity.d.ts +0 -1
- package/dist/esm/graphicLayer/BaseEntity.js +0 -1
- package/dist/esm/graphicLayer/BaseLayer.d.ts +3 -2
- package/dist/esm/graphicLayer/BaseLayer.js +73 -41
- package/dist/esm/graphicLayer/BasePointPrimitive.d.ts +4 -2
- package/dist/esm/graphicLayer/BasePointPrimitive.js +14 -10
- package/dist/esm/graphicLayer/BasePrimitive.d.ts +3 -5
- package/dist/esm/graphicLayer/BasePrimitive.js +4 -18
- package/dist/esm/graphicLayer/BasePrimitiveInstance.d.ts +1 -2
- package/dist/esm/graphicLayer/BasePrimitiveInstance.js +0 -1
- package/dist/esm/graphicLayer/BaseSource.d.ts +4 -3
- package/dist/esm/graphicLayer/BaseSource.js +28 -11
- package/dist/esm/graphicLayer/BillboardEntity.js +3 -6
- package/dist/esm/graphicLayer/BillboardPrimitive.d.ts +2 -0
- package/dist/esm/graphicLayer/BillboardPrimitive.js +29 -5
- package/dist/esm/graphicLayer/BoxEntity.js +2 -5
- package/dist/esm/graphicLayer/BoxPrimitive.d.ts +2 -2
- package/dist/esm/graphicLayer/BoxPrimitive.js +11 -6
- package/dist/esm/graphicLayer/BoxPrimitiveInstance.js +4 -6
- package/dist/esm/graphicLayer/EllipseEntity.js +2 -5
- package/dist/esm/graphicLayer/EllipsePrimitive.d.ts +1 -1
- package/dist/esm/graphicLayer/EllipsePrimitive.js +9 -4
- package/dist/esm/graphicLayer/EllipsePrimitiveInstance.js +4 -7
- package/dist/esm/graphicLayer/EllipsoidEntity.js +2 -5
- package/dist/esm/graphicLayer/EllipsoidPrimitive.d.ts +1 -1
- package/dist/esm/graphicLayer/EllipsoidPrimitive.js +9 -4
- package/dist/esm/graphicLayer/EllipsoidPrimitiveInstance.js +3 -3
- package/dist/esm/graphicLayer/GraphicLayerCollection.d.ts +9 -7
- package/dist/esm/graphicLayer/GraphicLayerCollection.js +118 -42
- package/dist/esm/graphicLayer/HtmlEntity.js +20 -9
- package/dist/esm/graphicLayer/LabelEntity.js +2 -5
- package/dist/esm/graphicLayer/LabelPrimitive.d.ts +2 -0
- package/dist/esm/graphicLayer/LabelPrimitive.js +31 -8
- package/dist/esm/graphicLayer/ModelEntity.js +2 -5
- package/dist/esm/graphicLayer/ModelPrimitive.d.ts +1 -1
- package/dist/esm/graphicLayer/ModelPrimitive.js +2 -1
- package/dist/esm/graphicLayer/ModelPrimitiveInstance.js +4 -7
- package/dist/esm/graphicLayer/PointEntity.js +2 -5
- package/dist/esm/graphicLayer/PointPrimitive.d.ts +2 -0
- package/dist/esm/graphicLayer/PointPrimitive.js +29 -5
- package/dist/esm/graphicLayer/PolygonEntity.js +4 -7
- package/dist/esm/graphicLayer/PolygonPrimitive.d.ts +2 -2
- package/dist/esm/graphicLayer/PolygonPrimitive.js +11 -6
- package/dist/esm/graphicLayer/PolygonPrimitiveInstance.js +4 -7
- package/dist/esm/graphicLayer/PolylineEntity.js +4 -7
- package/dist/esm/graphicLayer/PolylinePrimitive.d.ts +1 -1
- package/dist/esm/graphicLayer/PolylinePrimitive.js +9 -4
- package/dist/esm/graphicLayer/PolylinePrimitiveInstance.js +3 -3
- package/dist/esm/graphicLayer/PolylineVolumeEntity.js +3 -5
- package/dist/esm/graphicLayer/PolylineVolumePrimitive.d.ts +1 -1
- package/dist/esm/graphicLayer/PolylineVolumePrimitive.js +9 -4
- package/dist/esm/graphicLayer/PolylineVolumePrimitiveInstance.js +4 -7
- package/dist/esm/graphicLayer/WallEntity.js +4 -7
- package/dist/esm/graphicLayer/WallPrimitive.d.ts +1 -1
- package/dist/esm/graphicLayer/WallPrimitive.js +9 -4
- package/dist/esm/graphicLayer/WallPrimitiveInstance.js +4 -7
- package/dist/esm/index.js +1 -1
- package/dist/esm/map/Event.d.ts +4 -2
- package/dist/esm/map/Event.js +57 -32
- package/dist/esm/map/Map.d.ts +6 -1
- package/dist/esm/map/Map.js +14 -4
- package/dist/esm/material/WeatherEffects.d.ts +3 -1
- package/dist/esm/material/WeatherEffects.js +11 -6
- package/dist/esm/tool/common.d.ts +3 -1
- package/dist/esm/tool/common.js +13 -8
- package/dist/esm/tool/utils.d.ts +2 -0
- package/dist/esm/tool/utils.js +10 -0
- package/dist/esm/videoFusion/BaseVideo.d.ts +6 -2
- package/dist/esm/videoFusion/BaseVideo.js +48 -19
- package/dist/esm/videoFusion/VideoProject.js +16 -10
- package/dist/esm/videoFusion/VideoTexture.js +4 -2
- package/dist/esm/visualization/Airspace.d.ts +3 -1
- package/dist/esm/visualization/Airspace.js +27 -12
- package/dist/esm/visualization/BaseFrustum.d.ts +3 -1
- package/dist/esm/visualization/BaseFrustum.js +23 -9
- package/dist/esm/visualization/BaseHeatmap.d.ts +4 -2
- package/dist/esm/visualization/BaseHeatmap.js +22 -12
- package/dist/esm/visualization/Frustum.js +6 -6
- package/dist/esm/visualization/FrustumWithCamera.js +9 -9
- package/dist/esm/visualization/Heatmap2d.js +31 -5
- package/dist/esm/visualization/Heatmap3d.js +21 -4
- package/dist/esm/visualization/PointCluster.d.ts +3 -1
- package/dist/esm/visualization/PointCluster.js +26 -14
- package/dist/umd/deeptwins-engine-3d.min.js +1 -1
- package/package.json +1 -2
|
@@ -1,10 +1,12 @@
|
|
|
1
|
+
import { MapContext } from '../map/Map';
|
|
1
2
|
export default class RotateInPlace {
|
|
3
|
+
_mapContext: MapContext | undefined;
|
|
2
4
|
_timer: any;
|
|
3
|
-
private _map;
|
|
4
5
|
private _eventComplete;
|
|
5
6
|
private _eventCancel;
|
|
6
7
|
private _restAngle;
|
|
7
8
|
constructor(map: any, options?: any);
|
|
9
|
+
getMap(): any;
|
|
8
10
|
start(options: any): void;
|
|
9
11
|
stop(): void;
|
|
10
12
|
destroy(): void;
|
|
@@ -6,13 +6,12 @@ function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key i
|
|
|
6
6
|
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
|
|
7
7
|
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); }
|
|
8
8
|
import * as Cesium from 'deeptwins-cesium';
|
|
9
|
-
|
|
10
9
|
// 镜头原地旋转
|
|
11
10
|
var RotateInPlace = /*#__PURE__*/function () {
|
|
12
11
|
function RotateInPlace(map, options) {
|
|
13
12
|
_classCallCheck(this, RotateInPlace);
|
|
13
|
+
_defineProperty(this, "_mapContext", void 0);
|
|
14
14
|
_defineProperty(this, "_timer", void 0);
|
|
15
|
-
_defineProperty(this, "_map", void 0);
|
|
16
15
|
_defineProperty(this, "_eventComplete", void 0);
|
|
17
16
|
_defineProperty(this, "_eventCancel", void 0);
|
|
18
17
|
_defineProperty(this, "_restAngle", void 0);
|
|
@@ -21,9 +20,14 @@ var RotateInPlace = /*#__PURE__*/function () {
|
|
|
21
20
|
cancel = _ref.cancel;
|
|
22
21
|
complete && (this._eventComplete = complete);
|
|
23
22
|
cancel && (this._eventCancel = cancel);
|
|
24
|
-
this.
|
|
23
|
+
this._mapContext = map._mapContext;
|
|
25
24
|
}
|
|
26
25
|
_createClass(RotateInPlace, [{
|
|
26
|
+
key: "getMap",
|
|
27
|
+
value: function getMap() {
|
|
28
|
+
return this._mapContext && this._mapContext.getMap();
|
|
29
|
+
}
|
|
30
|
+
}, {
|
|
27
31
|
key: "start",
|
|
28
32
|
value: function start(options) {
|
|
29
33
|
var _this = this;
|
|
@@ -35,48 +39,48 @@ var RotateInPlace = /*#__PURE__*/function () {
|
|
|
35
39
|
// 每秒飞行的角度
|
|
36
40
|
var angleOneSecond = 360 / (360 / angle * duration);
|
|
37
41
|
// 倾斜角
|
|
38
|
-
var pitch = this.
|
|
42
|
+
var pitch = this.getMap().camera.pitch;
|
|
39
43
|
|
|
40
44
|
// 开始时间
|
|
41
45
|
var startTime = Cesium.JulianDate.fromDate(new Date());
|
|
42
46
|
// 结束时间
|
|
43
47
|
var stopTime = Cesium.JulianDate.addSeconds(startTime, duration, new Cesium.JulianDate());
|
|
44
|
-
this.
|
|
45
|
-
this.
|
|
46
|
-
this.
|
|
47
|
-
this.
|
|
48
|
-
this.
|
|
48
|
+
this.getMap().clock.startTime = startTime.clone(); // 开始时间
|
|
49
|
+
this.getMap().clock.stopTime = stopTime.clone(); // 结速时间
|
|
50
|
+
this.getMap().clock.currentTime = startTime.clone(); // 当前时间
|
|
51
|
+
this.getMap().clock.clockRange = Cesium.ClockRange.CLAMPED; // 行为方式
|
|
52
|
+
this.getMap().clock.clockStep = Cesium.ClockStep.SYSTEM_CLOCK; // 时钟设置为当前系统时间; 忽略所有其他设置。
|
|
49
53
|
// 相机的当前heading
|
|
50
|
-
var initialHeading = this.
|
|
54
|
+
var initialHeading = this.getMap().camera.heading;
|
|
51
55
|
this._timer = function () {
|
|
52
56
|
// 当前已经过去的时间,单位s
|
|
53
|
-
var delTime = Cesium.JulianDate.secondsDifference(_this.
|
|
57
|
+
var delTime = Cesium.JulianDate.secondsDifference(_this.getMap().clock.currentTime, _this.getMap().clock.startTime);
|
|
54
58
|
// 修改heading
|
|
55
59
|
var heading = Cesium.Math.toRadians(delTime * angleOneSecond) + initialHeading;
|
|
56
60
|
_this._restAngle = angle - Cesium.Math.toDegrees(Cesium.Math.toRadians(delTime * angleOneSecond));
|
|
57
|
-
_this.
|
|
61
|
+
_this.getMap().scene.camera.setView({
|
|
58
62
|
orientation: {
|
|
59
63
|
heading: heading,
|
|
60
64
|
pitch: pitch
|
|
61
65
|
}
|
|
62
66
|
});
|
|
63
|
-
if (Cesium.JulianDate.compare(_this.
|
|
64
|
-
_this.
|
|
67
|
+
if (Cesium.JulianDate.compare(_this.getMap().clock.currentTime, _this.getMap().clock.stopTime) >= 0) {
|
|
68
|
+
_this.getMap().clock.onTick.removeEventListener(_this._timer);
|
|
65
69
|
_this._timer = null;
|
|
66
70
|
if (_this._eventComplete) {
|
|
67
71
|
_this._eventComplete();
|
|
68
72
|
}
|
|
69
73
|
}
|
|
70
74
|
};
|
|
71
|
-
this.
|
|
75
|
+
this.getMap().clock.onTick.addEventListener(this._timer);
|
|
72
76
|
}
|
|
73
77
|
}, {
|
|
74
78
|
key: "stop",
|
|
75
79
|
value: function stop() {
|
|
76
|
-
this._timer && this.
|
|
80
|
+
this._timer && this.getMap().clock.onTick.removeEventListener(this._timer);
|
|
77
81
|
this._timer = null;
|
|
78
82
|
if (this._eventCancel) {
|
|
79
|
-
var time = Cesium.JulianDate.compare(this.
|
|
83
|
+
var time = Cesium.JulianDate.compare(this.getMap().clock.currentTime, this.getMap().clock.stopTime);
|
|
80
84
|
this._eventCancel({
|
|
81
85
|
restTime: time >= 0 ? 0 : time * -1,
|
|
82
86
|
restAngle: this._restAngle <= 0 ? 0 : this._restAngle
|
|
@@ -86,9 +90,8 @@ var RotateInPlace = /*#__PURE__*/function () {
|
|
|
86
90
|
}, {
|
|
87
91
|
key: "destroy",
|
|
88
92
|
value: function destroy() {
|
|
89
|
-
this._timer && this.
|
|
93
|
+
this._timer && this.getMap().clock.onTick.removeEventListener(this._timer);
|
|
90
94
|
this._timer = null;
|
|
91
|
-
this._map = null;
|
|
92
95
|
}
|
|
93
96
|
}]);
|
|
94
97
|
return RotateInPlace;
|
package/dist/esm/constant.d.ts
CHANGED
|
@@ -161,6 +161,18 @@ export declare const LAYER_EVENT_TYPE: {
|
|
|
161
161
|
MIDDLE_CLICK: Cesium.ScreenSpaceEventType;
|
|
162
162
|
MOUSE_MOVE: Cesium.ScreenSpaceEventType;
|
|
163
163
|
};
|
|
164
|
+
export declare const DEFAULT_PRIMITIVE_OPTIONS: () => {
|
|
165
|
+
modelMatrix: Cesium.Matrix4;
|
|
166
|
+
vertexCacheOptimize: boolean;
|
|
167
|
+
interleave: boolean;
|
|
168
|
+
compressVertices: boolean;
|
|
169
|
+
releaseGeometryInstances: boolean;
|
|
170
|
+
allowPicking: boolean;
|
|
171
|
+
cull: boolean;
|
|
172
|
+
asynchronous: boolean;
|
|
173
|
+
debugShowBoundingVolume: boolean;
|
|
174
|
+
shadows: Cesium.ShadowMode;
|
|
175
|
+
};
|
|
164
176
|
export declare const DEFAULT_POINT_OPTIONS: () => {
|
|
165
177
|
show: boolean;
|
|
166
178
|
pixelSize: number;
|
package/dist/esm/constant.js
CHANGED
|
@@ -480,6 +480,22 @@ export var LAYER_EVENT_TYPE = {
|
|
|
480
480
|
MOUSE_MOVE: Cesium.ScreenSpaceEventType.MOUSE_MOVE
|
|
481
481
|
};
|
|
482
482
|
|
|
483
|
+
// primitive默认配置
|
|
484
|
+
export var DEFAULT_PRIMITIVE_OPTIONS = function DEFAULT_PRIMITIVE_OPTIONS() {
|
|
485
|
+
return {
|
|
486
|
+
modelMatrix: Cesium.Matrix4.IDENTITY,
|
|
487
|
+
vertexCacheOptimize: false,
|
|
488
|
+
interleave: false,
|
|
489
|
+
compressVertices: true,
|
|
490
|
+
releaseGeometryInstances: true,
|
|
491
|
+
allowPicking: true,
|
|
492
|
+
cull: true,
|
|
493
|
+
asynchronous: true,
|
|
494
|
+
debugShowBoundingVolume: false,
|
|
495
|
+
shadows: Cesium.ShadowMode.DISABLED
|
|
496
|
+
};
|
|
497
|
+
};
|
|
498
|
+
|
|
483
499
|
// 点的默认配置
|
|
484
500
|
export var DEFAULT_POINT_OPTIONS = function DEFAULT_POINT_OPTIONS() {
|
|
485
501
|
return {
|
|
@@ -15,7 +15,6 @@ var BaseEntity = /*#__PURE__*/function () {
|
|
|
15
15
|
_defineProperty(this, "id", void 0);
|
|
16
16
|
_defineProperty(this, "source", void 0);
|
|
17
17
|
_defineProperty(this, "style", void 0);
|
|
18
|
-
_defineProperty(this, "graphic", void 0);
|
|
19
18
|
_defineProperty(this, "entity", void 0);
|
|
20
19
|
_defineProperty(this, "positionProperty", void 0);
|
|
21
20
|
_defineProperty(this, "type", void 0);
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
export default class BaseLayer {
|
|
2
|
+
private readonly _mapContext;
|
|
2
3
|
id: any;
|
|
3
4
|
type: any;
|
|
4
5
|
options: any;
|
|
@@ -10,8 +11,8 @@ export default class BaseLayer {
|
|
|
10
11
|
isPrimitive: boolean;
|
|
11
12
|
private _isCompleteInfo;
|
|
12
13
|
private readonly _renderClass;
|
|
13
|
-
|
|
14
|
-
|
|
14
|
+
constructor({ id, source, options, entity, mapContext }: any);
|
|
15
|
+
getMap(): any;
|
|
15
16
|
private _createPrimitiveCollection;
|
|
16
17
|
private _createEntity;
|
|
17
18
|
private _createPrimitive;
|
|
@@ -13,7 +13,6 @@ import { v4 as uuidv4 } from 'uuid';
|
|
|
13
13
|
import * as constant from "../constant";
|
|
14
14
|
import BaseSource from "../graphicLayer/BaseSource";
|
|
15
15
|
import * as utils from "../tool/utils";
|
|
16
|
-
import { cameraFlyToPositions } from "../tool/utils";
|
|
17
16
|
import BoxPrimitive from "./BoxPrimitive";
|
|
18
17
|
import EllipsePrimitive from "./EllipsePrimitive";
|
|
19
18
|
import EllipsoidPrimitive from "./EllipsoidPrimitive";
|
|
@@ -23,14 +22,17 @@ import PolylinePrimitive from "./PolylinePrimitive";
|
|
|
23
22
|
import PolylineVolumePrimitive from "./PolylineVolumePrimitive";
|
|
24
23
|
import WallPrimitive from "./WallPrimitive";
|
|
25
24
|
var BaseLayer = /*#__PURE__*/function () {
|
|
25
|
+
// 处理类的函数
|
|
26
|
+
|
|
26
27
|
function BaseLayer(_ref) {
|
|
27
28
|
var _this = this;
|
|
28
29
|
var id = _ref.id,
|
|
29
30
|
source = _ref.source,
|
|
30
31
|
options = _ref.options,
|
|
31
32
|
entity = _ref.entity,
|
|
32
|
-
|
|
33
|
+
mapContext = _ref.mapContext;
|
|
33
34
|
_classCallCheck(this, BaseLayer);
|
|
35
|
+
_defineProperty(this, "_mapContext", void 0);
|
|
34
36
|
_defineProperty(this, "id", void 0);
|
|
35
37
|
_defineProperty(this, "type", void 0);
|
|
36
38
|
_defineProperty(this, "options", void 0);
|
|
@@ -44,16 +46,15 @@ var BaseLayer = /*#__PURE__*/function () {
|
|
|
44
46
|
// 是否是完整的信息
|
|
45
47
|
_defineProperty(this, "_isCompleteInfo", true);
|
|
46
48
|
_defineProperty(this, "_renderClass", void 0);
|
|
47
|
-
// 处理类的函数
|
|
48
|
-
_defineProperty(this, "_graphicLayerCollection", void 0);
|
|
49
49
|
if (!(options !== null && options !== void 0 && options.type)) {
|
|
50
|
-
|
|
50
|
+
utils.error('请传入type参数');
|
|
51
|
+
return;
|
|
51
52
|
}
|
|
53
|
+
this._mapContext = mapContext;
|
|
52
54
|
this.id = id;
|
|
53
55
|
this.type = options.type;
|
|
54
56
|
this.options = options;
|
|
55
57
|
this.sourceId = source === null || source === void 0 ? void 0 : source.id;
|
|
56
|
-
this._graphicLayerCollection = graphicLayerCollection;
|
|
57
58
|
this._renderClass = constant.GRAPHIC_LAYER_TYPE_TO_CLASS[options.type];
|
|
58
59
|
if (entity) {
|
|
59
60
|
// 添加的是entity对象
|
|
@@ -68,12 +69,14 @@ var BaseLayer = /*#__PURE__*/function () {
|
|
|
68
69
|
this.isPrimitive = true;
|
|
69
70
|
// 创建集合
|
|
70
71
|
this._createPrimitiveCollection(options.type);
|
|
72
|
+
// 实例的集合
|
|
73
|
+
var primitiveInstance = [];
|
|
71
74
|
source.source.forEach(function (t) {
|
|
72
|
-
_this._createPrimitive(t, options);
|
|
75
|
+
_this._createPrimitive(t, options, primitiveInstance);
|
|
73
76
|
});
|
|
74
77
|
if (!['pointP', 'billboardP', 'labelP'].includes(options.type)) {
|
|
75
78
|
// 集合创建Primitive
|
|
76
|
-
this.primitiveCollection.createPrimitive(options);
|
|
79
|
+
this.primitiveCollection.createPrimitive(options, primitiveInstance);
|
|
77
80
|
}
|
|
78
81
|
} else {
|
|
79
82
|
// entity类型
|
|
@@ -83,9 +86,14 @@ var BaseLayer = /*#__PURE__*/function () {
|
|
|
83
86
|
});
|
|
84
87
|
}
|
|
85
88
|
}
|
|
86
|
-
|
|
87
|
-
// 根据类型创建不同的集合
|
|
88
89
|
_createClass(BaseLayer, [{
|
|
90
|
+
key: "getMap",
|
|
91
|
+
value: function getMap() {
|
|
92
|
+
return this._mapContext && this._mapContext.getMap();
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
// 根据类型创建不同的集合
|
|
96
|
+
}, {
|
|
89
97
|
key: "_createPrimitiveCollection",
|
|
90
98
|
value: function _createPrimitiveCollection(type) {
|
|
91
99
|
var _this2 = this,
|
|
@@ -95,34 +103,34 @@ var BaseLayer = /*#__PURE__*/function () {
|
|
|
95
103
|
_this2.primitiveCollection = new Cesium.PointPrimitiveCollection();
|
|
96
104
|
},
|
|
97
105
|
polylineP: function polylineP() {
|
|
98
|
-
_this2.primitiveCollection = new PolylinePrimitive(_this2.
|
|
106
|
+
_this2.primitiveCollection = new PolylinePrimitive(_this2._mapContext);
|
|
99
107
|
},
|
|
100
108
|
polygonP: function polygonP() {
|
|
101
|
-
_this2.primitiveCollection = new PolygonPrimitive(_this2.
|
|
109
|
+
_this2.primitiveCollection = new PolygonPrimitive(_this2._mapContext);
|
|
102
110
|
},
|
|
103
111
|
boxP: function boxP() {
|
|
104
|
-
_this2.primitiveCollection = new BoxPrimitive(_this2.
|
|
112
|
+
_this2.primitiveCollection = new BoxPrimitive(_this2._mapContext);
|
|
105
113
|
},
|
|
106
114
|
billboardP: function billboardP() {
|
|
107
115
|
_this2.primitiveCollection = new Cesium.BillboardCollection();
|
|
108
116
|
},
|
|
109
117
|
modelP: function modelP() {
|
|
110
|
-
_this2.primitiveCollection = new ModelPrimitive(_this2.
|
|
118
|
+
_this2.primitiveCollection = new ModelPrimitive(_this2._mapContext);
|
|
111
119
|
},
|
|
112
120
|
labelP: function labelP() {
|
|
113
121
|
_this2.primitiveCollection = new Cesium.LabelCollection();
|
|
114
122
|
},
|
|
115
123
|
wallP: function wallP() {
|
|
116
|
-
_this2.primitiveCollection = new WallPrimitive(_this2.
|
|
124
|
+
_this2.primitiveCollection = new WallPrimitive(_this2._mapContext);
|
|
117
125
|
},
|
|
118
126
|
polylineVolumeP: function polylineVolumeP() {
|
|
119
|
-
_this2.primitiveCollection = new PolylineVolumePrimitive(_this2.
|
|
127
|
+
_this2.primitiveCollection = new PolylineVolumePrimitive(_this2._mapContext);
|
|
120
128
|
},
|
|
121
129
|
ellipseP: function ellipseP() {
|
|
122
|
-
_this2.primitiveCollection = new EllipsePrimitive(_this2.
|
|
130
|
+
_this2.primitiveCollection = new EllipsePrimitive(_this2._mapContext);
|
|
123
131
|
},
|
|
124
132
|
ellipsoidP: function ellipsoidP() {
|
|
125
|
-
_this2.primitiveCollection = new EllipsoidPrimitive(_this2.
|
|
133
|
+
_this2.primitiveCollection = new EllipsoidPrimitive(_this2._mapContext);
|
|
126
134
|
}
|
|
127
135
|
};
|
|
128
136
|
(_createType$type = createType[type]) === null || _createType$type === void 0 || _createType$type.call(createType);
|
|
@@ -133,7 +141,7 @@ var BaseLayer = /*#__PURE__*/function () {
|
|
|
133
141
|
key: "_createEntity",
|
|
134
142
|
value: function _createEntity(data, options) {
|
|
135
143
|
var layer = new this._renderClass(_objectSpread(_objectSpread(_objectSpread({
|
|
136
|
-
map: this.
|
|
144
|
+
map: this.getMap()
|
|
137
145
|
}, data), options), {}, {
|
|
138
146
|
html: utils.isFunction(options.html) ? options.html(data.properties) : options.html,
|
|
139
147
|
source: data,
|
|
@@ -146,14 +154,16 @@ var BaseLayer = /*#__PURE__*/function () {
|
|
|
146
154
|
// 创建相应的primitive
|
|
147
155
|
}, {
|
|
148
156
|
key: "_createPrimitive",
|
|
149
|
-
value: function _createPrimitive(data, options) {
|
|
157
|
+
value: function _createPrimitive(data, options, primitiveInstance) {
|
|
150
158
|
var layer = new this._renderClass(_objectSpread(_objectSpread(_objectSpread({}, data), options), {}, {
|
|
151
159
|
source: data,
|
|
152
160
|
style: utils.styleFun(cloneDeep(options.style || {}), data.properties),
|
|
153
|
-
|
|
161
|
+
primitiveInstance: primitiveInstance,
|
|
162
|
+
primitiveCollection: this.primitiveCollection,
|
|
163
|
+
layerId: this.id,
|
|
164
|
+
mapContext: this._mapContext
|
|
154
165
|
}));
|
|
155
166
|
this.layers.push(layer);
|
|
156
|
-
return layer;
|
|
157
167
|
}
|
|
158
168
|
|
|
159
169
|
// 是否能进行操作
|
|
@@ -161,15 +171,19 @@ var BaseLayer = /*#__PURE__*/function () {
|
|
|
161
171
|
key: "_canOperate",
|
|
162
172
|
value: function _canOperate() {
|
|
163
173
|
if (this.isDestroyed) {
|
|
164
|
-
|
|
174
|
+
utils.error('BaseLayer实例已销毁');
|
|
175
|
+
return false;
|
|
165
176
|
}
|
|
177
|
+
return true;
|
|
166
178
|
}
|
|
167
179
|
|
|
168
180
|
// 显示隐藏
|
|
169
181
|
}, {
|
|
170
182
|
key: "show",
|
|
171
183
|
value: function show(isShow) {
|
|
172
|
-
this._canOperate()
|
|
184
|
+
if (!this._canOperate()) {
|
|
185
|
+
return;
|
|
186
|
+
}
|
|
173
187
|
if (this.isEntity) {
|
|
174
188
|
if (this.type === 'html') {
|
|
175
189
|
this.layers.forEach(function (t) {
|
|
@@ -199,7 +213,9 @@ var BaseLayer = /*#__PURE__*/function () {
|
|
|
199
213
|
key: "setStyle",
|
|
200
214
|
value: function setStyle(style) {
|
|
201
215
|
var _this3 = this;
|
|
202
|
-
this._canOperate()
|
|
216
|
+
if (!this._canOperate()) {
|
|
217
|
+
return;
|
|
218
|
+
}
|
|
203
219
|
this.layers.forEach(function (t) {
|
|
204
220
|
var originStyle = utils.styleFun(style, t.source.properties);
|
|
205
221
|
var handleStyle = _this3._renderClass.handleOptions(originStyle);
|
|
@@ -211,7 +227,9 @@ var BaseLayer = /*#__PURE__*/function () {
|
|
|
211
227
|
}, {
|
|
212
228
|
key: "setStyleOne",
|
|
213
229
|
value: function setStyleOne(layer, style) {
|
|
214
|
-
this._canOperate()
|
|
230
|
+
if (!this._canOperate()) {
|
|
231
|
+
return;
|
|
232
|
+
}
|
|
215
233
|
var currLayer = this._getOne(layer);
|
|
216
234
|
if (currLayer) {
|
|
217
235
|
var originStyle = utils.styleFun(style, currLayer.source.properties);
|
|
@@ -224,32 +242,41 @@ var BaseLayer = /*#__PURE__*/function () {
|
|
|
224
242
|
}, {
|
|
225
243
|
key: "setData",
|
|
226
244
|
value: function setData(data) {
|
|
227
|
-
this._canOperate()
|
|
245
|
+
if (!this._canOperate()) {
|
|
246
|
+
return;
|
|
247
|
+
}
|
|
248
|
+
// 获取数据源
|
|
228
249
|
var source = null;
|
|
229
250
|
var sourceType = BaseSource.analysisSourceType(data);
|
|
230
251
|
if (sourceType === 'sourceInstance') {
|
|
231
252
|
source = data;
|
|
232
253
|
} else if (sourceType === 'sourceId') {
|
|
233
|
-
source = this.
|
|
254
|
+
source = this.getMap().graphicLayerCollection.graphicSources.get(data);
|
|
234
255
|
} else {
|
|
235
|
-
source = this.
|
|
256
|
+
source = this.getMap().graphicLayerCollection.addSource(uuidv4(), data);
|
|
236
257
|
}
|
|
237
258
|
this.sourceId = source.id;
|
|
259
|
+
// 移除多余的
|
|
238
260
|
if (source.source.length < this.layers.length) {
|
|
239
|
-
|
|
261
|
+
var startIndex = this.layers.length - 1;
|
|
262
|
+
for (var i = startIndex; i >= source.source.length; i--) {
|
|
240
263
|
this.removeOne(this.layers[i]);
|
|
241
264
|
}
|
|
242
265
|
}
|
|
266
|
+
// 实例的集合
|
|
267
|
+
var primitiveInstance = [];
|
|
243
268
|
for (var _i = 0; _i < source.source.length; _i++) {
|
|
244
269
|
var sourceData = source.source[_i];
|
|
245
270
|
if (this.layers[_i]) {
|
|
271
|
+
// 更新数据
|
|
246
272
|
this.layers[_i].updateData(sourceData);
|
|
247
273
|
} else {
|
|
274
|
+
// 创建数据
|
|
248
275
|
if (this.isEntity) {
|
|
249
276
|
var layer = this._createEntity(sourceData, this.options);
|
|
250
|
-
layer.entity && this.
|
|
277
|
+
layer.entity && this.getMap().entities.add(layer.entity);
|
|
251
278
|
} else {
|
|
252
|
-
this._createPrimitive(sourceData, this.options);
|
|
279
|
+
this._createPrimitive(sourceData, this.options, primitiveInstance);
|
|
253
280
|
}
|
|
254
281
|
}
|
|
255
282
|
}
|
|
@@ -260,7 +287,9 @@ var BaseLayer = /*#__PURE__*/function () {
|
|
|
260
287
|
key: "remove",
|
|
261
288
|
value: function remove() {
|
|
262
289
|
var _this4 = this;
|
|
263
|
-
this._canOperate()
|
|
290
|
+
if (!this._canOperate()) {
|
|
291
|
+
return;
|
|
292
|
+
}
|
|
264
293
|
this.isDestroyed = true;
|
|
265
294
|
if (this.isEntity) {
|
|
266
295
|
if (this.type === 'html') {
|
|
@@ -269,30 +298,32 @@ var BaseLayer = /*#__PURE__*/function () {
|
|
|
269
298
|
});
|
|
270
299
|
} else {
|
|
271
300
|
this.layers.forEach(function (t) {
|
|
272
|
-
_this4.
|
|
301
|
+
_this4.getMap().entities.remove(t.entity);
|
|
273
302
|
});
|
|
274
303
|
}
|
|
275
304
|
} else {
|
|
276
305
|
this.primitiveCollection.removeAll();
|
|
277
|
-
this.
|
|
306
|
+
this.getMap().scene.primitives.remove(this.primitiveCollection);
|
|
278
307
|
}
|
|
279
308
|
this.layers = [];
|
|
280
309
|
// 移除相应的graphicLayers上的数据
|
|
281
|
-
this.
|
|
310
|
+
this.getMap().graphicLayerCollection._removeGraphicMapLayer(this.id);
|
|
282
311
|
}
|
|
283
312
|
|
|
284
313
|
// 清除图层中某个
|
|
285
314
|
}, {
|
|
286
315
|
key: "removeOne",
|
|
287
316
|
value: function removeOne(layer) {
|
|
288
|
-
this._canOperate()
|
|
317
|
+
if (!this._canOperate()) {
|
|
318
|
+
return;
|
|
319
|
+
}
|
|
289
320
|
var currLayer = this._getOne(layer);
|
|
290
321
|
if (currLayer) {
|
|
291
322
|
if (this.isEntity) {
|
|
292
323
|
if (this.type === 'html') {
|
|
293
324
|
currLayer.remove();
|
|
294
325
|
} else {
|
|
295
|
-
this.
|
|
326
|
+
this.getMap().entities.remove(currLayer.entity);
|
|
296
327
|
}
|
|
297
328
|
} else {
|
|
298
329
|
this.primitiveCollection.remove(currLayer.primitive);
|
|
@@ -312,18 +343,18 @@ var BaseLayer = /*#__PURE__*/function () {
|
|
|
312
343
|
return;
|
|
313
344
|
}
|
|
314
345
|
// 计算包围球
|
|
315
|
-
var camera = this.
|
|
346
|
+
var camera = this.getMap().camera;
|
|
316
347
|
var positions = flattenDeep(this.layers.map(function (t) {
|
|
317
348
|
return t.source.positions;
|
|
318
349
|
}));
|
|
319
|
-
cameraFlyToPositions(camera, positions, options);
|
|
350
|
+
utils.cameraFlyToPositions(camera, positions, options);
|
|
320
351
|
}
|
|
321
352
|
|
|
322
353
|
// 监听
|
|
323
354
|
}, {
|
|
324
355
|
key: "on",
|
|
325
356
|
value: function on(type, event) {
|
|
326
|
-
return this.
|
|
357
|
+
return this.getMap()._event.listenToLayer(type, event, this);
|
|
327
358
|
}
|
|
328
359
|
|
|
329
360
|
// 改成销毁状态
|
|
@@ -333,6 +364,7 @@ var BaseLayer = /*#__PURE__*/function () {
|
|
|
333
364
|
this.isDestroyed = true;
|
|
334
365
|
this.layers = [];
|
|
335
366
|
this.primitiveCollection && this.primitiveCollection.removeAll();
|
|
367
|
+
this.primitiveCollection = null;
|
|
336
368
|
}
|
|
337
369
|
}]);
|
|
338
370
|
return BaseLayer;
|
|
@@ -1,10 +1,12 @@
|
|
|
1
|
+
import { MapContext } from '../map/Map';
|
|
1
2
|
export default class BasePointPrimitive {
|
|
3
|
+
readonly _mapContext: MapContext;
|
|
4
|
+
_layerId: null;
|
|
2
5
|
id: any;
|
|
3
6
|
source: any;
|
|
4
7
|
style: any;
|
|
5
|
-
primitive: any;
|
|
6
8
|
type: string;
|
|
7
9
|
isPrimitive: boolean;
|
|
8
10
|
constructor(options: any);
|
|
9
|
-
|
|
11
|
+
getPrimitiveCollection(): any;
|
|
10
12
|
}
|
|
@@ -5,35 +5,39 @@ function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _d
|
|
|
5
5
|
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; }
|
|
6
6
|
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
|
|
7
7
|
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); }
|
|
8
|
-
import { merge } from 'lodash';
|
|
9
8
|
import { v4 as uuidv4 } from 'uuid';
|
|
10
|
-
|
|
11
9
|
// 基础Primitive图层
|
|
12
10
|
var BasePointPrimitive = /*#__PURE__*/function () {
|
|
13
11
|
function BasePointPrimitive(options) {
|
|
14
12
|
_classCallCheck(this, BasePointPrimitive);
|
|
13
|
+
_defineProperty(this, "_mapContext", void 0);
|
|
14
|
+
_defineProperty(this, "_layerId", null);
|
|
15
15
|
_defineProperty(this, "id", void 0);
|
|
16
16
|
_defineProperty(this, "source", void 0);
|
|
17
17
|
_defineProperty(this, "style", void 0);
|
|
18
|
-
_defineProperty(this, "primitive", void 0);
|
|
19
18
|
_defineProperty(this, "type", void 0);
|
|
20
19
|
_defineProperty(this, "isPrimitive", true);
|
|
21
20
|
this.id = uuidv4();
|
|
22
21
|
var style = options.style,
|
|
23
|
-
source = options.source
|
|
22
|
+
source = options.source,
|
|
23
|
+
layerId = options.layerId,
|
|
24
|
+
mapContext = options.mapContext;
|
|
25
|
+
this._layerId = layerId;
|
|
26
|
+
this._mapContext = mapContext;
|
|
24
27
|
this.type = options.type;
|
|
25
28
|
this.source = source;
|
|
26
29
|
this.style = style || {};
|
|
27
30
|
}
|
|
28
31
|
|
|
29
|
-
//
|
|
32
|
+
// 获取primitive集合
|
|
30
33
|
_createClass(BasePointPrimitive, [{
|
|
31
|
-
key: "
|
|
32
|
-
value: function
|
|
33
|
-
this.
|
|
34
|
-
|
|
35
|
-
this.primitive[key] = style[key];
|
|
34
|
+
key: "getPrimitiveCollection",
|
|
35
|
+
value: function getPrimitiveCollection() {
|
|
36
|
+
if (!this._mapContext || !this._layerId) {
|
|
37
|
+
return null;
|
|
36
38
|
}
|
|
39
|
+
var layer = this._mapContext.getMap().graphicLayerCollection.graphicLayers.get(this._layerId);
|
|
40
|
+
return layer === null || layer === void 0 ? void 0 : layer.primitiveCollection;
|
|
37
41
|
}
|
|
38
42
|
}]);
|
|
39
43
|
return BasePointPrimitive;
|
|
@@ -1,12 +1,10 @@
|
|
|
1
|
+
import { MapContext } from '../map/Map';
|
|
1
2
|
export default class BasePrimitive {
|
|
2
|
-
|
|
3
|
+
private readonly _mapContext;
|
|
3
4
|
primitive: any;
|
|
4
5
|
id: any;
|
|
5
|
-
|
|
6
|
-
constructor(map: any);
|
|
6
|
+
constructor(mapContext: MapContext);
|
|
7
7
|
get show(): any;
|
|
8
8
|
set show(v: any);
|
|
9
|
-
add(instance: any): void;
|
|
10
|
-
remove(): void;
|
|
11
9
|
removeAll(): void;
|
|
12
10
|
}
|
|
@@ -7,14 +7,13 @@ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol"
|
|
|
7
7
|
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); }
|
|
8
8
|
import { v4 as uuidv4 } from 'uuid';
|
|
9
9
|
var BasePrimitive = /*#__PURE__*/function () {
|
|
10
|
-
function BasePrimitive(
|
|
10
|
+
function BasePrimitive(mapContext) {
|
|
11
11
|
_classCallCheck(this, BasePrimitive);
|
|
12
|
-
_defineProperty(this, "
|
|
12
|
+
_defineProperty(this, "_mapContext", void 0);
|
|
13
13
|
_defineProperty(this, "primitive", void 0);
|
|
14
14
|
_defineProperty(this, "id", void 0);
|
|
15
|
-
_defineProperty(this, "map", void 0);
|
|
16
15
|
this.id = uuidv4();
|
|
17
|
-
this.
|
|
16
|
+
this._mapContext = mapContext;
|
|
18
17
|
}
|
|
19
18
|
_createClass(BasePrimitive, [{
|
|
20
19
|
key: "show",
|
|
@@ -25,24 +24,11 @@ var BasePrimitive = /*#__PURE__*/function () {
|
|
|
25
24
|
set: function set(v) {
|
|
26
25
|
this.primitive && (this.primitive.show = v);
|
|
27
26
|
}
|
|
28
|
-
}, {
|
|
29
|
-
key: "add",
|
|
30
|
-
value: function add(instance) {
|
|
31
|
-
this.primitiveInstance.push(instance);
|
|
32
|
-
}
|
|
33
|
-
}, {
|
|
34
|
-
key: "remove",
|
|
35
|
-
value: function remove() {
|
|
36
|
-
if (this.primitive) {
|
|
37
|
-
console.warn('primitive类型不支持删除单个对象');
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
27
|
}, {
|
|
41
28
|
key: "removeAll",
|
|
42
29
|
value: function removeAll() {
|
|
43
|
-
this.primitive && this.
|
|
30
|
+
this.primitive && this._mapContext.getMap().scene.primitives.remove(this.primitive);
|
|
44
31
|
this.primitive = null;
|
|
45
|
-
this.primitiveInstance = [];
|
|
46
32
|
}
|
|
47
33
|
}]);
|
|
48
34
|
return BasePrimitive;
|
|
@@ -14,7 +14,6 @@ var BasePrimitiveInstance = /*#__PURE__*/function () {
|
|
|
14
14
|
_defineProperty(this, "id", void 0);
|
|
15
15
|
_defineProperty(this, "source", void 0);
|
|
16
16
|
_defineProperty(this, "style", void 0);
|
|
17
|
-
_defineProperty(this, "instance", void 0);
|
|
18
17
|
_defineProperty(this, "type", void 0);
|
|
19
18
|
_defineProperty(this, "isPrimitive", true);
|
|
20
19
|
this.id = uuidv4();
|