Offscreen canvas and orbit controls

Hi all.

I am trying to use the offscreen canvas in my 3d threejs based viewer.

One of my problems is that I don’t know how to interact with my scene with an orbitControls in the webworker thread.

As far as I know, webworkers cannot interact with dom objects.

Is there any workarraound for this?

Best regards

Only thing you need is the camera in your worker, so use the OrbitControls in your main thread and just snycrhonize the camera quaternion and world position with your thread.

I have found an example:

https://threejsfundamentals.org/threejs/threejs-offscreencanvas-w-orbitcontrols.html

Best regards

1 Like

I wrote an example, you can view:
https://github.com/puxiao/using-orbitcontrols-in-worker