viewer_s3mbhyp.vue
5.21 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
<!--
* @Author: jiangbotao
* 演示大场景被淹没
* @Date: 2019-12-02 09:05:50
* @LastEditors: jiangbotao
* @LastEditTime: 2019-12-04 22:03:19
* @FilePath: \WebGL_Webpack_Vue\components\viewer.vue
-->
<template>
<div>
<div id="cesiumContainer" v-bind:style="styleObject"></div>
<div id='loadingbar' class="spinner">
<div class="spinner-container container1">
<div class="circle1"></div>
<div class="circle2"></div>
<div class="circle3"></div>
<div class="circle4"></div>
</div>
<div class="spinner-container container2">
<div class="circle1"></div>
<div class="circle2"></div>
<div class="circle3"></div>
<div class="circle4"></div>
</div>
<div class="spinner-container container3">
<div class="circle1"></div>
<div class="circle2"></div>
<div class="circle3"></div>
<div class="circle4"></div>
</div>
</div>
<div id="toolbar" class="param-container tool-bar">
<div id="setingBar">
<div class="form-group">
<input id="maxHeight" value="71" required="required" class="form-control"/>
<label class="form-label">最大高度 (米) : </label>
</div>
<div class="form-group">
<input id="minHeight" value="60" required="required" class="form-control"/>
<label class="form-label">最小高度 (米) :</label>
</div>
<div class="form-group">
<input id="speed" value="5" required="required" class="form-control"/>
<label class="form-label">淹没速度(米/秒):</label>
</div>
</div>
<div style="margin-left: 40px;">
<button type="button" id="begin" class="button black">开始</button>
<button type="button" id="clear" class="button black">清除</button>
</div>
</div>
</div>
</template>
<script>
import URL_CONFIG from './../config/urlConfig.vue';
const Cesium = window.Cesium;
export default {
data: function() {
return {
styleObject:{
width: '100%',
height: '100%',
position: 'absolute',
top: '0px',
bottom: '0px',
left: '0px',
backgroundColor: '#000000'
},
smviewer:{}
}
},
mounted: function(){
this.viewer=new Cesium.Viewer('cesiumContainer', {});
// 隐藏logo
$(".cesium-widget-credits")[0].style.visibility="hidden";
// 隐藏导航工具
// $(".cesium-viewer-navigationContainer")[0].style.visibility="hidden";
this.viewer.imageryLayers.addImageryProvider(new Cesium.BingMapsImageryProvider({
url : 'https://dev.virtualearth.net',
mapStyle : Cesium.BingMapsStyle.AERIAL,
key : URL_CONFIG.BING_MAP_KEY
}));
var scene = this.viewer.scene;
var widget = this.viewer.cesiumWidget;
$(".form-group").show();
$(".element").show();
$('#loadingbar').remove();
try{
var promise = scene.open(URL_CONFIG.SCENE_SRSB);
Cesium.when(promise, function(layers){
// 设置相机视角,便于查看模型
scene.camera.setView({
destination : Cesium.Cartesian3.fromDegrees(13.0353, 47.8084, 100.0),
orientation:{
heading:0.7272,
pitch:-0.2672,
roll:0
}
});
}, function(){
var title = '加载SCP失败,请检查网络连接状态或者url地址是否正确?';
widget.showErrorPanel(title, undefined, e);
});
}catch(e){
if (widget._showRenderLoopErrors) {
var title = '渲染时发生错误,已停止渲染。';
widget.showErrorPanel(title, undefined, e);
}
}
var currentHeight = 0;
var maxValue = 0;
var minValue = 0;
var int = null;
document.getElementById("begin").onclick = function() {
currentHeight = 0;
int = self.setInterval("flood()", 100);
maxValue = parseInt(document.getElementById("maxHeight").value);
minValue = parseInt(document.getElementById("minHeight").value);
};
window.flood = function() {
if(currentHeight > maxValue) {
self.clearInterval(int);
return;
}
var layer = scene.layers.find("srsb");
var hyp = new Cesium.HypsometricSetting();
//创建分层设色对象 设置最大/最小可见高度 颜色表 显示模式 透明度及线宽
var colorTable = new Cesium.ColorTable();
colorTable.insert(100, new Cesium.Color(0, 39/255, 148/255));
colorTable.insert(0, new Cesium.Color(149/255, 232/255, 249/255));
hyp.MaxVisibleValue = currentHeight;
hyp.MinVisibleValue = minValue;
hyp.ColorTable = colorTable;
hyp.DisplayMode = Cesium.HypsometricSettingEnum.DisplayMode.FACE;
hyp.Opacity = 0.6;
hyp.LineInterval = 10.0;
//设置图层分层设色属性
layer.hypsometricSetting = {
hypsometricSetting : hyp,
analysisMode : Cesium.HypsometricSettingEnum.AnalysisRegionMode.ARM_ALL
};
currentHeight += (parseInt(document.getElementById("speed").value))/10;
};
document.getElementById("clear").onclick = function() {
self.clearInterval(int);
var layer = scene.layers.find("sci_park");
var hyp = new Cesium.HypsometricSetting();
hyp.MaxVisibleValue = 0;
layer.hypsometricSetting = {
hypsometricSetting : hyp,
analysisMode : Cesium.HypsometricSettingEnum.AnalysisRegionMode.ARM_ALL
}
};
}
}
</script>
<style>
.form-group::before {
content: attr(data-foo);
color: black;
}
#setingBar{
width:150px;
height:110px;
background: rgba(42, 42, 42, 0.4);
padding: 8px;
border-radius: 4px;
color:cornflowerblue
}
#toolbar{
width: 200px;
}
</style>