forked from 3DGISKing/CesiumJsFirstPersonCameraController
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
63 lines (52 loc) · 2.1 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
<!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>Cesium First Person Camera</title>
<link rel="stylesheet" href="https://cesiumjs.org/releases/1.73/Build/Cesium/Widgets/widgets.css">
<link rel="stylesheet" href="https://cesiumjs.org/Cesium/Build/Apps/Sandcastle/templates/bucket.css">
<script src="https://cesiumjs.org/releases/1.73/Build/Cesium/Cesium.js"></script>
<script src = "https://sandcastle.cesium.com/Sandcastle-header.js"></script>
</head>
<body>
<div id="cesiumContainer" class="fullSize"></div>
<div id="toolbar"></div>
<script src = "CesiumFirstPersonCameraController.js"></script>
<script>
const worldTerrain = Cesium.createWorldTerrain({
requestWaterMask: true,
requestVertexNormals: true,
});
const viewer = new Cesium.Viewer('cesiumContainer', {
terrainProvider: worldTerrain,
});
const firstPersonCameraController = new Cesium.FirstPersonCameraController({
cesiumViewer : viewer
});
// look At Mt Everest
const target = new Cesium.Cartesian3(
300770.50872389384,
5634912.131394585,
2978152.2865545116
);
const offset = new Cesium.Cartesian3(
6344.974098678562,
-793.3419798081741,
2499.9508860763162
);
viewer.camera.lookAt(target, offset);
viewer.camera.lookAtTransform(Cesium.Matrix4.IDENTITY);
Sandcastle.addToolbarButton("Start", () => {
firstPersonCameraController.start();
});
Sandcastle.addToolbarButton("Stop", () => {
firstPersonCameraController.stop();
});
</script>
</body>
</html>