index.html 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. <!DOCTYPE html>
  2. <html xmlns="http://www.w3.org/1999/xhtml">
  3. <head>
  4. <title>Local Development</title>
  5. <script src="../assets/refs/dat.gui.min.js"></script>
  6. <script src="../tools/DevLoader/BabylonLoader.js"></script>
  7. <style>
  8. html, body {
  9. width: 100%;
  10. height: 100%;
  11. padding: 0;
  12. margin: 0;
  13. overflow: hidden;
  14. }
  15. #renderCanvas {
  16. width: 100%;
  17. height: 100%;
  18. }
  19. #fps {
  20. position: absolute;
  21. background-color: black;
  22. border: 2px solid red;
  23. text-align: center;
  24. font-size: 16px;
  25. color: white;
  26. top: 15px;
  27. left: 10px;
  28. width: 60px;
  29. height: 20px;
  30. }
  31. </style>
  32. </head>
  33. <body>
  34. <div id="fps">0</div>
  35. <canvas id="renderCanvas"></canvas>
  36. <script>
  37. var canvas = document.getElementById("renderCanvas");
  38. var divFps = document.getElementById("fps");
  39. // Global to simulate PG.
  40. var engine = null;
  41. // Allow querystring to navigate easily in debug in local samples.
  42. var indexjs = 'src/index';
  43. var sampleSearch = /sample=([0-9]+)/i;
  44. var matches = null;
  45. if ((matches = sampleSearch.exec(window.location)) !== null) {
  46. indexjs += '.';
  47. indexjs += matches[1];
  48. }
  49. indexjs += '.js';
  50. // Load the scripts + map file to allow vscode debug.
  51. BABYLONDEVTOOLS.Loader
  52. .require(indexjs)
  53. .load(function() {
  54. if (BABYLON.Engine.isSupported()) {
  55. engine = new BABYLON.Engine(canvas, true, { stencil: true });
  56. BABYLONDEVTOOLS.Loader.debugShortcut(engine);
  57. // call the scene creation from the js.
  58. var scene = createScene();
  59. // Register a render loop to repeatedly render the scene
  60. engine.runRenderLoop(function () {
  61. scene.render();
  62. divFps.innerHTML = engine.getFps().toFixed() + " fps";
  63. });
  64. // Resize
  65. window.addEventListener("resize", function () {
  66. engine.resize();
  67. });
  68. }
  69. else {
  70. alert('BabylonJS is not supported.')
  71. }
  72. });
  73. </script>
  74. </body>
  75. </html>