Remove set_head button + make it required to start

This commit is contained in:
Arne Keller 2022-01-31 09:22:10 +01:00
parent ecf4c24338
commit 6e8a13dd0d
2 changed files with 11 additions and 1 deletions

View File

@ -15,7 +15,7 @@
<button id="set_head">Calibrate neutral position</button>
<p id="log"></p>
</div>
<button id="start">Start</button>
<button id="start" disabled>Start</button>
<script src="/three.min.js"></script>
<script src="/game.js"></script>

10
game.js
View File

@ -136,6 +136,8 @@ function init_gn() {
start_gn();
}).catch(function(e) {
console.error(e);
document.getElementById("set_head").remove();
document.getElementById("start").disabled = false;
});
document.addEventListener('keydown', e => {
@ -187,7 +189,9 @@ function set_head_gn() {
}
document.getElementById("set_head").addEventListener("click", () => {
document.getElementById("set_head").remove();
set_head_gn();
document.getElementById("start").disabled = false;
});
init_gn();
@ -252,6 +256,12 @@ init();
animate();
document.getElementById("start").onclick = () => {
try {
document.body.requestFullscreen();
} catch (e) {
// browser doesn't support this API, try another hack
window.scrollTo(0,1);
}
document.getElementById("start").style.zIndex = -10;
document.getElementById("start").style.visibility = "hidden";
speed = 5.0;