-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
119 lines (115 loc) · 3.62 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
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<meta name="Description" content="Collision Web Simulator" />
<link
rel="icon"
href="https://avatars.githubusercontent.com/u/151067388"
type="image/png"
/>
<link rel="stylesheet" href="/lib/bulma.min.css" />
<title>Ratisbon Robotics</title>
<script>
document.addEventListener("DOMContentLoaded", function () {
loadExternalHTML("/lib/navbar.html", "navbar");
loadExternalHTML("/lib/footer.html", "footer");
});
</script>
<style>
.overlay {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
background: rgba(255, 255, 255, 0.8);
display: none;
justify-content: center;
align-items: center;
text-align: center;
z-index: 10;
}
.spinner {
border: 8px solid rgba(0, 0, 0, 0.1);
border-radius: 50%;
border-top: 8px solid #3498db;
width: 50px;
height: 50px;
animation: spin 2s linear infinite;
}
@keyframes spin {
0% {
transform: rotate(0deg);
}
100% {
transform: rotate(360deg);
}
}
</style>
</head>
<body>
<nav id="navbar"></nav>
<div style="position: relative">
<div class="overlay" id="loading_overlay">
<div>
<div class="spinner"></div>
</div>
</div>
<article class="box m-3 has-background-light">
<div class="columns">
<div class="column has-text-centered">
<canvas
style="border-radius: 5px; border: 2px solid black"
tabindex="1"
id="canvas"
aria-label="canvas"
></canvas>
</div>
</div>
<script src="/lib/util.js"></script>
<script src="/lib/vector3f.js"></script>
<script src="/lib/matrix3f.js"></script>
<script src="/lib/matrix4f.js"></script>
<script src="/lib/webgl.js"></script>
<script>
// --- SETUP ENVIRONMENT ---
let keys = {};
let mouse = { horizontal: 0, vertical: 0 };
const canvas = document.getElementById("canvas");
const gl = canvas.getContext("webgl");
init3D(gl);
resizeCanvas(canvas);
// --- ADD EVENT LISTENERS ---
window.addEventListener("orientationchange", function () {
resizeCanvas(canvas);
});
window.addEventListener("resize", function () {
resizeCanvas(canvas);
});
canvas.addEventListener("mousemove", function (event) {
if (document.pointerLockElement === canvas) {
mouse["horizontal"] = event.movementX;
mouse["vertical"] = event.movementY;
}
});
canvas.addEventListener("click", canvas.requestPointerLock);
canvas.addEventListener("keydown", function (event) {
keys[event.key] = true;
});
canvas.addEventListener("keyup", function (event) {
keys[event.key] = false;
});
</script>
<script src="/src/shader.js"></script>
<script src="/src/camera.js"></script>
<script src="/src/main.js"></script>
<p>
Control through clicking inside the canvas and pressing one of 'W', 'S', 'A', 'D', '1', '2', '3', '4', '5'. You may also choose to look around by moving the mouse.
</p>
</article>
</div>
<div id="footer"></div>
</body>
</html>