Skip to content

Cache cloned glTF model loads - #934

Open
ldmstudio7 wants to merge 1 commit into
tscircuit:mainfrom
ldmstudio7:bounty/cache-gltf-models
Open

Cache cloned glTF model loads#934
ldmstudio7 wants to merge 1 commit into
tscircuit:mainfrom
ldmstudio7:bounty/cache-gltf-models

Conversation

@ldmstudio7

Copy link
Copy Markdown

Summary

  • add a global glTF/GLB loader cache that mirrors the existing global OBJ cache
  • return fresh Object3D clones with cloned material instances for each consumer
  • reuse the clone helper in the OBJ/WRL cache so transparency, hover, and env-map mutations do not leak into cached source objects or duplicate model instances

Fixes #93.

Validation

  • npm install --legacy-peer-deps --package-lock=false
  • biome format --write src/hooks/use-global-gltf-loader.ts src/utils/clone-object3d-with-materials.ts src/hooks/use-global-obj-loader.ts src/three-components/GltfModel.tsx tests/clone-object3d-with-materials.test.ts
  • tsc --noEmit
  • npm run build
  • bun test tests/clone-object3d-with-materials.test.ts
  • bun test tests/clone-object3d-with-materials.test.ts tests/cad-model-transform.test.ts tests/resolve-model-url.test.ts tests/vrml-loader.test.ts
  • npm run test:node-bundle

Note: the full bun test suite still has unrelated pre-existing failures in outline-bounds and preprocess-circuit-json assertions.

@vercel

vercel Bot commented May 31, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
3d-viewer Ready Ready Preview, Comment May 31, 2026 11:32pm

Request Review

@MikeGarciaAGM MikeGarciaAGM left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Improve 3d model loading to avoid laggy browser

2 participants