On the worker side I use ImageBitmapLoader, CanvasTexture
. I create an object and put it in storage using the new Mesh(..., ...).toJSON()
method
As a result, I lose the image. In the logs I see images[uuid] = { uuid: '...', url: undefined } }
After a little research and looking for a solution to the problem, it seemed to me that I needed to modify the ImageUtils.getDataURL()
The part of my solution to fix:
export default class WorkerImageUtils {
async getDataURL(image) {
const canvas = new OffscreenCanvas(image.width, image.height)
const context = canvas.getContext('bitmaprenderer')
context.transferFromImageBitmap(image)
return await canvas.convertToBlob() .then(blob => {
return new FileReaderSync().readAsDataURL(blob)
})
}
}