fix: add global model cache to prevent duplicate loads and browser lag#923
Open
khozakhulile27-netizen wants to merge 3 commits into
Open
fix: add global model cache to prevent duplicate loads and browser lag#923khozakhulile27-netizen wants to merge 3 commits into
khozakhulile27-netizen wants to merge 3 commits into
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Author
|
/claim #93 This PR adds a global in-memory model cache ( |
Author
|
✅ All CI checks passing (format-check, type-check, test, Vercel). This PR is ready for review and merge. |
Author
|
/attempt #93 |
Author
|
Shibosoftwaredev please review |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #93
Problem
The
load3DModelutility had no caching, so the same 3D model file (STL/OBJ/GLTF/WRL) would be fetched and parsed multiple times when multiple components share the same model URL. This caused duplicate network requests and redundant Three.js geometry creation, making the browser laggy.Fix
Added a
window.TSCIRCUIT_MODEL_CACHEglobal Map that stores in-flight load promises. Before fetching, the function checks the cache. If a cached result exists, it clones theObject3D(so each usage gets its own independent scene graph node) instead of re-fetching.This follows the same pattern already used in
use-global-obj-loader.ts.