OpenJSCAD.org
OpenJSCAD.org copied to clipboard
Move render to worker and use offscreen-canvas (transferControlToOffscreen)
Expected Behavior
both render and model executor to be in the same space (preferably worker) then there is no need to convert to compactbinary
Actual Behavior
render is in main thread, model executor is in worker
Steps to Reproduce the Problem
it's just how it is right now
Specifications
https://caniuse.com/offscreencanvas browser support for this will only get better
https://developers.google.com/web/updates/2018/08/offscreen-canvas
Example I found was in three.js https://threejsfundamentals.org/threejs/lessons/threejs-offscreencanvas.html
- Version: V2
- Platform: all
- Environment: browser
FYI, there’s requirement for transferring the solids to the main thread, as the front end also ‘exports’ the solids to external formats.
I have looked into that previously, and I think that export can be done in the worker as well. The file is transferable. I will keep it in mind to test it too.
I have succeded in moving render to worker by making a new version of demo.html in regl-renderer package. I have some code cleanup to do, but will add an PR so there will be both simple demo and demo with workers.
I will also try to implement export in worker, and this way all 3 parts: model-gen, render, export will be in same scope and will not need postMessage