deeptwins-engine-3d 0.0.47 → 0.0.48

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.
@@ -6,6 +6,7 @@ interface Position {
6
6
  lng: number;
7
7
  lat: number;
8
8
  alt: number;
9
+ timestamp?: number;
9
10
  }
10
11
  export default class ModelRoamRealTime {
11
12
  readonly _map: any;
@@ -16,16 +17,16 @@ export default class ModelRoamRealTime {
16
17
  private readonly _onPositionUpdate;
17
18
  modelLayer: any;
18
19
  polylineLayer: any;
19
- private positions;
20
- private positionsLineC3;
21
- private positionInterC3;
20
+ private receivedPositions;
21
+ private completedSegments;
22
+ private currentSegment;
23
+ private futureSegments;
24
+ private currentPointIndex;
25
+ private segmentCounter;
22
26
  private _eventPreUpdate;
23
27
  private modelMatrix;
24
28
  private hpRoll;
25
- private _time;
26
29
  status: 'stop' | 'running' | 'destroy';
27
- private currentPathIndex;
28
- private maxPathIndex;
29
30
  private targetHeading;
30
31
  private currentHeading;
31
32
  private rotationSpeed;
@@ -35,9 +36,20 @@ export default class ModelRoamRealTime {
35
36
  /**
36
37
  * 实时添加点位
37
38
  * @param newPosition 新位置点
38
- * @throws 如果新位置与上一个位置完全相同
39
39
  */
40
40
  updatePosition(newPosition: Position): void;
41
+ /**
42
+ * 判断两个位置是否相同
43
+ */
44
+ private isSamePosition;
45
+ /**
46
+ * 创建新的路径段
47
+ */
48
+ private createNewSegment;
49
+ /**
50
+ * 开始漫游
51
+ */
52
+ private startRoaming;
41
53
  /**
42
54
  * 计算两点之间的路径点
43
55
  * 使用插值算法生成平滑的路径
@@ -49,7 +61,7 @@ export default class ModelRoamRealTime {
49
61
  private _getInterPosition;
50
62
  /**
51
63
  * 初始化模型
52
- * 加载模型
64
+ * 加载模型到第一个位置
53
65
  * @param initialPosition 初始位置
54
66
  */
55
67
  private initModel;
@@ -58,6 +70,31 @@ export default class ModelRoamRealTime {
58
70
  * 更新模型位置、朝向和路径线
59
71
  */
60
72
  private updateModel;
73
+ /**
74
+ * 完成当前路径段,切换到下一个路径段
75
+ */
76
+ private completeCurrentSegment;
77
+ /**
78
+ * 初始化轨迹线Entity
79
+ */
80
+ private initTrailLine;
81
+ /**
82
+ * 获取轨迹线位置点
83
+ * 返回:所有原始接收位置点 + 当前路径段已飞行的插值点
84
+ */
85
+ private getTrailLinePositions;
86
+ /**
87
+ * 更新轨迹线 - 现在由CallbackProperty自动更新
88
+ */
89
+ private updateTrailLine;
90
+ /**
91
+ * 获取当前状态信息
92
+ */
93
+ getStatus(): any;
94
+ /**
95
+ * 获取详细的飞行信息
96
+ */
97
+ getFlightDetails(): any;
61
98
  /**
62
99
  * 计算模型朝向
63
100
  * @param start 起始点
@@ -20,6 +20,10 @@ import { colorString } from "../tool/utils";
20
20
  * 位置信息
21
21
  */
22
22
 
23
+ /**
24
+ * 路径段信息
25
+ */
26
+
23
27
  /**
24
28
  * 相机设置
25
29
  */
@@ -44,12 +48,19 @@ var ModelRoamRealTime = /*#__PURE__*/function () {
44
48
  _defineProperty(this, "modelLayer", void 0);
45
49
  // 轨迹layer
46
50
  _defineProperty(this, "polylineLayer", void 0);
47
- // 所有位置信息点
48
- _defineProperty(this, "positions", []);
49
- // 所有轨迹位置信息点 Cartesian3
50
- _defineProperty(this, "positionsLineC3", []);
51
- // 插值后的位置信息点 Cartesian3
52
- _defineProperty(this, "positionInterC3", []);
51
+ // 重新设计的数据结构
52
+ // 接收到的原始位置数据
53
+ _defineProperty(this, "receivedPositions", []);
54
+ // 已完成飞行的路径段
55
+ _defineProperty(this, "completedSegments", []);
56
+ // 当前正在飞行的路径段
57
+ _defineProperty(this, "currentSegment", null);
58
+ // 未来计划飞行的路径段队列
59
+ _defineProperty(this, "futureSegments", []);
60
+ // 当前在路径段中的索引位置
61
+ _defineProperty(this, "currentPointIndex", 0);
62
+ // 路径段计数器
63
+ _defineProperty(this, "segmentCounter", 0);
53
64
  // 帧率更新的事件
54
65
  _defineProperty(this, "_eventPreUpdate", void 0);
55
66
  // 模型参数
@@ -58,14 +69,8 @@ var ModelRoamRealTime = /*#__PURE__*/function () {
58
69
  // 模型姿态
59
70
  _defineProperty(this, "hpRoll", new Cesium.HeadingPitchRoll());
60
71
  // 漫游相关
61
- // 上个点位的时间
62
- _defineProperty(this, "_time", new Date().getTime());
63
72
  // 状态
64
73
  _defineProperty(this, "status", 'stop');
65
- // 当前漫游路径点索引
66
- _defineProperty(this, "currentPathIndex", 0);
67
- // 最大路径点索引
68
- _defineProperty(this, "maxPathIndex", 0);
69
74
  // 目标朝向角度
70
75
  _defineProperty(this, "targetHeading", 0);
71
76
  // 当前朝向角度
@@ -87,55 +92,38 @@ var ModelRoamRealTime = /*#__PURE__*/function () {
87
92
  * 更新模型位置、朝向和路径线
88
93
  */
89
94
  _defineProperty(this, "updateModel", function () {
90
- if (_this.currentPathIndex >= _this.maxPathIndex) {
95
+ if (!_this.currentSegment || _this.status !== 'running') {
91
96
  return;
92
97
  }
93
- if (_this.currentPathIndex > 0 && _this.currentPathIndex < _this.positionInterC3.length - 1 && !_this.positionInterC3[_this.currentPathIndex - 1].equals(_this.positionInterC3[_this.currentPathIndex])) {
94
- _this.getHeading(_this.positionInterC3[_this.currentPathIndex - 1], _this.positionInterC3[_this.currentPathIndex]);
98
+
99
+ // 检查当前路径段是否完成
100
+ if (_this.currentPointIndex >= _this.currentSegment.interpolatedPoints.length) {
101
+ _this.completeCurrentSegment();
102
+ return;
103
+ }
104
+ var currentPos = _this.currentSegment.interpolatedPoints[_this.currentPointIndex];
105
+
106
+ // 计算朝向
107
+ if (_this.currentPointIndex > 0) {
108
+ var prevPos = _this.currentSegment.interpolatedPoints[_this.currentPointIndex - 1];
109
+ _this.getHeading(prevPos, currentPos);
95
110
  }
111
+
96
112
  // 更新朝向
97
113
  _this.updateHeading();
98
- var currentPos = _this.positionInterC3[_this.currentPathIndex];
99
- if (!_this.positionsLineC3.some(function (pos) {
100
- return pos.equals(currentPos);
101
- })) {
102
- _this.positionsLineC3.push(currentPos);
103
- if (_this.positions.length > 1) {
104
- // 更新轨迹
105
- _this.polylineLayer && _this._map.scene.primitives.remove(_this.polylineLayer);
106
- var trailGeometry = new Cesium.GeometryInstance({
107
- id: '_modelRoamRealTimePolyline',
108
- geometry: new Cesium.PolylineGeometry({
109
- positions: _this.positionsLineC3,
110
- width: _this.polylineOptions.width,
111
- vertexFormat: Cesium.PolylineMaterialAppearance.VERTEX_FORMAT
112
- })
113
- });
114
- _this.polylineLayer = _this._map.scene.primitives.add(new Cesium.Primitive({
115
- geometryInstances: trailGeometry,
116
- appearance: _this.polylineLayer ? _this.polylineLayer.appearance : new Cesium.PolylineMaterialAppearance({
117
- material: new Cesium.Material({
118
- fabric: {
119
- type: 'Color',
120
- uniforms: {
121
- color: colorString(_this.polylineOptions.color)
122
- }
123
- }
124
- })
125
- }),
126
- asynchronous: false
127
- }));
128
- }
129
- }
130
- if (_this.modelLayer && _this.currentPathIndex < _this.positionInterC3.length) {
131
- // 更新模型位置
132
- var _position = _this.positionInterC3[_this.currentPathIndex];
133
- _this.modelMatrix = Cesium.Transforms.headingPitchRollToFixedFrame(_position, _this.hpRoll, Cesium.Ellipsoid.WGS84, Cesium.Transforms.localFrameToFixedFrameGenerator('north', 'west'));
114
+
115
+ // 初始化轨迹线(如果还未创建)
116
+ _this.updateTrailLine();
117
+
118
+ // 更新模型位置
119
+ if (_this.modelLayer) {
120
+ // 只有位置真正发生变化时才更新矩阵
121
+ _this.modelMatrix = Cesium.Transforms.headingPitchRollToFixedFrame(currentPos, _this.hpRoll, Cesium.Ellipsoid.WGS84, Cesium.Transforms.localFrameToFixedFrameGenerator('north', 'west'));
134
122
  _this.modelLayer.modelMatrix = _this.modelMatrix;
135
123
 
136
124
  // 调用位置更新回调
137
125
  if (_this._onPositionUpdate) {
138
- var cartographic = Cesium.Cartographic.fromCartesian(_position);
126
+ var cartographic = Cesium.Cartographic.fromCartesian(currentPos);
139
127
  _this._onPositionUpdate({
140
128
  lon: Cesium.Math.toDegrees(cartographic.longitude),
141
129
  lat: Cesium.Math.toDegrees(cartographic.latitude),
@@ -146,19 +134,18 @@ var ModelRoamRealTime = /*#__PURE__*/function () {
146
134
  _this.updateCameraView();
147
135
  }
148
136
  }
149
- _this.currentPathIndex++;
137
+ _this.currentPointIndex++;
150
138
  });
151
- var _ref = options || {},
152
- model = _ref.model,
153
- polyline = _ref.polyline,
154
- onPositionUpdate = _ref.onPositionUpdate,
155
- flyTo = _ref.flyTo;
156
139
  if (!map) {
157
140
  throw new Error('undefined map');
158
141
  }
159
- if (!options.model && !((_options$model = options.model) !== null && _options$model !== void 0 && _options$model.url)) {
160
- throw new Error('undefined model');
142
+ if (!options || !options.model || !((_options$model = options.model) !== null && _options$model !== void 0 && _options$model.url)) {
143
+ throw new Error('undefined model or invalid options');
161
144
  }
145
+ var model = options.model,
146
+ polyline = options.polyline,
147
+ onPositionUpdate = options.onPositionUpdate,
148
+ flyTo = options.flyTo;
162
149
  this._map = map;
163
150
  this.modelOptions = model;
164
151
  this.polylineOptions = merge(constant.DEFAULT_POLYLINE_PRIMITIVE_OPTIONS(), cloneDeep(polyline || {}));
@@ -169,44 +156,97 @@ var ModelRoamRealTime = /*#__PURE__*/function () {
169
156
  /**
170
157
  * 实时添加点位
171
158
  * @param newPosition 新位置点
172
- * @throws 如果新位置与上一个位置完全相同
173
159
  */
174
160
  _createClass(ModelRoamRealTime, [{
175
161
  key: "updatePosition",
176
162
  value: function updatePosition(newPosition) {
163
+ console.log(newPosition);
164
+ if (!newPosition) return;
177
165
  if (this.status === 'destroy') return;
178
- if (!this.positions.length) {
166
+
167
+ // 添加时间戳
168
+ if (!newPosition.timestamp) {
169
+ newPosition.timestamp = new Date().getTime();
170
+ }
171
+
172
+ // 如果是第一次接收数据,初始化模型
173
+ if (this.receivedPositions.length === 0) {
174
+ this.receivedPositions.push(newPosition);
179
175
  this.initModel(newPosition);
180
176
  return;
181
177
  }
182
178
 
183
- // 获取最后一个目标点的位置(而不是当前飞行位置)
184
- var lastTargetPos = this.positions[this.positions.length - 1];
185
- if (lastTargetPos) {
186
- if (newPosition.lng === lastTargetPos.lng && newPosition.lat === lastTargetPos.lat && Math.abs(newPosition.alt - lastTargetPos.alt) < 0.1) {
187
- return;
188
- }
179
+ // 检查是否与上一个位置相同
180
+ var lastPos = this.receivedPositions[this.receivedPositions.length - 1];
181
+ if (this.isSamePosition(newPosition, lastPos)) {
182
+ return;
189
183
  }
190
184
 
191
- // 将新位置添加到目标点数组
192
- this.positions.push(newPosition);
193
-
194
- // 从最后一个目标点计算到新点的路径
195
- var lastPos = Cesium.Cartesian3.fromDegrees(lastTargetPos.lng, lastTargetPos.lat, lastTargetPos.alt);
196
- var newPos = Cesium.Cartesian3.fromDegrees(newPosition.lng, newPosition.lat, newPosition.alt);
197
-
198
- // 飞行时间
199
- var newTime = new Date().getTime();
200
- var flightTime = (newTime - this._time) / 1000;
201
- this._time = newTime;
202
- var newPath = this._getInterPosition(lastPos, newPos, flightTime);
203
- if (this.status === 'running') {
204
- this.positionInterC3 = this.positionInterC3.concat(newPath);
205
- this.maxPathIndex = this.positionInterC3.length;
185
+ // 添加新位置到接收队列
186
+ this.receivedPositions.push(newPosition);
187
+
188
+ // 创建新的路径段
189
+ this.createNewSegment(lastPos, newPosition);
190
+
191
+ // 如果模型还未开始运行,启动运行
192
+ if (this.status === 'stop') {
193
+ this.startRoaming();
194
+ }
195
+ }
196
+
197
+ /**
198
+ * 判断两个位置是否相同
199
+ */
200
+ }, {
201
+ key: "isSamePosition",
202
+ value: function isSamePosition(pos1, pos2) {
203
+ return pos1.lng === pos2.lng && pos1.lat === pos2.lat && Math.abs(pos1.alt - pos2.alt) < 0.1;
204
+ }
205
+
206
+ /**
207
+ * 创建新的路径段
208
+ */
209
+ }, {
210
+ key: "createNewSegment",
211
+ value: function createNewSegment(startPos, endPos) {
212
+ var startC3 = Cesium.Cartesian3.fromDegrees(startPos.lng, startPos.lat, startPos.alt);
213
+ var endC3 = Cesium.Cartesian3.fromDegrees(endPos.lng, endPos.lat, endPos.alt);
214
+
215
+ // 计算飞行时间
216
+ var flightTime = endPos.timestamp && startPos.timestamp ? (endPos.timestamp - startPos.timestamp) / 1000 : 5; // 默认5秒
217
+
218
+ // 计算插值点
219
+ var interpolatedPoints = this._getInterPosition(startC3, endC3, flightTime);
220
+ var newSegment = {
221
+ startPos: startPos,
222
+ endPos: endPos,
223
+ interpolatedPoints: interpolatedPoints,
224
+ segmentIndex: this.segmentCounter++,
225
+ isCompleted: false
226
+ };
227
+
228
+ // 如果当前没有正在飞行的路径段,则设为当前段
229
+ if (!this.currentSegment) {
230
+ this.currentSegment = newSegment;
231
+ this.currentPointIndex = 0;
206
232
  } else {
207
- this.currentPathIndex = 0;
233
+ // 否则加入未来路径段队列
234
+ this.futureSegments.push(newSegment);
208
235
  }
209
236
  }
237
+
238
+ /**
239
+ * 开始漫游
240
+ */
241
+ }, {
242
+ key: "startRoaming",
243
+ value: function startRoaming() {
244
+ if (this.status === 'running') return;
245
+ this.status = 'running';
246
+ // 监听帧率更新
247
+ this._eventPreUpdate = this._map.on(constant.SCENE_EVENT_TYPE.PRE_UPDATE, this.updateModel);
248
+ }
249
+
210
250
  /**
211
251
  * 计算两点之间的路径点
212
252
  * 使用插值算法生成平滑的路径
@@ -278,9 +318,10 @@ var ModelRoamRealTime = /*#__PURE__*/function () {
278
318
  }
279
319
  return arr;
280
320
  }
321
+
281
322
  /**
282
323
  * 初始化模型
283
- * 加载模型
324
+ * 加载模型到第一个位置
284
325
  * @param initialPosition 初始位置
285
326
  */
286
327
  }, {
@@ -292,20 +333,17 @@ var ModelRoamRealTime = /*#__PURE__*/function () {
292
333
  return _regeneratorRuntime().wrap(function _callee$(_context) {
293
334
  while (1) switch (_context.prev = _context.next) {
294
335
  case 0:
295
- // 添加初始位置到目标点数组
296
- this.positions.push(initialPosition);
297
- pos = Cesium.Cartesian3.fromDegrees(initialPosition.lng, initialPosition.lat, initialPosition.alt);
298
- this.positionsLineC3 = [pos];
299
- // 创建模型矩阵
336
+ pos = Cesium.Cartesian3.fromDegrees(initialPosition.lng, initialPosition.lat, initialPosition.alt); // 创建模型矩阵
300
337
  this.modelMatrix = Cesium.Transforms.headingPitchRollToFixedFrame(pos, this.hpRoll, Cesium.Ellipsoid.WGS84, Cesium.Transforms.localFrameToFixedFrameGenerator('north', 'west'));
301
- _context.next = 6;
338
+ _context.next = 4;
302
339
  return Cesium.Model.fromGltfAsync(_objectSpread({
303
340
  id: uuidv4(),
304
341
  modelMatrix: this.modelMatrix
305
342
  }, this.modelOptions));
306
- case 6:
343
+ case 4:
307
344
  model = _context.sent;
308
345
  this.modelLayer = this._map.scene.primitives.add(model);
346
+
309
347
  // 开启动画
310
348
  this.modelLayer.readyEvent.addEventListener(function () {
311
349
  if (_this2.flyTo) {
@@ -315,13 +353,8 @@ var ModelRoamRealTime = /*#__PURE__*/function () {
315
353
  loop: Cesium.ModelAnimationLoop.REPEAT,
316
354
  multiplier: 2
317
355
  });
318
- if (_this2.status === 'stop') {
319
- _this2.status = 'running';
320
- // 监听帧率
321
- _this2._eventPreUpdate = _this2._map.on(constant.SCENE_EVENT_TYPE.PRE_UPDATE, _this2.updateModel);
322
- }
323
356
  });
324
- case 9:
357
+ case 7:
325
358
  case "end":
326
359
  return _context.stop();
327
360
  }
@@ -333,14 +366,178 @@ var ModelRoamRealTime = /*#__PURE__*/function () {
333
366
  return initModel;
334
367
  }())
335
368
  }, {
336
- key: "getHeading",
369
+ key: "completeCurrentSegment",
337
370
  value:
371
+ /**
372
+ * 完成当前路径段,切换到下一个路径段
373
+ */
374
+ function completeCurrentSegment() {
375
+ if (!this.currentSegment) return;
376
+
377
+ // 标记当前段为已完成
378
+ this.currentSegment.isCompleted = true;
379
+ this.completedSegments.push(this.currentSegment);
380
+
381
+ // 从未来路径段队列中取出下一个路径段
382
+ if (this.futureSegments.length > 0) {
383
+ this.currentSegment = this.futureSegments.shift();
384
+ this.currentPointIndex = 0;
385
+ } else {
386
+ // 没有更多路径段,等待新数据
387
+ this.currentSegment = null;
388
+ this.currentPointIndex = 0;
389
+ }
390
+ }
391
+
392
+ /**
393
+ * 初始化轨迹线Entity
394
+ */
395
+ }, {
396
+ key: "initTrailLine",
397
+ value: function initTrailLine() {
398
+ var _this3 = this;
399
+ // 创建轨迹线Entity,使用callback动态更新位置
400
+ this.polylineLayer = this._map.entities.add({
401
+ id: '_modelRoamRealTimePolyline',
402
+ polyline: {
403
+ positions: new Cesium.CallbackProperty(function () {
404
+ return _this3.getTrailLinePositions();
405
+ }, false),
406
+ width: this.polylineOptions.width || 3,
407
+ material: colorString(this.polylineOptions.color || '#00ff00'),
408
+ clampToGround: false
409
+ }
410
+ });
411
+ }
412
+
413
+ /**
414
+ * 获取轨迹线位置点
415
+ * 返回:所有原始接收位置点 + 当前路径段已飞行的插值点
416
+ */
417
+ }, {
418
+ key: "getTrailLinePositions",
419
+ value: function getTrailLinePositions() {
420
+ var positions = [];
421
+
422
+ // 确保receivedPositions是数组且有足够数据
423
+ if (!Array.isArray(this.receivedPositions) || this.receivedPositions.length < 2) {
424
+ return positions;
425
+ }
426
+
427
+ // 添加所有原始接收到的位置点(转换为Cartesian3)
428
+ this.receivedPositions.forEach(function (pos) {
429
+ if (pos && typeof pos.lng === 'number' && typeof pos.lat === 'number' && typeof pos.alt === 'number') {
430
+ positions.push(Cesium.Cartesian3.fromDegrees(pos.lng, pos.lat, pos.alt));
431
+ }
432
+ });
433
+
434
+ // 如果当前有正在飞行的路径段,添加已飞行过的插值点
435
+ if (this.currentSegment && Array.isArray(this.currentSegment.interpolatedPoints) && this.currentPointIndex > 0) {
436
+ // 添加当前路径段中已经飞行过的插值点(跳过第一个点,避免重复)
437
+ for (var i = 1; i <= this.currentPointIndex && i < this.currentSegment.interpolatedPoints.length; i++) {
438
+ positions.push(this.currentSegment.interpolatedPoints[i]);
439
+ }
440
+ }
441
+ return positions;
442
+ }
443
+
444
+ /**
445
+ * 更新轨迹线 - 现在由CallbackProperty自动更新
446
+ */
447
+ }, {
448
+ key: "updateTrailLine",
449
+ value: function updateTrailLine() {
450
+ // 由于使用了CallbackProperty和getTrailLinePositions方法
451
+ // 轨迹线会自动更新显示:所有原始位置点 + 当前段已飞行的插值点
452
+ if (!this.polylineLayer && this.receivedPositions.length >= 2) {
453
+ this.initTrailLine();
454
+ }
455
+ }
456
+
457
+ /**
458
+ * 获取当前状态信息
459
+ */
460
+ }, {
461
+ key: "getStatus",
462
+ value: function getStatus() {
463
+ var _this$currentSegment;
464
+ var currentProgress = this.currentSegment ? Math.round(this.currentPointIndex / this.currentSegment.interpolatedPoints.length * 100) : 0;
465
+ return {
466
+ status: this.status,
467
+ receivedPositionsCount: this.receivedPositions.length,
468
+ completedSegmentsCount: this.completedSegments.length,
469
+ currentSegmentIndex: ((_this$currentSegment = this.currentSegment) === null || _this$currentSegment === void 0 ? void 0 : _this$currentSegment.segmentIndex) || null,
470
+ currentSegmentProgress: "".concat(currentProgress, "%"),
471
+ futureSegmentsCount: this.futureSegments.length,
472
+ currentPointIndex: this.currentPointIndex,
473
+ totalTrailPoints: this.getTrailLinePositions().length,
474
+ isWaitingForData: !this.currentSegment && this.futureSegments.length === 0
475
+ };
476
+ }
477
+
478
+ /**
479
+ * 获取详细的飞行信息
480
+ */
481
+ }, {
482
+ key: "getFlightDetails",
483
+ value: function getFlightDetails() {
484
+ var _this4 = this;
485
+ return {
486
+ // 当前位置信息
487
+ currentPosition: this.currentSegment && this.currentPointIndex < this.currentSegment.interpolatedPoints.length ? function () {
488
+ var pos = _this4.currentSegment.interpolatedPoints[_this4.currentPointIndex];
489
+ var cartographic = Cesium.Cartographic.fromCartesian(pos);
490
+ return {
491
+ longitude: Cesium.Math.toDegrees(cartographic.longitude),
492
+ latitude: Cesium.Math.toDegrees(cartographic.latitude),
493
+ height: cartographic.height
494
+ };
495
+ }() : null,
496
+ // 当前路径段信息
497
+ currentSegment: this.currentSegment ? {
498
+ index: this.currentSegment.segmentIndex,
499
+ startPos: this.currentSegment.startPos,
500
+ endPos: this.currentSegment.endPos,
501
+ totalPoints: this.currentSegment.interpolatedPoints.length,
502
+ currentPoint: this.currentPointIndex,
503
+ progress: Math.round(this.currentPointIndex / this.currentSegment.interpolatedPoints.length * 100)
504
+ } : null,
505
+ // 队列信息
506
+ queue: {
507
+ completed: Array.isArray(this.completedSegments) ? this.completedSegments.map(function (seg) {
508
+ return {
509
+ index: seg.segmentIndex,
510
+ from: "(".concat(seg.startPos.lng, ", ").concat(seg.startPos.lat, ")"),
511
+ to: "(".concat(seg.endPos.lng, ", ").concat(seg.endPos.lat, ")")
512
+ };
513
+ }) : [],
514
+ future: Array.isArray(this.futureSegments) ? this.futureSegments.map(function (seg) {
515
+ return {
516
+ index: seg.segmentIndex,
517
+ from: "(".concat(seg.startPos.lng, ", ").concat(seg.startPos.lat, ")"),
518
+ to: "(".concat(seg.endPos.lng, ", ").concat(seg.endPos.lat, ")"),
519
+ points: seg.interpolatedPoints.length
520
+ };
521
+ }) : []
522
+ },
523
+ // 整体统计
524
+ statistics: {
525
+ totalDataReceived: this.receivedPositions.length,
526
+ totalSegmentsCreated: this.segmentCounter,
527
+ totalTrailPoints: this.getTrailLinePositions().length,
528
+ memoryStatus: "\u5DF2\u5B8C\u6210\u6BB5\u6570: ".concat(this.completedSegments.length, ", \u7B49\u5F85\u6BB5\u6570: ").concat(this.futureSegments.length)
529
+ }
530
+ };
531
+ }
532
+
338
533
  /**
339
534
  * 计算模型朝向
340
535
  * @param start 起始点
341
536
  * @param end 终点
342
537
  */
343
- function getHeading(start, end) {
538
+ }, {
539
+ key: "getHeading",
540
+ value: function getHeading(start, end) {
344
541
  var startCartographic = Cesium.Cartographic.fromCartesian(start);
345
542
  var endCartographic = Cesium.Cartographic.fromCartesian(end);
346
543
  var startLonLat = [Cesium.Math.toDegrees(startCartographic.longitude), Cesium.Math.toDegrees(startCartographic.latitude)];
@@ -355,6 +552,7 @@ var ModelRoamRealTime = /*#__PURE__*/function () {
355
552
  var localDirection = Cesium.Matrix4.multiplyByPointAsVector(Cesium.Matrix4.inverse(transform, new Cesium.Matrix4()), direction, new Cesium.Cartesian3());
356
553
  this.targetHeading = Math.atan2(localDirection.x, localDirection.y);
357
554
  }
555
+
358
556
  /**
359
557
  * 更新模型朝向
360
558
  */
@@ -382,6 +580,7 @@ var ModelRoamRealTime = /*#__PURE__*/function () {
382
580
  // 更新模型朝向
383
581
  this.hpRoll = new Cesium.HeadingPitchRoll(this.currentHeading, 0.0, 0.0);
384
582
  }
583
+
385
584
  /**
386
585
  * 更新相机视角
387
586
  * 根据当前模式更新相机位置和朝向
@@ -389,16 +588,17 @@ var ModelRoamRealTime = /*#__PURE__*/function () {
389
588
  }, {
390
589
  key: "updateCameraView",
391
590
  value: function updateCameraView() {
392
- if (!this.modelLayer || !this.positionInterC3) {
591
+ if (!this.modelLayer || !this.currentSegment) {
393
592
  return;
394
593
  }
395
- var position = this.currentPathIndex >= this.positionInterC3.length ? this.positionInterC3[this.positionInterC3.length - 1] : this.positionInterC3[this.currentPathIndex];
594
+ var position = this.currentPointIndex >= this.currentSegment.interpolatedPoints.length ? this.currentSegment.interpolatedPoints[this.currentSegment.interpolatedPoints.length - 1] : this.currentSegment.interpolatedPoints[this.currentPointIndex];
396
595
  if (this.follow === 'first') {
397
596
  this.updateFirstPersonView(position);
398
597
  } else if (this.follow === 'third') {
399
598
  this.updateThirdPersonView(position);
400
599
  }
401
600
  }
601
+
402
602
  /**
403
603
  * 更新第一人称视角
404
604
  * @param position 模型当前位置
@@ -416,6 +616,7 @@ var ModelRoamRealTime = /*#__PURE__*/function () {
416
616
  }
417
617
  });
418
618
  }
619
+
419
620
  /**
420
621
  * 更新第三人称视角
421
622
  * @param position 模型当前位置
@@ -425,6 +626,7 @@ var ModelRoamRealTime = /*#__PURE__*/function () {
425
626
  value: function updateThirdPersonView(position) {
426
627
  this._map.camera.lookAt(position, new Cesium.HeadingPitchRange(this.hpRoll.heading, Cesium.Math.toRadians(this.thirdPersonSettings.pitch), this.thirdPersonSettings.distance));
427
628
  }
629
+
428
630
  /**
429
631
  * 设置第一人称视角
430
632
  */
@@ -436,6 +638,7 @@ var ModelRoamRealTime = /*#__PURE__*/function () {
436
638
  this.follow = 'first';
437
639
  this.updateCameraView();
438
640
  }
641
+
439
642
  /**
440
643
  * 设置第一人称视角
441
644
  */
@@ -447,6 +650,7 @@ var ModelRoamRealTime = /*#__PURE__*/function () {
447
650
  this.follow = 'third';
448
651
  this.updateCameraView();
449
652
  }
653
+
450
654
  /**
451
655
  * 取消视角跟随
452
656
  */
@@ -456,6 +660,7 @@ var ModelRoamRealTime = /*#__PURE__*/function () {
456
660
  if (this.status === 'destroy') return;
457
661
  this.follow = null;
458
662
  }
663
+
459
664
  /**
460
665
  * 飞行定位到模型
461
666
  */
@@ -466,6 +671,7 @@ var ModelRoamRealTime = /*#__PURE__*/function () {
466
671
  boundingSphere.radius = Math.max(boundingSphere.radius || 100);
467
672
  this._map.camera.flyToBoundingSphere(boundingSphere);
468
673
  }
674
+
469
675
  /**
470
676
  * 监听
471
677
  */
@@ -474,6 +680,7 @@ var ModelRoamRealTime = /*#__PURE__*/function () {
474
680
  value: function on(type, event) {
475
681
  return this._map._event.listenToModelRoam(type, event, this);
476
682
  }
683
+
477
684
  /**
478
685
  * 销毁实例
479
686
  * 清理所有资源
@@ -489,14 +696,15 @@ var ModelRoamRealTime = /*#__PURE__*/function () {
489
696
  this.modelLayer = null;
490
697
  }
491
698
  if (this.polylineLayer) {
492
- this._map.scene.primitives.remove(this.polylineLayer);
699
+ this._map.entities.remove(this.polylineLayer);
493
700
  this.polylineLayer = null;
494
701
  }
495
- this.positions = [];
496
- this.positionsLineC3 = [];
497
- this.positionInterC3 = [];
498
- this.currentPathIndex = 0;
499
- this.maxPathIndex = 0;
702
+ this.receivedPositions = [];
703
+ this.completedSegments = [];
704
+ this.currentSegment = null;
705
+ this.futureSegments = [];
706
+ this.currentPointIndex = 0;
707
+ this.segmentCounter = 0;
500
708
  }
501
709
  }]);
502
710
  return ModelRoamRealTime;
@@ -39,7 +39,8 @@ var DeepTwins = /*#__PURE__*/function () {
39
39
  terrain: this._getTerrain.bind(this),
40
40
  moduleLayer: this._getModuleLayer.bind(this),
41
41
  trafficHistoryLayer: this._YunJing.TrafficHistoryLayer,
42
- trafficLayer: this._YunJing.TrafficLayer
42
+ trafficLayer: this._YunJing.TrafficLayer,
43
+ gridVTLayer: this._YunJing.GridVTLayer
43
44
  });
44
45
  }
45
46
  case 5:
package/dist/index.js CHANGED
@@ -45,7 +45,7 @@ window.Cesium = Cesium;
45
45
  var DeepTwinsEngine3D = /*#__PURE__*/_createClass(function DeepTwinsEngine3D() {
46
46
  _classCallCheck(this, DeepTwinsEngine3D);
47
47
  });
48
- _defineProperty(DeepTwinsEngine3D, "Version", '0.0.47');
48
+ _defineProperty(DeepTwinsEngine3D, "Version", '0.0.48');
49
49
  _defineProperty(DeepTwinsEngine3D, "Map", Map);
50
50
  _defineProperty(DeepTwinsEngine3D, "GroundSkyBox", GroundSkyBox);
51
51
  _defineProperty(DeepTwinsEngine3D, "RasterLayer", RasterLayer);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "deeptwins-engine-3d",
3
- "version": "0.0.47",
3
+ "version": "0.0.48",
4
4
  "description": "map for 3d",
5
5
  "module": "dist/index.js",
6
6
  "types": "dist/index.d.ts",