index.html 2.2 KB

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