Skip to content Skip to sidebar Skip to footer

Loading Texture From Web Worker In Three.js

When applying a large texture image to a Mesh for a noticeable period of time Three.js locks-up browser's main thread. Let's consider the following example: var texLoader = new THR

Solution 1:

Just run into this issue while trying to load textures in parallel with workers. Main roadblock seems to be THREE.Texture holds a reference to the <img> (DOM element) which in turn holds the actual image data. Don't know of a way to serialize an <img>, also webgl accepts <img> as texture data. So there is no need for THREE to touch it.

A solution might be to use a THREE.DataTexture, but that involves turning possibly compressed images into uncompressed RGB. Unfortunately a detour via a <canvas> drawImage() + getImageData() is not possible, because workers can't deal with DOM elements.

Eventually I've decided parallel texture loading has to wait for the-offscreen-canvas-interface.


Post a Comment for "Loading Texture From Web Worker In Three.js"