|
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187 |
- <!doctype html>
- <html lang="en-us">
- <head>
- <meta charset="utf-8">
- <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
- <title>YOUR PAGE NAME HERE</title>
-
- <style>
- .emscripten
- {
- padding-right: 0;
- margin-left: auto;
- margin-right: auto;
- display: block;
- }
- textarea.emscripten
- {
- font-family: monospace;
- width: 80%;
- }
- div.emscripten
- {
- text-align: center;
- }
- div.emscripten_border
- {
- border: 1px solid black;
- position: absolute;
- left: 0px;
- top: 0px;
- }
- /* the canvas *must not* have any border or padding, or mouse coords will be wrong */
- canvas.emscripten
- {
- border: 0px none;
- }
- </style>
- </head>
-
- <body>
- <div class="emscripten_border" id="id_div_embed_data">
- <canvas class="emscripten" id="id_cvas_render" oncontextmenu="event.preventDefault()"></canvas>
- </div>
-
- <!-- this part is a little weird, I don't really know what to do with it. -->
- <div class="emscripten">
- <input type="checkbox" id="id_ckbox_resize">Resize canvas
- <input type="checkbox" id="id_ckbox_pointer_lock" checked>Lock/hide mouse pointer
-
- <input type="button" value="Fullscreen" onclick="ClickFullscreen()">
- </div>
- <textarea class="emscripten" id="id_txt_output" rows="8"> </textarea>
-
- <script type='text/javascript'>
- // connect to canvas
- var Module =
- {
- output: document.getElementById('id_txt_output'),
- canvas: document.getElementById('id_cvas_render'),
- preRun: [],
- postRun: [],
- clickFullsreen: function()
- {
- Module.requestFullScreen(document.getElementById('id_ckbox_pointer_lock').checked,
- document.getElementById('id_ckbox_resize').checked);
- },
- print: (function()
- {
- if (this.output)
- {
- this.output.value = ''; // clear browser cache
- return function(text)
- {
- this.text = Array.prototype.slice.call(arguments).join(' ');
- // These replacements are necessary if you render to raw HTML
- /*
- text = text.replace(/&/g, "&");
- text = text.replace(/</g, "<");
- text = text.replace(/ >/g, ">");
- text = text.replace('\n', '<br>', 'g');
- */
- this.output.value += text + "\n";
- this.output.scrollTop = 99999; // focus on bottom
- };
- }
- else
- return '';
- })(),
- printErr: function(text)
- {
- text = Array.prototype.slice.call(arguments).join(' ');
- if (0) // XXX disabled for safety typeof dump == 'function')
- dump(text + '\n'); // fast, straight to the real console
- else
- console.log(text);
- },
- //Load Status handling
- setStatus: function(text, new_value, new_max)
- {
- var tmp_status = '';
- var tmp_value = undefined;
- var tmp_max = undefined;
- var should_hide = false;
-
- //Clear any interval put on this Status.
- if (Module.setStatus.interval)
- clearInterval(Module.setStatus.interval);
- //If value and max have been set, directly go for the win.
- if (new_value != undefined && new_max != undefined)
- {
- tmp_status = text;
- tmp_value = new_value;
- tmp_max = new_max;
- }
- else
- //Else do the complicated stuff.
- {
- var m = text.match(/([^(]+)\((\d+(\.\d+)?)\/(\d+)\)/);
- if (m)
- {
- text = m[1];
- tmp_value = parseInt(m[2]) * 100;
- tmp_max = parseInt(m[4]) * 100;
- }
- else
- should_hide = true;
- }
- if (parent)
- {
- //parent.UpdateProgressBarValue(tmp_status, tmp_value, tmp_max);
- //parent.HideProgressStatus(should_hide);
- }
- },
- totalDependencies: 0,
- monitorRunDependencies:
- function(left)
- {
- this.totalDependencies = Math.max(this.totalDependencies, left);
- if (left)
- Module.setStatus('Downloading dependencies ', (this.totalDependencies - left), this.totalDependencies);
- else
- Module.setStatus('All downloads complete.', 1, 1);
- },
- //IMPORTANT : This is the C -> Javascript wraping, add your functions list here.
- wrapup_list: [ {src_obj: null, func_name: 'DoSendMessage', c_func_name: 'C_Send', return_var: 'number', args: ['string'] } ],
- do_wrapup: function()
- {
- for (var i = 0; i < this.wrapup_list.length; i++)
- {
- if (!this.wrapup_list[i].src_obj)
- this.wrapup_list[i].src_obj = this;
- this.wrapup_list[i].src_obj[this.wrapup_list[i].func_name] =
- cwrap(this.wrapup_list[i].c_func_name,
- this.wrapup_list[i].return_var,
- this.wrapup_list[i].args);
- }
- },
- //Module <-> Page communication setup
- SendMessage:function(message)
- {
- this.DoSendMessage(message);
- },
- ModuleSendMessage:function(message)
- {
- alert(message);
- }
- };
- </script>
-
- <!-- Copy this HTML in your site folder and put your built program script in the src. -->
- <script src="./meshviewer.em.js"></script>
- <!-- -->
-
- <script type='text/javascript'>
- //This call NEEDS TO BE after the .js include, because "cwrap" is set in it.
- Module.do_wrapup();
-
- //Parent communication datas
- function GetDivEmbed() { return document.getElementById('id_div_embed_data'); }
- function GetEmbedModule() { return Module; }
-
- parent.InitModuleVar();
- Module.setStatus('Please wait, calculating load balance ...', 0, 1);
- </script>
-
- </body>
- </html>
|