deeptwins-engine-3d 0.1.17 → 0.1.19

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.
@@ -222,9 +222,6 @@ var ModelRoamRealTime = /*#__PURE__*/function () {
222
222
  this.receivedPositions.push(newPosition);
223
223
  this.currentPos = Cesium.Cartesian3.fromDegrees(newPosition.lng, newPosition.lat, newPosition.alt);
224
224
  this.initModel(newPosition);
225
- if (this.follow) {
226
- this.updateCameraView();
227
- }
228
225
  if (this._onPositionUpdate) {
229
226
  this._onPositionUpdate({
230
227
  lng: newPosition.lng,
@@ -406,6 +403,9 @@ var ModelRoamRealTime = /*#__PURE__*/function () {
406
403
  if (_this2.flyTo) {
407
404
  _this2._flyToModel();
408
405
  }
406
+ if (_this2.follow) {
407
+ _this2.updateCameraView();
408
+ }
409
409
  _this2.modelLayer.activeAnimations.addAll({
410
410
  loop: Cesium.ModelAnimationLoop.REPEAT,
411
411
  multiplier: 2
@@ -1,4 +1,5 @@
1
1
  export default class BaseEntity {
2
+ private readonly _mapContext;
2
3
  id: any;
3
4
  source: any;
4
5
  style: any;
@@ -7,5 +8,6 @@ export default class BaseEntity {
7
8
  type: string;
8
9
  isEntity: boolean;
9
10
  constructor(options: any);
11
+ getMap(): any;
10
12
  updateStyle(originStyle: any, style: any): void;
11
13
  }
@@ -7,11 +7,11 @@ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol"
7
7
  function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
8
8
  import { merge } from 'lodash';
9
9
  import { v4 as uuidv4 } from 'uuid';
10
-
11
10
  // 基础实体图层
12
11
  var BaseEntity = /*#__PURE__*/function () {
13
12
  function BaseEntity(options) {
14
13
  _classCallCheck(this, BaseEntity);
14
+ _defineProperty(this, "_mapContext", void 0);
15
15
  _defineProperty(this, "id", void 0);
16
16
  _defineProperty(this, "source", void 0);
17
17
  _defineProperty(this, "style", void 0);
@@ -22,15 +22,22 @@ var BaseEntity = /*#__PURE__*/function () {
22
22
  this.id = uuidv4();
23
23
  var style = options.style,
24
24
  source = options.source,
25
- positionProperty = options.positionProperty;
25
+ positionProperty = options.positionProperty,
26
+ map = options.map;
27
+ this._mapContext = map._mapContext;
26
28
  this.type = options.type;
27
29
  this.positionProperty = positionProperty;
28
30
  this.source = source;
29
31
  this.style = style || {};
30
32
  }
31
-
32
- // 更新样式
33
33
  _createClass(BaseEntity, [{
34
+ key: "getMap",
35
+ value: function getMap() {
36
+ return this._mapContext && this._mapContext.getMap();
37
+ }
38
+
39
+ // 更新样式
40
+ }, {
34
41
  key: "updateStyle",
35
42
  value: function updateStyle(originStyle, style) {
36
43
  this.style = merge(this.style, originStyle);
@@ -15,7 +15,7 @@ export default class BaseSource {
15
15
  remove(): void;
16
16
  setData(data: any): this | undefined;
17
17
  _toDestroy(): void;
18
- static analysisSourceType(data: any): "other" | "wkt" | "sourceId" | "sourceInstance" | "geoJson";
18
+ static analysisSourceType(data: any): "wkt" | "sourceId" | "sourceInstance" | "geoJson" | "other";
19
19
  static wktToGeoJon(wkt: string): any;
20
20
  static geoJsonToGeoCartesian3Array(geoJson: any): any[];
21
21
  static handleFeaturePoint(feature: any): any;
@@ -79,7 +79,7 @@ var HtmlEntity = /*#__PURE__*/function (_BaseEntity) {
79
79
  _createClass(HtmlEntity, [{
80
80
  key: "_init",
81
81
  value: function _init(options) {
82
- var _document$getElementB;
82
+ var _this$getMap;
83
83
  var html = options.html,
84
84
  style = options.style;
85
85
  this.container = document.createElement('div');
@@ -91,7 +91,7 @@ var HtmlEntity = /*#__PURE__*/function (_BaseEntity) {
91
91
  this.container.style.cssText = 'position: absolute; left: 0; top: 0; pointer-events: auto;';
92
92
  this._setStyle(style);
93
93
  this.container.style.transform = 'translate3d(10000px, 10000px, 0)';
94
- (_document$getElementB = document.getElementById(HTML_CONTAINER_ID)) === null || _document$getElementB === void 0 || _document$getElementB.appendChild(this.container);
94
+ (_this$getMap = this.getMap()) === null || _this$getMap === void 0 || (_this$getMap = _this$getMap.container) === null || _this$getMap === void 0 || (_this$getMap = _this$getMap.querySelector('#' + HTML_CONTAINER_ID)) === null || _this$getMap === void 0 || _this$getMap.appendChild(this.container);
95
95
  this.postDomBack && this.postDomBack(this.container, this.source);
96
96
  this.isInit = true;
97
97
  }
package/dist/esm/index.js CHANGED
@@ -50,7 +50,7 @@ loadCss(Cesium.buildModuleUrl('Widgets/widgets.css'));
50
50
  export var DeepTwinsEngine3D = /*#__PURE__*/_createClass(function DeepTwinsEngine3D() {
51
51
  _classCallCheck(this, DeepTwinsEngine3D);
52
52
  });
53
- _defineProperty(DeepTwinsEngine3D, "Version", "0.1.17");
53
+ _defineProperty(DeepTwinsEngine3D, "Version", "0.1.19");
54
54
  _defineProperty(DeepTwinsEngine3D, "Map", Map);
55
55
  _defineProperty(DeepTwinsEngine3D, "GroundSkyBox", GroundSkyBox);
56
56
  _defineProperty(DeepTwinsEngine3D, "RasterLayer", RasterLayer);
@@ -59,6 +59,7 @@ export default class Map extends Cesium.Viewer implements MapContext {
59
59
  destroyGraphicLayer(): void;
60
60
  flyToGraphicLayer(layer: any, options: any): void;
61
61
  flyToGraphicLayers(layers: any[], options: any): void;
62
+ flyToPoints(geoJson: any, options: any): void;
62
63
  addTrafficHistory(TrafficHistoryLayer: any): any;
63
64
  addTerrain(terrain: any): Promise<unknown>;
64
65
  resetTerrain(): void;
@@ -23,8 +23,10 @@ function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key i
23
23
  function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
24
24
  function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
25
25
  import * as Cesium from 'deeptwins-cesium';
26
- import { isNil, merge, round } from 'lodash';
26
+ import { flattenDeep, isNil, merge, round } from 'lodash';
27
+ import { v4 as uuidv4 } from 'uuid';
27
28
  import * as constant from "../constant";
29
+ import BaseSource from "../graphicLayer/BaseSource";
28
30
  import GraphicLayerCollection from "../graphicLayer/GraphicLayerCollection";
29
31
  import * as common from "../tool/common";
30
32
  import * as utils from "../tool/utils";
@@ -582,6 +584,21 @@ var Map = /*#__PURE__*/function (_Cesium$Viewer) {
582
584
  this.graphicLayerCollection.flyToLayers(layers, options);
583
585
  }
584
586
 
587
+ // 飞行至多个点位的视角
588
+ }, {
589
+ key: "flyToPoints",
590
+ value: function flyToPoints(geoJson, options) {
591
+ var source = new BaseSource({
592
+ id: uuidv4(),
593
+ source: geoJson,
594
+ mapContext: this._mapContext
595
+ });
596
+ var positions = flattenDeep(source.source.map(function (t) {
597
+ return t.positions;
598
+ }));
599
+ utils.cameraFlyToPositions(this.getMap().camera, positions, options);
600
+ }
601
+
585
602
  // 添加路况
586
603
  }, {
587
604
  key: "addTrafficHistory",
@@ -56,8 +56,9 @@ var BaseVideo = /*#__PURE__*/function () {
56
56
  }, {
57
57
  key: "_init",
58
58
  value: function _init() {
59
- var _this = this;
60
- var videoContainer = document.getElementById(VIDEO_CONTAINER_ID);
59
+ var _this$getMap,
60
+ _this = this;
61
+ var videoContainer = (_this$getMap = this.getMap()) === null || _this$getMap === void 0 || (_this$getMap = _this$getMap.container) === null || _this$getMap === void 0 ? void 0 : _this$getMap.querySelector('#' + VIDEO_CONTAINER_ID);
61
62
  if (!videoContainer) {
62
63
  return;
63
64
  }
@@ -19,6 +19,7 @@ import h337 from "../tool/heatmap.js";
19
19
  import * as utils from "../tool/utils";
20
20
  var BaseHeatmap = /*#__PURE__*/function () {
21
21
  function BaseHeatmap() {
22
+ var _this$getMap;
22
23
  var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
23
24
  _classCallCheck(this, BaseHeatmap);
24
25
  _defineProperty(this, "_mapContext", void 0);
@@ -43,7 +44,7 @@ var BaseHeatmap = /*#__PURE__*/function () {
43
44
  var el = document.createElement('div');
44
45
  el.id = this.id;
45
46
  el.style.cssText = 'width: 100%; height: 100%; pointer-events: none; overflow: hidden; opacity: 0;';
46
- var heatmapContainer = document.getElementById(constant.HEATMAP_CONTAINER_ID);
47
+ var heatmapContainer = (_this$getMap = this.getMap()) === null || _this$getMap === void 0 || (_this$getMap = _this$getMap.container) === null || _this$getMap === void 0 ? void 0 : _this$getMap.querySelector('#' + constant.HEATMAP_CONTAINER_ID);
47
48
  if (!heatmapContainer) {
48
49
  return;
49
50
  }