index-views.html 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183
  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/ammo.js"></script>
  10. <script src="../dist/preview%20release/recast.js"></script>
  11. <script src="../dist/preview%20release/libktx.js"></script>
  12. <script src="../Tools/DevLoader/BabylonLoader.js"></script>
  13. <style>
  14. html,
  15. body {
  16. width: 100%;
  17. height: 100%;
  18. padding: 0;
  19. margin: 0;
  20. overflow: hidden;
  21. }
  22. .container {
  23. width: 100%;
  24. height: 100%;
  25. display: grid;
  26. grid-template-rows: 50% 50%;
  27. grid-template-columns: 50% 50%;
  28. font-size: 0;
  29. }
  30. .renderCanvas {
  31. width: 100%;
  32. height: 100%;
  33. }
  34. #renderCanvas0 {
  35. grid-row: 1;
  36. grid-column: 1;
  37. }
  38. #renderCanvas1 {
  39. grid-row: 1;
  40. grid-column: 2;
  41. }
  42. #renderCanvas2 {
  43. grid-row: 2;
  44. grid-column: 1;
  45. }
  46. #renderCanvas3 {
  47. grid-row: 2;
  48. grid-column: 2;
  49. }
  50. #fps {
  51. position: absolute;
  52. background-color: black;
  53. border: 2px solid red;
  54. text-align: center;
  55. font-size: 16px;
  56. color: white;
  57. top: 15px;
  58. right: 10px;
  59. width: 60px;
  60. height: 20px;
  61. }
  62. @font-face {
  63. font-family: BabylonJSglyphs;
  64. /* src: url("http://www.killer-squid.com/fonts/BabylonJSglyphs.otf"); */
  65. src: local("BabylonJSglyphs");
  66. }
  67. </style>
  68. </head>
  69. <body>
  70. <div id="fps">0</div>
  71. <div class="container">
  72. <canvas class="renderCanvas" id="renderCanvas0" touch-action="none"></canvas>
  73. <canvas class="renderCanvas" id="renderCanvas1" touch-action="none"></canvas>
  74. <canvas class="renderCanvas" id="renderCanvas2" touch-action="none"></canvas>
  75. <canvas class="renderCanvas" id="renderCanvas3" touch-action="none"></canvas>
  76. </div>
  77. <script>
  78. var canvas = document.createElement("canvas");
  79. // canvas = WebGLDebugUtils.makeLostContextSimulatingCanvas(canvas);
  80. var divFps = document.getElementById("fps");
  81. // Global to simulate PG.
  82. var engine = null;
  83. // Allow querystring to navigate easily in debug in local samples.
  84. var indexjs = 'src/index';
  85. var sampleSearch = /sample=([0-9]+)/i;
  86. var matches = null;
  87. if ((matches = sampleSearch.exec(window.location)) !== null) {
  88. indexjs += '.';
  89. indexjs += matches[1];
  90. }
  91. indexjs += '.js';
  92. // var indexjs = "http://localhost:1234/index.js"
  93. // Load the scripts + map file to allow vscode debug.
  94. BABYLONDEVTOOLS.Loader
  95. .require(indexjs)
  96. .load(function() {
  97. BABYLON.DracoCompression.Configuration.decoder = {
  98. wasmUrl: "../dist/preview%20release/draco_wasm_wrapper_gltf.js",
  99. wasmBinaryUrl: "../dist/preview%20release/draco_decoder_gltf.wasm",
  100. fallbackUrl: "../dist/preview%20release/draco_decoder_gltf.js"
  101. };
  102. BABYLON.GLTFValidation.Configuration = {
  103. url: "../dist/preview%20release/gltf_validator.js"
  104. };
  105. if (BABYLON.Engine.isSupported()) {
  106. if (typeof createEngine !== "undefined") {
  107. engine = createEngine();
  108. } else {
  109. engine = new BABYLON.Engine(canvas, true, { premultipliedAlpha: false, stencil: true, disableWebGL2Support: false, preserveDrawingBuffer: true });
  110. }
  111. BABYLONDEVTOOLS.Loader.debugShortcut(engine);
  112. engine.inputElement = document.getElementById("renderCanvas0");
  113. // call the scene creation from the js.
  114. if (typeof delayCreateScene !== "undefined") {
  115. var scene = delayCreateScene();
  116. if (scene) {
  117. // Register a render loop to repeatedly render the scene
  118. engine.runRenderLoop(function() {
  119. if (scene.activeCamera) {
  120. scene.render();
  121. }
  122. divFps.innerHTML = engine.getFps().toFixed() + " fps";
  123. });
  124. }
  125. }
  126. else {
  127. var scene = createScene();
  128. if (scene) {
  129. var processCurrentScene = function(scene) {
  130. engine.runRenderLoop(function() {
  131. scene.render();
  132. divFps.innerHTML = engine.getFps().toFixed() + " fps";
  133. });
  134. }
  135. if (scene.then) {
  136. // Handle if createScene returns a promise
  137. scene.then(function(currentScene) {
  138. processCurrentScene(currentScene);
  139. }).catch(function(e) {
  140. console.error(e);
  141. onError();
  142. });
  143. } else {
  144. // Register a render loop to repeatedly render the scene
  145. processCurrentScene(scene);
  146. }
  147. }
  148. }
  149. }
  150. else {
  151. alert('BabylonJS is not supported.')
  152. }
  153. });
  154. </script>
  155. </body>
  156. </html>