Skip to content

WebXR: Added model caching to XRHandModelFactory.#33252

Merged
Mugen87 merged 2 commits into
mrdoob:devfrom
NssGourav:feature/xr-hand-caching
Mar 28, 2026
Merged

WebXR: Added model caching to XRHandModelFactory.#33252
Mugen87 merged 2 commits into
mrdoob:devfrom
NssGourav:feature/xr-hand-caching

Conversation

@NssGourav

@NssGourav NssGourav commented Mar 27, 2026

Copy link
Copy Markdown
Contributor

Fixed #33242

Description

Implemented model caching for XRHandMeshModel to improve performance and prevent redundant network requests.

Previously, XRHandMeshModel lacked the asset caching found in XRControllerModelFactory, causing the hand model (${handedness}.glb) to be re-fetched every time a hand connected or re-entered view. This PR introduces a shared _assetCache in XRHandModelFactory and updates XRHandMeshModel to:

  • Check for cached assets before initiating a load.
  • Populate the cache after a successful fetch.
  • Use .clone() on cached models to ensure independent instances for multiple hand models.

These changes unify the WebXR model factories and optimize hand-tracking experiences by reducing fetch overhead.

Comment thread examples/jsm/webxr/XRHandMeshModel.js Outdated
loader.load( `${handedness}.glb`, gltf => {

const object = gltf.scene.children[ 0 ];
const object = gltf.scene.children[ 0 ].clone();

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

I don't think this code works. The glb is supposed to hold a skinned mesh and those can't be cloned via clone(). You must use SkeletonUtils.clone().

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I'll do that .

@Mugen87 Mugen87 Mar 28, 2026

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

You know...even if you are using AI to code things you are supposed to test what you are doing. This bug is quite obvious for developers who actually understand three.js.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I'm sorry this is my first issue to work on so to have a review I have used AI , but I have tested this on my own I'll make sure that this won't repeat again, sorry for the inconvenience

* @param {?Function} [onLoad=null] - A callback that is executed when a controller model has been loaded.
*/
constructor( handModel, controller, path, handedness, loader = null, onLoad = null ) {
constructor( handModel, controller, path, handedness, loader = null, onLoad = null, customCache = null ) {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Please document the new parameter.

@Mugen87

Mugen87 commented Mar 28, 2026

Copy link
Copy Markdown
Collaborator

@mrdoob How about adding an AI/LLM Usage Guideline to the Contribution guide? Gemini comes up with something like this:


AI/LLM Usage Guidelines

You are responsible for the code you submit.

While AI tools can provide powerful assistance, we strictly discourage "copy-paste" contributions. PRs are frequently rejected because the submitter did not understand the code the AI generated.

  • Do not submit code you do not understand.
  • Do not rely on AI to check for functional correctness. Test and verify changes by yourself.
  • Do not expect maintainers to debug AI-generated errors for you.

If a PR is found to be low-quality or "hallucinated" code, it will be closed immediately. Please value our time by thoroughly reviewing and testing your contributions.


Then we have something we can link to instead of explaining these things over and over again.

@NssGourav

Copy link
Copy Markdown
Contributor Author

From my perspective a suggestion that if you know the code and want to review from ai ,I want to have some guidelines so it will help contributor's like me to review the code easily and get the suggestions.

@Mugen87

Mugen87 commented Mar 28, 2026

Copy link
Copy Markdown
Collaborator

The first thing you should keep in mind is: Don't contribute to projects you are not familiar with.

At the end, you are causing more troubles with your "contribution" than producing a benefit. The real contributors and maintainers need to spend a lot of time to review your PR and explain the bugs you introduce. At the end, we are faster when we implement issues like #33242 ourselves.

@NssGourav

Copy link
Copy Markdown
Contributor Author

The first thing you should bear in mind is: Don't contribute to projects you are not familiar with. At the end, you are causing more troubles with your "contribution" than producing a benefit.

Completely agreed 💯

@Mugen87

Mugen87 commented Mar 28, 2026

Copy link
Copy Markdown
Collaborator

I'll fix the open issues and merge.

@Mugen87 Mugen87 added this to the r184 milestone Mar 28, 2026
@Mugen87 Mugen87 merged commit e584798 into mrdoob:dev Mar 28, 2026
9 checks passed
@NssGourav NssGourav deleted the feature/xr-hand-caching branch April 1, 2026 13:47
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.

XR: Allow caching of hand mesh model

2 participants