deeptwins-engine-3d 0.1.8 → 0.1.10
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 +19 -14
- 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
|
@@ -11,44 +11,52 @@ function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e
|
|
|
11
11
|
import { flattenDeep } from 'lodash';
|
|
12
12
|
import { v4 as uuidv4 } from 'uuid';
|
|
13
13
|
import * as utils from "../tool/utils";
|
|
14
|
-
import { cameraFlyToPositions, isArray } from "../tool/utils";
|
|
15
14
|
import BaseLayer from "./BaseLayer";
|
|
16
15
|
import BaseSource from "./BaseSource";
|
|
17
16
|
var GraphicLayerCollection = /*#__PURE__*/function () {
|
|
18
|
-
function GraphicLayerCollection(
|
|
17
|
+
function GraphicLayerCollection(mapContext) {
|
|
19
18
|
_classCallCheck(this, GraphicLayerCollection);
|
|
20
|
-
_defineProperty(this, "
|
|
21
|
-
_defineProperty(this, "
|
|
19
|
+
_defineProperty(this, "_mapContext", void 0);
|
|
20
|
+
_defineProperty(this, "isDestroyed", false);
|
|
22
21
|
// @ts-ignore
|
|
23
22
|
_defineProperty(this, "graphicLayers", new Map());
|
|
24
23
|
// @ts-ignore
|
|
25
24
|
_defineProperty(this, "graphicSources", new Map());
|
|
26
|
-
this.
|
|
25
|
+
this._mapContext = mapContext;
|
|
27
26
|
}
|
|
28
27
|
|
|
29
28
|
// 是否能进行操作
|
|
30
29
|
_createClass(GraphicLayerCollection, [{
|
|
31
30
|
key: "_canOperate",
|
|
32
31
|
value: function _canOperate() {
|
|
33
|
-
if (this.
|
|
34
|
-
|
|
32
|
+
if (this.isDestroyed) {
|
|
33
|
+
utils.error('GraphicLayerCollection实例已销毁');
|
|
34
|
+
return false;
|
|
35
35
|
}
|
|
36
|
+
return true;
|
|
37
|
+
}
|
|
38
|
+
}, {
|
|
39
|
+
key: "getMap",
|
|
40
|
+
value: function getMap() {
|
|
41
|
+
return this._mapContext && this._mapContext.getMap();
|
|
36
42
|
}
|
|
37
43
|
|
|
38
44
|
// 添加数据
|
|
39
45
|
}, {
|
|
40
46
|
key: "addSource",
|
|
41
47
|
value: function addSource(id, geoJson) {
|
|
42
|
-
this._canOperate()
|
|
48
|
+
if (!this._canOperate()) {
|
|
49
|
+
return;
|
|
50
|
+
}
|
|
43
51
|
var uuid = id;
|
|
44
52
|
if (this.graphicSources.get(uuid)) {
|
|
45
|
-
|
|
53
|
+
utils.warn("id".concat(uuid, "\u5DF2\u7ECF\u5B58\u5728\uFF0C\u5DF2\u81EA\u52A8\u751F\u6210\u968F\u673Aid"));
|
|
46
54
|
uuid = uuidv4();
|
|
47
55
|
}
|
|
48
56
|
var source = new BaseSource({
|
|
49
57
|
id: uuid,
|
|
50
58
|
source: geoJson,
|
|
51
|
-
|
|
59
|
+
mapContext: this._mapContext
|
|
52
60
|
});
|
|
53
61
|
this.graphicSources.set(source.id, source);
|
|
54
62
|
return source;
|
|
@@ -58,16 +66,18 @@ var GraphicLayerCollection = /*#__PURE__*/function () {
|
|
|
58
66
|
}, {
|
|
59
67
|
key: "addCustomSource",
|
|
60
68
|
value: function addCustomSource(id, positions) {
|
|
61
|
-
this._canOperate()
|
|
69
|
+
if (!this._canOperate()) {
|
|
70
|
+
return;
|
|
71
|
+
}
|
|
62
72
|
var uuid = id;
|
|
63
73
|
if (this.graphicSources.get(uuid)) {
|
|
64
|
-
|
|
74
|
+
utils.warn("id".concat(uuid, "\u5DF2\u7ECF\u5B58\u5728\uFF0C\u5DF2\u81EA\u52A8\u751F\u6210\u968F\u673Aid"));
|
|
65
75
|
uuid = uuidv4();
|
|
66
76
|
}
|
|
67
77
|
var source = new BaseSource({
|
|
68
78
|
id: uuid,
|
|
69
79
|
customSource: positions,
|
|
70
|
-
|
|
80
|
+
mapContext: this._mapContext
|
|
71
81
|
});
|
|
72
82
|
this.graphicSources.set(source.id, source);
|
|
73
83
|
return source;
|
|
@@ -77,7 +87,9 @@ var GraphicLayerCollection = /*#__PURE__*/function () {
|
|
|
77
87
|
}, {
|
|
78
88
|
key: "addLayer",
|
|
79
89
|
value: function addLayer(data, options) {
|
|
80
|
-
this._canOperate()
|
|
90
|
+
if (!this._canOperate()) {
|
|
91
|
+
return;
|
|
92
|
+
}
|
|
81
93
|
var _ref = options || {},
|
|
82
94
|
id = _ref.id;
|
|
83
95
|
var uuid = id ? String(id) : uuidv4();
|
|
@@ -99,7 +111,7 @@ var GraphicLayerCollection = /*#__PURE__*/function () {
|
|
|
99
111
|
id: uuid,
|
|
100
112
|
source: source,
|
|
101
113
|
options: options,
|
|
102
|
-
|
|
114
|
+
mapContext: this._mapContext
|
|
103
115
|
});
|
|
104
116
|
// 添加到地图上
|
|
105
117
|
this._addLayerToMap(layer, options);
|
|
@@ -110,7 +122,9 @@ var GraphicLayerCollection = /*#__PURE__*/function () {
|
|
|
110
122
|
}, {
|
|
111
123
|
key: "addCustomSourceToLayer",
|
|
112
124
|
value: function addCustomSourceToLayer(positions, options) {
|
|
113
|
-
this._canOperate()
|
|
125
|
+
if (!this._canOperate()) {
|
|
126
|
+
return;
|
|
127
|
+
}
|
|
114
128
|
var uuid = uuidv4();
|
|
115
129
|
var source = this.addCustomSource(uuid, positions);
|
|
116
130
|
// 生成graphicLayer
|
|
@@ -118,7 +132,7 @@ var GraphicLayerCollection = /*#__PURE__*/function () {
|
|
|
118
132
|
id: uuid,
|
|
119
133
|
source: source,
|
|
120
134
|
options: options,
|
|
121
|
-
|
|
135
|
+
mapContext: this._mapContext
|
|
122
136
|
});
|
|
123
137
|
// 添加到地图上
|
|
124
138
|
this._addLayerToMap(layer, options);
|
|
@@ -133,14 +147,14 @@ var GraphicLayerCollection = /*#__PURE__*/function () {
|
|
|
133
147
|
if (layer.isEntity) {
|
|
134
148
|
layer.layers.forEach(function (t) {
|
|
135
149
|
if (t.entity) {
|
|
136
|
-
_this.
|
|
150
|
+
_this.getMap().entities.add(t.entity);
|
|
137
151
|
}
|
|
138
152
|
});
|
|
139
153
|
} else {
|
|
140
154
|
if (['pointP', 'billboardP', 'labelP'].includes(options.type)) {
|
|
141
|
-
this.
|
|
155
|
+
this.getMap().scene.primitives.add(layer.primitiveCollection);
|
|
142
156
|
} else {
|
|
143
|
-
this.
|
|
157
|
+
this.getMap().scene.primitives.add(layer.primitiveCollection.primitive);
|
|
144
158
|
}
|
|
145
159
|
}
|
|
146
160
|
this.graphicLayers.set(layer.id, layer);
|
|
@@ -150,7 +164,9 @@ var GraphicLayerCollection = /*#__PURE__*/function () {
|
|
|
150
164
|
}, {
|
|
151
165
|
key: "_removeGraphicMapLayer",
|
|
152
166
|
value: function _removeGraphicMapLayer(layerId) {
|
|
153
|
-
this._canOperate()
|
|
167
|
+
if (!this._canOperate()) {
|
|
168
|
+
return;
|
|
169
|
+
}
|
|
154
170
|
this.graphicLayers.delete(layerId);
|
|
155
171
|
}
|
|
156
172
|
|
|
@@ -158,7 +174,9 @@ var GraphicLayerCollection = /*#__PURE__*/function () {
|
|
|
158
174
|
}, {
|
|
159
175
|
key: "_removeGraphicMapSource",
|
|
160
176
|
value: function _removeGraphicMapSource(sourceId) {
|
|
161
|
-
this._canOperate()
|
|
177
|
+
if (!this._canOperate()) {
|
|
178
|
+
return;
|
|
179
|
+
}
|
|
162
180
|
this.graphicSources.delete(sourceId);
|
|
163
181
|
var graphicValues = this.graphicLayers.values();
|
|
164
182
|
var _iterator = _createForOfIteratorHelper(graphicValues),
|
|
@@ -181,7 +199,9 @@ var GraphicLayerCollection = /*#__PURE__*/function () {
|
|
|
181
199
|
}, {
|
|
182
200
|
key: "_clearGraphicMapLayer",
|
|
183
201
|
value: function _clearGraphicMapLayer() {
|
|
184
|
-
this._canOperate()
|
|
202
|
+
if (!this._canOperate()) {
|
|
203
|
+
return;
|
|
204
|
+
}
|
|
185
205
|
this.graphicLayers.clear();
|
|
186
206
|
}
|
|
187
207
|
|
|
@@ -189,7 +209,9 @@ var GraphicLayerCollection = /*#__PURE__*/function () {
|
|
|
189
209
|
}, {
|
|
190
210
|
key: "_clearGraphicMapSource",
|
|
191
211
|
value: function _clearGraphicMapSource() {
|
|
192
|
-
this._canOperate()
|
|
212
|
+
if (!this._canOperate()) {
|
|
213
|
+
return;
|
|
214
|
+
}
|
|
193
215
|
this.graphicSources.clear();
|
|
194
216
|
}
|
|
195
217
|
|
|
@@ -197,7 +219,9 @@ var GraphicLayerCollection = /*#__PURE__*/function () {
|
|
|
197
219
|
}, {
|
|
198
220
|
key: "getLayer",
|
|
199
221
|
value: function getLayer(id) {
|
|
200
|
-
this._canOperate()
|
|
222
|
+
if (!this._canOperate()) {
|
|
223
|
+
return;
|
|
224
|
+
}
|
|
201
225
|
return utils.isString(id) ? this.graphicLayers.get(id) : id;
|
|
202
226
|
}
|
|
203
227
|
|
|
@@ -205,7 +229,9 @@ var GraphicLayerCollection = /*#__PURE__*/function () {
|
|
|
205
229
|
}, {
|
|
206
230
|
key: "getSource",
|
|
207
231
|
value: function getSource(id) {
|
|
208
|
-
this._canOperate()
|
|
232
|
+
if (!this._canOperate()) {
|
|
233
|
+
return;
|
|
234
|
+
}
|
|
209
235
|
return utils.isString(id) ? this.graphicSources.get(id) : id;
|
|
210
236
|
}
|
|
211
237
|
|
|
@@ -213,8 +239,13 @@ var GraphicLayerCollection = /*#__PURE__*/function () {
|
|
|
213
239
|
}, {
|
|
214
240
|
key: "showLayer",
|
|
215
241
|
value: function showLayer(layer, isShow) {
|
|
216
|
-
this._canOperate()
|
|
242
|
+
if (!this._canOperate()) {
|
|
243
|
+
return;
|
|
244
|
+
}
|
|
217
245
|
var graphicLayer = this.getLayer(layer);
|
|
246
|
+
if (!graphicLayer) {
|
|
247
|
+
utils.warn('未找到对应图层');
|
|
248
|
+
}
|
|
218
249
|
graphicLayer.show(isShow);
|
|
219
250
|
}
|
|
220
251
|
|
|
@@ -222,8 +253,13 @@ var GraphicLayerCollection = /*#__PURE__*/function () {
|
|
|
222
253
|
}, {
|
|
223
254
|
key: "removeLayer",
|
|
224
255
|
value: function removeLayer(layer) {
|
|
225
|
-
this._canOperate()
|
|
256
|
+
if (!this._canOperate()) {
|
|
257
|
+
return;
|
|
258
|
+
}
|
|
226
259
|
var graphicLayer = this.getLayer(layer);
|
|
260
|
+
if (!graphicLayer) {
|
|
261
|
+
utils.warn('未找到对应图层');
|
|
262
|
+
}
|
|
227
263
|
graphicLayer.remove();
|
|
228
264
|
}
|
|
229
265
|
|
|
@@ -231,8 +267,13 @@ var GraphicLayerCollection = /*#__PURE__*/function () {
|
|
|
231
267
|
}, {
|
|
232
268
|
key: "removeSource",
|
|
233
269
|
value: function removeSource(source) {
|
|
234
|
-
this._canOperate()
|
|
270
|
+
if (!this._canOperate()) {
|
|
271
|
+
return;
|
|
272
|
+
}
|
|
235
273
|
var graphicSource = this.getSource(source);
|
|
274
|
+
if (!graphicSource) {
|
|
275
|
+
utils.warn('未找到对应的数据源');
|
|
276
|
+
}
|
|
236
277
|
graphicSource.remove();
|
|
237
278
|
}
|
|
238
279
|
|
|
@@ -240,9 +281,11 @@ var GraphicLayerCollection = /*#__PURE__*/function () {
|
|
|
240
281
|
}, {
|
|
241
282
|
key: "clearLayer",
|
|
242
283
|
value: function clearLayer() {
|
|
243
|
-
this._canOperate()
|
|
244
|
-
|
|
245
|
-
|
|
284
|
+
if (!this._canOperate()) {
|
|
285
|
+
return;
|
|
286
|
+
}
|
|
287
|
+
this.getMap().entities.removeAll();
|
|
288
|
+
this.getMap().scene.primitives.removeAll();
|
|
246
289
|
var graphicLayers = this.graphicLayers.values();
|
|
247
290
|
var _iterator2 = _createForOfIteratorHelper(graphicLayers),
|
|
248
291
|
_step2;
|
|
@@ -257,13 +300,16 @@ var GraphicLayerCollection = /*#__PURE__*/function () {
|
|
|
257
300
|
_iterator2.f();
|
|
258
301
|
}
|
|
259
302
|
this._clearGraphicMapLayer();
|
|
303
|
+
this._clearGraphicMapSource();
|
|
260
304
|
}
|
|
261
305
|
|
|
262
306
|
// 清除所有数据
|
|
263
307
|
}, {
|
|
264
308
|
key: "clearSource",
|
|
265
309
|
value: function clearSource() {
|
|
266
|
-
this._canOperate()
|
|
310
|
+
if (!this._canOperate()) {
|
|
311
|
+
return;
|
|
312
|
+
}
|
|
267
313
|
var graphicSources = this.graphicSources.values();
|
|
268
314
|
var _iterator3 = _createForOfIteratorHelper(graphicSources),
|
|
269
315
|
_step3;
|
|
@@ -284,8 +330,13 @@ var GraphicLayerCollection = /*#__PURE__*/function () {
|
|
|
284
330
|
}, {
|
|
285
331
|
key: "setLayerStyle",
|
|
286
332
|
value: function setLayerStyle(layer, style) {
|
|
287
|
-
this._canOperate()
|
|
333
|
+
if (!this._canOperate()) {
|
|
334
|
+
return;
|
|
335
|
+
}
|
|
288
336
|
var graphicLayer = this.getLayer(layer);
|
|
337
|
+
if (!graphicLayer) {
|
|
338
|
+
utils.warn('未找到对应图层');
|
|
339
|
+
}
|
|
289
340
|
graphicLayer.setStyle(style);
|
|
290
341
|
}
|
|
291
342
|
|
|
@@ -293,7 +344,9 @@ var GraphicLayerCollection = /*#__PURE__*/function () {
|
|
|
293
344
|
}, {
|
|
294
345
|
key: "setLayerData",
|
|
295
346
|
value: function setLayerData(layer, data) {
|
|
296
|
-
this._canOperate()
|
|
347
|
+
if (!this._canOperate()) {
|
|
348
|
+
return;
|
|
349
|
+
}
|
|
297
350
|
var source = null;
|
|
298
351
|
var sourceType = BaseSource.analysisSourceType(data);
|
|
299
352
|
if (sourceType === 'sourceInstance') {
|
|
@@ -326,7 +379,11 @@ var GraphicLayerCollection = /*#__PURE__*/function () {
|
|
|
326
379
|
graphicLayers.push(this.getLayer(layer));
|
|
327
380
|
}
|
|
328
381
|
graphicLayers.forEach(function (t) {
|
|
329
|
-
t
|
|
382
|
+
if (t) {
|
|
383
|
+
t.setData(source);
|
|
384
|
+
} else {
|
|
385
|
+
utils.warn("\u56FE\u5C42".concat(t.id, "\u4E0D\u5B58\u5728"));
|
|
386
|
+
}
|
|
330
387
|
});
|
|
331
388
|
}
|
|
332
389
|
|
|
@@ -334,8 +391,14 @@ var GraphicLayerCollection = /*#__PURE__*/function () {
|
|
|
334
391
|
}, {
|
|
335
392
|
key: "setSourceData",
|
|
336
393
|
value: function setSourceData(source, data) {
|
|
337
|
-
this._canOperate()
|
|
394
|
+
if (!this._canOperate()) {
|
|
395
|
+
return;
|
|
396
|
+
}
|
|
338
397
|
var graphicSource = this.getSource(source);
|
|
398
|
+
if (!graphicSource) {
|
|
399
|
+
utils.warn('未找到对应的数据源');
|
|
400
|
+
return;
|
|
401
|
+
}
|
|
339
402
|
graphicSource.setData(data);
|
|
340
403
|
}
|
|
341
404
|
|
|
@@ -343,8 +406,14 @@ var GraphicLayerCollection = /*#__PURE__*/function () {
|
|
|
343
406
|
}, {
|
|
344
407
|
key: "flyToLayer",
|
|
345
408
|
value: function flyToLayer(layer, options) {
|
|
346
|
-
this._canOperate()
|
|
409
|
+
if (!this._canOperate()) {
|
|
410
|
+
return;
|
|
411
|
+
}
|
|
347
412
|
var graphicLayer = this.getLayer(layer);
|
|
413
|
+
if (!graphicLayer) {
|
|
414
|
+
utils.warn('未找到对应图层');
|
|
415
|
+
return;
|
|
416
|
+
}
|
|
348
417
|
graphicLayer.flyTo(options);
|
|
349
418
|
}
|
|
350
419
|
|
|
@@ -353,8 +422,10 @@ var GraphicLayerCollection = /*#__PURE__*/function () {
|
|
|
353
422
|
key: "flyToLayers",
|
|
354
423
|
value: function flyToLayers(layers, options) {
|
|
355
424
|
var _this2 = this;
|
|
356
|
-
this._canOperate()
|
|
357
|
-
|
|
425
|
+
if (!this._canOperate()) {
|
|
426
|
+
return;
|
|
427
|
+
}
|
|
428
|
+
if (utils.isArray(layers)) {
|
|
358
429
|
var graphicLayers = layers.map(function (layer) {
|
|
359
430
|
return _this2.getLayer(layer);
|
|
360
431
|
});
|
|
@@ -363,7 +434,7 @@ var GraphicLayerCollection = /*#__PURE__*/function () {
|
|
|
363
434
|
return p.source.positions;
|
|
364
435
|
});
|
|
365
436
|
}));
|
|
366
|
-
cameraFlyToPositions(this.
|
|
437
|
+
utils.cameraFlyToPositions(this.getMap().camera, positions, options);
|
|
367
438
|
}
|
|
368
439
|
}
|
|
369
440
|
|
|
@@ -371,8 +442,13 @@ var GraphicLayerCollection = /*#__PURE__*/function () {
|
|
|
371
442
|
}, {
|
|
372
443
|
key: "destroy",
|
|
373
444
|
value: function destroy() {
|
|
374
|
-
this.
|
|
445
|
+
if (!this._canOperate()) {
|
|
446
|
+
return;
|
|
447
|
+
}
|
|
375
448
|
this.clearLayer();
|
|
449
|
+
this.graphicLayers = new Map();
|
|
450
|
+
this.graphicSources = new Map();
|
|
451
|
+
this.isDestroyed = true;
|
|
376
452
|
}
|
|
377
453
|
}]);
|
|
378
454
|
return GraphicLayerCollection;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
var _excluded = ["style", "
|
|
1
|
+
var _excluded = ["style", "postDomBack", "map"];
|
|
2
2
|
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); }
|
|
3
3
|
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; }
|
|
4
4
|
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; }
|
|
@@ -20,6 +20,7 @@ function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e
|
|
|
20
20
|
import { cloneDeep, isNil, merge } from 'lodash';
|
|
21
21
|
import { DEFAULT_HTML_OPTIONS, HTML_CONTAINER_ID } from "../constant";
|
|
22
22
|
import { ClampToGround } from "../tool/common";
|
|
23
|
+
import * as utils from "../tool/utils";
|
|
23
24
|
import { isString } from "../tool/utils";
|
|
24
25
|
import BaseEntity from "./BaseEntity";
|
|
25
26
|
var horizontalOriginObj = {
|
|
@@ -47,7 +48,6 @@ var HtmlEntity = /*#__PURE__*/function (_BaseEntity) {
|
|
|
47
48
|
var _this;
|
|
48
49
|
_classCallCheck(this, HtmlEntity);
|
|
49
50
|
_this = _super.call(this, options);
|
|
50
|
-
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
51
51
|
_defineProperty(_assertThisInitialized(_this), "isDestroyed", false);
|
|
52
52
|
_defineProperty(_assertThisInitialized(_this), "isInit", false);
|
|
53
53
|
_defineProperty(_assertThisInitialized(_this), "container", void 0);
|
|
@@ -56,7 +56,6 @@ var HtmlEntity = /*#__PURE__*/function (_BaseEntity) {
|
|
|
56
56
|
_defineProperty(_assertThisInitialized(_this), "postDomBack", void 0);
|
|
57
57
|
_defineProperty(_assertThisInitialized(_this), "_clampToGround", void 0);
|
|
58
58
|
var style = options.style,
|
|
59
|
-
source = options.source,
|
|
60
59
|
postDomBack = options.postDomBack,
|
|
61
60
|
map = options.map,
|
|
62
61
|
currOptions = _objectWithoutProperties(options, _excluded);
|
|
@@ -102,15 +101,19 @@ var HtmlEntity = /*#__PURE__*/function (_BaseEntity) {
|
|
|
102
101
|
key: "_canOperate",
|
|
103
102
|
value: function _canOperate() {
|
|
104
103
|
if (this.isDestroyed) {
|
|
105
|
-
|
|
104
|
+
utils.error('Html实例已销毁');
|
|
105
|
+
return false;
|
|
106
106
|
}
|
|
107
|
+
return true;
|
|
107
108
|
}
|
|
108
109
|
|
|
109
110
|
// 更新位置
|
|
110
111
|
}, {
|
|
111
112
|
key: "reSetPosition",
|
|
112
113
|
value: function reSetPosition(position, cameraHeight) {
|
|
113
|
-
this._canOperate()
|
|
114
|
+
if (!this._canOperate()) {
|
|
115
|
+
return;
|
|
116
|
+
}
|
|
114
117
|
if (!this.isInit) return;
|
|
115
118
|
this.container.style.transform = "translate3d(".concat(position.x - (this.horizontalOrigin ? this.container.clientWidth / this.horizontalOrigin : 0), "px, ").concat(position.y - (this.verticalOrigin ? this.container.clientHeight / this.verticalOrigin : 0), "px, 0) ").concat(this.style.scaleOfDistance ? "scale(".concat(Math.min(1, this.style.scaleOfDistance / cameraHeight), ")") : '');
|
|
116
119
|
}
|
|
@@ -119,7 +122,9 @@ var HtmlEntity = /*#__PURE__*/function (_BaseEntity) {
|
|
|
119
122
|
}, {
|
|
120
123
|
key: "show",
|
|
121
124
|
value: function show(isShow) {
|
|
122
|
-
this._canOperate()
|
|
125
|
+
if (!this._canOperate()) {
|
|
126
|
+
return;
|
|
127
|
+
}
|
|
123
128
|
if (isShow) {
|
|
124
129
|
this.container.style.display = 'block';
|
|
125
130
|
} else {
|
|
@@ -131,7 +136,9 @@ var HtmlEntity = /*#__PURE__*/function (_BaseEntity) {
|
|
|
131
136
|
}, {
|
|
132
137
|
key: "remove",
|
|
133
138
|
value: function remove() {
|
|
134
|
-
this._canOperate()
|
|
139
|
+
if (!this._canOperate()) {
|
|
140
|
+
return;
|
|
141
|
+
}
|
|
135
142
|
this.isDestroyed = true;
|
|
136
143
|
this.container.remove();
|
|
137
144
|
}
|
|
@@ -140,7 +147,9 @@ var HtmlEntity = /*#__PURE__*/function (_BaseEntity) {
|
|
|
140
147
|
}, {
|
|
141
148
|
key: "updateStyle",
|
|
142
149
|
value: function updateStyle(style) {
|
|
143
|
-
this._canOperate()
|
|
150
|
+
if (!this._canOperate()) {
|
|
151
|
+
return;
|
|
152
|
+
}
|
|
144
153
|
var mergeStyle = merge(DEFAULT_HTML_OPTIONS(), cloneDeep(style || {}));
|
|
145
154
|
this._setStyle(mergeStyle);
|
|
146
155
|
}
|
|
@@ -163,7 +172,9 @@ var HtmlEntity = /*#__PURE__*/function (_BaseEntity) {
|
|
|
163
172
|
key: "updateData",
|
|
164
173
|
value: function updateData(data) {
|
|
165
174
|
var _this2 = this;
|
|
166
|
-
this._canOperate()
|
|
175
|
+
if (!this._canOperate()) {
|
|
176
|
+
return;
|
|
177
|
+
}
|
|
167
178
|
this.source = data;
|
|
168
179
|
if (this.style.clampToGround) {
|
|
169
180
|
this._clampToGround.getHeightByTypeToCartesian3([this.source.positions], this.style.clampToGround).then(function (res) {
|
|
@@ -1,5 +1,5 @@
|
|
|
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
|
-
var _excluded = ["style", "
|
|
2
|
+
var _excluded = ["style", "entity"],
|
|
3
3
|
_excluded2 = ["backgroundColor", "fillColor", "outlineColor", "backgroundPadding", "pixelOffset", "eyeOffset"];
|
|
4
4
|
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; }
|
|
5
5
|
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; }
|
|
@@ -33,9 +33,7 @@ var LabelEntity = /*#__PURE__*/function (_BaseEntity) {
|
|
|
33
33
|
var _this;
|
|
34
34
|
_classCallCheck(this, LabelEntity);
|
|
35
35
|
_this = _super.call(this, options);
|
|
36
|
-
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
37
36
|
var style = options.style,
|
|
38
|
-
source = options.source,
|
|
39
37
|
entity = options.entity,
|
|
40
38
|
currOptions = _objectWithoutProperties(options, _excluded);
|
|
41
39
|
if (entity) {
|
|
@@ -58,11 +56,10 @@ var LabelEntity = /*#__PURE__*/function (_BaseEntity) {
|
|
|
58
56
|
function _init(options) {
|
|
59
57
|
var style = options.style;
|
|
60
58
|
var positions = PositionProperty.changeToPropertyData.call(this);
|
|
61
|
-
this.graphic = new Cesium.LabelGraphics(style);
|
|
62
59
|
this.entity = new Cesium.Entity({
|
|
63
60
|
position: positions,
|
|
64
61
|
id: this.id,
|
|
65
|
-
label:
|
|
62
|
+
label: new Cesium.LabelGraphics(style)
|
|
66
63
|
});
|
|
67
64
|
}
|
|
68
65
|
|
|
@@ -2,6 +2,8 @@ import BasePointPrimitive from './BasePointPrimitive';
|
|
|
2
2
|
export default class LabelPrimitive extends BasePointPrimitive {
|
|
3
3
|
constructor(options: any);
|
|
4
4
|
static handleOptions(style: any): any;
|
|
5
|
+
getPrimitive(): any;
|
|
5
6
|
private _init;
|
|
6
7
|
updateData(data: any): void;
|
|
8
|
+
updateStyle(originStyle: any, style: any): void;
|
|
7
9
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
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
|
-
var _excluded = ["style"
|
|
2
|
+
var _excluded = ["style"],
|
|
3
3
|
_excluded2 = ["backgroundColor", "fillColor", "outlineColor", "backgroundPadding", "pixelOffset", "eyeOffset"];
|
|
4
4
|
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; }
|
|
5
5
|
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; }
|
|
@@ -31,10 +31,7 @@ var LabelPrimitive = /*#__PURE__*/function (_BasePointPrimitive) {
|
|
|
31
31
|
var _this;
|
|
32
32
|
_classCallCheck(this, LabelPrimitive);
|
|
33
33
|
_this = _super.call(this, options);
|
|
34
|
-
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
35
34
|
var style = options.style,
|
|
36
|
-
source = options.source,
|
|
37
|
-
entity = options.entity,
|
|
38
35
|
currOptions = _objectWithoutProperties(options, _excluded);
|
|
39
36
|
var mergeStyle = merge(DEFAULT_LABEL_PRIMITIVE_OPTIONS(), cloneDeep(style || {}));
|
|
40
37
|
var currStyle = LabelPrimitive.handleOptions(mergeStyle);
|
|
@@ -46,14 +43,26 @@ var LabelPrimitive = /*#__PURE__*/function (_BasePointPrimitive) {
|
|
|
46
43
|
|
|
47
44
|
// 处理点的参数
|
|
48
45
|
_createClass(LabelPrimitive, [{
|
|
49
|
-
key: "
|
|
46
|
+
key: "getPrimitive",
|
|
50
47
|
value:
|
|
48
|
+
// 获取primitive
|
|
49
|
+
function getPrimitive() {
|
|
50
|
+
var _primitiveCollection$,
|
|
51
|
+
_this2 = this;
|
|
52
|
+
var primitiveCollection = this.getPrimitiveCollection();
|
|
53
|
+
return primitiveCollection === null || primitiveCollection === void 0 || (_primitiveCollection$ = primitiveCollection._labels) === null || _primitiveCollection$ === void 0 ? void 0 : _primitiveCollection$.find(function (t) {
|
|
54
|
+
return t.id === _this2.id;
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
|
|
51
58
|
// 初始化
|
|
52
|
-
|
|
59
|
+
}, {
|
|
60
|
+
key: "_init",
|
|
61
|
+
value: function _init(options) {
|
|
53
62
|
var style = options.style,
|
|
54
63
|
positions = options.positions,
|
|
55
64
|
primitiveCollection = options.primitiveCollection;
|
|
56
|
-
|
|
65
|
+
primitiveCollection.add(_objectSpread({
|
|
57
66
|
id: this.id,
|
|
58
67
|
position: positions
|
|
59
68
|
}, style));
|
|
@@ -65,7 +74,21 @@ var LabelPrimitive = /*#__PURE__*/function (_BasePointPrimitive) {
|
|
|
65
74
|
value: function updateData(data) {
|
|
66
75
|
var positions = data.positions;
|
|
67
76
|
this.source = data;
|
|
68
|
-
|
|
77
|
+
var primitive = this.getPrimitive();
|
|
78
|
+
if (!primitive) return;
|
|
79
|
+
primitive.position = positions;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
// 更新样式
|
|
83
|
+
}, {
|
|
84
|
+
key: "updateStyle",
|
|
85
|
+
value: function updateStyle(originStyle, style) {
|
|
86
|
+
this.style = merge(this.style, originStyle);
|
|
87
|
+
var primitive = this.getPrimitive();
|
|
88
|
+
if (!primitive) return;
|
|
89
|
+
for (var key in style) {
|
|
90
|
+
primitive[key] = style[key];
|
|
91
|
+
}
|
|
69
92
|
}
|
|
70
93
|
}], [{
|
|
71
94
|
key: "handleOptions",
|
|
@@ -1,5 +1,5 @@
|
|
|
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
|
-
var _excluded = ["style", "
|
|
2
|
+
var _excluded = ["style", "entity"],
|
|
3
3
|
_excluded2 = ["orientation"],
|
|
4
4
|
_excluded3 = ["silhouetteColor", "color", "imageBasedLightingFactor", "lightColor", "orientation"];
|
|
5
5
|
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; }
|
|
@@ -34,9 +34,7 @@ var ModelEntity = /*#__PURE__*/function (_BaseEntity) {
|
|
|
34
34
|
var _this;
|
|
35
35
|
_classCallCheck(this, ModelEntity);
|
|
36
36
|
_this = _super.call(this, options);
|
|
37
|
-
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
38
37
|
var style = options.style,
|
|
39
|
-
source = options.source,
|
|
40
38
|
entity = options.entity,
|
|
41
39
|
currOptions = _objectWithoutProperties(options, _excluded);
|
|
42
40
|
if (entity) {
|
|
@@ -62,11 +60,10 @@ var ModelEntity = /*#__PURE__*/function (_BaseEntity) {
|
|
|
62
60
|
style = _objectWithoutProperties(_options$style, _excluded2);
|
|
63
61
|
var positions = PositionProperty.changeToPropertyData.call(this);
|
|
64
62
|
var newOrientation = PositionProperty.changeToPropertyOrientation.call(this, orientation);
|
|
65
|
-
this.graphic = new Cesium.ModelGraphics(style);
|
|
66
63
|
this.entity = new Cesium.Entity({
|
|
67
64
|
position: positions,
|
|
68
65
|
id: this.id,
|
|
69
|
-
model:
|
|
66
|
+
model: new Cesium.ModelGraphics(style),
|
|
70
67
|
orientation: newOrientation
|
|
71
68
|
});
|
|
72
69
|
}
|
|
@@ -27,9 +27,10 @@ var ModelPrimitive = /*#__PURE__*/function (_BasePrimitive) {
|
|
|
27
27
|
value: function createPrimitive() {
|
|
28
28
|
var _this = this;
|
|
29
29
|
var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
30
|
+
var primitiveInstance = arguments.length > 1 ? arguments[1] : undefined;
|
|
30
31
|
var style = merge(DEFAULT_MODEL_PRIMITIVE_OPTIONS(), cloneDeep(options.style || {}));
|
|
31
32
|
this.primitive = new Cesium.PrimitiveCollection();
|
|
32
|
-
Promise.allSettled(
|
|
33
|
+
Promise.allSettled(primitiveInstance).then(function (models) {
|
|
33
34
|
models.forEach(function (model) {
|
|
34
35
|
if (model.status === 'fulfilled') {
|
|
35
36
|
_this.primitive.add(model.value);
|