deeptwins-engine-3d 0.1.37 → 0.1.39

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.
@@ -146,6 +146,7 @@ export declare const DEFAULT_SUN_ANALYSIS_OPTIONS: () => {
146
146
  clockRange: Cesium.ClockRange;
147
147
  clockStep: Cesium.ClockStep;
148
148
  };
149
+ export declare const DEFAULT_VIEWSHED_ANALYSIS_OPTIONS: () => {};
149
150
  export declare const DEFAULT_BASE_LAYER_TYPE: any;
150
151
  export declare const DEFAULT_BASE_LAYER: any;
151
152
  export declare const LAYER_TYPE_TO_CLASS: any;
@@ -233,6 +233,11 @@ export var DEFAULT_SUN_ANALYSIS_OPTIONS = function DEFAULT_SUN_ANALYSIS_OPTIONS(
233
233
  };
234
234
  };
235
235
 
236
+ // 默认可视域分析
237
+ export var DEFAULT_VIEWSHED_ANALYSIS_OPTIONS = function DEFAULT_VIEWSHED_ANALYSIS_OPTIONS() {
238
+ return {};
239
+ };
240
+
236
241
  // 默认的底图类型
237
242
  export var DEFAULT_BASE_LAYER_TYPE = {
238
243
  GAO_DE_IMG: 'gd_img',
@@ -4,36 +4,67 @@
4
4
 
5
5
  .deeptwins-compass {
6
6
  position: relative;
7
- width: 92px;
8
- height: 92px;
9
- background: #f7f7f7;
7
+ width: 90px;
8
+ height: 90px;
10
9
  border-radius: 50%;
11
- box-shadow: 0 0 10px rgba(0, 0, 0, 0.3);
10
+ box-shadow: 0 0 16px 0 rgba(48, 113, 144, 0.40);
12
11
  display: flex;
13
12
  align-items: center;
13
+ justify-content: center;
14
14
  user-select: none;
15
15
  }
16
16
 
17
+ .deeptwins-compass-bg {
18
+ position: absolute;
19
+ left: 0;
20
+ top: 0;
21
+ width: 100%;
22
+ height: 100%;
23
+ z-index: 1;
24
+ }
25
+
17
26
  .deeptwins-compass-left-direction {
27
+ position: relative;
28
+ z-index: 2;
18
29
  cursor: pointer;
30
+ width: 8px;
31
+ height: 32.5px;
32
+ }
33
+
34
+ .deeptwins-compass-pointer {
35
+ position: relative;
36
+ z-index: 2;
37
+ width: 44px;
38
+ height: 44px;
39
+ margin: 0 4px;
19
40
  }
20
41
 
21
42
  .deeptwins-compass-right-direction {
43
+ position: relative;
44
+ z-index: 2;
22
45
  cursor: pointer;
46
+ width: 8px;
47
+ height: 32.5px;
23
48
  }
24
49
 
25
50
  .deeptwins-compass-pitch-up {
26
51
  cursor: pointer;
27
52
  position: absolute;
28
- top: 3px;
53
+ z-index: 2;
54
+ top: 10px;
29
55
  left: 50%;
30
56
  transform: translateX(-50%);
57
+ width: 9px;
58
+ height: 5.5px;
31
59
  }
32
60
 
33
61
  .deeptwins-compass-pitch-down {
34
- cursor: pointer;
35
62
  position: absolute;
36
- bottom: 3px;
63
+ cursor: pointer;
64
+ z-index: 2;
65
+ bottom: 10px;
37
66
  left: 50%;
38
67
  transform: translateX(-50%);
68
+ width: 9px;
69
+ height: 5.5px;
39
70
  }
@@ -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;
@@ -63,5 +63,6 @@ export declare class DeepTwinsEngine3D {
63
63
  static SubmergenceAnalysis: any;
64
64
  static SunLightAnalysis: any;
65
65
  static KmlDataSource: any;
66
+ static Compass: any;
66
67
  }
67
68
  export default DeepTwinsEngine3D;
package/dist/esm/index.js CHANGED
@@ -34,6 +34,7 @@ import ArcGisLayer from "./tileLayer/ArcGisLayer";
34
34
  import RasterLayer from "./tileLayer/RasterLayer";
35
35
  import WmsLayer from "./tileLayer/WmsLayer";
36
36
  import WmtsLayer from "./tileLayer/WmtsLayer";
37
+ import Compass from "./tool/Compass";
37
38
  import TimerInterval from "./tool/TimerInterval";
38
39
  import { ClampToGround, ShapeSection } from "./tool/common";
39
40
  import { loadCss } from "./tool/utils";
@@ -51,11 +52,11 @@ DEEP_TWINS_BASE_URL && (window.CESIUM_BASE_URL = DEEP_TWINS_BASE_URL);
51
52
  // 全局加载css
52
53
  loadCss(Cesium.buildModuleUrl('Widgets/widgets.css'));
53
54
  // 打印版本信息
54
- console.log('DeepTwinsEngine3D Version:', "0.1.37");
55
+ console.log('DeepTwinsEngine3D Version:', "0.1.39");
55
56
  export var DeepTwinsEngine3D = /*#__PURE__*/_createClass(function DeepTwinsEngine3D() {
56
57
  _classCallCheck(this, DeepTwinsEngine3D);
57
58
  });
58
- _defineProperty(DeepTwinsEngine3D, "Version", "0.1.37");
59
+ _defineProperty(DeepTwinsEngine3D, "Version", "0.1.39");
59
60
  _defineProperty(DeepTwinsEngine3D, "Map", Map);
60
61
  _defineProperty(DeepTwinsEngine3D, "GroundSkyBox", GroundSkyBox);
61
62
  _defineProperty(DeepTwinsEngine3D, "RasterLayer", RasterLayer);
@@ -118,4 +119,5 @@ _defineProperty(DeepTwinsEngine3D, "ImageGlowingMaterialProperty", ImageGlowingM
118
119
  _defineProperty(DeepTwinsEngine3D, "SubmergenceAnalysis", SubmergenceAnalysis);
119
120
  _defineProperty(DeepTwinsEngine3D, "SunLightAnalysis", SunLightAnalysis);
120
121
  _defineProperty(DeepTwinsEngine3D, "KmlDataSource", Cesium.KmlDataSource);
122
+ _defineProperty(DeepTwinsEngine3D, "Compass", Compass);
121
123
  export default DeepTwinsEngine3D;
@@ -0,0 +1,23 @@
1
+ declare class Compass {
2
+ private readonly _mapContext;
3
+ isDestroyed: boolean;
4
+ container: any;
5
+ private _cameraChangeEvent;
6
+ private _rotate;
7
+ compassEl: any;
8
+ private _rotateTimer;
9
+ private _isRotating;
10
+ private _pitchTimer;
11
+ private _isPitching;
12
+ constructor(map: any, container: any);
13
+ private _canOperate;
14
+ getMap(): any;
15
+ private _create;
16
+ private _updateDirection;
17
+ private _startContinuousRotation;
18
+ private _stopContinuousRotation;
19
+ private _startContinuousPitch;
20
+ private _stopContinuousPitch;
21
+ destroy(): void;
22
+ }
23
+ export default Compass;
@@ -0,0 +1,250 @@
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
+ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
3
+ function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } }
4
+ function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
5
+ function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
6
+ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
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
+ import * as Cesium from 'deeptwins-cesium';
9
+ import { isString } from 'lodash';
10
+ import Rotate from "../cameraControl/Rotate";
11
+ import { CAMERA_EVENT_TYPE } from "../constant";
12
+ import { error, getDeepTwinsFile, lngLatAltToCartesian3, toDegrees, toRadians } from "../tool/utils";
13
+
14
+ // 罗盘
15
+ var Compass = /*#__PURE__*/function () {
16
+ function Compass(map, container) {
17
+ var _this = this;
18
+ _classCallCheck(this, Compass);
19
+ _defineProperty(this, "_mapContext", void 0);
20
+ _defineProperty(this, "isDestroyed", false);
21
+ _defineProperty(this, "container", void 0);
22
+ _defineProperty(this, "_cameraChangeEvent", void 0);
23
+ _defineProperty(this, "_rotate", void 0);
24
+ _defineProperty(this, "compassEl", {});
25
+ _defineProperty(this, "_rotateTimer", null);
26
+ _defineProperty(this, "_isRotating", false);
27
+ _defineProperty(this, "_pitchTimer", null);
28
+ _defineProperty(this, "_isPitching", false);
29
+ this._mapContext = map._mapContext;
30
+ this.container = isString(container) ? document.getElementById(container) : container;
31
+ this._rotate = new Rotate(map);
32
+ this._cameraChangeEvent = this.getMap().on(CAMERA_EVENT_TYPE.CHANGED, function (e) {
33
+ _this._updateDirection(e === null || e === void 0 ? void 0 : e.position);
34
+ });
35
+ this._create();
36
+ }
37
+
38
+ // 是否能进行操作
39
+ _createClass(Compass, [{
40
+ key: "_canOperate",
41
+ value: function _canOperate() {
42
+ if (this.isDestroyed) {
43
+ error('Compass实例已销毁');
44
+ return false;
45
+ }
46
+ return true;
47
+ }
48
+ }, {
49
+ key: "getMap",
50
+ value: function getMap() {
51
+ return this._mapContext && this._mapContext.getMap();
52
+ }
53
+ }, {
54
+ key: "_create",
55
+ value: function _create() {
56
+ var _this2 = this;
57
+ if (!this._canOperate()) {
58
+ return;
59
+ }
60
+ var el = document.createElement('div');
61
+ el.className = 'deeptwins-compass';
62
+ var bg = document.createElement('img');
63
+ bg.className = 'deeptwins-compass-bg';
64
+ bg.src = getDeepTwinsFile('Image/compass/compass-bg.png');
65
+ el.appendChild(bg);
66
+ var leftDirection = document.createElement('img');
67
+ leftDirection.className = 'deeptwins-compass-left-direction';
68
+ leftDirection.src = getDeepTwinsFile('Image/compass/compass-direction-left.png');
69
+ el.appendChild(leftDirection);
70
+
71
+ // 左箭头持续旋转
72
+ leftDirection.onmousedown = function () {
73
+ _this2._startContinuousRotation(1);
74
+ };
75
+ leftDirection.onmouseup = function () {
76
+ _this2._stopContinuousRotation();
77
+ };
78
+ leftDirection.onmouseleave = function () {
79
+ _this2._stopContinuousRotation();
80
+ };
81
+ this.compassEl.leftDirection = leftDirection;
82
+ var pointer = document.createElement('img');
83
+ pointer.className = 'deeptwins-compass-pointer';
84
+ pointer.src = getDeepTwinsFile('Image/compass/compass-pointer.png');
85
+ el.appendChild(pointer);
86
+ this.compassEl.pointer = pointer;
87
+ var rightDirection = document.createElement('img');
88
+ rightDirection.className = 'deeptwins-compass-right-direction';
89
+ rightDirection.src = getDeepTwinsFile('Image/compass/compass-direction-right.png');
90
+ el.appendChild(rightDirection);
91
+ // 右箭头持续旋转
92
+ rightDirection.onmousedown = function () {
93
+ _this2._startContinuousRotation(-1);
94
+ };
95
+ rightDirection.onmouseup = function () {
96
+ _this2._stopContinuousRotation();
97
+ };
98
+ rightDirection.onmouseleave = function () {
99
+ _this2._stopContinuousRotation();
100
+ };
101
+ this.compassEl.rightDirection = rightDirection;
102
+ var pitchUp = document.createElement('img');
103
+ pitchUp.className = 'deeptwins-compass-pitch-up';
104
+ pitchUp.src = getDeepTwinsFile('Image/compass/compass-pitch-up.png');
105
+ el.appendChild(pitchUp);
106
+ pitchUp.onmousedown = function () {
107
+ _this2._startContinuousPitch(1);
108
+ };
109
+ pitchUp.onmouseup = function () {
110
+ _this2._stopContinuousPitch();
111
+ };
112
+ pitchUp.onmouseleave = function () {
113
+ _this2._stopContinuousPitch();
114
+ };
115
+ this.compassEl.pitchUp = pitchUp;
116
+ var pitchDown = document.createElement('img');
117
+ pitchDown.className = 'deeptwins-compass-pitch-down';
118
+ pitchDown.src = getDeepTwinsFile('Image/compass/compass-pitch-down.png');
119
+ el.appendChild(pitchDown);
120
+ pitchDown.onmousedown = function () {
121
+ _this2._startContinuousPitch(-1);
122
+ };
123
+ pitchDown.onmouseup = function () {
124
+ _this2._stopContinuousPitch();
125
+ };
126
+ pitchDown.onmouseleave = function () {
127
+ _this2._stopContinuousPitch();
128
+ };
129
+ this.compassEl.pitchDown = pitchDown;
130
+ this.container.appendChild(el);
131
+ this._updateDirection(this.getMap().getCameraView());
132
+ }
133
+ }, {
134
+ key: "_updateDirection",
135
+ value: function _updateDirection(cameraView) {
136
+ if (!this._canOperate()) {
137
+ return;
138
+ }
139
+ var _ref = cameraView || {},
140
+ pitch = _ref.pitch,
141
+ heading = _ref.heading;
142
+ this.compassEl.pointer.style.transform = "rotateX(".concat(Math.min(90 + pitch, 80), "deg) rotateZ(").concat(360 - heading, "deg)");
143
+ }
144
+
145
+ // 开始持续旋转
146
+ }, {
147
+ key: "_startContinuousRotation",
148
+ value: function _startContinuousRotation(direction) {
149
+ var _this3 = this;
150
+ if (!this._canOperate()) return;
151
+ if (this._isRotating) return;
152
+ this._isRotating = true;
153
+ var rotate = function rotate() {
154
+ if (!_this3._isRotating) return;
155
+ // 立即旋转一个小角度
156
+ _this3._rotate.start({
157
+ duration: 0,
158
+ angle: direction * 2 // 每次旋转2度
159
+ });
160
+ _this3._updateDirection(_this3.getMap().getCameraView());
161
+ // 设置下次旋转
162
+ _this3._rotateTimer = setTimeout(rotate, 16); // 约60fps
163
+ };
164
+ rotate();
165
+ }
166
+
167
+ // 停止持续旋转
168
+ }, {
169
+ key: "_stopContinuousRotation",
170
+ value: function _stopContinuousRotation() {
171
+ if (!this._canOperate()) return;
172
+ this._isRotating = false;
173
+ if (this._rotateTimer) {
174
+ clearTimeout(this._rotateTimer);
175
+ this._rotateTimer = null;
176
+ }
177
+ }
178
+
179
+ // 开始持续pitch
180
+ }, {
181
+ key: "_startContinuousPitch",
182
+ value: function _startContinuousPitch(direction) {
183
+ var _this4 = this;
184
+ if (!this._canOperate()) return;
185
+ if (this._isPitching) return;
186
+ this._isPitching = true;
187
+ var setPitch = function setPitch() {
188
+ if (!_this4._isPitching) return;
189
+ if (direction === 1 && toDegrees(_this4.getMap().camera.pitch) >= -10) {
190
+ return;
191
+ }
192
+ var _this4$getMap$getMapC = _this4.getMap().getMapCenter(),
193
+ lng = _this4$getMap$getMapC.lng,
194
+ lat = _this4$getMap$getMapC.lat,
195
+ alt = _this4$getMap$getMapC.alt;
196
+ var position = lngLatAltToCartesian3(lng, lat, alt);
197
+ var cameraPosition = _this4.getMap().camera.position;
198
+ // 根据屏幕中心像素的坐标获取中心点笛卡尔坐标
199
+ var centerCartesian = _this4.getMap().camera.pickEllipsoid(new Cesium.Cartesian2(_this4.getMap().canvas.clientWidth / 2, _this4.getMap().canvas.clientHeight / 2), _this4.getMap().scene.globe.ellipsoid);
200
+ // 相机距离中心点的位置
201
+ var distance = Cesium.Cartesian3.distance(cameraPosition, centerCartesian);
202
+ // 倾斜角
203
+ var finalPitch = Math.min(toRadians(-9), Math.max(toRadians(-89), _this4.getMap().camera.pitch + toRadians(direction)));
204
+ _this4.getMap().scene.camera.setView({
205
+ destination: position,
206
+ orientation: {
207
+ heading: _this4.getMap().camera.heading,
208
+ pitch: finalPitch
209
+ }
210
+ });
211
+ _this4.getMap().scene.camera.moveBackward(distance);
212
+ // 设置下次调整
213
+ _this4._pitchTimer = setTimeout(setPitch, 16); // 约60fps
214
+ };
215
+ setPitch();
216
+ }
217
+
218
+ // 停止持续pitch
219
+ }, {
220
+ key: "_stopContinuousPitch",
221
+ value: function _stopContinuousPitch() {
222
+ if (!this._canOperate()) return;
223
+ this._isPitching = false;
224
+ if (this._pitchTimer) {
225
+ clearTimeout(this._pitchTimer);
226
+ this._pitchTimer = null;
227
+ }
228
+ }
229
+
230
+ // 销毁
231
+ }, {
232
+ key: "destroy",
233
+ value: function destroy() {
234
+ if (!this._canOperate()) {
235
+ return;
236
+ }
237
+ this.isDestroyed = true;
238
+ this.container.removeChild(this.container.querySelector('.deeptwins-compass'));
239
+ this._cameraChangeEvent && this._cameraChangeEvent.off();
240
+ this._cameraChangeEvent = null;
241
+
242
+ // 清理旋转和倾斜定时器
243
+ this._stopContinuousRotation();
244
+ this._stopContinuousPitch();
245
+ this.compassEl = {};
246
+ }
247
+ }]);
248
+ return Compass;
249
+ }();
250
+ export default Compass;
@@ -1 +1 @@
1
- .deepTwins-toolTip{background:rgba(42,42,42,.9);border-radius:4px;color:#fff;display:none;font-size:12px;padding:4px 8px;pointer-events:none;position:absolute;transform:translate3d(10px,-50%,0);white-space:nowrap}.deepTwins-toolTip:before{border-bottom:5px solid transparent;border-right:5px solid rgba(0,0,0,.6);border-top:5px solid transparent;content:"";display:block;left:-5px;pointer-events:none;position:absolute;top:calc(50% - 5px)}#yunjinglogo{display:none}.deeptwins-compass{align-items:center;background:#f7f7f7;border-radius:50%;box-shadow:0 0 10px rgba(0,0,0,.3);display:flex;height:92px;position:relative;-ms-user-select:none;user-select:none;width:92px}.deeptwins-compass-left-direction,.deeptwins-compass-right-direction{cursor:pointer}.deeptwins-compass-pitch-up{top:3px}.deeptwins-compass-pitch-down,.deeptwins-compass-pitch-up{cursor:pointer;left:50%;position:absolute;transform:translateX(-50%)}.deeptwins-compass-pitch-down{bottom:3px}
1
+ .deepTwins-toolTip{background:rgba(42,42,42,.9);border-radius:4px;color:#fff;display:none;font-size:12px;padding:4px 8px;pointer-events:none;position:absolute;transform:translate3d(10px,-50%,0);white-space:nowrap}.deepTwins-toolTip:before{border-bottom:5px solid transparent;border-right:5px solid rgba(0,0,0,.6);border-top:5px solid transparent;content:"";display:block;left:-5px;pointer-events:none;position:absolute;top:calc(50% - 5px)}#yunjinglogo{display:none}.deeptwins-compass{align-items:center;border-radius:50%;box-shadow:0 0 16px 0 rgba(48,113,144,.4);display:flex;height:90px;justify-content:center;position:relative;-ms-user-select:none;user-select:none;width:90px}.deeptwins-compass-bg{height:100%;left:0;position:absolute;top:0;width:100%;z-index:1}.deeptwins-compass-left-direction{cursor:pointer;height:32.5px;position:relative;width:8px;z-index:2}.deeptwins-compass-pointer{height:44px;margin:0 4px;position:relative;width:44px;z-index:2}.deeptwins-compass-right-direction{cursor:pointer;height:32.5px;position:relative;width:8px;z-index:2}.deeptwins-compass-pitch-up{top:10px}.deeptwins-compass-pitch-down,.deeptwins-compass-pitch-up{cursor:pointer;height:5.5px;left:50%;position:absolute;transform:translateX(-50%);width:9px;z-index:2}.deeptwins-compass-pitch-down{bottom:10px}