mirror of
https://git.dev.opencascade.org/repos/occt.git
synced 2025-08-04 13:13:25 +03:00
0032065: Samples - use MODULARIZE within WebGL sample
Fixed multitouch input. Module is now exported with global functions hidden via MODULARIZE as global object OccViewerModule created by createOccViewerModule(). Global Module setup has been moved to occt-webgl-viewer.js. Use EMSCRIPTEN_KEEPALIVE attribute istead of listing C functions via EXTRA_EXPORTED_RUNTIME_METHODS. WasmOcctView now exports static methods as Module functions using EMSCRIPTEN_BINDINGS. Standard_ASSERT_DBGBREAK_() is now defined using emscripten_debugger().
This commit is contained in:
28
samples/webgl/occt-webgl-viewer.js
Normal file
28
samples/webgl/occt-webgl-viewer.js
Normal file
@@ -0,0 +1,28 @@
|
||||
var OccViewerModule =
|
||||
{
|
||||
print: (function() {
|
||||
var anElement = document.getElementById('output');
|
||||
return function(theText) { anElement.innerHTML += theText + "<br>"; };
|
||||
})(),
|
||||
printErr: function(theText) {
|
||||
//var anElement = document.getElementById('output');
|
||||
//anElement.innerHTML += theText + "<br>";
|
||||
console.warn(theText);
|
||||
},
|
||||
canvas: (function() {
|
||||
var aCanvas = document.getElementById('occViewerCanvas');
|
||||
var aGlCtx = aCanvas.getContext ('webgl2', { alpha: false, depth: true, antialias: false, preserveDrawingBuffer: true } );
|
||||
if (aGlCtx == null) { aGlCtx = aCanvas.getContext ('webgl', { alpha: false, depth: true, antialias: false, preserveDrawingBuffer: true } ); }
|
||||
return aCanvas;
|
||||
})(),
|
||||
|
||||
onRuntimeInitialized: function() {
|
||||
//console.log(" @@ onRuntimeInitialized()" + Object.getOwnPropertyNames(OccViewerModule));
|
||||
}
|
||||
};
|
||||
|
||||
const OccViewerModuleInitialized = createOccViewerModule(OccViewerModule);
|
||||
OccViewerModuleInitialized.then(function(Module) {
|
||||
//OccViewerModule.setCubemapBackground ("cubemap.jpg");
|
||||
OccViewerModule.openFromUrl ("ball", "samples/Ball.brep");
|
||||
});
|
Reference in New Issue
Block a user