-
Notifications
You must be signed in to change notification settings - Fork 0
/
Main.js
29 lines (24 loc) · 830 Bytes
/
Main.js
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
const scene = new Scene();
let timeDisplay = null;
let tickIntervalId = 0;
function sceneTick() {
scene.updateScene();
//displays time
timeDisplay.textContent = `Time: ${(new Date()).toLocaleTimeString()}`;
}
window.addEventListener("load", () => {
// Called once *all* resources are loaded including images and stylesheets.
// This also begins its own internal timer event for updating the scene state.
scene.onload();
timeDisplay = document.getElementById("time");
timeDisplay.textContent = `Time: ${(new Date()).toLocaleTimeString()}`;
// Speed up for quicker stat decay
setInterval(sceneTick, 1000);
});
window.addEventListener("beforeunload", () => {
if (tickIntervalId != 0){
clearInterval(tickIntervalId);
tickIntervalId = 0;
}
scene.onunload();
});