index.html 4.1 KB

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