index.html 2.0 KB

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