deeptwins-engine-3d 0.1.33 → 0.1.35
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.
- package/dist/assets/Build/DeepTwins/Image/compass/compass-direction-left.png +0 -0
- package/dist/assets/Build/DeepTwins/Image/compass/compass-direction-right.png +0 -0
- package/dist/assets/Build/DeepTwins/Image/compass/pointer-white.png +0 -0
- package/dist/esm/analyze/SubmergenceAnalysis.d.ts +19 -0
- package/dist/esm/analyze/SubmergenceAnalysis.js +137 -0
- package/dist/esm/cameraControl/Rotate.js +22 -2
- package/dist/esm/constant.d.ts +8 -0
- package/dist/esm/constant.js +17 -0
- package/dist/esm/global.css +36 -0
- package/dist/esm/index.d.ts +3 -0
- package/dist/esm/index.js +7 -2
- package/dist/esm/tool/Compass.d.ts +23 -0
- package/dist/esm/tool/Compass.js +245 -0
- package/dist/esm/visualization/Airspace.js +6 -1
- package/dist/umd/deeptwins-engine-3d.min.css +1 -1
- package/dist/umd/deeptwins-engine-3d.min.js +1 -1
- package/package.json +1 -1
|
Binary file
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
declare class SubmergenceAnalysis {
|
|
2
|
+
private readonly _mapContext;
|
|
3
|
+
options: any;
|
|
4
|
+
isDestroyed: boolean;
|
|
5
|
+
extent: any;
|
|
6
|
+
private _layer;
|
|
7
|
+
private _timer;
|
|
8
|
+
private _currWaterHeight;
|
|
9
|
+
constructor(map: any, extent: any, options?: any);
|
|
10
|
+
private _canOperate;
|
|
11
|
+
getMap(): any;
|
|
12
|
+
private _createEntity;
|
|
13
|
+
flyTo(): void;
|
|
14
|
+
start(): void;
|
|
15
|
+
pause(): void;
|
|
16
|
+
stop(): void;
|
|
17
|
+
private destroy;
|
|
18
|
+
}
|
|
19
|
+
export default SubmergenceAnalysis;
|
|
@@ -0,0 +1,137 @@
|
|
|
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 { merge } from 'lodash';
|
|
10
|
+
import { DEFAULT_SUBMERGENCE_ANALYSIS_OPTIONS } from "../constant";
|
|
11
|
+
import TimerInterval from "../tool/TimerInterval";
|
|
12
|
+
import * as utils from "../tool/utils";
|
|
13
|
+
|
|
14
|
+
// 淹没分析
|
|
15
|
+
var SubmergenceAnalysis = /*#__PURE__*/function () {
|
|
16
|
+
function SubmergenceAnalysis(map, extent) {
|
|
17
|
+
var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
|
|
18
|
+
_classCallCheck(this, SubmergenceAnalysis);
|
|
19
|
+
_defineProperty(this, "_mapContext", void 0);
|
|
20
|
+
_defineProperty(this, "options", void 0);
|
|
21
|
+
_defineProperty(this, "isDestroyed", false);
|
|
22
|
+
_defineProperty(this, "extent", void 0);
|
|
23
|
+
// 范围 geojson类型
|
|
24
|
+
_defineProperty(this, "_layer", void 0);
|
|
25
|
+
_defineProperty(this, "_timer", void 0);
|
|
26
|
+
_defineProperty(this, "_currWaterHeight", void 0);
|
|
27
|
+
this._mapContext = map._mapContext;
|
|
28
|
+
this.extent = extent;
|
|
29
|
+
this.options = merge(DEFAULT_SUBMERGENCE_ANALYSIS_OPTIONS(), options);
|
|
30
|
+
this._currWaterHeight = this.options.waterHeight;
|
|
31
|
+
this._createEntity();
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
// 是否能进行操作
|
|
35
|
+
_createClass(SubmergenceAnalysis, [{
|
|
36
|
+
key: "_canOperate",
|
|
37
|
+
value: function _canOperate() {
|
|
38
|
+
if (this.isDestroyed) {
|
|
39
|
+
utils.error('Drawer实例已销毁');
|
|
40
|
+
return false;
|
|
41
|
+
}
|
|
42
|
+
return true;
|
|
43
|
+
}
|
|
44
|
+
}, {
|
|
45
|
+
key: "getMap",
|
|
46
|
+
value: function getMap() {
|
|
47
|
+
return this._mapContext && this._mapContext.getMap();
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
//创建淹没实体
|
|
51
|
+
}, {
|
|
52
|
+
key: "_createEntity",
|
|
53
|
+
value: function _createEntity() {
|
|
54
|
+
var _this = this;
|
|
55
|
+
if (!this._canOperate()) return;
|
|
56
|
+
this._layer = this.getMap().addGraphicLayer(this.extent, {
|
|
57
|
+
type: 'polygon',
|
|
58
|
+
style: {
|
|
59
|
+
heightReference: Cesium.HeightReference.CLAMP_TO_GROUND,
|
|
60
|
+
perPositionHeight: false,
|
|
61
|
+
material: this.options.color,
|
|
62
|
+
extrudedHeight: new Cesium.CallbackProperty(function () {
|
|
63
|
+
return _this._currWaterHeight;
|
|
64
|
+
}, false)
|
|
65
|
+
}
|
|
66
|
+
});
|
|
67
|
+
}
|
|
68
|
+
}, {
|
|
69
|
+
key: "flyTo",
|
|
70
|
+
value: function flyTo() {
|
|
71
|
+
if (!this._canOperate()) return;
|
|
72
|
+
this._layer && this._layer.flyTo();
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
//开始
|
|
76
|
+
}, {
|
|
77
|
+
key: "start",
|
|
78
|
+
value: function start() {
|
|
79
|
+
var _this2 = this;
|
|
80
|
+
if (!this._canOperate()) return;
|
|
81
|
+
this._timer = new TimerInterval(function () {
|
|
82
|
+
var sp = _this2.options.speed / 50;
|
|
83
|
+
if (_this2.options.changeType == 'up') {
|
|
84
|
+
_this2._currWaterHeight += sp;
|
|
85
|
+
if (_this2._currWaterHeight > _this2.options.targetHeight) {
|
|
86
|
+
_this2._currWaterHeight = _this2.options.targetHeight; //给个最大值
|
|
87
|
+
window.clearInterval(_this2._timer);
|
|
88
|
+
_this2.options.onComplete && _this2.options.onComplete();
|
|
89
|
+
}
|
|
90
|
+
} else {
|
|
91
|
+
_this2._currWaterHeight -= sp;
|
|
92
|
+
if (_this2._currWaterHeight < _this2.options.targetHeight) {
|
|
93
|
+
_this2._currWaterHeight = _this2.options.targetHeight; //给个最大值
|
|
94
|
+
window.clearInterval(_this2._timer);
|
|
95
|
+
_this2.options.onComplete && _this2.options.onComplete();
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
_this2.options.onChange && _this2.options.onChange(_this2._currWaterHeight);
|
|
99
|
+
}, 20);
|
|
100
|
+
this._timer.start(true);
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
// 暂停
|
|
104
|
+
}, {
|
|
105
|
+
key: "pause",
|
|
106
|
+
value: function pause() {
|
|
107
|
+
if (!this._canOperate()) return;
|
|
108
|
+
this._timer && this._timer.stop();
|
|
109
|
+
this._timer = null;
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
// 停止
|
|
113
|
+
}, {
|
|
114
|
+
key: "stop",
|
|
115
|
+
value: function stop() {
|
|
116
|
+
if (!this._canOperate()) return;
|
|
117
|
+
this._timer && this._timer.stop();
|
|
118
|
+
this._timer = null;
|
|
119
|
+
this._currWaterHeight = this.options.waterHeight;
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
//关闭
|
|
123
|
+
}, {
|
|
124
|
+
key: "destroy",
|
|
125
|
+
value: function destroy() {
|
|
126
|
+
if (!this._canOperate()) return;
|
|
127
|
+
this.isDestroyed = true;
|
|
128
|
+
this._timer && this._timer.stop();
|
|
129
|
+
this._timer = null;
|
|
130
|
+
this._currWaterHeight = null;
|
|
131
|
+
this._layer && this._layer.remove();
|
|
132
|
+
this._layer = null;
|
|
133
|
+
}
|
|
134
|
+
}]);
|
|
135
|
+
return SubmergenceAnalysis;
|
|
136
|
+
}();
|
|
137
|
+
export default SubmergenceAnalysis;
|
|
@@ -46,13 +46,33 @@ var Rotate = /*#__PURE__*/function () {
|
|
|
46
46
|
var cameraPosition = this.getMap().camera.position;
|
|
47
47
|
// 根据屏幕中心像素的坐标获取中心点笛卡尔坐标
|
|
48
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);
|
|
49
|
-
// 每秒飞行的角度
|
|
50
|
-
var angleOneSecond = 360 / (360 / angle * duration);
|
|
51
49
|
// 相机距离中心点的位置
|
|
52
50
|
var distance = Cesium.Cartesian3.distance(cameraPosition, centerCartesian);
|
|
53
51
|
// 倾斜角
|
|
54
52
|
var pitch = this.getMap().camera.pitch;
|
|
55
53
|
|
|
54
|
+
// 如果duration为0,立即飞行到目标位置
|
|
55
|
+
if (duration === 0) {
|
|
56
|
+
var finalHeading = this.getMap().camera.heading + Cesium.Math.toRadians(angle);
|
|
57
|
+
this.getMap().scene.camera.setView({
|
|
58
|
+
destination: position,
|
|
59
|
+
// 点的坐标
|
|
60
|
+
orientation: {
|
|
61
|
+
heading: finalHeading,
|
|
62
|
+
pitch: pitch
|
|
63
|
+
}
|
|
64
|
+
});
|
|
65
|
+
this.getMap().scene.camera.moveBackward(distance);
|
|
66
|
+
// 立即触发完成事件
|
|
67
|
+
if (this._eventComplete) {
|
|
68
|
+
this._eventComplete();
|
|
69
|
+
}
|
|
70
|
+
return;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
// 每秒飞行的角度
|
|
74
|
+
var angleOneSecond = 360 / (360 / angle * duration);
|
|
75
|
+
|
|
56
76
|
// 开始时间
|
|
57
77
|
var startTime = Cesium.JulianDate.fromDate(new Date());
|
|
58
78
|
// 结束时间
|
package/dist/esm/constant.d.ts
CHANGED
|
@@ -131,6 +131,14 @@ export declare const DEFAULT_VIDEO_TEXTURE_HLS: () => {
|
|
|
131
131
|
width: number;
|
|
132
132
|
height: number;
|
|
133
133
|
};
|
|
134
|
+
export declare const DEFAULT_SUBMERGENCE_ANALYSIS_OPTIONS: () => {
|
|
135
|
+
startHeight: number;
|
|
136
|
+
targetHeight: number;
|
|
137
|
+
waterHeight: number;
|
|
138
|
+
speed: number;
|
|
139
|
+
color: string;
|
|
140
|
+
changeType: string;
|
|
141
|
+
};
|
|
134
142
|
export declare const DEFAULT_BASE_LAYER_TYPE: any;
|
|
135
143
|
export declare const DEFAULT_BASE_LAYER: any;
|
|
136
144
|
export declare const LAYER_TYPE_TO_CLASS: any;
|
package/dist/esm/constant.js
CHANGED
|
@@ -205,6 +205,23 @@ export var DEFAULT_VIDEO_TEXTURE_HLS = function DEFAULT_VIDEO_TEXTURE_HLS() {
|
|
|
205
205
|
};
|
|
206
206
|
};
|
|
207
207
|
|
|
208
|
+
// 默认淹没分析配置选项 SubmergenceAnalysis
|
|
209
|
+
export var DEFAULT_SUBMERGENCE_ANALYSIS_OPTIONS = function DEFAULT_SUBMERGENCE_ANALYSIS_OPTIONS() {
|
|
210
|
+
return {
|
|
211
|
+
startHeight: 0,
|
|
212
|
+
// 开始高度
|
|
213
|
+
targetHeight: 100,
|
|
214
|
+
// 目标高度
|
|
215
|
+
waterHeight: 0,
|
|
216
|
+
// 水面高度
|
|
217
|
+
speed: 1,
|
|
218
|
+
// 速度
|
|
219
|
+
color: '#409DFD',
|
|
220
|
+
// 颜色
|
|
221
|
+
changeType: 'up' // 变化类型 up/down
|
|
222
|
+
};
|
|
223
|
+
};
|
|
224
|
+
|
|
208
225
|
// 默认的底图类型
|
|
209
226
|
export var DEFAULT_BASE_LAYER_TYPE = {
|
|
210
227
|
GAO_DE_IMG: 'gd_img',
|
package/dist/esm/global.css
CHANGED
|
@@ -1,3 +1,39 @@
|
|
|
1
1
|
#yunjinglogo {
|
|
2
2
|
display: none;
|
|
3
3
|
}
|
|
4
|
+
|
|
5
|
+
.deeptwins-compass {
|
|
6
|
+
position: relative;
|
|
7
|
+
width: 92px;
|
|
8
|
+
height: 92px;
|
|
9
|
+
background: #f7f7f7;
|
|
10
|
+
border-radius: 50%;
|
|
11
|
+
box-shadow: 0 0 10px rgba(0, 0, 0, 0.3);
|
|
12
|
+
display: flex;
|
|
13
|
+
align-items: center;
|
|
14
|
+
user-select: none;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
.deeptwins-compass-left-direction {
|
|
18
|
+
cursor: pointer;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
.deeptwins-compass-right-direction {
|
|
22
|
+
cursor: pointer;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
.deeptwins-compass-pitch-up {
|
|
26
|
+
cursor: pointer;
|
|
27
|
+
position: absolute;
|
|
28
|
+
top: 3px;
|
|
29
|
+
left: 50%;
|
|
30
|
+
transform: translateX(-50%);
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
.deeptwins-compass-pitch-down {
|
|
34
|
+
cursor: pointer;
|
|
35
|
+
position: absolute;
|
|
36
|
+
bottom: 3px;
|
|
37
|
+
left: 50%;
|
|
38
|
+
transform: translateX(-50%);
|
|
39
|
+
}
|
package/dist/esm/index.d.ts
CHANGED
|
@@ -60,5 +60,8 @@ export declare class DeepTwinsEngine3D {
|
|
|
60
60
|
static BoundingRectangle: any;
|
|
61
61
|
static SplitDirection: any;
|
|
62
62
|
static ImageGlowingMaterialProperty: any;
|
|
63
|
+
static SubmergenceAnalysis: any;
|
|
64
|
+
static Compass: any;
|
|
65
|
+
static KmlDataSource: any;
|
|
63
66
|
}
|
|
64
67
|
export default DeepTwinsEngine3D;
|
package/dist/esm/index.js
CHANGED
|
@@ -7,6 +7,7 @@ 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
|
//引入cesium基础库
|
|
9
9
|
import * as Cesium from 'deeptwins-cesium';
|
|
10
|
+
import SubmergenceAnalysis from "./analyze/SubmergenceAnalysis";
|
|
10
11
|
import ModelRoamHistory from "./cameraControl/ModelRoamHistory";
|
|
11
12
|
import ModelRoamRealTime from "./cameraControl/ModelRoamRealTime";
|
|
12
13
|
import Roam from "./cameraControl/Roam";
|
|
@@ -32,6 +33,7 @@ import ArcGisLayer from "./tileLayer/ArcGisLayer";
|
|
|
32
33
|
import RasterLayer from "./tileLayer/RasterLayer";
|
|
33
34
|
import WmsLayer from "./tileLayer/WmsLayer";
|
|
34
35
|
import WmtsLayer from "./tileLayer/WmtsLayer";
|
|
36
|
+
import Compass from "./tool/Compass";
|
|
35
37
|
import TimerInterval from "./tool/TimerInterval";
|
|
36
38
|
import { ClampToGround, ShapeSection } from "./tool/common";
|
|
37
39
|
import { loadCss } from "./tool/utils";
|
|
@@ -49,11 +51,11 @@ DEEP_TWINS_BASE_URL && (window.CESIUM_BASE_URL = DEEP_TWINS_BASE_URL);
|
|
|
49
51
|
// 全局加载css
|
|
50
52
|
loadCss(Cesium.buildModuleUrl('Widgets/widgets.css'));
|
|
51
53
|
// 打印版本信息
|
|
52
|
-
console.log('DeepTwinsEngine3D Version:', "0.1.
|
|
54
|
+
console.log('DeepTwinsEngine3D Version:', "0.1.35");
|
|
53
55
|
export var DeepTwinsEngine3D = /*#__PURE__*/_createClass(function DeepTwinsEngine3D() {
|
|
54
56
|
_classCallCheck(this, DeepTwinsEngine3D);
|
|
55
57
|
});
|
|
56
|
-
_defineProperty(DeepTwinsEngine3D, "Version", "0.1.
|
|
58
|
+
_defineProperty(DeepTwinsEngine3D, "Version", "0.1.35");
|
|
57
59
|
_defineProperty(DeepTwinsEngine3D, "Map", Map);
|
|
58
60
|
_defineProperty(DeepTwinsEngine3D, "GroundSkyBox", GroundSkyBox);
|
|
59
61
|
_defineProperty(DeepTwinsEngine3D, "RasterLayer", RasterLayer);
|
|
@@ -113,4 +115,7 @@ _defineProperty(DeepTwinsEngine3D, "DistanceDisplayCondition", Cesium.DistanceDi
|
|
|
113
115
|
_defineProperty(DeepTwinsEngine3D, "BoundingRectangle", Cesium.BoundingRectangle);
|
|
114
116
|
_defineProperty(DeepTwinsEngine3D, "SplitDirection", Cesium.SplitDirection);
|
|
115
117
|
_defineProperty(DeepTwinsEngine3D, "ImageGlowingMaterialProperty", ImageGlowingMaterialProperty);
|
|
118
|
+
_defineProperty(DeepTwinsEngine3D, "SubmergenceAnalysis", SubmergenceAnalysis);
|
|
119
|
+
_defineProperty(DeepTwinsEngine3D, "Compass", Compass);
|
|
120
|
+
_defineProperty(DeepTwinsEngine3D, "KmlDataSource", Cesium.KmlDataSource);
|
|
116
121
|
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,245 @@
|
|
|
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 leftDirection = document.createElement('img');
|
|
63
|
+
leftDirection.className = 'deeptwins-compass-left-direction';
|
|
64
|
+
leftDirection.src = getDeepTwinsFile('Image/compass/compass-direction-left.png');
|
|
65
|
+
el.appendChild(leftDirection);
|
|
66
|
+
|
|
67
|
+
// 左箭头持续旋转
|
|
68
|
+
leftDirection.onmousedown = function () {
|
|
69
|
+
_this2._startContinuousRotation(1);
|
|
70
|
+
};
|
|
71
|
+
leftDirection.onmouseup = function () {
|
|
72
|
+
_this2._stopContinuousRotation();
|
|
73
|
+
};
|
|
74
|
+
leftDirection.onmouseleave = function () {
|
|
75
|
+
_this2._stopContinuousRotation();
|
|
76
|
+
};
|
|
77
|
+
this.compassEl.leftDirection = leftDirection;
|
|
78
|
+
var pointer = document.createElement('img');
|
|
79
|
+
pointer.className = 'deeptwins-compass-pointer';
|
|
80
|
+
pointer.src = getDeepTwinsFile('Image/compass/pointer-white.png');
|
|
81
|
+
el.appendChild(pointer);
|
|
82
|
+
this.compassEl.pointer = pointer;
|
|
83
|
+
var rightDirection = document.createElement('img');
|
|
84
|
+
rightDirection.className = 'deeptwins-compass-right-direction';
|
|
85
|
+
rightDirection.src = getDeepTwinsFile('Image/compass/compass-direction-right.png');
|
|
86
|
+
el.appendChild(rightDirection);
|
|
87
|
+
// 右箭头持续旋转
|
|
88
|
+
rightDirection.onmousedown = function () {
|
|
89
|
+
_this2._startContinuousRotation(-1);
|
|
90
|
+
};
|
|
91
|
+
rightDirection.onmouseup = function () {
|
|
92
|
+
_this2._stopContinuousRotation();
|
|
93
|
+
};
|
|
94
|
+
rightDirection.onmouseleave = function () {
|
|
95
|
+
_this2._stopContinuousRotation();
|
|
96
|
+
};
|
|
97
|
+
this.compassEl.rightDirection = rightDirection;
|
|
98
|
+
var pitchUp = document.createElement('img');
|
|
99
|
+
pitchUp.className = 'deeptwins-compass-pitch-up';
|
|
100
|
+
pitchUp.src = getDeepTwinsFile('Image/compass/compass-pitch-up.png');
|
|
101
|
+
el.appendChild(pitchUp);
|
|
102
|
+
pitchUp.onmousedown = function () {
|
|
103
|
+
_this2._startContinuousPitch(1);
|
|
104
|
+
};
|
|
105
|
+
pitchUp.onmouseup = function () {
|
|
106
|
+
_this2._stopContinuousPitch();
|
|
107
|
+
};
|
|
108
|
+
pitchUp.onmouseleave = function () {
|
|
109
|
+
_this2._stopContinuousPitch();
|
|
110
|
+
};
|
|
111
|
+
this.compassEl.pitchUp = pitchUp;
|
|
112
|
+
var pitchDown = document.createElement('img');
|
|
113
|
+
pitchDown.className = 'deeptwins-compass-pitch-down';
|
|
114
|
+
pitchDown.src = getDeepTwinsFile('Image/compass/compass-pitch-down.png');
|
|
115
|
+
el.appendChild(pitchDown);
|
|
116
|
+
pitchDown.onmousedown = function () {
|
|
117
|
+
_this2._startContinuousPitch(-1);
|
|
118
|
+
};
|
|
119
|
+
pitchDown.onmouseup = function () {
|
|
120
|
+
_this2._stopContinuousPitch();
|
|
121
|
+
};
|
|
122
|
+
pitchDown.onmouseleave = function () {
|
|
123
|
+
_this2._stopContinuousPitch();
|
|
124
|
+
};
|
|
125
|
+
this.compassEl.pitchDown = pitchDown;
|
|
126
|
+
this.container.appendChild(el);
|
|
127
|
+
this._updateDirection(this.getMap().getCameraView());
|
|
128
|
+
}
|
|
129
|
+
}, {
|
|
130
|
+
key: "_updateDirection",
|
|
131
|
+
value: function _updateDirection(cameraView) {
|
|
132
|
+
if (!this._canOperate()) {
|
|
133
|
+
return;
|
|
134
|
+
}
|
|
135
|
+
var _ref = cameraView || {},
|
|
136
|
+
pitch = _ref.pitch,
|
|
137
|
+
heading = _ref.heading;
|
|
138
|
+
this.compassEl.pointer.style.transform = "rotateX(".concat(Math.min(90 + pitch, 80), "deg) rotateZ(").concat(360 - heading, "deg)");
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
// 开始持续旋转
|
|
142
|
+
}, {
|
|
143
|
+
key: "_startContinuousRotation",
|
|
144
|
+
value: function _startContinuousRotation(direction) {
|
|
145
|
+
var _this3 = this;
|
|
146
|
+
if (!this._canOperate()) return;
|
|
147
|
+
if (this._isRotating) return;
|
|
148
|
+
this._isRotating = true;
|
|
149
|
+
var rotate = function rotate() {
|
|
150
|
+
if (!_this3._isRotating) return;
|
|
151
|
+
// 立即旋转一个小角度
|
|
152
|
+
_this3._rotate.start({
|
|
153
|
+
duration: 0,
|
|
154
|
+
angle: direction * 2 // 每次旋转2度
|
|
155
|
+
});
|
|
156
|
+
// 设置下次旋转
|
|
157
|
+
_this3._rotateTimer = setTimeout(rotate, 16); // 约60fps
|
|
158
|
+
};
|
|
159
|
+
rotate();
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
// 停止持续旋转
|
|
163
|
+
}, {
|
|
164
|
+
key: "_stopContinuousRotation",
|
|
165
|
+
value: function _stopContinuousRotation() {
|
|
166
|
+
if (!this._canOperate()) return;
|
|
167
|
+
this._isRotating = false;
|
|
168
|
+
if (this._rotateTimer) {
|
|
169
|
+
clearTimeout(this._rotateTimer);
|
|
170
|
+
this._rotateTimer = null;
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
// 开始持续pitch
|
|
175
|
+
}, {
|
|
176
|
+
key: "_startContinuousPitch",
|
|
177
|
+
value: function _startContinuousPitch(direction) {
|
|
178
|
+
var _this4 = this;
|
|
179
|
+
if (!this._canOperate()) return;
|
|
180
|
+
if (this._isPitching) return;
|
|
181
|
+
this._isPitching = true;
|
|
182
|
+
var setPitch = function setPitch() {
|
|
183
|
+
if (!_this4._isPitching) return;
|
|
184
|
+
if (direction === 1 && toDegrees(_this4.getMap().camera.pitch) >= -10) {
|
|
185
|
+
return;
|
|
186
|
+
}
|
|
187
|
+
var _this4$getMap$getMapC = _this4.getMap().getMapCenter(),
|
|
188
|
+
lng = _this4$getMap$getMapC.lng,
|
|
189
|
+
lat = _this4$getMap$getMapC.lat,
|
|
190
|
+
alt = _this4$getMap$getMapC.alt;
|
|
191
|
+
var position = lngLatAltToCartesian3(lng, lat, alt);
|
|
192
|
+
var cameraPosition = _this4.getMap().camera.position;
|
|
193
|
+
// 根据屏幕中心像素的坐标获取中心点笛卡尔坐标
|
|
194
|
+
var centerCartesian = _this4.getMap().camera.pickEllipsoid(new Cesium.Cartesian2(_this4.getMap().canvas.clientWidth / 2, _this4.getMap().canvas.clientHeight / 2), _this4.getMap().scene.globe.ellipsoid);
|
|
195
|
+
// 相机距离中心点的位置
|
|
196
|
+
var distance = Cesium.Cartesian3.distance(cameraPosition, centerCartesian);
|
|
197
|
+
// 倾斜角
|
|
198
|
+
var finalPitch = Math.min(toRadians(-9), Math.max(toRadians(-89), _this4.getMap().camera.pitch + toRadians(direction)));
|
|
199
|
+
_this4.getMap().scene.camera.setView({
|
|
200
|
+
destination: position,
|
|
201
|
+
orientation: {
|
|
202
|
+
heading: _this4.getMap().camera.heading,
|
|
203
|
+
pitch: finalPitch
|
|
204
|
+
}
|
|
205
|
+
});
|
|
206
|
+
_this4.getMap().scene.camera.moveBackward(distance);
|
|
207
|
+
// 设置下次调整
|
|
208
|
+
_this4._pitchTimer = setTimeout(setPitch, 16); // 约60fps
|
|
209
|
+
};
|
|
210
|
+
setPitch();
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
// 停止持续pitch
|
|
214
|
+
}, {
|
|
215
|
+
key: "_stopContinuousPitch",
|
|
216
|
+
value: function _stopContinuousPitch() {
|
|
217
|
+
if (!this._canOperate()) return;
|
|
218
|
+
this._isPitching = false;
|
|
219
|
+
if (this._pitchTimer) {
|
|
220
|
+
clearTimeout(this._pitchTimer);
|
|
221
|
+
this._pitchTimer = null;
|
|
222
|
+
}
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
// 销毁
|
|
226
|
+
}, {
|
|
227
|
+
key: "destroy",
|
|
228
|
+
value: function destroy() {
|
|
229
|
+
if (!this._canOperate()) {
|
|
230
|
+
return;
|
|
231
|
+
}
|
|
232
|
+
this.isDestroyed = true;
|
|
233
|
+
this.container.removeChild(this.container.querySelector('.deeptwins-compass'));
|
|
234
|
+
this._cameraChangeEvent && this._cameraChangeEvent.off();
|
|
235
|
+
this._cameraChangeEvent = null;
|
|
236
|
+
|
|
237
|
+
// 清理旋转和倾斜定时器
|
|
238
|
+
this._stopContinuousRotation();
|
|
239
|
+
this._stopContinuousPitch();
|
|
240
|
+
this.compassEl = {};
|
|
241
|
+
}
|
|
242
|
+
}]);
|
|
243
|
+
return Compass;
|
|
244
|
+
}();
|
|
245
|
+
export default Compass;
|
|
@@ -92,7 +92,12 @@ var Airspace = /*#__PURE__*/function () {
|
|
|
92
92
|
boxPrimitive.createPrimitive({
|
|
93
93
|
style: _objectSpread(_objectSpread({}, this.options), {}, {
|
|
94
94
|
show: this._isShow
|
|
95
|
-
})
|
|
95
|
+
}),
|
|
96
|
+
primitive: {
|
|
97
|
+
interleave: true,
|
|
98
|
+
allowPicking: false,
|
|
99
|
+
cull: false
|
|
100
|
+
}
|
|
96
101
|
}, primitiveInstance);
|
|
97
102
|
this.getMap().scene.primitives.add(boxPrimitive.primitive);
|
|
98
103
|
}
|
|
@@ -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}
|
|
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}
|