Loaders: Use unique cache keys per loader type.#31315
Conversation
📦 Bundle sizeFull ESM build, minified and gzipped.
🌳 Bundle size after tree-shakingMinimal build including a renderer, camera, empty scene, and dependencies.
|
|
Hmm... Would it make sense to do this all the loaders instead? |
|
No other loaders are directly using |
|
Ah wait..I see what you mean. Honoring the owner of the current file or image (bitmap) loader in the key instead of always using a name per loader type. However, I'm not sure there is a benefit of doing this. I can understand if an image is loaded differently like described in #27301 (comment) but I don't think there is a use case for loading a glTF (or OBJ, FBX etc.) asset with a different kind of asset loader. Besides, the "owner" information does not exists in the three basic loaders so we would need to pass additional name information from |
Fixed #27301.
Description
THREE.Cacheis currently used by three core loaders:FileLoader,ImageLoaderandImageBitmapLoader.Since the cache is global, loaders potentially share cache entries if the same URL is loaded by different loaders. Granted, that is an edge case but the OP of #27301 described a potential use case in #27301 (comment).
And since the cached results are incompatible between loaders anyway, it makes sense like described in #27301 (comment) to make the cache entries unique per loader. This is done by adding an additional loader-specific key part to the actual cache key.