OpenJSCAD.org icon indicating copy to clipboard operation
OpenJSCAD.org copied to clipboard

Move render to worker and use offscreen-canvas (transferControlToOffscreen)

Open hrgdavor opened this issue 3 years ago • 3 comments

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

hrgdavor avatar Apr 30 '21 21:04 hrgdavor

FYI, there’s requirement for transferring the solids to the main thread, as the front end also ‘exports’ the solids to external formats.

z3dev avatar Jun 11 '21 22:06 z3dev

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.

hrgdavor avatar Jun 11 '21 23:06 hrgdavor

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

hrgdavor avatar Jul 01 '21 14:07 hrgdavor