Cache GLTF model loads#920
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: 45b72930e1
ℹ️ 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".
| } | ||
|
|
||
| export const cloneGltfSceneForInstance = (scene: THREE.Group) => { | ||
| const clonedScene = scene.clone(true) |
There was a problem hiding this comment.
Clone GLTF scenes with SkeletonUtils
Replace scene.clone(true) here with SkeletonUtils.clone(...) for cached instance creation. Object3D.clone does not reliably preserve bone associations for SkinnedMesh hierarchies, so rigs/animations can break or share incorrect skeleton state when the loaded GLTF contains skinned content. This only appears for GLTF assets that include skinning, but in that case repeated cached instances may render or animate incorrectly.
Useful? React with 👍 / 👎.
|
Closing this out as part of wrapping up my bounty/OSS cleanup. Thanks for the time and review. |
Closes #93
/claim #93
Changes
isTranslucentupdates, so translucency changes update materials on the loaded scene without triggering a fresh model load.Validation
./node_modules/.bin/biome check src/three-components/GltfModel.tsx src/utils/gltf-model-cache.ts tests/gltf-model-cache.test.tsnpx --yes tsc --noEmit --pretty falsenpx --yes bun test tests/gltf-model-cache.test.ts tests/cad-model-transform.test.ts tests/cad-model-fit.test.ts-> 17 passednpm run buildgit diff --checkNote: the local shell does not have a global
bun, so I usednpx --yes bunfor the focused Bun tests and npm-installed tooling for build/type/format verification.