index.html 2.2 KB

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