-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathcesium
91 lines (89 loc) · 3.46 KB
/
cesium
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
<!DOCTYPE html>
<html lang="en">
<head>
<!-- Use correct character set. -->
<meta charset="utf-8" />
<!-- Tell IE to use the latest, best version. -->
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<!-- Make the application on mobile take up the full browser screen and disable user scaling. -->
<meta
name="viewport"
content="width=device-width, initial-scale=1, maximum-scale=1, minimum-scale=1, user-scalable=no"
/>
<title>Hello World!</title>
//your js path
<script src="../Build/Cesium/Cesium.js"></script>
<script src="trans.js"></script>
<style>
//your css path
@import url(../Build/Cesium/Widgets/widgets.css);
html,
body,
#cesiumContainer {
width: 100%;
height: 100%;
margin: 0;
padding: 0;
overflow: hidden;
}
</style>
</head>
<body>
//cesiumContatiner 模块
<div id="cesiumContainer"></div>
<script>
//卫星影像数据加载
// var viewer = new Cesium.Viewer("cesiumContainer", {
// imageryProvider:new Cesium.BingMapsImageryProvider({
// url : 'https://dev.virtualearth.net',
// key : 'AqpgilHPiwyQmv4knD-fSBMwWS_qx6RQONccKJoG2pCGPSZsIJfqeYV5JxBTPftw'
// }),
// terrainProvider: new Cesium.createWorldTerrain({
// requestVertexNormals:true,
// requestWaterMask:true
// })
// });
var viewer = new Cesium.Viewer("cesiumContainer", {
imageryProvider:new Cesium.BingMapsImageryProvider({
url : 'https://dev.virtualearth.net',
//your private token
key : 'AqpgilHPiwyQmv4knD-fSBMwWS_qx6RQONccKJoG2pCGPSZsIJfqeYV5JxBTPftw'
})
});
// 显示帧率
viewer.scene.debugShowFramesPerSecond = true;
var tileset = viewer.scene.primitives.add(new Cesium.Cesium3DTileset({
url: 'http://10.164.28.50:9003/model/t0vT2M90i/tileset.json'//your url,3dtiles path
}));
//viewer.scene.primitives.add(tileset);
//viewer.zoomTo(tileset, new Cesium.HeadingPitchRange(0.0, -0.3, 0.0));
// 经纬度等
var longitude = 120.369750
var latitude = 30.328600
var height = -20
// var heading = 0 // 方位角
// 模型加载完毕后的回调
tileset.readyPromise.then(function (argument) {
// 1、旋转
let hpr = new Cesium.Matrix3()
// new Cesium.HeadingPitchRoll(heading, pitch, roll)
// heading围绕负z轴的旋转。pitch是围绕负y轴的旋转。Roll是围绕正x轴的旋转
let hprObj = new Cesium.HeadingPitchRoll(Math.PI, Math.PI, Math.PI)
// Cesium.Matrix3.fromHeadingPitchRoll (headingPitchRoll,result)
hpr = Cesium.Matrix3.fromHeadingPitchRoll(hprObj, hpr)
// 2、平移
// 2.3储存平移的结果
let modelMatrix = Cesium.Matrix4.multiplyByTranslation(
// 2.1从以度为单位的经度和纬度值返回Cartesian3位置
// 2.2计算4x4变换矩阵
Cesium.Transforms.eastNorthUpToFixedFrame(Cesium.Cartesian3.fromDegrees(longitude, latitude, height)), new Cesium.Cartesian3(), new Cesium.Matrix4()
)
/// 3、应用旋转
// Cesium.Matrix4.multiplyByMatrix3 (矩阵,旋转,结果)
Cesium.Matrix4.multiplyByMatrix3(modelMatrix, hpr, modelMatrix)
tileset._root.transform = modelMatrix
})
viewer.zoomTo(tileset)
</script>
</body>
</html>