index.html 3.9 KB

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