-
-
Notifications
You must be signed in to change notification settings - Fork 35.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ImageBitmapLoader: Cache promises to deduplicate requests. #27270
Conversation
sampleRenderTarget is being deleted and set to null by super.dispose(); the check for undefined was incorrect causing an attempt to call dispose on a null object.
Fix code style.
Something is wrong with the PR since the diff is the same as #27106. |
So that if multiple calls to load the same image come in, before the first one is loaded it will still only load it once.
📦 Bundle sizeFull ESM build, minified and gzipped.
🌳 Bundle size after tree-shakingMinimal build including a renderer, camera, empty scene, and dependencies.
|
Thanks, something got out of sync. Fixed now. |
I'm also looking into this for my project! Just a question, is there a benefit to doing it this way—introducing promises to three.js/src/loaders/FileLoader.js Line 4 in 9c5fcd3
three.js/src/loaders/FileLoader.js Line 53 in 9c5fcd3
|
@sxxov That is a good question. The solution of this PR tries to achieve the same (monitoring pending requests) like what is already implemented in I tend to prefer the promise based solution though. The approach in |
Why not migrate this loader to use There seems to some workarounds in |
Now that However, it does not prevent us from merging this PR and apply a refactoring in |
) * Fix for dispose error sampleRenderTarget is being deleted and set to null by super.dispose(); the check for undefined was incorrect causing an attempt to call dispose on a null object. * Removed disposal of sampleRenderTarget entierly * Fix for setting path not affecting GLTF Sub Assets correctly. * Fixed Comment * Update GLTFLoader.js Fix code style. * Added additional caching to ImageBitmapLoader So that if multiple calls to load the same image come in, before the first one is loaded it will still only load it once. * Lint --------- Co-authored-by: Michael Herzog <[email protected]>
Related issue: #XXXX
Description
Currently I am loading several GLTF files that reference the same texture. Since those calls all come in before the textures have downloaded the cache is failing.
This PR adds the promise to the cache so subsequent calls can see that the fetch is in progress and it will wait for them rather than downloading again.