deeptwins-engine-3d 0.1.7 → 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.
Files changed (97) hide show
  1. package/dist/esm/cameraControl/ModelRoamHistory.d.ts +2 -1
  2. package/dist/esm/cameraControl/ModelRoamHistory.js +33 -29
  3. package/dist/esm/cameraControl/ModelRoamRealTime.d.ts +4 -3
  4. package/dist/esm/cameraControl/ModelRoamRealTime.js +26 -22
  5. package/dist/esm/cameraControl/Roam.d.ts +3 -1
  6. package/dist/esm/cameraControl/Roam.js +17 -13
  7. package/dist/esm/cameraControl/Rotate.d.ts +3 -1
  8. package/dist/esm/cameraControl/Rotate.js +29 -25
  9. package/dist/esm/cameraControl/RotateInPlace.d.ts +3 -1
  10. package/dist/esm/cameraControl/RotateInPlace.js +22 -19
  11. package/dist/esm/constant.d.ts +12 -0
  12. package/dist/esm/constant.js +16 -0
  13. package/dist/esm/graphicLayer/BaseEntity.d.ts +0 -1
  14. package/dist/esm/graphicLayer/BaseEntity.js +0 -1
  15. package/dist/esm/graphicLayer/BaseLayer.d.ts +3 -2
  16. package/dist/esm/graphicLayer/BaseLayer.js +73 -41
  17. package/dist/esm/graphicLayer/BasePointPrimitive.d.ts +4 -2
  18. package/dist/esm/graphicLayer/BasePointPrimitive.js +14 -10
  19. package/dist/esm/graphicLayer/BasePrimitive.d.ts +3 -5
  20. package/dist/esm/graphicLayer/BasePrimitive.js +4 -18
  21. package/dist/esm/graphicLayer/BasePrimitiveInstance.d.ts +1 -2
  22. package/dist/esm/graphicLayer/BasePrimitiveInstance.js +0 -1
  23. package/dist/esm/graphicLayer/BaseSource.d.ts +4 -3
  24. package/dist/esm/graphicLayer/BaseSource.js +28 -11
  25. package/dist/esm/graphicLayer/BillboardEntity.js +3 -6
  26. package/dist/esm/graphicLayer/BillboardPrimitive.d.ts +2 -0
  27. package/dist/esm/graphicLayer/BillboardPrimitive.js +29 -5
  28. package/dist/esm/graphicLayer/BoxEntity.js +2 -5
  29. package/dist/esm/graphicLayer/BoxPrimitive.d.ts +2 -2
  30. package/dist/esm/graphicLayer/BoxPrimitive.js +11 -6
  31. package/dist/esm/graphicLayer/BoxPrimitiveInstance.js +4 -6
  32. package/dist/esm/graphicLayer/EllipseEntity.js +2 -5
  33. package/dist/esm/graphicLayer/EllipsePrimitive.d.ts +1 -1
  34. package/dist/esm/graphicLayer/EllipsePrimitive.js +9 -4
  35. package/dist/esm/graphicLayer/EllipsePrimitiveInstance.js +4 -7
  36. package/dist/esm/graphicLayer/EllipsoidEntity.js +2 -5
  37. package/dist/esm/graphicLayer/EllipsoidPrimitive.d.ts +1 -1
  38. package/dist/esm/graphicLayer/EllipsoidPrimitive.js +9 -4
  39. package/dist/esm/graphicLayer/EllipsoidPrimitiveInstance.js +3 -3
  40. package/dist/esm/graphicLayer/GraphicLayerCollection.d.ts +9 -7
  41. package/dist/esm/graphicLayer/GraphicLayerCollection.js +118 -42
  42. package/dist/esm/graphicLayer/HtmlEntity.js +20 -9
  43. package/dist/esm/graphicLayer/LabelEntity.js +2 -5
  44. package/dist/esm/graphicLayer/LabelPrimitive.d.ts +2 -0
  45. package/dist/esm/graphicLayer/LabelPrimitive.js +31 -8
  46. package/dist/esm/graphicLayer/ModelEntity.js +2 -5
  47. package/dist/esm/graphicLayer/ModelPrimitive.d.ts +1 -1
  48. package/dist/esm/graphicLayer/ModelPrimitive.js +2 -1
  49. package/dist/esm/graphicLayer/ModelPrimitiveInstance.js +4 -7
  50. package/dist/esm/graphicLayer/PointEntity.js +2 -5
  51. package/dist/esm/graphicLayer/PointPrimitive.d.ts +2 -0
  52. package/dist/esm/graphicLayer/PointPrimitive.js +29 -5
  53. package/dist/esm/graphicLayer/PolygonEntity.js +4 -7
  54. package/dist/esm/graphicLayer/PolygonPrimitive.d.ts +2 -2
  55. package/dist/esm/graphicLayer/PolygonPrimitive.js +11 -6
  56. package/dist/esm/graphicLayer/PolygonPrimitiveInstance.js +4 -7
  57. package/dist/esm/graphicLayer/PolylineEntity.js +4 -7
  58. package/dist/esm/graphicLayer/PolylinePrimitive.d.ts +1 -1
  59. package/dist/esm/graphicLayer/PolylinePrimitive.js +9 -4
  60. package/dist/esm/graphicLayer/PolylinePrimitiveInstance.js +3 -3
  61. package/dist/esm/graphicLayer/PolylineVolumeEntity.js +3 -5
  62. package/dist/esm/graphicLayer/PolylineVolumePrimitive.d.ts +1 -1
  63. package/dist/esm/graphicLayer/PolylineVolumePrimitive.js +9 -4
  64. package/dist/esm/graphicLayer/PolylineVolumePrimitiveInstance.js +4 -7
  65. package/dist/esm/graphicLayer/WallEntity.js +4 -7
  66. package/dist/esm/graphicLayer/WallPrimitive.d.ts +1 -1
  67. package/dist/esm/graphicLayer/WallPrimitive.js +9 -4
  68. package/dist/esm/graphicLayer/WallPrimitiveInstance.js +4 -7
  69. package/dist/esm/index.js +1 -1
  70. package/dist/esm/map/Event.d.ts +4 -2
  71. package/dist/esm/map/Event.js +19 -14
  72. package/dist/esm/map/Map.d.ts +6 -1
  73. package/dist/esm/map/Map.js +14 -4
  74. package/dist/esm/material/WeatherEffects.d.ts +3 -1
  75. package/dist/esm/material/WeatherEffects.js +11 -6
  76. package/dist/esm/tool/common.d.ts +3 -1
  77. package/dist/esm/tool/common.js +13 -8
  78. package/dist/esm/tool/utils.d.ts +2 -0
  79. package/dist/esm/tool/utils.js +10 -0
  80. package/dist/esm/videoFusion/BaseVideo.d.ts +6 -2
  81. package/dist/esm/videoFusion/BaseVideo.js +48 -19
  82. package/dist/esm/videoFusion/VideoProject.js +16 -10
  83. package/dist/esm/videoFusion/VideoTexture.js +4 -2
  84. package/dist/esm/visualization/Airspace.d.ts +3 -1
  85. package/dist/esm/visualization/Airspace.js +27 -12
  86. package/dist/esm/visualization/BaseFrustum.d.ts +3 -1
  87. package/dist/esm/visualization/BaseFrustum.js +23 -9
  88. package/dist/esm/visualization/BaseHeatmap.d.ts +4 -2
  89. package/dist/esm/visualization/BaseHeatmap.js +22 -12
  90. package/dist/esm/visualization/Frustum.js +6 -6
  91. package/dist/esm/visualization/FrustumWithCamera.js +9 -9
  92. package/dist/esm/visualization/Heatmap2d.js +32 -6
  93. package/dist/esm/visualization/Heatmap3d.js +21 -4
  94. package/dist/esm/visualization/PointCluster.d.ts +3 -1
  95. package/dist/esm/visualization/PointCluster.js +26 -14
  96. package/dist/umd/deeptwins-engine-3d.min.js +1 -1
  97. package/package.json +1 -2
