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.

meshviewer.index.html 13 KiB

11 jaren geleden
11 jaren geleden
11 jaren geleden
11 jaren geleden
11 jaren geleden
11 jaren geleden
11 jaren geleden
11 jaren geleden
11 jaren geleden
11 jaren geleden
11 jaren geleden
11 jaren geleden
11 jaren geleden
11 jaren geleden
11 jaren geleden
11 jaren geleden
11 jaren geleden
11 jaren geleden
11 jaren geleden
11 jaren geleden
11 jaren geleden
11 jaren geleden
11 jaren geleden
11 jaren geleden
11 jaren geleden
11 jaren geleden
11 jaren geleden
11 jaren geleden
11 jaren geleden
11 jaren geleden
11 jaren geleden
11 jaren geleden
11 jaren geleden
11 jaren geleden
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396
  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. z-index: 1;
  38. }
  39. progress
  40. {
  41. background-color: #f3f3f3;
  42. border: 0;
  43. height: 18px;
  44. width: 200px;
  45. border-radius: 9px;
  46. }
  47. progress::-webkit-progress-bar
  48. {
  49. background-color: #f3f3f3;
  50. border: 1px solid #000000;
  51. padding: 2px 2px;
  52. height: 20px;
  53. border-radius: 0px;
  54. }
  55. progress::-webkit-progress-value
  56. {
  57. background-color: #22BB22;
  58. border: 0px;
  59. height: 14px;
  60. border-radius: 0px;
  61. }
  62. #id_div_listener
  63. {
  64. position: relative;
  65. }
  66. #id_div_frame_embed
  67. {
  68. position: absolute;
  69. top: 2px;
  70. left: 2px;
  71. z-index: 0;
  72. }
  73. #BGCanvas
  74. {
  75. border:1px solid #000000;
  76. }
  77. #id_div_helper_cmd_0
  78. {
  79. margin-left: 5px;
  80. }
  81. </style>
  82. <title>Mesh Viewer Web Edition</title>
  83. </head>
  84. <script type="text/javascript">
  85. //Base data Setup : GLOBAL STYLE
  86. g_div_frame_embed_save = '';
  87. g_div_frame_embed = null;
  88. g_txtarea_code_src = null;
  89. g_div_helper_cmd = [null, null];
  90. g_div_helper_args = null;
  91. g_div_helper_cmnt = null;
  92. g_div_helper_vars = null;
  93. g_div_alphabet = null;
  94. g_div_progress = null;
  95. g_div_progress_status = null;
  96. g_progress_bar = null;
  97. g_var_progress_bar = -1;
  98. g_frame_embed = null;
  99. //This is the module pointer : can be either the NaCl or Em one depending on the context.
  100. g_embed_module = null;
  101. var g_autosave_timer = 4.0;
  102. var g_autosave_time = 4.0;
  103. var g_code_addin = [' custom setmesh "#CODE#" ', '#CODE#'];
  104. var g_code_base = [];
  105. var CodeDictionnary = [];
  106. var g_code_id = 0;
  107. g_code_base[0] = "//This is a comment\nsc#f8f afcb 1 1 1 0";
  108. g_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\nshowgizmo true\nshowlight true";
  109. function machinchose() { return 'test machin '; }
  110. function GetTextAreaCodeSrc() { return g_txtarea_code_src; }
  111. function GetDivProgress() { return g_div_progress; }
  112. function GetProgressBar() { return g_progress_bar; }
  113. function GetDivProgressStatus() { return g_div_progress_status; }
  114. function GetDivEmbedData() { return g_div_frame_embed; }
  115. function GetDivEmbedDataSave() { return g_div_frame_embed_save; }
  116. function GetFrameData() { return g_frame_embed; }
  117. //Communication with iframe content.
  118. function InitModuleVar() { g_embed_module = GetiFrameModuleVar(); }
  119. function GetiFrameDivEmbed() { return (!g_frame_embed) ? (null) : (g_frame_embed.contentWindow.GetDivEmbed()); }
  120. function GetiFrameModuleVar() { return (!g_frame_embed) ? (null) : (g_frame_embed.contentWindow.GetEmbedModule()); }
  121. function IsUsingNaCl() { return window.chrome; }
  122. </script>
  123. <script src="../javascript/utils.js"></script>
  124. <script src="../javascript/progressstatus.js"></script>
  125. <script type="text/javascript">
  126. //Used by typedictionnary.js
  127. function GetCmdDictionnary() { return CodeDictionnary[g_code_id]; }
  128. g_code_id = 1;
  129. </script>
  130. <script src="../javascript/typedictionnary.js"></script>
  131. <!-- Init Scene setup dictionnary -->
  132. <script type="text/javascript">
  133. CodeDictionnary[g_code_id] = new TypeDictionnary("SceneSetup");
  134. </script>
  135. <script src="./scenesetupdictionnary.js"></script>
  136. <!-- Init Easy mesh dictionnary -->
  137. <script type="text/javascript">
  138. g_code_id--;
  139. CodeDictionnary[g_code_id] = new TypeDictionnary("EasyMesh");
  140. </script>
  141. <script src="./easymeshdictionnary.js"></script>
  142. <!-- Revert datas to normal -->
  143. <script type="text/javascript">
  144. g_code_id = 0;
  145. </script>
  146. <script type="text/javascript">
  147. //Base init for all datas
  148. function VarInit()
  149. {
  150. //Init frame variable first.
  151. g_frame_embed = document.getElementById('id_frame_embed');
  152. //This is in an iframe.
  153. g_div_frame_embed = g_frame_embed.contentDocument.getElementById('id_div_frame_embed');
  154. //The rest of these are in this page.
  155. g_txtarea_code_src = document.getElementById('id_txtarea_code_src');
  156. g_div_helper_cmd[0] = document.getElementById('id_div_helper_cmd_0');
  157. g_div_helper_cmd[1] = document.getElementById('id_div_helper_cmd_1');
  158. g_div_helper_args = document.getElementById('id_div_helper_args');
  159. g_div_helper_cmnt = document.getElementById('id_div_helper_cmnt');
  160. g_div_helper_vars = document.getElementById('id_div_helper_vars');
  161. g_div_alphabet = document.getElementById('id_div_alphabet');
  162. g_div_progress = document.getElementById('id_div_progress');
  163. g_div_progress_status = document.getElementById('id_div_progress_status');
  164. g_progress_bar = document.getElementById('id_progress_bar');
  165. }
  166. //Base init
  167. function Init()
  168. {
  169. VarInit();
  170. //Put here any cookie update
  171. if (DoesLolCookieExist("LolMeshViewerAutosave"))
  172. {
  173. var lol_cookie = GetLolCookie("LolMeshViewerAutosave", false);
  174. var value_list = lol_cookie.m_value.split(";");
  175. for (var i = 0; i < g_code_base.length && i < value_list.length; i++)
  176. {
  177. g_code_base[i] = value_list[i];
  178. var addins = g_code_addin[i].split('#CODE#');
  179. for (var j = 0; j < addins.length; j++)
  180. if (addins[j] && addins[j] != '')
  181. g_code_base[i] = g_code_base[i].replace(addins[j], "");
  182. }
  183. g_txtarea_code_src.value = g_code_base[g_code_id];
  184. }
  185. else if (!g_txtarea_code_src.value)
  186. g_txtarea_code_src.value = g_code_base[g_code_id];
  187. //Fill the TOC
  188. if (!g_div_alphabet.innerHTML)
  189. {
  190. for (var i = 0; i < CodeDictionnary.length; i++)
  191. {
  192. g_code_id = i;
  193. var new_toc = BuildTOC(true);
  194. var pattern = new RegExp("^[a-zA-Z\.]");
  195. while (pattern.test(new_toc))
  196. new_toc = new_toc.replace(pattern, "<b>$&");
  197. pattern = new RegExp("[a-zA-Z\.]$");
  198. while (pattern.test(new_toc))
  199. new_toc = new_toc.replace(pattern, "$&</b>");
  200. pattern = new RegExp("([a-zA-Z])([\.])");
  201. while (pattern.test(new_toc))
  202. new_toc = new_toc.replace(pattern, "$1</b>$2");
  203. pattern = new RegExp("([\.])([a-zA-Z])");
  204. while (pattern.test(new_toc))
  205. new_toc = new_toc.replace(pattern, "$1<b>$2");
  206. CodeDictionnary[i].m_alphabet = new_toc;
  207. }
  208. g_code_id = 0;
  209. InitEditValues();
  210. }
  211. //NaCl Specific
  212. if (IsUsingNaCl())
  213. {
  214. DynLoadFile("../javascript/naclloading.js");
  215. g_frame_embed.src = 'meshviewer.nacl.html';
  216. }
  217. else
  218. g_frame_embed.src = 'meshviewer.em.html';
  219. g_frame_embed.onload = function() { VarInit(); }
  220. //Tick has been done, start Tick
  221. window.setTimeout("Tick(.2)", 200);
  222. }
  223. function Tick(seconds)
  224. {
  225. window.setTimeout("Tick(.1)", 100);
  226. var text_src = g_txtarea_code_src;
  227. var div_cmds = g_div_helper_cmd;
  228. var div_args = g_div_helper_args;
  229. var div_cmnt = g_div_helper_cmnt;
  230. var div_vars = g_div_helper_vars;
  231. CmdLookup(div_cmds, div_args, div_cmnt, div_vars, text_src);
  232. g_autosave_timer -= seconds;
  233. if (g_autosave_timer < 0.0)
  234. {
  235. g_autosave_timer = g_autosave_time;
  236. StoreCodeCookie();
  237. }
  238. }
  239. function StoreCodeCookie()
  240. {
  241. var result = '';
  242. for (var i = 0; i < g_code_base.length; i++)
  243. { result += g_code_addin[i].replace('#CODE#', g_code_base[i]) + ";"; }
  244. StoreLolCookie(new LolCookieDays("LolMeshViewerAutosave", result, 10));
  245. }
  246. function StoreTextAreaValue()
  247. {
  248. g_code_base[g_code_id] = GetTextAreaCodeSrc().value;
  249. }
  250. function ExchangeSetup()
  251. {
  252. StoreTextAreaValue();
  253. g_code_id = (g_code_id + 1) % 2;
  254. InitEditValues();
  255. }
  256. function InitEditValues()
  257. {
  258. GetTextAreaCodeSrc().value = g_code_base[g_code_id];
  259. g_div_alphabet.innerHTML = '&nbsp;Table of content<br>&nbsp;[' + CodeDictionnary[g_code_id].m_alphabet + ']&nbsp;<br>&nbsp;';
  260. }
  261. //Handle message from the NaCl module
  262. function ModuleSentMessage(message)
  263. {
  264. alert('Module sent message: ' + message.data);
  265. }
  266. //When module is live, it calls this.
  267. function ModuleIsLive()
  268. {
  269. for (var i = 0; i < g_code_base.length; i++)
  270. {
  271. SendMessageToModule();
  272. ExchangeSetup();
  273. }
  274. }
  275. //Called by the "Send Mesh Command !" button
  276. function SendMessageToModule()
  277. {
  278. StoreTextAreaValue();
  279. if (g_embed_module)
  280. {
  281. StoreCodeCookie();
  282. g_embed_module.SendMessage(g_code_addin[g_code_id].replace('#CODE#', g_code_base[g_code_id]));
  283. }
  284. else
  285. alert("Module not loaded !");
  286. }
  287. </script>
  288. <body>
  289. <h1>Mesh Viewer : Web version.</h1>
  290. <table border="0" cellpadding="0" cellspacing="0">
  291. <tr height="404">
  292. <td>
  293. <p>
  294. <div id="final_div">
  295. <div id="id_div_listener" align="center" style="width:800px;height:400px">
  296. <canvas id="BGCanvas" width="802" height="402"></canvas>
  297. <div id="id_div_progress">
  298. <br>&nbsp;
  299. <progress id="id_progress_bar" align="left"></progress>
  300. <div id="id_div_progress_status">....</div>&nbsp;
  301. </div>
  302. <div id="id_div_frame_embed">
  303. <iframe onload="Init();" id="id_frame_embed" src="../javascript/empty.html" width=800 height=400 frameborder=0 scrolling=no></iframe>
  304. </div>
  305. </div>
  306. </div>
  307. </p>
  308. </td>
  309. <td>
  310. </td>
  311. </tr>
  312. <tr>
  313. <td rowspan="2">
  314. <table border="0" cellpadding="0" cellspacing="0" width="802">
  315. <tr>
  316. <td align="left">
  317. <div><button onclick="SendMessageToModule()">Update program</button></div>
  318. </td>
  319. <td align="right">
  320. <div><button onclick="ExchangeSetup()">Change edit data</button></div>
  321. </td>
  322. </tr>
  323. </table>
  324. <table border="0" cellpadding="0" cellspacing="0">
  325. <tr>
  326. <td height="1%">
  327. <div id="bouton">
  328. <textarea autofocus id="id_txtarea_code_src" rows="6" cols="94" style="font: 14px Consolas; resize: none;"></textarea>
  329. </div>
  330. </td>
  331. <td valign="top" rowspan="3">&nbsp;</td>
  332. <td valign="top" rowspan="3">
  333. <div><b><u>Variable Types usage :</u></b></div>
  334. <div id="id_div_helper_vars"></div>
  335. </td>
  336. </tr>
  337. <tr>
  338. <td height="1%">
  339. <div id="id_div_alphabet"></div>
  340. </td>
  341. </tr>
  342. <tr>
  343. <td valign="top">
  344. <table border="0" cellpadding="0" cellspacing="0">
  345. <tr>
  346. <td valign="top"><div id="id_div_helper_cmd_0"></div></td>
  347. <td valign="top"><div id="id_div_helper_cmd_1"></div></td>
  348. <td valign="top"><div id="id_div_helper_args" ></div></td>
  349. <td valign="top"><div id="id_div_helper_cmnt" ></div></td>
  350. </tr>
  351. </table>
  352. </td>
  353. </tr>
  354. </table>
  355. </td>
  356. </tr>
  357. </table>
  358. </body>
  359. </html>