Skip to content

Conversation

@tracygardner
Copy link
Contributor

Motivation

  • Reduce repeated model loads by caching a template instance per modelName so new characters can be quickly created by cloning.
  • Avoid reloading the same asset when multiple instances of the same character model are requested.
  • Keep prior readiness and animation-preload behavior while enabling reuse of loaded assets.

Description

  • Add flock.modelCache usage and flock.modelsBeingLoaded tracking to reuse or await an in-flight load before cloning a cached template.
  • Introduce setTemplateFlags to mark cached template meshes as non-interactive and hidden, and create a finalizeMesh helper that centralizes per-instance setup such as setupMesh, material/color application, child mesh interactivity, animation preloading, and readiness announcement.
  • On first load, clone a template from the loaded mesh and store it in the cache, and for subsequent requests clone from the cached template using the provided blockKey.
  • Retain cleanup of readiness bookkeeping by deleting the modelReadyPromises entry after a short TTL with setTimeout and preserve abort/error handling paths.

Testing

  • No automated tests were run for this change.
  • Manual runtime validation was not recorded in automated output.

Codex Task

@tracygardner tracygardner deleted the codex/implement-model-caching-in-createcharacter branch January 11, 2026 09:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants