Skip to content

CameraControls at WebWorker (ThreeJS & Offscreen Canvas) #479

Answered by yomotsu
QuisMagni asked this question in Q&A
Discussion options

You must be logged in to vote

Thanks for the details.
It seems worth supporting WebWorker.

Although camera-controls requires a DOM element, I think It's possible with some internal changes, according to
https://github.com/puxiao/using-orbitcontrols-in-worker/tree/main

  1. Prepare a virtual dom element pure JS object that extends an EventDispatcher class.
  2. Pass the virtual element to new CameraControl( camera, virtualElement )
  3. Then sync the virtual element state with a real dom element with worker's postMessage. Also, the virtual element emits virtual pointer events via the real dom.
  4. camera-controls just use the pure JS object as the Dom element internally.

Replies: 2 comments 3 replies

Comment options

You must be logged in to vote
3 replies
@QuisMagni
Comment options

@yomotsu
Comment options

Answer selected by QuisMagni
@QuisMagni
Comment options

Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants