Skip to content

Clone cached OBJ models safely#884

Open
phungkaizen wants to merge 1 commit into
tscircuit:mainfrom
phungkaizen:devin/1778598900-cache-clone-models
Open

Clone cached OBJ models safely#884
phungkaizen wants to merge 1 commit into
tscircuit:mainfrom
phungkaizen:devin/1778598900-cache-clone-models

Conversation

@phungkaizen
Copy link
Copy Markdown

Summary

  • Add cloneLoadedObject so cached OBJ loads return independent object trees while reusing geometry.
  • Clone mesh materials for each cached instance to avoid shared mutable material state between viewers.
  • Use the clone helper for cache hits, pending cache promises, and first-load cache storage returns.
  • Add a regression test for cached model cloning behavior.

Fixes #93
/claim #93

Review & Testing Checklist for Human

  • Verify repeated use of the same model URL no longer shares mutable object/material state between rendered instances.
  • Confirm cached geometry reuse does not regress model display or memory behavior.
  • Check preview/Storybook with repeated OBJ footprints if available.

Notes

Tested locally:

  • bun test tests/global-obj-loader-cache.test.ts
  • bun run build
  • bunx --bun tsc --noEmit

Full bun test currently has pre-existing failures unrelated to this change in existing outline/preprocess suites.

@vercel
Copy link
Copy Markdown

vercel Bot commented May 12, 2026

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

Project Deployment Actions Updated (UTC)
3d-viewer Ready Ready Preview, Comment May 12, 2026 7:44pm

Request Review

Copy link
Copy Markdown
Author

@phungkaizen phungkaizen left a comment

Choose a reason for hiding this comment

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

Hi maintainers, I added validation details for this focused OBJ cached clone fix.

Validation:

  • GitHub checks are passing, including test, type-check, and format-check.
  • Vercel preview is Ready.
  • The PR includes regression coverage for cached OBJ clone behavior.

Minimal demo/GIF plan:

  1. Open a preview scene with repeated OBJ models using the same source URL.
  2. Confirm the model is loaded through the cache path.
  3. Confirm each rendered instance has an independent cloned Object3D tree.
  4. Confirm geometry is reused while materials are cloned per instance, so hover/transparency state does not leak between repeated models.

I’m happy to add an actual short GIF/video if needed for review.

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Improve 3d model loading to avoid laggy browser

1 participant