Skip to content

fix: use deepClone for Skin._skinMatrices to prevent undefined after clone#2941

Open
cptbtptpbcptdtptp wants to merge 1 commit intogalacean:dev/2.0from
cptbtptpbcptdtptp:fix/skin-matrices-clone
Open

fix: use deepClone for Skin._skinMatrices to prevent undefined after clone#2941
cptbtptpbcptdtptp wants to merge 1 commit intogalacean:dev/2.0from
cptbtptpbcptdtptp:fix/skin-matrices-clone

Conversation

@cptbtptpbcptdtptp
Copy link
Copy Markdown
Collaborator

@cptbtptpbcptdtptp cptbtptpbcptdtptp commented Mar 25, 2026

Summary

  • Change @ignoreClone to @deepClone for Skin._skinMatrices property
  • This ensures cloned Skin objects have their own Float32Array for skin matrices instead of undefined

Problem

When cloning a Skin object, _skinMatrices was decorated with @ignoreClone. According to the clone logic in CloneManager.cloneProperty(), when CloneMode.Ignore is set, the property is skipped entirely during cloning. This results in the cloned Skin object having _skinMatrices as undefined, which causes rendering issues when the cloned SkinnedMeshRenderer tries to update skin matrices.

Solution

Use @deepClone instead to create a deep copy of the Float32Array, ensuring each cloned Skin instance has its own properly initialized skin matrices array.

Test plan

  • Verify Skin cloning creates independent _skinMatrices
  • Verify cloned SkinnedMeshRenderer renders correctly
  • Run existing unit tests

🤖 Generated with Claude Code

When cloning a Skin object, _skinMatrices should be deep cloned instead
of ignored. Using @ignoreClone causes the cloned Skin to share the same
Float32Array reference with the original, leading to incorrect skinning
behavior when the clone is modified.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Mar 25, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: 91d3e096-537b-4647-8b21-634c30b15d50

📥 Commits

Reviewing files that changed from the base of the PR and between 0597e61 and 76f6a98.

📒 Files selected for processing (1)
  • packages/core/src/mesh/Skin.ts

Walkthrough

The _skinMatrices internal field in the Skin class has its clone behavior annotation updated from @ignoreClone to @deepClone, changing how the Float32Array buffer is handled during object duplication.

Changes

Cohort / File(s) Summary
Clone Annotation Update
packages/core/src/mesh/Skin.ts
Modified the _skinMatrices field's clone annotation from @ignoreClone to @deepClone, ensuring the buffer is deep copied during cloning operations rather than ignored.

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~3 minutes

Poem

🐰 A copy, a clone, a buffer so true,
From ignore to deep, we make something new,
The skinned matrices dance with their kin,
No longer forgotten—they'll follow along in! ✨

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately summarizes the main change: switching the clone annotation for Skin._skinMatrices from @ignoreClone to @deepClone to prevent shared references between cloned instances.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@codecov
Copy link
Copy Markdown

codecov bot commented Mar 25, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 77.12%. Comparing base (0597e61) to head (76f6a98).

Additional details and impacted files
@@             Coverage Diff             @@
##           dev/2.0    #2941      +/-   ##
===========================================
+ Coverage    77.07%   77.12%   +0.04%     
===========================================
  Files          899      899              
  Lines        98229    98229              
  Branches      9683     9693      +10     
===========================================
+ Hits         75706    75755      +49     
+ Misses       22355    22306      -49     
  Partials       168      168              
Flag Coverage Δ
unittests 77.12% <100.00%> (+0.04%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@augmentcode
Copy link
Copy Markdown

augmentcode bot commented Mar 25, 2026

🤖 Augment PR Summary

Summary: Fixes Skin cloning to avoid shared skinning matrix buffers between the original and its clone.

Changes: Switches Skin._skinMatrices from @ignoreClone to @deepClone so clones get their own Float32Array copy.

🤖 Was this summary useful? React with 👍 or 👎

Copy link
Copy Markdown

@augmentcode augmentcode bot left a comment

Choose a reason for hiding this comment

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

Review completed. 1 suggestion posted.

Fix All in Augment

Comment augment review to trigger a new review at any time.


/** @internal */
@ignoreClone
@deepClone
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Consider adding a small regression test that Skin.clone() produces an independent _skinMatrices (i.e., not the same Float32Array reference), since this change is specifically fixing shared-state cloning bugs.

Severity: low

Fix This in Augment

🤖 Was this useful? React with 👍 or 👎, or 🚀 if it prevented an incident/outage.

@cptbtptpbcptdtptp cptbtptpbcptdtptp changed the title fix: use deepClone for Skin._skinMatrices to prevent shared reference fix: use deepClone for Skin._skinMatrices to prevent undefined after clone Mar 25, 2026
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.

1 participant