deeptwins-engine-3d 0.1.40 → 0.1.41

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.
@@ -14,6 +14,7 @@ function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key i
14
14
  function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
15
15
  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); }
16
16
  import * as Cesium from 'deeptwins-cesium';
17
+ import * as utils from "../tool/utils";
17
18
 
18
19
  /**
19
20
  * 障碍物图层 - 基于MVT数据渲染障碍物网格
@@ -32,7 +33,7 @@ import * as Cesium from 'deeptwins-cesium';
32
33
  var BarrierLayer = /*#__PURE__*/function () {
33
34
  /**
34
35
  * 创建障碍物图层
35
- * @param viewer Cesium Viewer实例
36
+ * @param map Cesium Viewer实例
36
37
  * @param options 配置选项
37
38
  * @param options.gridVTLayer GridVTLayer类(从DeepTwins.onLoad中获取)
38
39
  * @param options.url MVT数据URL模板,默认为障碍物数据地址
@@ -44,15 +45,16 @@ var BarrierLayer = /*#__PURE__*/function () {
44
45
  * @param options.minHeight 最小高度(米),低于此高度的障碍物不渲染,默认0
45
46
  * @param options.maxHeight 最大高度(米),高于此高度的障碍物不渲染,默认Infinity
46
47
  */
47
- function BarrierLayer(viewer) {
48
+ function BarrierLayer(map) {
48
49
  var _this = this;
49
50
  var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
50
51
  _classCallCheck(this, BarrierLayer);
52
+ _defineProperty(this, "_mapContext", void 0);
53
+ _defineProperty(this, "isDestroyed", false);
51
54
  _defineProperty(this, "_gridVTLayer", null);
52
- _defineProperty(this, "_viewer", null);
53
55
  _defineProperty(this, "_options", {});
54
56
  _defineProperty(this, "_heightColors", []);
55
- this._viewer = viewer;
57
+ this._mapContext = map._mapContext;
56
58
  if (!options.gridVTLayer) {
57
59
  console.error('BarrierLayer: 请提供gridVTLayer参数,可通过DeepTwins.onLoad获取');
58
60
  return;
@@ -85,7 +87,7 @@ var BarrierLayer = /*#__PURE__*/function () {
85
87
  // 创建 GridVTLayer
86
88
  var customPrimitiveCallbacks = {
87
89
  createPrimitives: function createPrimitives(tileNum, renderData, viewer) {
88
- var targetViewer = viewer || _this._viewer;
90
+ var targetViewer = viewer || _this.getMap();
89
91
  return _this._createPrimitives(tileNum, renderData, targetViewer);
90
92
  },
91
93
  destroyPrimitives: function destroyPrimitives(tileNum, primitives) {
@@ -102,7 +104,7 @@ var BarrierLayer = /*#__PURE__*/function () {
102
104
  }
103
105
  };
104
106
  this._gridVTLayer = new GridVTLayer({
105
- viewer: this._viewer,
107
+ viewer: this.getMap(),
106
108
  url: this._options.url,
107
109
  cacheSize: this._options.cacheSize,
108
110
  dataZooms: this._options.dataZooms,
@@ -119,11 +121,27 @@ var BarrierLayer = /*#__PURE__*/function () {
119
121
  }
120
122
  }
121
123
 
122
- /**
123
- * 创建primitives
124
- * 按照示例代码的逻辑实现,每个feature创建一个障碍物实例
125
- */
124
+ // 是否能进行操作
126
125
  _createClass(BarrierLayer, [{
126
+ key: "_canOperate",
127
+ value: function _canOperate() {
128
+ if (this.isDestroyed) {
129
+ utils.error('SubmergenceAnalysis实例已销毁');
130
+ return false;
131
+ }
132
+ return true;
133
+ }
134
+ }, {
135
+ key: "getMap",
136
+ value: function getMap() {
137
+ return this._mapContext && this._mapContext.getMap();
138
+ }
139
+
140
+ /**
141
+ * 创建primitives
142
+ * 按照示例代码的逻辑实现,每个feature创建一个障碍物实例
143
+ */
144
+ }, {
127
145
  key: "_createPrimitives",
128
146
  value: function _createPrimitives(tileNum, renderData, viewer) {
129
147
  var features = (renderData === null || renderData === void 0 ? void 0 : renderData.default) || [];
@@ -169,7 +187,7 @@ var BarrierLayer = /*#__PURE__*/function () {
169
187
  closed: true
170
188
  })
171
189
  });
172
- var targetViewer = viewer || this._viewer;
190
+ var targetViewer = viewer || this.getMap();
173
191
  targetViewer.scene.primitives.add(primitive);
174
192
  primitives.push(primitive);
175
193
  }
@@ -186,8 +204,7 @@ var BarrierLayer = /*#__PURE__*/function () {
186
204
  if (!(primitives !== null && primitives !== void 0 && primitives.length)) return;
187
205
  primitives.forEach(function (primitive) {
188
206
  primitive.show = false;
189
- _this2._viewer.scene.primitives.remove(primitive);
190
- primitive.destroy();
207
+ _this2.getMap().scene.primitives.remove(primitive);
191
208
  });
192
209
  primitives.length = 0;
193
210
  }
@@ -65,17 +65,21 @@ var Compass = /*#__PURE__*/function () {
65
65
  el.appendChild(bg);
66
66
  var leftDirection = document.createElement('img');
67
67
  leftDirection.className = 'deeptwins-compass-left-direction';
68
- leftDirection.src = getDeepTwinsFile('Image/compass/compass-direction-left.png');
68
+ var leftDirectionImg = getDeepTwinsFile('Image/compass/compass-direction-left.png');
69
+ leftDirection.src = leftDirectionImg;
69
70
  el.appendChild(leftDirection);
70
71
 
71
72
  // 左箭头持续旋转
72
73
  leftDirection.onmousedown = function () {
74
+ leftDirection.src = getDeepTwinsFile('Image/compass/compass-direction-left-active.png');
73
75
  _this2._startContinuousRotation(1);
74
76
  };
75
77
  leftDirection.onmouseup = function () {
78
+ leftDirection.src = leftDirectionImg;
76
79
  _this2._stopContinuousRotation();
77
80
  };
78
81
  leftDirection.onmouseleave = function () {
82
+ leftDirection.src = leftDirectionImg;
79
83
  _this2._stopContinuousRotation();
80
84
  };
81
85
  this.compassEl.leftDirection = leftDirection;
@@ -86,44 +90,56 @@ var Compass = /*#__PURE__*/function () {
86
90
  this.compassEl.pointer = pointer;
87
91
  var rightDirection = document.createElement('img');
88
92
  rightDirection.className = 'deeptwins-compass-right-direction';
89
- rightDirection.src = getDeepTwinsFile('Image/compass/compass-direction-right.png');
93
+ var rightDirectionImg = getDeepTwinsFile('Image/compass/compass-direction-right.png');
94
+ rightDirection.src = rightDirectionImg;
90
95
  el.appendChild(rightDirection);
91
96
  // 右箭头持续旋转
92
97
  rightDirection.onmousedown = function () {
98
+ rightDirection.src = getDeepTwinsFile('Image/compass/compass-direction-right-active.png');
93
99
  _this2._startContinuousRotation(-1);
94
100
  };
95
101
  rightDirection.onmouseup = function () {
102
+ rightDirection.src = rightDirectionImg;
96
103
  _this2._stopContinuousRotation();
97
104
  };
98
105
  rightDirection.onmouseleave = function () {
106
+ rightDirection.src = rightDirectionImg;
99
107
  _this2._stopContinuousRotation();
100
108
  };
101
109
  this.compassEl.rightDirection = rightDirection;
102
110
  var pitchUp = document.createElement('img');
103
111
  pitchUp.className = 'deeptwins-compass-pitch-up';
104
- pitchUp.src = getDeepTwinsFile('Image/compass/compass-pitch-up.png');
112
+ var pitchUpImg = getDeepTwinsFile('Image/compass/compass-pitch-up.png');
113
+ pitchUp.src = pitchUpImg;
105
114
  el.appendChild(pitchUp);
106
115
  pitchUp.onmousedown = function () {
116
+ pitchUp.src = getDeepTwinsFile('Image/compass/compass-pitch-up-active.png');
107
117
  _this2._startContinuousPitch(1);
108
118
  };
109
119
  pitchUp.onmouseup = function () {
120
+ pitchUp.src = pitchUpImg;
110
121
  _this2._stopContinuousPitch();
111
122
  };
112
123
  pitchUp.onmouseleave = function () {
124
+ pitchUp.src = pitchUpImg;
113
125
  _this2._stopContinuousPitch();
114
126
  };
115
127
  this.compassEl.pitchUp = pitchUp;
116
128
  var pitchDown = document.createElement('img');
117
129
  pitchDown.className = 'deeptwins-compass-pitch-down';
118
- pitchDown.src = getDeepTwinsFile('Image/compass/compass-pitch-down.png');
130
+ var pitchDownImg = getDeepTwinsFile('Image/compass/compass-pitch-down.png');
131
+ pitchDown.src = pitchDownImg;
119
132
  el.appendChild(pitchDown);
120
133
  pitchDown.onmousedown = function () {
134
+ pitchDown.src = getDeepTwinsFile('Image/compass/compass-pitch-down-active.png');
121
135
  _this2._startContinuousPitch(-1);
122
136
  };
123
137
  pitchDown.onmouseup = function () {
138
+ pitchDown.src = pitchDownImg;
124
139
  _this2._stopContinuousPitch();
125
140
  };
126
141
  pitchDown.onmouseleave = function () {
142
+ pitchDown.src = pitchDownImg;
127
143
  _this2._stopContinuousPitch();
128
144
  };
129
145
  this.compassEl.pitchDown = pitchDown;