ai / offscreen-canvas

Polyfill for OffscreenCanvas to move Three.js/WebGL/2D canvas to Web Worker
MIT License
332 stars 13 forks source link

Pass extra data to worker #4

Closed unlocomqx closed 5 years ago

unlocomqx commented 5 years ago

In my use case, I'm converting a SVG to JPG so I need to pass the svg code to the worker. It would be better if the createWorker function would accept a data argument to pass arbitrary data

PS: I can assign the svg code to the canvas dataset for now

ai commented 5 years ago

You can send additional message with converted data:

worker.post({ message: 'image', image: jpg })

It is better because SVG→JPG conversion can take a while and you can load OffscreenCanvas while an image is loading.

Will it help you?

unlocomqx commented 5 years ago

Yes, I will try it

Thank you