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.
 
 
 

337 líneas
10 KiB

  1. <DOCTYPE html>
  2. <html>
  3. <meta http-equiv="Content-type" content="text/html;charset=UTF-8" />
  4. <!--
  5. Copyright (c) 2012 The Native Client Authors. All rights reserved.
  6. Use of this source code is governed by a BSD-style license that can be
  7. found in the LICENSE file.
  8. -->
  9. <head>
  10. <style type="text/css">
  11. body
  12. {
  13. font:12px Consolas;
  14. }
  15. button
  16. {
  17. font:14px Consolas;
  18. }
  19. textarea
  20. {
  21. font:14px Consolas;
  22. }
  23. #id_div_progress_status
  24. {
  25. font:12px Consolas;
  26. }
  27. #id_div_progress
  28. {
  29. position: absolute;
  30. top: 20%;
  31. left: 30%;
  32. right: 30%;
  33. z-index: 3;
  34. background-color:white;
  35. border:1px solid #000000;
  36. visibility: hidden;
  37. }
  38. progress
  39. {
  40. background-color: #f3f3f3;
  41. border: 0;
  42. height: 18px;
  43. width: 200px;
  44. border-radius: 9px;
  45. }
  46. progress::-webkit-progress-bar
  47. {
  48. background-color: #f3f3f3;
  49. border: 1px solid #000000;
  50. padding: 2px 2px;
  51. height: 20px;
  52. border-radius: 0px;
  53. }
  54. progress::-webkit-progress-value
  55. {
  56. background-color: #22BB22;
  57. border: 0px;
  58. height: 14px;
  59. border-radius: 0px;
  60. }
  61. #id_div_listener
  62. {
  63. position: relative;
  64. }
  65. #id_div_frame_embed
  66. {
  67. position: absolute;
  68. top: 2px;
  69. left: 2px;
  70. z-index: -1;
  71. }
  72. #BGCanvas
  73. {
  74. border:1px solid #000000;
  75. }
  76. #id_div_helper_cmd_0
  77. {
  78. margin-left: 5px;
  79. }
  80. </style>
  81. <title>Mesh Viewer Web Edition</title>
  82. </head>
  83. <script type="text/javascript">
  84. //Base data Setup : GLOBAL STYLE
  85. g_div_frame_embed_save = '';
  86. g_div_frame_embed = null;
  87. g_txtarea_code_src = null;
  88. g_div_helper_cmd = [null, null];
  89. g_div_helper_args = null;
  90. g_div_helper_cmnt = null;
  91. g_div_helper_vars = null;
  92. g_div_alphabet = null;
  93. g_div_progress = null;
  94. g_div_progress_status = null;
  95. g_progress_bar = null;
  96. g_var_progress_bar = -1;
  97. g_frame_embed = null;
  98. //This is the module pointer : can be either the NaCl or Em one depending on the context.
  99. g_embed_module = null;
  100. var g_mesh_code_base = [];
  101. var CodeDictionnary = [];
  102. g_code_id = 0;
  103. g_mesh_code_base[0] = "//This is a comment\nsc#f8f afcb 1 1 1 0";
  104. g_mesh_code_base[1] = "//This is a comment\naddlight 0.0 position (4 -1 -4) color (.0 .2 .5 1)\naddlight 0.0 position (8 2 6) color #ffff";
  105. function machinchose() { return 'test machin '; }
  106. function GetTextAreaCodeSrc() { return g_txtarea_code_src; }
  107. function GetDivProgress() { return g_div_progress; }
  108. function GetProgressBar() { return g_progress_bar; }
  109. function GetDivProgressStatus() { return g_div_progress_status; }
  110. function GetDivEmbedData() { return g_div_frame_embed; }
  111. function GetDivEmbedDataSave() { return g_div_frame_embed_save; }
  112. function GetFrameData() { return g_frame_embed; }
  113. //Communication with iframe content.
  114. function InitModuleVar() { g_embed_module = GetiFrameModuleVar(); }
  115. function GetiFrameDivEmbed() { return (!g_frame_embed) ? (null) : (g_frame_embed.contentWindow.GetDivEmbed()); }
  116. function GetiFrameModuleVar() { return (!g_frame_embed) ? (null) : (g_frame_embed.contentWindow.GetEmbedModule()); }
  117. function IsUsingNaCl() { return window.chrome; }
  118. </script>
  119. <script src="../javascript/utils.js"></script>
  120. <script src="../javascript/progressstatus.js"></script>
  121. <script type="text/javascript">
  122. //Used by typedictionnary.js
  123. function GetCmdDictionnary() { return CodeDictionnary[g_code_id]; }
  124. g_code_id = 1;
  125. </script>
  126. <script src="../javascript/typedictionnary.js"></script>
  127. <!-- Init Scene setup dictionnary -->
  128. <script type="text/javascript">
  129. CodeDictionnary[g_code_id] = new TypeDictionnary("SceneSetup");
  130. </script>
  131. <script src="./scenesetupdictionnary.js"></script>
  132. <!-- Init Easy mesh dictionnary -->
  133. <script type="text/javascript">
  134. g_code_id--;
  135. CodeDictionnary[g_code_id] = new TypeDictionnary("EasyMesh");
  136. </script>
  137. <script src="./easymeshdictionnary.js"></script>
  138. <!-- Revert datas to normal -->
  139. <script type="text/javascript">
  140. g_code_id = 0;
  141. </script>
  142. <script type="text/javascript">
  143. //Base init for all datas
  144. function VarInit()
  145. {
  146. //Init frame variable first.
  147. g_frame_embed = document.getElementById('id_frame_embed');
  148. //This is in an iframe.
  149. g_div_frame_embed = g_frame_embed.contentDocument.getElementById('id_div_frame_embed');
  150. //The rest of these are in this page.
  151. g_txtarea_code_src = document.getElementById('id_txtarea_code_src');
  152. g_div_helper_cmd[0] = document.getElementById('id_div_helper_cmd_0');
  153. g_div_helper_cmd[1] = document.getElementById('id_div_helper_cmd_1');
  154. g_div_helper_args = document.getElementById('id_div_helper_args');
  155. g_div_helper_cmnt = document.getElementById('id_div_helper_cmnt');
  156. g_div_helper_vars = document.getElementById('id_div_helper_vars');
  157. g_div_alphabet = document.getElementById('id_div_alphabet');
  158. g_div_progress = document.getElementById('id_div_progress');
  159. g_div_progress_status = document.getElementById('id_div_progress_status');
  160. g_progress_bar = document.getElementById('id_progress_bar');
  161. }
  162. //Base init
  163. function Init()
  164. {
  165. VarInit();
  166. //Put here any cookie update
  167. if (!g_txtarea_code_src.value)
  168. g_txtarea_code_src.value = g_mesh_code_base[g_code_id];
  169. //Fill the TOC
  170. if (!g_div_alphabet.innerHTML)
  171. {
  172. for (var i = 0; i < CodeDictionnary.length; i++)
  173. {
  174. g_code_id = i;
  175. var new_toc = BuildTOC(true);
  176. var pattern = new RegExp("^[a-zA-Z\.]");
  177. while (pattern.test(new_toc))
  178. new_toc = new_toc.replace(pattern, "<b>$&");
  179. pattern = new RegExp("[a-zA-Z\.]$");
  180. while (pattern.test(new_toc))
  181. new_toc = new_toc.replace(pattern, "$&</b>");
  182. pattern = new RegExp("([a-zA-Z])([\.])");
  183. while (pattern.test(new_toc))
  184. new_toc = new_toc.replace(pattern, "$1</b>$2");
  185. pattern = new RegExp("([\.])([a-zA-Z])");
  186. while (pattern.test(new_toc))
  187. new_toc = new_toc.replace(pattern, "$1<b>$2");
  188. CodeDictionnary[i].m_alphabet = new_toc;
  189. }
  190. g_code_id = 0;
  191. InitEditValues();
  192. }
  193. //NaCl Specific
  194. if (IsUsingNaCl())
  195. {
  196. DynLoadFile("../javascript/naclloading.js");
  197. g_frame_embed.src = 'meshviewer.nacl.html';
  198. }
  199. else
  200. g_frame_embed.src = 'meshviewer.em.html';
  201. g_frame_embed.onload = function() { VarInit(); }
  202. //Tick has been done, start Tick
  203. window.setTimeout("Tick()", 200);
  204. }
  205. function Tick()
  206. {
  207. window.setTimeout("Tick()", 100);
  208. var text_src = g_txtarea_code_src;
  209. var div_cmds = g_div_helper_cmd;
  210. var div_args = g_div_helper_args;
  211. var div_cmnt = g_div_helper_cmnt;
  212. var div_vars = g_div_helper_vars;
  213. CmdLookup(div_cmds, div_args, div_cmnt, div_vars, text_src);
  214. }
  215. function StoreTextAreaValue()
  216. {
  217. g_mesh_code_base[g_code_id] = GetTextAreaCodeSrc().value;
  218. }
  219. function ExchangeSetup()
  220. {
  221. StoreTextAreaValue();
  222. g_code_id = (g_code_id + 1) % 2;
  223. InitEditValues();
  224. }
  225. function InitEditValues()
  226. {
  227. GetTextAreaCodeSrc().value = g_mesh_code_base[g_code_id];
  228. g_div_alphabet.innerHTML = '&nbsp;Table of content<br>&nbsp;[' + CodeDictionnary[g_code_id].m_alphabet + ']&nbsp;<br>&nbsp;';
  229. }
  230. //Handle message from the NaCl module
  231. function ModuleSentMessage(message)
  232. {
  233. alert('Module sent message: ' + message.data);
  234. }
  235. //Called by the "Send Mesh Command !" button
  236. function SendMessageToModule()
  237. {
  238. StoreTextAreaValue();
  239. var message = g_mesh_code_base[1] + ' \n';
  240. message += ' custom setmesh "' + g_mesh_code_base[0] + '"';
  241. if (g_embed_module)
  242. g_embed_module.SendMessage(message);
  243. else
  244. alert("Module not loaded !");
  245. }
  246. </script>
  247. <body>
  248. <h1>Mesh Viewer : Web version.</h1>
  249. <p>
  250. <div id="final_div">
  251. <div id="id_div_listener" align="center" style="width:770px;height:200px">
  252. <canvas id="BGCanvas" width="772" height="202"></canvas>
  253. <div id="id_div_progress">
  254. <br>&nbsp;
  255. <progress id="id_progress_bar" align="left"></progress>
  256. <div id="id_div_progress_status">....</div>&nbsp;
  257. </div>
  258. <div id="id_div_frame_embed">
  259. <iframe onload="Init();" id="id_frame_embed" src="empty.html" width=770 height=200 frameborder=0 scrolling=no></iframe>
  260. </div>
  261. </div>
  262. </div>
  263. </p>
  264. <table border="0" cellpadding="0" cellspacing="0" width="772">
  265. <tr>
  266. <td align="left">
  267. <div><button onclick="SendMessageToModule()">Send Mesh Command</button></div>
  268. </td>
  269. <td align="right">
  270. <div><button onclick="ExchangeSetup()">Edit Scene Setup</button></div>
  271. </td>
  272. </tr>
  273. </table>
  274. <table border="0" cellpadding="0" cellspacing="0">
  275. <tr>
  276. <td height="1%">
  277. <div id="bouton">
  278. <textarea autofocus id="id_txtarea_code_src" rows="6" cols="94" style="font: 14px Consolas; resize: none;"></textarea>
  279. </div>
  280. </td>
  281. <td valign="top" rowspan="3">&nbsp;</td>
  282. <td valign="top" rowspan="3">
  283. <div><b><u>Variable Types usage :</u></b></div>
  284. <div id="id_div_helper_vars"></div>
  285. </td>
  286. </tr>
  287. <tr>
  288. <td height="1%">
  289. <div id="id_div_alphabet"></div>
  290. </td>
  291. </tr>
  292. <tr>
  293. <td valign="top">
  294. <table border="0" cellpadding="0" cellspacing="0">
  295. <tr>
  296. <td valign="top"><div id="id_div_helper_cmd_0"></div></td>
  297. <td valign="top"><div id="id_div_helper_cmd_1"></div></td>
  298. <td valign="top"><div id="id_div_helper_args" ></div></td>
  299. <td valign="top"><div id="id_div_helper_cmnt" ></div></td>
  300. </tr>
  301. </table>
  302. </td>
  303. </tr>
  304. </table>
  305. </body>
  306. </html>