index.html 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123
  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://cdnjs.cloudflare.com/ajax/libs/dat-gui/0.6.2/dat.gui.min.js"></script>
  7. <script src="../dist/preview%20release/cannon.js"></script>
  8. <script src="../dist/preview%20release/Oimo.js"></script>
  9. <script src="../dist/preview%20release/draco_decoder.js" type="text/x-draco-decoder"></script>
  10. <script src="../dist/preview%20release/draco_decoder.wasm" type="text/x-draco-decoder-wasm-binary"></script>
  11. <script src="../dist/preview%20release/draco_wasm_wrapper.js" type="text/x-draco-decoder-wasm-wrapper"></script>
  12. <script src="../Tools/DevLoader/BabylonLoader.js"></script>
  13. <script src="src/webgl-debug.js"></script>
  14. <style>
  15. html,
  16. body {
  17. width: 100%;
  18. height: 100%;
  19. padding: 0;
  20. margin: 0;
  21. overflow: hidden;
  22. }
  23. #renderCanvas {
  24. width: 100%;
  25. height: 100%;
  26. }
  27. #fps {
  28. position: absolute;
  29. background-color: black;
  30. border: 2px solid red;
  31. text-align: center;
  32. font-size: 16px;
  33. color: white;
  34. top: 15px;
  35. right: 10px;
  36. width: 60px;
  37. height: 20px;
  38. }
  39. </style>
  40. </head>
  41. <body>
  42. <div id="fps">0</div>
  43. <canvas id="renderCanvas" touch-action="none"></canvas>
  44. <script>
  45. var canvas = document.getElementById("renderCanvas");
  46. // canvas = WebGLDebugUtils.makeLostContextSimulatingCanvas(canvas);
  47. var divFps = document.getElementById("fps");
  48. // Global to simulate PG.
  49. var engine = null;
  50. // Allow querystring to navigate easily in debug in local samples.
  51. var indexjs = 'src/index';
  52. var sampleSearch = /sample=([0-9]+)/i;
  53. var matches = null;
  54. if ((matches = sampleSearch.exec(window.location)) !== null) {
  55. indexjs += '.';
  56. indexjs += matches[1];
  57. }
  58. indexjs += '.js';
  59. // Load the scripts + map file to allow vscode debug.
  60. BABYLONDEVTOOLS.Loader
  61. .require(indexjs)
  62. .load(function () {
  63. if (BABYLON.Engine.isSupported()) {
  64. if (typeof createEngine !== "undefined") {
  65. engine = createEngine();
  66. } else {
  67. engine = new BABYLON.Engine(canvas, true, { stencil: true, disableWebGL2Support: false, preserveDrawingBuffer: true });
  68. }
  69. BABYLONDEVTOOLS.Loader.debugShortcut(engine);
  70. // call the scene creation from the js.
  71. if (typeof delayCreateScene !== "undefined") {
  72. var scene = delayCreateScene();
  73. if (scene) {
  74. // Register a render loop to repeatedly render the scene
  75. engine.runRenderLoop(function () {
  76. if (scene.activeCamera) {
  77. scene.render();
  78. }
  79. divFps.innerHTML = engine.getFps().toFixed() + " fps";
  80. });
  81. }
  82. }
  83. else {
  84. var scene = createScene();
  85. if (scene) {
  86. // Register a render loop to repeatedly render the scene
  87. engine.runRenderLoop(function () {
  88. scene.render();
  89. divFps.innerHTML = engine.getFps().toFixed() + " fps";
  90. });
  91. }
  92. }
  93. // Resize
  94. window.addEventListener("resize", function () {
  95. engine.resize();
  96. });
  97. }
  98. else {
  99. alert('BabylonJS is not supported.')
  100. }
  101. });
  102. </script>
  103. </body>
  104. </html>