viewer_ms3m.vue
3.12 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
<!--
* @Author: jiangbotao
* 添加倾斜摄影场景和倾斜摄影图层
* @Date: 2019-12-02 09:05:50
* @LastEditors: jiangbotao
* @LastEditTime: 2019-12-04 20:20:18
* @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>
</template>
<script>
import URL_CONFIG from "./../config/urlConfig.vue";
const Cesium=window.Cesium;
export default {
data: function() {
return {
styleObject:{
width: "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;
$("#loadingbar").remove();
try{
//依次向场景添加S3M图层服务
var promise1 = scene.addS3MTilesLayerByScp(URL_CONFIG.SCP_SRSB, {
name : "srsb"
});
var promise2 = scene.addS3MTilesLayerByScp(URL_CONFIG.SCP_SRSB_WATER, {
name : "srsb_water"
});
var promise = scene.open(URL_CONFIG.SCENE_SRSB);
Cesium.when(promise, function(){
//查找水面图层
var waterLayer =scene.layers.find("水面@vector");
var style = new Cesium.Style3D();
style.bottomAltitude = 5;
//设置水面图层的底部高程,确保水面与模型贴合
waterLayer.style3D = style;
//设置风格后需刷新
waterLayer.refresh();
//设置相机位置、视角,便于观察场景
var d1 = Cesium.Math.toDegrees(0.8344578907203247);
var d2 = Cesium.Math.toDegrees(0.22751343457105547);
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);
}
}
}
}
</script>
<style>
</style>