index.html 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="utf-8">
  5. <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no, user-scalable=no">
  6. <meta name="theme-color" content="#000000">
  7. <title>Rogue LAN Player</title>
  8. <style>
  9. html, body, #rogue-app {
  10. margin: 0;
  11. width: 100%;
  12. height: 100%;
  13. -webkit-user-select: none;
  14. -ms-user-select: none;
  15. user-select: none;
  16. background-color: #252933;
  17. overflow: hidden;
  18. }
  19. </style>
  20. </head>
  21. <body>
  22. <noscript>
  23. You need to enable JavaScript to run this app.
  24. </noscript>
  25. <div id="rogue-app"></div>
  26. <script src="/dist/engine-bundle.js"></script>
  27. <script src="/dist/rogue-engine-user-scripts.js"></script>
  28. <script>
  29. if (global === undefined) {
  30. var global = window;
  31. }
  32. init();
  33. async function init() {
  34. const refreshCount = await (await fetch("/getRefreshCount")).json();
  35. window.onfocus = async () => {
  36. const curRefreshCount = await (await fetch("/getRefreshCount")).json();
  37. if (curRefreshCount !== refreshCount && RE?.Runtime?.isRunning) window.location.reload();
  38. };
  39. window['ROGUE_ISDEV'] = true;
  40. const RE = window["rogue-engine"];
  41. const THREE = window["three"];
  42. RE.Input.mouse.init();
  43. RE.Input.keyboard.init();
  44. RE.Input.touch.init();
  45. const res = await fetch("/getScenePlayerConfig");
  46. const {appConfig, sceneJson, assetPaths} = await res.json();
  47. console.log({appConfig, sceneJson, assetPaths});
  48. RE.AssetManager.setAssetPaths(assetPaths || {});
  49. RE.AssetManager.loadAssetConfigs(sceneJson.assetConfigs);
  50. RE.App.fromJSON(appConfig);
  51. RE.App.activeCamera = sceneJson.initialCameraId;
  52. RE.App.sceneController = RE.Runtime;
  53. RE.App.currentScene = new THREE.ObjectLoader().parse(sceneJson.scene);
  54. RE.initComponents( RE.App.currentScene, sceneJson.components );
  55. await RE.AssetManager.preloadAssets();
  56. RE.Skybox.init(sceneJson.skybox);
  57. RE.Runtime.play(RE.App.currentScene);
  58. }
  59. </script>
  60. </body>
  61. </html>