index.html 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  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="https://cdnjs.cloudflare.com/ajax/libs/dat-gui/0.6.2/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, disableWebGL2Support: false });
  61. BABYLONDEVTOOLS.Loader.debugShortcut(engine);
  62. // call the scene creation from the js.
  63. if (typeof delayCreateScene !== "undefined") {
  64. var scene = delayCreateScene();
  65. if (scene) {
  66. // Register a render loop to repeatedly render the scene
  67. engine.runRenderLoop(function () {
  68. if (scene.activeCamera) {
  69. scene.render();
  70. }
  71. divFps.innerHTML = engine.getFps().toFixed() + " fps";
  72. });
  73. }
  74. }
  75. else {
  76. var scene = createScene();
  77. if (scene) {
  78. // Register a render loop to repeatedly render the scene
  79. engine.runRenderLoop(function () {
  80. scene.render();
  81. divFps.innerHTML = engine.getFps().toFixed() + " fps";
  82. });
  83. }
  84. }
  85. // Resize
  86. window.addEventListener("resize", function () {
  87. engine.resize();
  88. });
  89. }
  90. else {
  91. alert('BabylonJS is not supported.')
  92. }
  93. });
  94. </script>
  95. </body>
  96. </html>