[v9] fix(useLoader): localize url caching per loader#3243
[v9] fix(useLoader): localize url caching per loader#3243CodyJasonBennett wants to merge 261 commits intomasterfrom
Conversation
…. priority flag deprecated for render
Co-authored-by: Gianmarco <gianmarcosimone89@gmail.com>
This reverts commit f23ecaf.
…ixedStages also has substepDeltas returning an array of deltas for each substep
…alues and now that we have deltas there are useland ways to hanlde this
Releases: @react-three/fiber@9.0.0-alpha.4 @react-three/test-renderer@9.0.0-alpha.4 [skip ci]
|
This pull request is automatically built and testable in CodeSandbox. To see build info of the built libraries, click here or the icon next to each commit SHA. Latest deployment of this branch, based on commit 97c969f:
|
| // TODO: merge errors for multiple urls | ||
| throw new Error(`Could not load ${url}: ${(error as ErrorEvent)?.message}`) |
|
The items in this PR were merged in v9 it seems, reopen if im wrong but the code mentioned is in the codebase already |
|
Whoops. I mesread the memoizedLoaders as the memoized results. reopened |
|
So I've gone a different way with this. In the meantime, to solve the key issue instead of passing the array of URLs to a single loadingFn/preload setup, I do the loop in the preload phase. (clear as well) /**
* Preloads an asset into cache as a side-effect.
*/
useLoader.preload = function <I extends InputLike, L extends LoaderLike | ConstructorRepresentation<LoaderLike>>(
loader: L,
input: I,
extensions?: Extensions<L>,
): void {
const keys = (Array.isArray(input) ? input : [input]) as string[]
// Preload each key individually so cache keys match useLoader calls
keys.forEach((key) => preload(loadingFn(extensions), [loader, key]))
}This passes the exact key/pair to useLoader.preload(gltfLoader, [URL_A, URL_B])
function ComponentA() {
const gltf = useLoader(gltfLoader, URL_A)
}Now the pair I've also added a test for this usecase See in v10 |
enhances pmndrs#3243 Further closes pmndrs#3151
Follow-up to #3131 as per #3151 (comment). Related: mrdoob/three.js#27301.