4 <meta charset=utf-8><meta content="text/html; charset=utf-8" http-equiv=Content-Type>
5 <link rel="shortcut icon" href="lamp.ico" type="image/x-icon" />
6 <title>OCCT Draw Harness</title>
10 <h2>OCCT Draw Harness</h2>
12 <canvas id=occViewerCanvas oncontextmenu=event.preventDefault() tabindex=-1 style="border:0 none;background-color:#000" width="409" height="409"></canvas>
14 <h4>For output - open JavaScript console in your Browser.</h4>
16 <script type="text/javascript" src="DRAWEXE.js" charset="utf-8"></script>
19 * Class defining an interface to DRAWEXE and WebAssembly Module.
28 // define WebGL canvas for WebAssembly viewer
29 this.canvas = document.getElementById ('occViewerCanvas'); // canvas element for OpenGL context
30 this.canvas.tabIndex = -1;
31 this.canvas.onclick = (theEvent) =>
38 * C++ std::cout callback redirecting to console.
42 //var anElement = document.getElementById('output');
43 //anElement.innerHTML += theText + "<br>";
44 console.warn (theText);
48 * C++ std::cerr callback redirecting to console.
52 //var anElement = document.getElementById('output');
53 //anElement.innerHTML += theText + "<br>";
54 console.warn (theText);
58 * C++ Message::Send() callback redirecting to Terminal.
60 printMessage (theText, theGravity)
65 console.debug (theText);
68 console.info (theText);
71 console.warn (theText);
75 console.error (theText);
78 console.info (theText);
81 onRuntimeInitialized()
86 // Define a global DRAWEXE instance (will be initialized asynchronously).
87 var DRAWEXE = new DrawTerm();
89 //! Check browser support.
90 function isWasmSupported()
93 if (typeof WebAssembly === "object"
94 && typeof WebAssembly.instantiate === "function") {
95 const aDummyModule = new WebAssembly.Module (Uint8Array.of (0x0, 0x61, 0x73, 0x6d, 0x01, 0x00, 0x00, 0x00));
96 if (aDummyModule instanceof WebAssembly.Module)
98 return new WebAssembly.Instance(aDummyModule) instanceof WebAssembly.Instance;
105 if (!isWasmSupported())
107 var anElement = document.getElementById('output');
108 anElement.innerHTML += "Browser is too old - WebAssembly support is missing!<br>Please check updates or install a modern browser.<br>";
112 // load DRAWEXE.wasm (asynchronously) and wait initialization completion
113 createDRAWEXE(DRAWEXE).then (function(Module) {
114 //DRAWEXE.printMessage ("Hint: use \"pload ALL\" command to load standard commands\r\n", 1);
115 //DRAWEXE.eval ("dversion");
116 }).catch ((theError) => {
117 DRAWEXE.printMessage ("WebAssebly initialization has failed:\r\n" + theError, 4);