index.html 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  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. // call the scene creation from the js.
  57. var scene = createScene();
  58. // Register a render loop to repeatedly render the scene
  59. engine.runRenderLoop(function () {
  60. scene.render();
  61. divFps.innerHTML = engine.getFps().toFixed() + " fps";
  62. });
  63. // Resize
  64. window.addEventListener("resize", function () {
  65. engine.resize();
  66. });
  67. }
  68. else {
  69. alert('BabylonJS is not supported.')
  70. }
  71. });
  72. </script>
  73. </body>
  74. </html>