No puede seleccionar más de 25 temas Los temas deben comenzar con una letra o número, pueden incluir guiones ('-') y pueden tener hasta 35 caracteres de largo.

meshviewer.em.html 7.1 KiB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187
  1. <!doctype html>
  2. <html lang="en-us">
  3. <head>
  4. <meta charset="utf-8">
  5. <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
  6. <title>YOUR PAGE NAME HERE</title>
  7. <style>
  8. .emscripten
  9. {
  10. padding-right: 0;
  11. margin-left: auto;
  12. margin-right: auto;
  13. display: block;
  14. }
  15. textarea.emscripten
  16. {
  17. font-family: monospace;
  18. width: 80%;
  19. }
  20. div.emscripten
  21. {
  22. text-align: center;
  23. }
  24. div.emscripten_border
  25. {
  26. border: 1px solid black;
  27. position: absolute;
  28. left: 0px;
  29. top: 0px;
  30. }
  31. /* the canvas *must not* have any border or padding, or mouse coords will be wrong */
  32. canvas.emscripten
  33. {
  34. border: 0px none;
  35. }
  36. </style>
  37. </head>
  38. <body>
  39. <div class="emscripten_border" id="id_div_embed_data">
  40. <canvas class="emscripten" id="id_cvas_render" oncontextmenu="event.preventDefault()"></canvas>
  41. </div>
  42. <!-- this part is a little weird, I don't really know what to do with it. -->
  43. <div class="emscripten">
  44. <input type="checkbox" id="id_ckbox_resize">Resize canvas
  45. <input type="checkbox" id="id_ckbox_pointer_lock" checked>Lock/hide mouse pointer
  46. &nbsp;&nbsp;&nbsp;
  47. <input type="button" value="Fullscreen" onclick="ClickFullscreen()">
  48. </div>
  49. <textarea class="emscripten" id="id_txt_output" rows="8"> </textarea>
  50. <script type='text/javascript'>
  51. // connect to canvas
  52. var Module =
  53. {
  54. output: document.getElementById('id_txt_output'),
  55. canvas: document.getElementById('id_cvas_render'),
  56. preRun: [],
  57. postRun: [],
  58. clickFullsreen: function()
  59. {
  60. Module.requestFullScreen(document.getElementById('id_ckbox_pointer_lock').checked,
  61. document.getElementById('id_ckbox_resize').checked);
  62. },
  63. print: (function()
  64. {
  65. if (this.output)
  66. {
  67. this.output.value = ''; // clear browser cache
  68. return function(text)
  69. {
  70. this.text = Array.prototype.slice.call(arguments).join(' ');
  71. // These replacements are necessary if you render to raw HTML
  72. /*
  73. text = text.replace(/&/g, "&amp;");
  74. text = text.replace(/</g, "&lt;");
  75. text = text.replace(/ >/g, "&gt;");
  76. text = text.replace('\n', '<br>', 'g');
  77. */
  78. this.output.value += text + "\n";
  79. this.output.scrollTop = 99999; // focus on bottom
  80. };
  81. }
  82. else
  83. return '';
  84. })(),
  85. printErr: function(text)
  86. {
  87. text = Array.prototype.slice.call(arguments).join(' ');
  88. if (0) // XXX disabled for safety typeof dump == 'function')
  89. dump(text + '\n'); // fast, straight to the real console
  90. else
  91. console.log(text);
  92. },
  93. //Load Status handling
  94. setStatus: function(text, new_value, new_max)
  95. {
  96. var tmp_status = '';
  97. var tmp_value = undefined;
  98. var tmp_max = undefined;
  99. var should_hide = false;
  100. //Clear any interval put on this Status.
  101. if (Module.setStatus.interval)
  102. clearInterval(Module.setStatus.interval);
  103. //If value and max have been set, directly go for the win.
  104. if (new_value != undefined && new_max != undefined)
  105. {
  106. tmp_status = text;
  107. tmp_value = new_value;
  108. tmp_max = new_max;
  109. }
  110. else
  111. //Else do the complicated stuff.
  112. {
  113. var m = text.match(/([^(]+)\((\d+(\.\d+)?)\/(\d+)\)/);
  114. if (m)
  115. {
  116. text = m[1];
  117. tmp_value = parseInt(m[2]) * 100;
  118. tmp_max = parseInt(m[4]) * 100;
  119. }
  120. else
  121. should_hide = true;
  122. }
  123. if (parent)
  124. {
  125. //parent.UpdateProgressBarValue(tmp_status, tmp_value, tmp_max);
  126. //parent.HideProgressStatus(should_hide);
  127. }
  128. },
  129. totalDependencies: 0,
  130. monitorRunDependencies:
  131. function(left)
  132. {
  133. this.totalDependencies = Math.max(this.totalDependencies, left);
  134. if (left)
  135. Module.setStatus('Downloading dependencies ', (this.totalDependencies - left), this.totalDependencies);
  136. else
  137. Module.setStatus('All downloads complete.', 1, 1);
  138. },
  139. //IMPORTANT : This is the C -> Javascript wraping, add your functions list here.
  140. wrapup_list: [ {src_obj: null, func_name: 'DoSendMessage', c_func_name: 'C_Send', return_var: 'number', args: ['string'] } ],
  141. do_wrapup: function()
  142. {
  143. for (var i = 0; i < this.wrapup_list.length; i++)
  144. {
  145. if (!this.wrapup_list[i].src_obj)
  146. this.wrapup_list[i].src_obj = this;
  147. this.wrapup_list[i].src_obj[this.wrapup_list[i].func_name] =
  148. cwrap(this.wrapup_list[i].c_func_name,
  149. this.wrapup_list[i].return_var,
  150. this.wrapup_list[i].args);
  151. }
  152. },
  153. //Module <-> Page communication setup
  154. SendMessage:function(message)
  155. {
  156. this.DoSendMessage(message);
  157. },
  158. ModuleSendMessage:function(message)
  159. {
  160. alert(message);
  161. }
  162. };
  163. </script>
  164. <!-- Copy this HTML in your site folder and put your built program script in the src. -->
  165. <script src="./meshviewer.em.js"></script>
  166. <!-- -->
  167. <script type='text/javascript'>
  168. //This call NEEDS TO BE after the .js include, because "cwrap" is set in it.
  169. Module.do_wrapup();
  170. //Parent communication datas
  171. function GetDivEmbed() { return document.getElementById('id_div_embed_data'); }
  172. function GetEmbedModule() { return Module; }
  173. parent.InitModuleVar();
  174. Module.setStatus('Please wait, calculating load balance ...', 0, 1);
  175. </script>
  176. </body>
  177. </html>