@@ -1,4 +1,5 @@
1
1
  export default class ModelRoamHistory {
2
+ private readonly _mapContext;
2
3
  polylineLayer: any;
3
4
  polylineEntity: any;
4
5
  modelLayer: any;
@@ -6,7 +7,6 @@ export default class ModelRoamHistory {
6
7
  positionProperty: any;
7
8
  private follow;
8
9
  status: string;
9
- private _map;
10
10
  private readonly _eventRunning;
11
11
  private readonly _eventComplete;
12
12
  private readonly _eventCancel;
@@ -18,6 +18,7 @@ export default class ModelRoamHistory {
18
18
  private firstCameraSettings;
19
19
  private thirdPersonSettings;
20
20
  constructor(map: any, positions: any, options?: any);
21
+ getMap(): any;
21
22
  private _init;
22
23
  private _getHeading;
23
24
  start(): void;
@@ -15,6 +15,7 @@ import { cartesian3ToLngLatAlt, lngLatAltToCartesian3 } from "../tool/utils";
15
15
  var ModelRoamHistory = /*#__PURE__*/function () {
16
16
  function ModelRoamHistory(map, positions, options) {
17
17
  _classCallCheck(this, ModelRoamHistory);
18
+ _defineProperty(this, "_mapContext", void 0);
18
19
  _defineProperty(this, "polylineLayer", void 0);
19
20
  _defineProperty(this, "polylineEntity", void 0);
20
21
  _defineProperty(this, "modelLayer", void 0);
@@ -23,7 +24,6 @@ var ModelRoamHistory = /*#__PURE__*/function () {
23
24
  // 视角
24
25
  _defineProperty(this, "follow", null);
25
26
  _defineProperty(this, "status", 'stop');
26
- _defineProperty(this, "_map", void 0);
27
27
  _defineProperty(this, "_eventRunning", void 0);
28
28
  _defineProperty(this, "_eventComplete", void 0);
29
29
  _defineProperty(this, "_eventCancel", void 0);
@@ -50,11 +50,16 @@ var ModelRoamHistory = /*#__PURE__*/function () {
50
50
  complete && (this._eventComplete = complete);
51
51
  cancel && (this._eventCancel = cancel);
52
52
  onRunning && (this._eventRunning = onRunning);
53
- this._map = map;
53
+ this._mapContext = map._mapContext;
54
54
  this._positions = positions;
55
55
  this._init(options);
56
56
  }
57
57
  _createClass(ModelRoamHistory, [{
58
+ key: "getMap",
59
+ value: function getMap() {
60
+ return this._mapContext && this._mapContext.getMap();
61
+ }
62
+ }, {
58
63
  key: "_init",
59
64
  value: function _init(options) {
60
65
  var _this = this;
@@ -83,7 +88,7 @@ var ModelRoamHistory = /*#__PURE__*/function () {
83
88
  }
84
89
  }]
85
90
  };
86
- this.polylineLayer = this._map.addGraphicLayer(geoJson, {
91
+ this.polylineLayer = this.getMap().addGraphicLayer(geoJson, {
87
92
  type: 'polyline',
88
93
  id: '_modelHistoryRoam',
89
94
  style: _objectSpread(_objectSpread({}, polyline), {}, {
@@ -96,26 +101,26 @@ var ModelRoamHistory = /*#__PURE__*/function () {
96
101
  }
97
102
  var start = Cesium.JulianDate.fromDate(this._positions[0].time);
98
103
  var stop = Cesium.JulianDate.fromDate(this._positions[this._positions.length - 1].time);
99
- this._map.clock.startTime = start.clone();
100
- this._map.clock.stopTime = stop.clone();
101
- this._map.clock.currentTime = start.clone();
104
+ this.getMap().clock.startTime = start.clone();
105
+ this.getMap().clock.stopTime = stop.clone();
106
+ this.getMap().clock.currentTime = start.clone();
102
107
  // 播放速率
103
- this._map.clock.multiplier = multiplier;
104
- this._map.clock.clockRange = clockRange;
108
+ this.getMap().clock.multiplier = multiplier;
109
+ this.getMap().clock.clockRange = clockRange;
105
110
  // 停止播放
106
- this._map.clock.shouldAnimate = false;
111
+ this.getMap().clock.shouldAnimate = false;
107
112
  this._listenRunning = function () {
108
113
  // 判断结束
109
- if (Cesium.JulianDate.compare(_this._map.clock.currentTime, _this._map.clock.stopTime) >= 0 && clockRange !== Cesium.ClockRange.LOOP_STOP) {
114
+ if (Cesium.JulianDate.compare(_this.getMap().clock.currentTime, _this.getMap().clock.stopTime) >= 0 && clockRange !== Cesium.ClockRange.LOOP_STOP) {
110
115
  if (_this._eventComplete && _this.status === 'running') {
111
116
  _this._eventComplete();
112
117
  }
113
118
  _this.status = 'stop';
114
119
  } else {
115
120
  // 监听运行状态
116
- if (_this._eventRunning && _this._map.clock.shouldAnimate) {
121
+ if (_this._eventRunning && _this.getMap().clock.shouldAnimate) {
117
122
  // 获取当前时间
118
- var currentTime = _this._map.clock.currentTime;
123
+ var currentTime = _this.getMap().clock.currentTime;
119
124
  // 获取前一帧时间
120
125
  var beforeTime = Cesium.JulianDate.addSeconds(currentTime, -0.1, new Cesium.JulianDate());
121
126
  // 获取插值后的当前位置
@@ -135,7 +140,7 @@ var ModelRoamHistory = /*#__PURE__*/function () {
135
140
  }
136
141
  };
137
142
  // 监听帧率
138
- this._eventPreUpdate = this._map.on(constant.SCENE_EVENT_TYPE.PRE_UPDATE, this._listenRunning);
143
+ this._eventPreUpdate = this.getMap().on(constant.SCENE_EVENT_TYPE.PRE_UPDATE, this._listenRunning);
139
144
  this.positionProperty = new Cesium.SampledPositionProperty();
140
145
  if (clampToGround) {
141
146
  // 贴地计算
@@ -144,7 +149,7 @@ var ModelRoamHistory = /*#__PURE__*/function () {
144
149
  var position1 = _this._positions[i];
145
150
  var position2 = _this._positions[i + 1];
146
151
  var points = lineClampToGroundSplit({
147
- map: _this._map,
152
+ map: _this.getMap(),
148
153
  pos1: lngLatAltToCartesian3(position1.lng, position1.lat, position1.alt),
149
154
  pos2: lngLatAltToCartesian3(position2.lng, position2.lat, position2.alt),
150
155
  splitNum: splitNum
@@ -154,7 +159,7 @@ var ModelRoamHistory = /*#__PURE__*/function () {
154
159
  return Cesium.Cartographic.fromCartesian(point);
155
160
  });
156
161
  // 贴地计算
157
- Cesium.sampleTerrainMostDetailed(_this._map.terrainProvider, cartographicPoints).then(function (updatedPoints) {
162
+ Cesium.sampleTerrainMostDetailed(_this.getMap().terrainProvider, cartographicPoints).then(function (updatedPoints) {
158
163
  var startTime = position1.time;
159
164
  var endTime = position2.time;
160
165
  var totalInterval = endTime - startTime;
@@ -186,7 +191,7 @@ var ModelRoamHistory = /*#__PURE__*/function () {
186
191
  position: this.positionProperty,
187
192
  model: ModelEntity.handleOptions(model)
188
193
  });
189
- this.modelLayer = this._map.addCustomSourceToGraphicLayer(this.modelEntity.position, {
194
+ this.modelLayer = this.getMap().addCustomSourceToGraphicLayer(this.modelEntity.position, {
190
195
  type: 'model',
191
196
  entity: this.modelEntity
192
197
  });
@@ -228,7 +233,7 @@ var ModelRoamHistory = /*#__PURE__*/function () {
228
233
  value: function start() {
229
234
  if (this.status === 'destroy') return;
230
235
  this.status = 'running';
231
- this._map.clock.shouldAnimate = true;
236
+ this.getMap().clock.shouldAnimate = true;
232
237
  }
233
238
 
234
239
  // 暂停
@@ -237,7 +242,7 @@ var ModelRoamHistory = /*#__PURE__*/function () {
237
242
  value: function pause() {
238
243
  if (this.status === 'destroy') return;
239
244
  this.status = 'pause';
240
- this._map.clock.shouldAnimate = false;
245
+ this.getMap().clock.shouldAnimate = false;
241
246
  this._eventCancel && this._eventCancel();
242
247
  }
243
248
 
@@ -247,7 +252,7 @@ var ModelRoamHistory = /*#__PURE__*/function () {
247
252
  value: function proceed() {
248
253
  if (this.status === 'destroy') return;
249
254
  this.status = 'running';
250
- this._map.clock.shouldAnimate = true;
255
+ this.getMap().clock.shouldAnimate = true;
251
256
  }
252
257
 
253
258
  // 停止
@@ -256,8 +261,8 @@ var ModelRoamHistory = /*#__PURE__*/function () {
256
261
  value: function stop() {
257
262
  if (this.status === 'destroy') return;
258
263
  this.status = 'stop';
259
- this._map.clock.shouldAnimate = false;
260
- this._map.clock.currentTime = Cesium.JulianDate.fromDate(this._positions[0].time);
264
+ this.getMap().clock.shouldAnimate = false;
265
+ this.getMap().clock.currentTime = Cesium.JulianDate.fromDate(this._positions[0].time);
261
266
  this._eventCancel && this._eventCancel();
262
267
  }
263
268
 
@@ -297,7 +302,7 @@ var ModelRoamHistory = /*#__PURE__*/function () {
297
302
  return;
298
303
  }
299
304
  // 设置相机位置和朝向
300
- this._map.camera.setView({
305
+ this.getMap().camera.setView({
301
306
  destination: position,
302
307
  orientation: {
303
308
  heading: heading,
@@ -314,14 +319,14 @@ var ModelRoamHistory = /*#__PURE__*/function () {
314
319
  if (!position || !heading) {
315
320
  return;
316
321
  }
317
- this._map.camera.lookAt(position, new Cesium.HeadingPitchRange(heading, Cesium.Math.toRadians(this.thirdPersonSettings.pitch), this.thirdPersonSettings.distance));
322
+ this.getMap().camera.lookAt(position, new Cesium.HeadingPitchRange(heading, Cesium.Math.toRadians(this.thirdPersonSettings.pitch), this.thirdPersonSettings.distance));
318
323
  }
319
324
 
320
325
  // 监听
321
326
  }, {
322
327
  key: "on",
323
328
  value: function on(type, event) {
324
- return this._map._event.listenToModelRoam(type, event, this);
329
+ return this.getMap()._event.listenToModelRoam(type, event, this);
325
330
  }
326
331
 
327
332
  // 更新线
@@ -343,12 +348,12 @@ var ModelRoamHistory = /*#__PURE__*/function () {
343
348
  key: "destroy",
344
349
  value: function destroy() {
345
350
  this.status = 'destroy';
346
- this._map.clock.shouldAnimate = false;
347
- this._map.clock.currentTime = Cesium.JulianDate.fromDate(new Date());
351
+ this.getMap().clock.shouldAnimate = false;
352
+ this.getMap().clock.currentTime = Cesium.JulianDate.fromDate(new Date());
348
353
  this._eventPreUpdate.off();
349
354
  this._listenRunning = null;
350
- this._map.removeLayer('_modelHistoryRoam');
351
- this._map.removeSource('_modelHistoryRoam');
355
+ this.getMap().removeLayer('_modelHistoryRoam');
356
+ this.getMap().removeSource('_modelHistoryRoam');
352
357
  this.cancelFollow();
353
358
  this.polylineLayer.remove();
354
359
  this.polylineEntity = null;
@@ -356,7 +361,6 @@ var ModelRoamHistory = /*#__PURE__*/function () {
356
361
  this.modelEntity = null;
357
362
  this._positions = [];
358
363
  this.positionProperty = null;
359
- this._map = null;
360
364
  }
361
365
  }]);
362
366
  return ModelRoamHistory;
@@ -1,4 +1,4 @@
1
- import type { Viewer } from 'deeptwins-cesium';
1
+ import { MapContext } from '../map/Map';
2
2
  /**
3
3
  * 位置信息
4
4
  */
@@ -9,7 +9,7 @@ interface Position {
9
9
  timestamp: number;
10
10
  }
11
11
  export default class ModelRoamRealTime {
12
- readonly _map: any;
12
+ _mapContext: MapContext | undefined;
13
13
  modelOptions: any;
14
14
  polylineOptions: any;
15
15
  private follow;
@@ -42,7 +42,8 @@ export default class ModelRoamRealTime {
42
42
  private rotationSpeed;
43
43
  private firstCameraSettings;
44
44
  private thirdPersonSettings;
45
- constructor(map: Viewer, options: any);
45
+ constructor(map: any, options: any);
46
+ getMap(): any;
46
47
  /**
47
48
  * 实时添加点位
48
49
  * @param newPosition 新位置点
@@ -38,8 +38,7 @@ var ModelRoamRealTime = /*#__PURE__*/function () {
38
38
  var _this = this,
39
39
  _options$model;
40
40
  _classCallCheck(this, ModelRoamRealTime);
41
- //传入的参数
42
- _defineProperty(this, "_map", void 0);
41
+ _defineProperty(this, "_mapContext", void 0);
43
42
  // 模型参数
44
43
  _defineProperty(this, "modelOptions", void 0);
45
44
  // 轨迹参数
@@ -119,7 +118,7 @@ var ModelRoamRealTime = /*#__PURE__*/function () {
119
118
  _this._frameCount++;
120
119
  var elapsed = currentTime - _this._lastFrameTime;
121
120
  if (elapsed > 60) {
122
- _this._fps = Math.min(Math.round(_this._frameCount * 1000 / elapsed), _this._map.targetFrameRate);
121
+ _this._fps = Math.min(Math.round(_this._frameCount * 1000 / elapsed), _this.getMap().targetFrameRate);
123
122
  _this._frameCount = 0;
124
123
  _this._lastFrameTime = currentTime;
125
124
  }
@@ -173,7 +172,7 @@ var ModelRoamRealTime = /*#__PURE__*/function () {
173
172
  _this.currentPointIndex++;
174
173
  } else {
175
174
  // 每帧应飞的"点数"(允许小数)
176
- var exactStep = _this._fps ? _this._map.targetFrameRate / _this._fps : 1;
175
+ var exactStep = _this._fps ? _this.getMap().targetFrameRate / _this._fps : 1;
177
176
  // 累加步长
178
177
  _this._stepAccumulator += exactStep;
179
178
  // 取整:当前帧应飞的"完整点数"
@@ -193,7 +192,7 @@ var ModelRoamRealTime = /*#__PURE__*/function () {
193
192
  polyline = options.polyline,
194
193
  onPositionUpdate = options.onPositionUpdate,
195
194
  flyTo = options.flyTo;
196
- this._map = map;
195
+ this._mapContext = map._mapContext;
197
196
  this.modelOptions = model;
198
197
  this.polylineOptions = merge(constant.DEFAULT_POLYLINE_PRIMITIVE_OPTIONS(), cloneDeep(polyline || {}));
199
198
  this.flyTo = flyTo || false;
@@ -204,12 +203,17 @@ var ModelRoamRealTime = /*#__PURE__*/function () {
204
203
  this.trailShowState = this.polylineOptions.show;
205
204
  }
206
205
  }
207
-
208
- /**
209
- * 实时添加点位
210
- * @param newPosition 新位置点
211
- */
212
206
  _createClass(ModelRoamRealTime, [{
207
+ key: "getMap",
208
+ value: function getMap() {
209
+ return this._mapContext && this._mapContext.getMap();
210
+ }
211
+
212
+ /**
213
+ * 实时添加点位
214
+ * @param newPosition 新位置点
215
+ */
216
+ }, {
213
217
  key: "updatePosition",
214
218
  value: function updatePosition(newPosition) {
215
219
  if (!newPosition) return;
@@ -304,7 +308,7 @@ var ModelRoamRealTime = /*#__PURE__*/function () {
304
308
  if (this.status === 'running') return;
305
309
  this.status = 'running';
306
310
  // 监听帧率更新
307
- this._eventPostUpdate = this._map.on(constant.SCENE_EVENT_TYPE.POST_UPDATE, this.updateModel);
311
+ this._eventPostUpdate = this.getMap().on(constant.SCENE_EVENT_TYPE.POST_UPDATE, this.updateModel);
308
312
  }
309
313
 
310
314
  /**
@@ -340,7 +344,7 @@ var ModelRoamRealTime = /*#__PURE__*/function () {
340
344
  }
341
345
 
342
346
  // 计算总的插值点数 用最大帧率*时间计算点位
343
- var numberOfPoints = Math.max(2, Math.floor(flightTime * this._map.targetFrameRate) - 1);
347
+ var numberOfPoints = Math.max(2, Math.floor(flightTime * this.getMap().targetFrameRate) - 1);
344
348
 
345
349
  // 计算时间步长
346
350
  var timeStep = 1.0 / (numberOfPoints - 1);
@@ -399,7 +403,7 @@ var ModelRoamRealTime = /*#__PURE__*/function () {
399
403
  }, this.modelOptions));
400
404
  case 4:
401
405
  model = _context.sent;
402
- this.modelLayer = this._map.scene.primitives.add(model);
406
+ this.modelLayer = this.getMap().scene.primitives.add(model);
403
407
 
404
408
  // 开启动画
405
409
  this.modelLayer.readyEvent.addEventListener(function () {
@@ -456,7 +460,7 @@ var ModelRoamRealTime = /*#__PURE__*/function () {
456
460
  var mergeStyle = merge(constant.DEFAULT_POLYLINE_OPTIONS(), cloneDeep(this.polylineOptions || {}));
457
461
  var currStyle = PolylineEntity.handleOptions(mergeStyle);
458
462
  // 创建轨迹线Entity,使用callback动态更新位置
459
- this.polylineLayer = this._map.entities.add({
463
+ this.polylineLayer = this.getMap().entities.add({
460
464
  id: uuidv4(),
461
465
  polyline: _objectSpread({
462
466
  positions: new Cesium.CallbackProperty(function () {
@@ -483,7 +487,7 @@ var ModelRoamRealTime = /*#__PURE__*/function () {
483
487
  var mergeStyle = merge(constant.DEFAULT_POLYLINE_OPTIONS(), cloneDeep(this.polylineOptions || {}));
484
488
  var currStyle = PolylineEntity.handleOptions(mergeStyle);
485
489
  // 创建历史轨迹线Entity,使用静态位置
486
- this.historyPolylineLayer = this._map.entities.add({
490
+ this.historyPolylineLayer = this.getMap().entities.add({
487
491
  id: uuidv4(),
488
492
  polyline: _objectSpread({
489
493
  positions: this.historyTrailPositions
@@ -691,7 +695,7 @@ var ModelRoamRealTime = /*#__PURE__*/function () {
691
695
  key: "updateFirstPersonView",
692
696
  value: function updateFirstPersonView(position) {
693
697
  // 设置相机位置和朝向
694
- this._map.camera.setView({
698
+ this.getMap().camera.setView({
695
699
  destination: position,
696
700
  orientation: {
697
701
  heading: this.hpRoll.heading,
@@ -714,7 +718,7 @@ var ModelRoamRealTime = /*#__PURE__*/function () {
714
718
  var cameraPosition = Cesium.Matrix4.multiplyByPoint(transform, offset, new Cesium.Cartesian3());
715
719
 
716
720
  // 设置相机位置和朝向
717
- this._map.camera.setView({
721
+ this.getMap().camera.setView({
718
722
  destination: cameraPosition,
719
723
  orientation: {
720
724
  heading: this.hpRoll.heading,
@@ -766,7 +770,7 @@ var ModelRoamRealTime = /*#__PURE__*/function () {
766
770
  value: function _flyToModel() {
767
771
  var boundingSphere = this.modelLayer.boundingSphere;
768
772
  boundingSphere.radius = Math.max(boundingSphere.radius || 100);
769
- this._map.camera.flyToBoundingSphere(boundingSphere);
773
+ this.getMap().camera.flyToBoundingSphere(boundingSphere);
770
774
  }
771
775
 
772
776
  /**
@@ -813,7 +817,7 @@ var ModelRoamRealTime = /*#__PURE__*/function () {
813
817
  }, {
814
818
  key: "on",
815
819
  value: function on(type, event) {
816
- return this._map._event.listenToModelRoam(type, event, this);
820
+ return this.getMap()._event.listenToModelRoam(type, event, this);
817
821
  }
818
822
 
819
823
  /**
@@ -827,15 +831,15 @@ var ModelRoamRealTime = /*#__PURE__*/function () {
827
831
  this.status = 'destroy';
828
832
  this._eventPostUpdate && this._eventPostUpdate.off();
829
833
  if (this.modelLayer) {
830
- this._map.scene.primitives.remove(this.modelLayer);
834
+ this.getMap().scene.primitives.remove(this.modelLayer);
831
835
  this.modelLayer = null;
832
836
  }
833
837
  if (this.polylineLayer) {
834
- this._map.entities.remove(this.polylineLayer);
838
+ this.getMap().entities.remove(this.polylineLayer);
835
839
  this.polylineLayer = null;
836
840
  }
837
841
  if (this.historyPolylineLayer) {
838
- this._map.entities.remove(this.historyPolylineLayer);
842
+ this.getMap().entities.remove(this.historyPolylineLayer);
839
843
  this.historyPolylineLayer = null;
840
844
  }
841
845
  this.receivedPositions = [];
@@ -1,5 +1,6 @@
1
+ import { MapContext } from '../map/Map';
1
2
  export default class Roam {
2
- private _map;
3
+ _mapContext: MapContext | undefined;
3
4
  cameraViews: any[];
4
5
  step: number;
5
6
  status: string;
@@ -8,6 +9,7 @@ export default class Roam {
8
9
  private _eventCancel;
9
10
  private _cameraViewTypeFun;
10
11
  constructor(map: any, cameraViews: any[], options?: any);
12
+ getMap(): any;
11
13
  start(start?: number, cameraViews?: any[]): Promise<void>;
12
14
  pause(): void;
13
15
  proceed(): Promise<void>;
@@ -22,7 +22,7 @@ import RotateInPlace from "./RotateInPlace";
22
22
  var Roam = /*#__PURE__*/function () {
23
23
  function Roam(map, cameraViews, options) {
24
24
  _classCallCheck(this, Roam);
25
- _defineProperty(this, "_map", void 0);
25
+ _defineProperty(this, "_mapContext", void 0);
26
26
  _defineProperty(this, "cameraViews", void 0);
27
27
  _defineProperty(this, "step", 0);
28
28
  _defineProperty(this, "status", 'prepare');
@@ -40,12 +40,17 @@ var Roam = /*#__PURE__*/function () {
40
40
  cancel = _ref.cancel;
41
41
  complete && (this._eventComplete = complete);
42
42
  cancel && (this._eventCancel = cancel);
43
- this._map = map;
43
+ this._mapContext = map._mapContext;
44
44
  this.cameraViews = cameraViews || [];
45
45
  }
46
-
47
- // 开始
48
46
  _createClass(Roam, [{
47
+ key: "getMap",
48
+ value: function getMap() {
49
+ return this._mapContext && this._mapContext.getMap();
50
+ }
51
+
52
+ // 开始
53
+ }, {
49
54
  key: "start",
50
55
  value: function () {
51
56
  var _start2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
@@ -110,7 +115,7 @@ var Roam = /*#__PURE__*/function () {
110
115
  value: function pause() {
111
116
  if (this.status !== 'start') return;
112
117
  this.status = 'cancel';
113
- this._map.camera.cancelFlight();
118
+ this.getMap().camera.cancelFlight();
114
119
  var step = this._stepSituation[this.step - 1];
115
120
  step.instance && step.instance.stop();
116
121
  }
@@ -163,7 +168,7 @@ var Roam = /*#__PURE__*/function () {
163
168
  value: function stop() {
164
169
  if (this.status !== 'start') return;
165
170
  this.status = 'prepare';
166
- this._map.camera.cancelFlight();
171
+ this.getMap().camera.cancelFlight();
167
172
  var step = this._stepSituation[this.step - 1];
168
173
  step.instance && step.instance.stop();
169
174
  this.step = 0;
@@ -173,7 +178,6 @@ var Roam = /*#__PURE__*/function () {
173
178
  key: "destroy",
174
179
  value: function destroy() {
175
180
  this.stop();
176
- this._map = null;
177
181
  this.cameraViews = [];
178
182
  this._eventComplete = null;
179
183
  this._eventCancel = null;
@@ -204,7 +208,7 @@ var Roam = /*#__PURE__*/function () {
204
208
  _context3.next = 4;
205
209
  return sleep(delay / 1000);
206
210
  case 4:
207
- _this._map.setCameraView({
211
+ _this.getMap().setCameraView({
208
212
  lat: lat,
209
213
  lng: lng,
210
214
  alt: alt,
@@ -226,7 +230,7 @@ var Roam = /*#__PURE__*/function () {
226
230
  status: 'cancel',
227
231
  type: 'camera',
228
232
  index: index,
229
- cameraView: _this._map.getCameraView()
233
+ cameraView: _this.getMap().getCameraView()
230
234
  };
231
235
  resolve('cancel');
232
236
  }
@@ -275,7 +279,7 @@ var Roam = /*#__PURE__*/function () {
275
279
  case 3:
276
280
  result = _context4.sent;
277
281
  if (result === 'complete') {
278
- rotate = new Rotate(_this2._map, {
282
+ rotate = new Rotate(_this2.getMap(), {
279
283
  complete: function complete() {
280
284
  _this2._stepSituation[_this2.step - 1] = {
281
285
  status: 'complete',
@@ -291,7 +295,7 @@ var Roam = /*#__PURE__*/function () {
291
295
  type: 'rotate',
292
296
  index: index,
293
297
  instance: rotate,
294
- cameraView: _this2._map.getCameraView()
298
+ cameraView: _this2.getMap().getCameraView()
295
299
  }, e);
296
300
  resolve('cancel');
297
301
  }
@@ -358,7 +362,7 @@ var Roam = /*#__PURE__*/function () {
358
362
  case 3:
359
363
  result = _context5.sent;
360
364
  if (result === 'complete') {
361
- rotateInPlace = new RotateInPlace(_this3._map, {
365
+ rotateInPlace = new RotateInPlace(_this3.getMap(), {
362
366
  complete: function complete() {
363
367
  _this3._stepSituation[_this3.step - 1] = {
364
368
  status: 'complete',
@@ -374,7 +378,7 @@ var Roam = /*#__PURE__*/function () {
374
378
  type: 'rotateInPlace',
375
379
  index: index,
376
380
  instance: rotateInPlace,
377
- cameraView: _this3._map.getCameraView()
381
+ cameraView: _this3.getMap().getCameraView()
378
382
  }, e);
379
383
  resolve('cancel');
380
384
  }
@@ -1,10 +1,12 @@
1
+ import { MapContext } from '../map/Map';
1
2
  export default class Rotate {
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;
@@ -12,8 +12,8 @@ import { lngLatAltToCartesian3 } from "../tool/utils";
12
12
  var Rotate = /*#__PURE__*/function () {
13
13
  function Rotate(map, options) {
14
14
  _classCallCheck(this, Rotate);
15
+ _defineProperty(this, "_mapContext", void 0);
15
16
  _defineProperty(this, "_timer", void 0);
16
- _defineProperty(this, "_map", void 0);
17
17
  _defineProperty(this, "_eventComplete", void 0);
18
18
  _defineProperty(this, "_eventCancel", void 0);
19
19
  _defineProperty(this, "_restAngle", void 0);
@@ -22,9 +22,14 @@ var Rotate = /*#__PURE__*/function () {
22
22
  cancel = _ref.cancel;
23
23
  complete && (this._eventComplete = complete);
24
24
  cancel && (this._eventCancel = cancel);
25
- this._map = map;
25
+ this._mapContext = map._mapContext;
26
26
  }
27
27
  _createClass(Rotate, [{
28
+ key: "getMap",
29
+ value: function getMap() {
30
+ return this._mapContext && this._mapContext.getMap();
31
+ }
32
+ }, {
28
33
  key: "start",
29
34
  value: function start(options) {
30
35
  var _this = this;
@@ -33,39 +38,39 @@ var Rotate = /*#__PURE__*/function () {
33
38
  duration = _ref2$duration === void 0 ? 10 : _ref2$duration,
34
39
  _ref2$angle = _ref2.angle,
35
40
  angle = _ref2$angle === void 0 ? 360 : _ref2$angle;
36
- var _this$_map$getMapCent = this._map.getMapCenter(),
37
- lng = _this$_map$getMapCent.lng,
38
- lat = _this$_map$getMapCent.lat,
39
- alt = _this$_map$getMapCent.alt;
41
+ var _this$getMap$getMapCe = this.getMap().getMapCenter(),
42
+ lng = _this$getMap$getMapCe.lng,
43
+ lat = _this$getMap$getMapCe.lat,
44
+ alt = _this$getMap$getMapCe.alt;
40
45
  var position = lngLatAltToCartesian3(lng, lat, alt);
41
- var cameraPosition = this._map.camera.position;
46
+ var cameraPosition = this.getMap().camera.position;
42
47
  // 根据屏幕中心像素的坐标获取中心点笛卡尔坐标
43
- var centerCartesian = this._map.camera.pickEllipsoid(new Cesium.Cartesian2(this._map.canvas.clientWidth / 2, this._map.canvas.clientHeight / 2), this._map.scene.globe.ellipsoid);
48
+ var centerCartesian = this.getMap().camera.pickEllipsoid(new Cesium.Cartesian2(this.getMap().canvas.clientWidth / 2, this.getMap().canvas.clientHeight / 2), this.getMap().scene.globe.ellipsoid);
44
49
  // 每秒飞行的角度
45
50
  var angleOneSecond = 360 / (360 / angle * duration);
46
51
  // 相机距离中心点的位置
47
52
  var distance = Cesium.Cartesian3.distance(cameraPosition, centerCartesian);
48
53
  // 倾斜角
49
- var pitch = this._map.camera.pitch;
54
+ var pitch = this.getMap().camera.pitch;
50
55
 
51
56
  // 开始时间
52
57
  var startTime = Cesium.JulianDate.fromDate(new Date());
53
58
  // 结束时间
54
59
  var stopTime = Cesium.JulianDate.addSeconds(startTime, duration, new Cesium.JulianDate());
55
- this._map.clock.startTime = startTime.clone(); // 开始时间
56
- this._map.clock.stopTime = stopTime.clone(); // 结速时间
57
- this._map.clock.currentTime = startTime.clone(); // 当前时间
58
- this._map.clock.clockRange = Cesium.ClockRange.CLAMPED; // 行为方式
59
- this._map.clock.clockStep = Cesium.ClockStep.SYSTEM_CLOCK; // 时钟设置为当前系统时间; 忽略所有其他设置。
60
+ this.getMap().clock.startTime = startTime.clone(); // 开始时间
61
+ this.getMap().clock.stopTime = stopTime.clone(); // 结速时间
62
+ this.getMap().clock.currentTime = startTime.clone(); // 当前时间
63
+ this.getMap().clock.clockRange = Cesium.ClockRange.CLAMPED; // 行为方式
64
+ this.getMap().clock.clockStep = Cesium.ClockStep.SYSTEM_CLOCK; // 时钟设置为当前系统时间; 忽略所有其他设置。
60
65
  // 相机的当前heading
61
- var initialHeading = this._map.camera.heading;
66
+ var initialHeading = this.getMap().camera.heading;
62
67
  this._timer = function () {
63
68
  // 当前已经过去的时间,单位s
64
- var delTime = Cesium.JulianDate.secondsDifference(_this._map.clock.currentTime, _this._map.clock.startTime);
69
+ var delTime = Cesium.JulianDate.secondsDifference(_this.getMap().clock.currentTime, _this.getMap().clock.startTime);
65
70
  // 修改heading
66
71
  var heading = Cesium.Math.toRadians(delTime * angleOneSecond) + initialHeading;
67
72
  _this._restAngle = angle - Cesium.Math.toDegrees(Cesium.Math.toRadians(delTime * angleOneSecond));
68
- _this._map.scene.camera.setView({
73
+ _this.getMap().scene.camera.setView({
69
74
  destination: position,
70
75
  // 点的坐标
71
76
  orientation: {
@@ -73,24 +78,24 @@ var Rotate = /*#__PURE__*/function () {
73
78
  pitch: pitch
74
79
  }
75
80
  });
76
- _this._map.scene.camera.moveBackward(distance);
77
- if (Cesium.JulianDate.compare(_this._map.clock.currentTime, _this._map.clock.stopTime) >= 0) {
78
- _this._map.clock.onTick.removeEventListener(_this._timer);
81
+ _this.getMap().scene.camera.moveBackward(distance);
82
+ if (Cesium.JulianDate.compare(_this.getMap().clock.currentTime, _this.getMap().clock.stopTime) >= 0) {
83
+ _this.getMap().clock.onTick.removeEventListener(_this._timer);
79
84
  _this._timer = null;
80
85
  if (_this._eventComplete) {
81
86
  _this._eventComplete();
82
87
  }
83
88
  }
84
89
  };
85
- this._map.clock.onTick.addEventListener(this._timer);
90
+ this.getMap().clock.onTick.addEventListener(this._timer);
86
91
  }
87
92
  }, {
88
93
  key: "stop",
89
94
  value: function stop() {
90
- this._timer && this._map.clock.onTick.removeEventListener(this._timer);
95
+ this._timer && this.getMap().clock.onTick.removeEventListener(this._timer);
91
96
  this._timer = null;
92
97
  if (this._eventCancel) {
93
- var time = Cesium.JulianDate.compare(this._map.clock.currentTime, this._map.clock.stopTime);
98
+ var time = Cesium.JulianDate.compare(this.getMap().clock.currentTime, this.getMap().clock.stopTime);
94
99
  this._eventCancel({
95
100
  restTime: time >= 0 ? 0 : time * -1,
96
101
  restAngle: this._restAngle <= 0 ? 0 : this._restAngle
@@ -100,9 +105,8 @@ var Rotate = /*#__PURE__*/function () {
100
105
  }, {
101
106
  key: "destroy",
102
107
  value: function destroy() {
103
- this._timer && this._map.clock.onTick.removeEventListener(this._timer);
108
+ this._timer && this.getMap().clock.onTick.removeEventListener(this._timer);
104
109
  this._timer = null;
105
- this._map = null;
106
110
  }
107
111
  }]);
108
112
  return Rotate;