deeptwins-engine-3d 0.1.34 → 0.1.36
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.js +1 -1
- package/dist/esm/analyze/SunLightAnalysis.d.ts +14 -0
- package/dist/esm/analyze/SunLightAnalysis.js +91 -0
- package/dist/esm/cameraControl/Rotate.js +22 -2
- package/dist/esm/constant.d.ts +7 -0
- package/dist/esm/constant.js +11 -0
- package/dist/esm/global.css +36 -0
- package/dist/esm/index.d.ts +2 -0
- package/dist/esm/index.js +5 -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,14 @@
|
|
|
1
|
+
declare class SunLightAnalysis {
|
|
2
|
+
private readonly _mapContext;
|
|
3
|
+
options: any;
|
|
4
|
+
isDestroyed: boolean;
|
|
5
|
+
constructor(map: any, options: any);
|
|
6
|
+
private _canOperate;
|
|
7
|
+
getMap(): any;
|
|
8
|
+
private _create;
|
|
9
|
+
start(): void;
|
|
10
|
+
pause(): void;
|
|
11
|
+
stop(): void;
|
|
12
|
+
destroy(): void;
|
|
13
|
+
}
|
|
14
|
+
export default SunLightAnalysis;
|
|
@@ -0,0 +1,91 @@
|
|
|
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_SUN_ANALYSIS_OPTIONS } from "../constant";
|
|
11
|
+
import * as utils from "../tool/utils";
|
|
12
|
+
var SunLightAnalysis = /*#__PURE__*/function () {
|
|
13
|
+
function SunLightAnalysis(map, options) {
|
|
14
|
+
_classCallCheck(this, SunLightAnalysis);
|
|
15
|
+
_defineProperty(this, "_mapContext", void 0);
|
|
16
|
+
_defineProperty(this, "options", void 0);
|
|
17
|
+
_defineProperty(this, "isDestroyed", false);
|
|
18
|
+
this._mapContext = map._mapContext;
|
|
19
|
+
this.options = merge(DEFAULT_SUN_ANALYSIS_OPTIONS(), options);
|
|
20
|
+
this._create();
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
// 是否能进行操作
|
|
24
|
+
_createClass(SunLightAnalysis, [{
|
|
25
|
+
key: "_canOperate",
|
|
26
|
+
value: function _canOperate() {
|
|
27
|
+
if (this.isDestroyed) {
|
|
28
|
+
utils.error('SunLightAnalysis实例已销毁');
|
|
29
|
+
return false;
|
|
30
|
+
}
|
|
31
|
+
return true;
|
|
32
|
+
}
|
|
33
|
+
}, {
|
|
34
|
+
key: "getMap",
|
|
35
|
+
value: function getMap() {
|
|
36
|
+
return this._mapContext && this._mapContext.getMap();
|
|
37
|
+
}
|
|
38
|
+
}, {
|
|
39
|
+
key: "_create",
|
|
40
|
+
value: function _create() {
|
|
41
|
+
var map = this.getMap();
|
|
42
|
+
map.clock.shouldAnimate = false;
|
|
43
|
+
var _this$options = this.options,
|
|
44
|
+
startTime = _this$options.startTime,
|
|
45
|
+
endTime = _this$options.endTime,
|
|
46
|
+
clockRange = _this$options.clockRange,
|
|
47
|
+
clockStep = _this$options.clockStep,
|
|
48
|
+
multiplier = _this$options.multiplier;
|
|
49
|
+
map.scene.globe.enableLighting = true;
|
|
50
|
+
map.shadows = true;
|
|
51
|
+
map.clock.startTime = Cesium.JulianDate.fromDate(new Date(startTime));
|
|
52
|
+
map.clock.stopTime = Cesium.JulianDate.fromDate(new Date(endTime));
|
|
53
|
+
map.clock.clockRange = clockRange;
|
|
54
|
+
map.clock.clockStep = clockStep;
|
|
55
|
+
map.clock.multiplier = multiplier;
|
|
56
|
+
}
|
|
57
|
+
}, {
|
|
58
|
+
key: "start",
|
|
59
|
+
value: function start() {
|
|
60
|
+
if (!this._canOperate()) return;
|
|
61
|
+
var map = this.getMap();
|
|
62
|
+
map.clock.shouldAnimate = true;
|
|
63
|
+
}
|
|
64
|
+
}, {
|
|
65
|
+
key: "pause",
|
|
66
|
+
value: function pause() {
|
|
67
|
+
if (!this._canOperate()) return;
|
|
68
|
+
var map = this.getMap();
|
|
69
|
+
map.clock.shouldAnimate = false;
|
|
70
|
+
}
|
|
71
|
+
}, {
|
|
72
|
+
key: "stop",
|
|
73
|
+
value: function stop() {
|
|
74
|
+
if (!this._canOperate()) return;
|
|
75
|
+
var map = this.getMap();
|
|
76
|
+
map.clock.currentTime = Cesium.JulianDate.fromDate(new Date(this.options.startTime));
|
|
77
|
+
map.clock.shouldAnimate = false;
|
|
78
|
+
}
|
|
79
|
+
}, {
|
|
80
|
+
key: "destroy",
|
|
81
|
+
value: function destroy() {
|
|
82
|
+
if (!this._canOperate()) return;
|
|
83
|
+
this.isDestroyed = true;
|
|
84
|
+
var map = this.getMap();
|
|
85
|
+
map.clock.shouldAnimate = false;
|
|
86
|
+
map.clock.currentTime = Cesium.JulianDate.fromDate(new Date());
|
|
87
|
+
}
|
|
88
|
+
}]);
|
|
89
|
+
return SunLightAnalysis;
|
|
90
|
+
}();
|
|
91
|
+
export default SunLightAnalysis;
|
|
@@ -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
|
@@ -139,6 +139,13 @@ export declare const DEFAULT_SUBMERGENCE_ANALYSIS_OPTIONS: () => {
|
|
|
139
139
|
color: string;
|
|
140
140
|
changeType: string;
|
|
141
141
|
};
|
|
142
|
+
export declare const DEFAULT_SUN_ANALYSIS_OPTIONS: () => {
|
|
143
|
+
startTime: number;
|
|
144
|
+
endTime: number;
|
|
145
|
+
multiplier: number;
|
|
146
|
+
clockRange: Cesium.ClockRange;
|
|
147
|
+
clockStep: Cesium.ClockStep;
|
|
148
|
+
};
|
|
142
149
|
export declare const DEFAULT_BASE_LAYER_TYPE: any;
|
|
143
150
|
export declare const DEFAULT_BASE_LAYER: any;
|
|
144
151
|
export declare const LAYER_TYPE_TO_CLASS: any;
|
package/dist/esm/constant.js
CHANGED
|
@@ -222,6 +222,17 @@ export var DEFAULT_SUBMERGENCE_ANALYSIS_OPTIONS = function DEFAULT_SUBMERGENCE_A
|
|
|
222
222
|
};
|
|
223
223
|
};
|
|
224
224
|
|
|
225
|
+
// 默认日照分析配置选项
|
|
226
|
+
export var DEFAULT_SUN_ANALYSIS_OPTIONS = function DEFAULT_SUN_ANALYSIS_OPTIONS() {
|
|
227
|
+
return {
|
|
228
|
+
startTime: new Date().setHours(8, 0, 0, 0),
|
|
229
|
+
endTime: new Date().setHours(12, 0, 0, 0),
|
|
230
|
+
multiplier: 500,
|
|
231
|
+
clockRange: Cesium.ClockRange.LOOP_STOP,
|
|
232
|
+
clockStep: Cesium.ClockStep.SYSTEM_CLOCK_MULTIPLIER
|
|
233
|
+
};
|
|
234
|
+
};
|
|
235
|
+
|
|
225
236
|
// 默认的底图类型
|
|
226
237
|
export var DEFAULT_BASE_LAYER_TYPE = {
|
|
227
238
|
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
package/dist/esm/index.js
CHANGED
|
@@ -8,6 +8,7 @@ function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e
|
|
|
8
8
|
//引入cesium基础库
|
|
9
9
|
import * as Cesium from 'deeptwins-cesium';
|
|
10
10
|
import SubmergenceAnalysis from "./analyze/SubmergenceAnalysis";
|
|
11
|
+
import SunLightAnalysis from "./analyze/SunLightAnalysis";
|
|
11
12
|
import ModelRoamHistory from "./cameraControl/ModelRoamHistory";
|
|
12
13
|
import ModelRoamRealTime from "./cameraControl/ModelRoamRealTime";
|
|
13
14
|
import Roam from "./cameraControl/Roam";
|
|
@@ -50,11 +51,11 @@ DEEP_TWINS_BASE_URL && (window.CESIUM_BASE_URL = DEEP_TWINS_BASE_URL);
|
|
|
50
51
|
// 全局加载css
|
|
51
52
|
loadCss(Cesium.buildModuleUrl('Widgets/widgets.css'));
|
|
52
53
|
// 打印版本信息
|
|
53
|
-
console.log('DeepTwinsEngine3D Version:', "0.1.
|
|
54
|
+
console.log('DeepTwinsEngine3D Version:', "0.1.36");
|
|
54
55
|
export var DeepTwinsEngine3D = /*#__PURE__*/_createClass(function DeepTwinsEngine3D() {
|
|
55
56
|
_classCallCheck(this, DeepTwinsEngine3D);
|
|
56
57
|
});
|
|
57
|
-
_defineProperty(DeepTwinsEngine3D, "Version", "0.1.
|
|
58
|
+
_defineProperty(DeepTwinsEngine3D, "Version", "0.1.36");
|
|
58
59
|
_defineProperty(DeepTwinsEngine3D, "Map", Map);
|
|
59
60
|
_defineProperty(DeepTwinsEngine3D, "GroundSkyBox", GroundSkyBox);
|
|
60
61
|
_defineProperty(DeepTwinsEngine3D, "RasterLayer", RasterLayer);
|
|
@@ -115,4 +116,6 @@ _defineProperty(DeepTwinsEngine3D, "BoundingRectangle", Cesium.BoundingRectangle
|
|
|
115
116
|
_defineProperty(DeepTwinsEngine3D, "SplitDirection", Cesium.SplitDirection);
|
|
116
117
|
_defineProperty(DeepTwinsEngine3D, "ImageGlowingMaterialProperty", ImageGlowingMaterialProperty);
|
|
117
118
|
_defineProperty(DeepTwinsEngine3D, "SubmergenceAnalysis", SubmergenceAnalysis);
|
|
119
|
+
_defineProperty(DeepTwinsEngine3D, "SunLightAnalysis", SunLightAnalysis);
|
|
120
|
+
_defineProperty(DeepTwinsEngine3D, "KmlDataSource", Cesium.KmlDataSource);
|
|
118
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}
|