ImageLoader: Optimize caching.#31258
Conversation
📦 Bundle sizeFull ESM build, minified and gzipped.
🌳 Bundle size after tree-shakingMinimal build including a renderer, camera, empty scene, and dependencies.
|
|
The For example, the following snippet logs a warning: THREE.Cache.enabled = true;
const loader = new THREE.TextureLoader();
loader.load( 'image.png' );
loader.load( 'image.png', (texture) => renderer.initTexture(texture) );
// THREE.WebGLRenderer: Texture marked for update but image is incompleteIt might still be possible to cache early, but there'll have to be an additional code path for when subsequent requests encounter |
|
Good catch! I've adopted a similar approach like |
For consistency the calls to Other than that, looks good to me. |
Fixed #31256.
Description
The idea of this PR is to cache the image object in
ImageLoadera bit earlier. In this way, concurrent pending requests get the same cached image.If the request fails, the cache entry is removed so subsequent
load()calls (like retries) perform a fresh request.