You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

330 lines
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. function GetCmdDictionnary() { return CodeDictionnary[g_code_id]; }
  119. </script>
  120. <script src="./utils.js"></script>
  121. <script src="./progress_status.js"></script>
  122. <script src="./type_dictionnary.js"></script>
  123. <script type="text/javascript">
  124. CodeDictionnary[0] = new TypeDictionnary("EasyMesh");
  125. </script>
  126. <script src="./easy_mesh_dictionnary.js"></script>
  127. <script type="text/javascript">
  128. g_code_id = 1;
  129. CodeDictionnary[1] = new TypeDictionnary("EasyMesh");
  130. </script>
  131. <script src="./scenesetup.js"></script>
  132. <script type="text/javascript">
  133. g_code_id = 0;
  134. </script>
  135. <script type="text/javascript">
  136. //Base init for all datas
  137. function VarInit()
  138. {
  139. //Init frame variable first.
  140. g_frame_embed = document.getElementById('id_frame_embed');
  141. //This is in an iframe.
  142. g_div_frame_embed = g_frame_embed.contentDocument.getElementById('id_div_frame_embed');
  143. //The rest of these are in this page.
  144. g_txtarea_code_src = document.getElementById('id_txtarea_code_src');
  145. g_div_helper_cmd[0] = document.getElementById('id_div_helper_cmd_0');
  146. g_div_helper_cmd[1] = document.getElementById('id_div_helper_cmd_1');
  147. g_div_helper_args = document.getElementById('id_div_helper_args');
  148. g_div_helper_cmnt = document.getElementById('id_div_helper_cmnt');
  149. g_div_helper_vars = document.getElementById('id_div_helper_vars');
  150. g_div_alphabet = document.getElementById('id_div_alphabet');
  151. g_div_progress = document.getElementById('id_div_progress');
  152. g_div_progress_status = document.getElementById('id_div_progress_status');
  153. g_progress_bar = document.getElementById('id_progress_bar');
  154. }
  155. //Base init
  156. function Init()
  157. {
  158. VarInit();
  159. //Put here any cookie update
  160. if (!g_txtarea_code_src.value)
  161. g_txtarea_code_src.value = g_mesh_code_base[g_code_id];
  162. //Fill the TOC
  163. if (!g_div_alphabet.innerHTML)
  164. {
  165. for (var i = 0; i < CodeDictionnary.length; i++)
  166. {
  167. g_code_id = i;
  168. var new_toc = BuildTOC(true);
  169. var pattern = new RegExp("^[a-zA-Z\.]");
  170. while (pattern.test(new_toc))
  171. new_toc = new_toc.replace(pattern, "<b>$&");
  172. pattern = new RegExp("[a-zA-Z\.]$");
  173. while (pattern.test(new_toc))
  174. new_toc = new_toc.replace(pattern, "$&</b>");
  175. pattern = new RegExp("([a-zA-Z])([\.])");
  176. while (pattern.test(new_toc))
  177. new_toc = new_toc.replace(pattern, "$1</b>$2");
  178. pattern = new RegExp("([\.])([a-zA-Z])");
  179. while (pattern.test(new_toc))
  180. new_toc = new_toc.replace(pattern, "$1<b>$2");
  181. CodeDictionnary[i].m_alphabet = new_toc;
  182. }
  183. g_code_id = 0;
  184. InitEditValues();
  185. }
  186. //NaCl Specific
  187. if (IsUsingNaCl())
  188. {
  189. DynLoadFile("nacl_loading.js");
  190. g_frame_embed.src = 'meshviewer_nacl.html';
  191. }
  192. else
  193. g_frame_embed.src = 'meshviewer_em.html';
  194. g_frame_embed.onload = function() { VarInit(); }
  195. //Tick has been done, start Tick
  196. window.setTimeout("Tick()", 200);
  197. }
  198. function Tick()
  199. {
  200. window.setTimeout("Tick()", 100);
  201. var text_src = g_txtarea_code_src;
  202. var div_cmds = g_div_helper_cmd;
  203. var div_args = g_div_helper_args;
  204. var div_cmnt = g_div_helper_cmnt;
  205. var div_vars = g_div_helper_vars;
  206. CmdLookup(div_cmds, div_args, div_cmnt, div_vars, text_src);
  207. }
  208. function StoreTextAreaValue()
  209. {
  210. g_mesh_code_base[g_code_id] = GetTextAreaCodeSrc().value;
  211. }
  212. function ExchangeSetup()
  213. {
  214. StoreTextAreaValue();
  215. g_code_id = (g_code_id + 1) % 2;
  216. InitEditValues();
  217. }
  218. function InitEditValues()
  219. {
  220. GetTextAreaCodeSrc().value = g_mesh_code_base[g_code_id];
  221. g_div_alphabet.innerHTML = '&nbsp;Table of content<br>&nbsp;[' + CodeDictionnary[g_code_id].m_alphabet + ']&nbsp;<br>&nbsp;';
  222. }
  223. //Handle message from the NaCl module
  224. function ModuleSentMessage(message)
  225. {
  226. alert('Module sent message: ' + message.data);
  227. }
  228. //Called by the "Send Mesh Command !" button
  229. function SendMessageToModule()
  230. {
  231. StoreTextAreaValue();
  232. var message = g_mesh_code_base[1] + ' \n';
  233. message += ' custom setmesh "' + g_mesh_code_base[0] + '"';
  234. if (g_embed_module)
  235. g_embed_module.SendMessage(message);
  236. else
  237. alert("Module not loaded !");
  238. }
  239. </script>
  240. <body>
  241. <h1>Mesh Viewer : Web version.</h1>
  242. <p>
  243. <div id="final_div">
  244. <div id="id_div_listener" align="center" style="width:770px;height:200px">
  245. <canvas id="BGCanvas" width="772" height="202"></canvas>
  246. <div id="id_div_progress">
  247. <br>&nbsp;
  248. <progress id="id_progress_bar" align="left"></progress>
  249. <div id="id_div_progress_status">....</div>&nbsp;
  250. </div>
  251. <div id="id_div_frame_embed">
  252. <iframe onload="Init();" id="id_frame_embed" src="empty.html" width=770 height=200 frameborder=0 scrolling=no></iframe>
  253. </div>
  254. </div>
  255. </div>
  256. </p>
  257. <table border="0" cellpadding="0" cellspacing="0" width="772">
  258. <tr>
  259. <td align="left">
  260. <div><button onclick="SendMessageToModule()">Send Mesh Command !</button></div>
  261. </td>
  262. <td align="right">
  263. <div><button onclick="ExchangeSetup()">Edit Scene Setup.</button></div>
  264. </td>
  265. </tr>
  266. </table>
  267. <table border="0" cellpadding="0" cellspacing="0">
  268. <tr>
  269. <td height="1%">
  270. <div id="bouton">
  271. <textarea autofocus id="id_txtarea_code_src" rows="6" cols="94" style="font: 14px Consolas; resize: none;"></textarea>
  272. </div>
  273. </td>
  274. <td valign="top" rowspan="3">&nbsp;</td>
  275. <td valign="top" rowspan="3">
  276. <div><b><u>Variable Types usage :</u></b></div>
  277. <div id="id_div_helper_vars"></div>
  278. </td>
  279. </tr>
  280. <tr>
  281. <td height="1%">
  282. <div id="id_div_alphabet"></div>
  283. </td>
  284. </tr>
  285. <tr>
  286. <td valign="top">
  287. <table border="0" cellpadding="0" cellspacing="0">
  288. <tr>
  289. <td valign="top"><div id="id_div_helper_cmd_0"></div></td>
  290. <td valign="top"><div id="id_div_helper_cmd_1"></div></td>
  291. <td valign="top"><div id="id_div_helper_args" ></div></td>
  292. <td valign="top"><div id="id_div_helper_cmnt" ></div></td>
  293. </tr>
  294. </table>
  295. </td>
  296. </tr>
  297. </table>
  298. </body>
  299. </html>