-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
77 lines (61 loc) · 2.11 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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no, user-scalable=no">
<meta name="theme-color" content="#000000">
<title>Rogue LAN Player</title>
<style>
html, body, #rogue-app {
margin: 0;
width: 100%;
height: 100%;
-webkit-user-select: none;
-ms-user-select: none;
user-select: none;
background-color: #252933;
overflow: hidden;
}
</style>
</head>
<body>
<noscript>
You need to enable JavaScript to run this app.
</noscript>
<div id="rogue-app"></div>
<script src="/dist/engine-bundle.js"></script>
<script src="/dist/rogue-engine-user-scripts.js"></script>
<script>
if (global === undefined) {
var global = window;
}
init();
async function init() {
const refreshCount = await (await fetch("/getRefreshCount")).json();
window.onfocus = async () => {
const curRefreshCount = await (await fetch("/getRefreshCount")).json();
if (curRefreshCount !== refreshCount) window.location.reload();
};
window['ROGUE_ISDEV'] = true;
const RE = window["rogue-engine"];
const THREE = window["three"];
RE.Input.mouse.init();
RE.Input.keyboard.init();
RE.Input.touch.init();
const res = await fetch("/getScenePlayerConfig");
const {appConfig, sceneJson, assetPaths} = await res.json();
console.log({appConfig, sceneJson, assetPaths});
RE.AssetManager.setAssetPaths(assetPaths || {});
RE.AssetManager.loadAssetConfigs(sceneJson.assetConfigs);
RE.App.fromJSON(appConfig);
RE.App.activeCamera = sceneJson.initialCameraId;
RE.App.sceneController = RE.Runtime;
RE.App.currentScene = new THREE.ObjectLoader().parse(sceneJson.scene);
RE.initComponents( RE.App.currentScene, sceneJson.components );
await RE.AssetManager.preloadAssets();
RE.Skybox.init(sceneJson.skybox);
RE.Runtime.play(RE.App.currentScene);
}
</script>
</body>
</html>