-
Notifications
You must be signed in to change notification settings - Fork 6
/
index.html
97 lines (86 loc) · 3.31 KB
/
index.html
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
<!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>
<script src="./cesium/Cesium.js"></script>
<script src="./ext/testPrimitive.js"></script>
<style>
@import url(./cesium/Widgets/widgets.css);
html,
body,
#cesiumContainer {
width: 100%;
height: 100%;
margin: 0;
padding: 0;
overflow: hidden;
}
#trailer {
position: absolute;
top: 10px;
left: 20px;
z-index: 10;
visibility: hidden;
}
</style>
</head>
<body>
<div id="cesiumContainer"></div>
<div style="position: absolute;z-index: 10;top:20px;left: 20px;background-color: rgba(0, 0, 100,0.3)">
<button type="button" onclick="add();">添加</button>
<button type="button" onclick="clearPrimitive();">清除</button>
</div>
<div style="position: absolute;z-index: 10;top:50px;left: 20px;background-color: rgba(0, 0, 100,0.3)">
<button type="button" onclick="addTest();">添加</button>
<button type="button" onclick="clearTestPrimitive();">清除</button>
</div>
<div style="position: absolute;z-index: 10;top:80px;left: 20px;background-color: rgba(0, 0, 100,0.3)">
<button type="button" onclick="addGroundPrimitive();">添加</button>
<button type="button" onclick="clearGroundPrimitive();">清除</button>
</div>
<video id="trailer" muted="" autoplay="" loop="" crossorigin="" controls="">
<source src="./source/video-diqiu.mp4" type="video/mp4">
Your browser does not support the <code>video</code> element.
</video>
<script>
var viewer = new Cesium.Viewer('cesiumContainer');
var videoElm = document.getElementById("trailer");
var tilesets = new Cesium.Cesium3DTileset({
url: "http://localhost:8011/tileset.json",
})
viewer.scene.primitives.add(tilesets);
tilesets.readyPromise.then(function (tileset) {
viewer.camera.flyToBoundingSphere(tileset.boundingSphere);
});
var videoPrimitives = [];
function addTest() {
var scene = viewer.scene;
var camera = viewer.camera;
var orientation = VideoProjectionPrimitive.createOratetionFromCamera(camera);
var frustum = camera.frustum;
var origin = camera.position;
var primitive = new VideoProjectionPrimitive({
frustum: frustum,
orientation: orientation,
origin: origin,
outline: true
});
scene.primitives.add(primitive);
videoPrimitives.push(primitive)
}
function clearTestPrimitive() {
videoPrimitives.forEach(x => {
viewer.scene.primitives.remove(x);
});
videoPrimitives = [];
}
</script>
</body>
</html>