-
Notifications
You must be signed in to change notification settings - Fork 536
/
simplified.html
90 lines (78 loc) · 2.8 KB
/
simplified.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
<!DOCTYPE html>
<head>
<base href="../../../">
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, minimum-scale=1, user-scalable=no">
<script src="libs/cesium/Cesium.js"></script>
<script src="dist/jeelizFaceFilter.js"></script>
<script src="helpers/HeadControls.js"></script>
<style>
@import url(libs/cesium/Widgets/widgets.css);
html, body, #cesiumContainer {
width: 100%; height: 100%; margin: 0; padding: 0; overflow: hidden;
}
#startHeadControlsButton {
position: fixed;
width: 256px;
top: 1em;
left: 50%;
margin-left: -128px;
cursor: pointer;
}
#headControlsCanvas {
position: fixed;
right: 0px;
bottom: 30px;
z-index: 1000;
transform-origin: bottom right;
max-height: 25%;
max-width: 25%;
}
</style>
</head>
<body>
<div id="cesiumContainer"></div>
<button id='startHeadControlsButton'>START HEAD CONTROLLED NAVIGATION !</button>
<canvas id='headControlsCanvas' width='512' height='512'></canvas>
<script>
// initialize Cesium:
const CESIUMVIEWER = new Cesium.Viewer('cesiumContainer');
const SETTINGS = {
zoomSensibility: 5.5,
panSensibility: 0.00000015
};
function callbackMove(mv){
const cameraHeight = CESIUMVIEWER.scene.globe.ellipsoid.cartesianToCartographic(CESIUMVIEWER.camera.position).height/1000.0 || Number.MAX_VALUE;
if (mv.dZ!==0) { // move head forward/backward
const zoomAmount = mv.dZ * SETTINGS.zoomSensibility * cameraHeight;
CESIUMVIEWER.camera.moveForward(zoomAmount);
}
if (mv.dRx!==0) { // turn head up-down
const panAmountX = SETTINGS.panSensibility*mv.dRx * cameraHeight;
CESIUMVIEWER.scene.camera.rotateUp(panAmountX);
}
if (mv.dRy!==0) { // turn head left-right
const panAmountY = SETTINGS.panSensibility*mv.dRy * cameraHeight;
CESIUMVIEWER.scene.camera.rotate(Cesium.Cartesian3.UNIT_Z, panAmountY);
}
}
const DOMbutton = document.getElementById('startHeadControlsButton');
DOMbutton.onclick = function(){
HeadControls.init({
canvasId: 'headControlsCanvas',
callbackMove: callbackMove,
callbackReady: function(errCode){
if (errCode){
console.log('ERROR: HEAD CONTROLS NOT READY. errCode =', errCode);
} else {
console.log('INFO: HEAD CONTROLS ARE READY :)');
HeadControls.toggle(true);
}
},
NNCPath: './neuralNets/' // where to find NN_DEFAULT.json from the current path
}); //end HeadControls.init params
}; //end DOMbutton.onclick
</script>
</body>
</html>