Cache repeated 3D model loads#882
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 1b06d9cc2e
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| function isAbsoluteUrl(url: string) { | ||
| return /^[a-z][a-z\d+\-.]*:/i.test(url) |
There was a problem hiding this comment.
Treat protocol-relative model URLs as absolute
normalizeModelCacheKey relies on isAbsoluteUrl, but the current regex only recognizes scheme-prefixed URLs and classifies protocol-relative URLs (//...) as relative. In that case the hostname is dropped (//cdn-a/x.glb and //cdn-b/x.glb both normalize to /x.glb), so load3DModel can reuse the wrong cached asset across different CDNs/hosts. This is a correctness bug whenever model URLs are provided in protocol-relative form.
Useful? React with 👍 / 👎.
|
Addressed the protocol-relative URL cache-key case from review. |
/claim #93
Summary
.glb,.gltf,.obj,.stl, and.wrlURLs still resolve when they include query strings or hashes.load3DModelresults by normalized URL, stripping onlycachebust_origin, and reuse in-flight loads for duplicate model requests.GltfModelthrough the shared loader while keeping a GLB fallback for extensionless GLTF/GLB endpoints.Testing
npx biome check src/utils/load-model.ts src/three-components/GltfModel.tsx tests/load-model.test.tsnpx bun test tests/load-model.test.tsnpm run buildnpx bun testcurrently has unrelated existing failures intests/preprocess-circuit-json.test.tsfaux-board z-offset expectations andtests/outline-bounds.test.tsAtari SVG color expectation; the new load-model tests pass.