index-views.html 6.1 KB

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