Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update spine doc for 1.4 #2501

Open
wants to merge 27 commits into
base: dev/1.4
Choose a base branch
from

Conversation

johanzhu
Copy link
Contributor

@johanzhu johanzhu commented Jan 10, 2025

Please check if the PR fulfills these requirements

  • The commit message follows our guidelines
  • Tests for the changes have been added (for bug fixes / features)
  • Docs have been added / updated (for bug fixes / features)

What kind of change does this PR introduce? (Bug fix, feature, docs update, ...)

What is the current behavior? (You can also link to an open issue here)

What is the new behavior (if this is a feature change)?

Does this PR introduce a breaking change? (What changes might users need to make in their application due to this PR?)

Other information:

Summary by CodeRabbit

Release Notes for Spine Animation Documentation and Examples

  • Documentation Updates

    • Enhanced documentation for Spine animations in the Galacean editor
    • Updated terminology and clarified instructions across multiple documentation files
    • Introduced new sections on templates and examples for Spine animations
  • New Features

    • Added PremultiplyAlpha configuration option for Spine animations
    • Introduced new method instantiate() for creating Spine animation entities
    • Added support for dynamic loading of atlas files and attachment replacement
  • Performance Improvements

    • Updated recommendations for optimizing Spine animation performance
    • Simplified entity creation and component management
    • Adjusted camera and scene positioning for better rendering
  • Breaking Changes

    • Deprecated addComponent(SpineAnimationRenderer) method
    • Replaced defaultState with defaultConfig in configuration

Copy link

coderabbitai bot commented Jan 10, 2025

Walkthrough

This pull request involves comprehensive updates to the Chinese documentation for Spine animations in the Galacean engine. The changes span multiple documentation files and example scripts, focusing on clarifying terminology, updating configuration methods, and streamlining the process of creating and managing Spine animation entities. Key modifications include renaming sections, updating code examples, and introducing new methods for instantiating Spine resources.

Changes

File Change Summary
docs/zh/graphics/2D/spine/*.md Documentation updates including formatting improvements, terminology clarifications, and section restructuring for Spine animation documentation
examples/spine-*.ts Consistent changes across example files:
- Removed Entity import
- Updated camera positioning
- Simplified spine entity instantiation
- Changed component configuration from defaultState to defaultConfig

Suggested labels

documentation, enhancement, GUI

Suggested reviewers

  • GuoLei1990
  • cptbtptpbcptdtptp

Possibly related PRs

Poem

🐰 Spine animations dance with grace,
Code refactored, a rabbit's embrace!
Documentation shines so bright,
Configs simplified, pure delight!
Galacean's magic takes its flight! 🎬

Finishing Touches

  • 📝 Generate Docstrings (Beta)

Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR. (Beta)
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@github-actions github-actions bot added the documentation Improvements or additions to documentation label Jan 10, 2025
Copy link

codecov bot commented Jan 10, 2025

Codecov Report

Attention: Patch coverage is 0% with 51 lines in your changes missing coverage. Please review.

Project coverage is 68.53%. Comparing base (a8414f9) to head (42b218a).

Files with missing lines Patch % Lines
examples/spine-follow-shoot.ts 0.00% 10 Missing ⚠️
examples/spine-physics.ts 0.00% 9 Missing ⚠️
examples/spine-change-attachment.ts 0.00% 7 Missing ⚠️
examples/spine-full-skin-change.ts 0.00% 7 Missing ⚠️
examples/spine-mix-and-match.ts 0.00% 7 Missing ⚠️
examples/spine-performance.ts 0.00% 6 Missing ⚠️
examples/spine-animation.ts 0.00% 5 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff             @@
##           dev/1.4    #2501      +/-   ##
===========================================
+ Coverage    68.50%   68.53%   +0.03%     
===========================================
  Files          956      956              
  Lines       100007    99981      -26     
  Branches      8545     8549       +4     
===========================================
+ Hits         68506    68519      +13     
+ Misses       31245    31206      -39     
  Partials       256      256              
Flag Coverage Δ
unittests 68.53% <0.00%> (+0.03%) ⬆️

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.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 2

🧹 Nitpick comments (10)
examples/spine-physics.ts (1)

37-37: Replace single quotes with double quotes as per code style guidelines

According to the static analysis hint, the string 'wind-idle' should use double quotes to conform to the project's code style.

Apply this diff to fix the issue:

-          spine.defaultConfig.animationName = 'wind-idle';
+          spine.defaultConfig.animationName = "wind-idle";
🧰 Tools
🪛 eslint

[error] 37-37: Replace 'wind-idle' with "wind-idle"

(prettier/prettier)

examples/spine-animation.ts (1)

26-26: Remove unnecessary trailing comma

Static analysis indicates that there is an unnecessary trailing comma after the last property in the object literal. Please remove it to comply with the project's code style guidelines.

Apply this diff to fix the issue:

         .load({
           url: "https://mdn.alipayobjects.com/huamei_kz4wfo/uri/file/as/2/kz4wfo/4/mp/qGISZ7QTJFkEL0Qx/spineboy/spineboy.json",
-          type: "spine",
+          type: "spine"
         })
🧰 Tools
🪛 eslint

[error] 26-26: Delete ,

(prettier/prettier)

examples/spine-change-attachment.ts (1)

29-33: Use double quotes for string literals

For consistency with TypeScript conventions and to align with the static analysis requirements, use double quotes for string literals.

-      spine.defaultConfig.skinName = 'full-skins/girl';
-      spine.defaultConfig.animationName = 'idle';
+      spine.defaultConfig.skinName = "full-skins/girl";
+      spine.defaultConfig.animationName = "idle";
🧰 Tools
🪛 eslint

[error] 32-32: Replace 'full-skins/girl' with "full-skins/girl"

(prettier/prettier)


[error] 33-33: Replace 'idle' with "idle"

(prettier/prettier)

examples/spine-full-skin-change.ts (1)

35-36: Use double quotes for string literals

For consistency with TypeScript conventions and to align with the static analysis requirements, use double quotes for string literals.

-      spine.defaultConfig.skinName = 'full-skins/girl';
-      spine.defaultConfig.animationName = 'idle';
+      spine.defaultConfig.skinName = "full-skins/girl";
+      spine.defaultConfig.animationName = "idle";
🧰 Tools
🪛 eslint

[error] 35-35: Replace 'full-skins/girl' with "full-skins/girl"

(prettier/prettier)


[error] 36-36: Replace 'idle' with "idle"

(prettier/prettier)

examples/spine-mix-and-match.ts (1)

35-36: Use double quotes for string literals

For consistency with TypeScript conventions and to align with the static analysis requirements, use double quotes for string literals.

-      spine.defaultConfig.skinName = 'full-skins/girl';
-      spine.defaultConfig.animationName = 'idle';
+      spine.defaultConfig.skinName = "full-skins/girl";
+      spine.defaultConfig.animationName = "idle";
🧰 Tools
🪛 eslint

[error] 35-35: Replace 'full-skins/girl' with "full-skins/girl"

(prettier/prettier)


[error] 36-36: Replace 'idle' with "idle"

(prettier/prettier)

docs/zh/graphics/2D/spine/other.md (2)

9-15: Enhance the upgrade instructions with version compatibility information.

While the upgrade instructions are clear, consider adding a compatibility matrix or version requirements to help users understand which versions of Spine are supported in editor version 1.4.


22-25: Consider providing specific performance metrics for atlas optimization.

The performance recommendations about atlas textures could be enhanced with:

  1. Recommended maximum atlas size
  2. Quantitative impact on loading times
  3. Example scenarios showing before/after optimization
docs/zh/graphics/2D/spine/example.md (2)

16-17: Fix grammatical issues in template descriptions.

Remove the redundant "通过" in these sentences:

-该模板通过展示了如何通过 setAnimation 与 addAnimation API 来编排 spine 动画队列:
+该模板展示了如何通过 setAnimation 与 addAnimation API 来编排 spine 动画队列:

-该模板通过展示了 Spine 动画如何设置过渡以及不同轨道之间的动画混合:
+该模板展示了 Spine 动画如何设置过渡以及不同轨道之间的动画混合:

Also applies to: 21-22


17-17: Add alt text to template images for accessibility.

The template images are missing descriptive alt text. Consider adding more descriptive alt text to improve accessibility:

-<img src="..." alt="spine-animation" />
+<img src="..." alt="Spine animation control template showing animation queue management" />

-<img src="..." alt="spine-mix-blend" />
+<img src="..." alt="Spine animation transition and blending template demonstrating track mixing" />

-<img src="..." alt="mix-and-match" />
+<img src="..." alt="Spine mix-and-match template showing skin combination capabilities" />

-<img src="..." alt="spine-dynamic-change" />
+<img src="..." alt="Spine dynamic local skinning template demonstrating attachment replacement" />

Also applies to: 22-22, 27-27, 32-32

docs/zh/graphics/2D/spine/editor.md (1)

130-130: Add more details about PremultiplyAlpha parameter.

The description of PremultiplyAlpha parameter could be enhanced with:

  1. When to enable/disable this option
  2. Impact on rendering quality
  3. Common troubleshooting scenarios
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between a8414f9 and 42b218a.

📒 Files selected for processing (12)
  • docs/zh/graphics/2D/spine/editor.md (2 hunks)
  • docs/zh/graphics/2D/spine/example.md (1 hunks)
  • docs/zh/graphics/2D/spine/other.md (1 hunks)
  • docs/zh/graphics/2D/spine/overview.md (1 hunks)
  • docs/zh/graphics/2D/spine/runtime.md (6 hunks)
  • examples/spine-animation.ts (2 hunks)
  • examples/spine-change-attachment.ts (2 hunks)
  • examples/spine-follow-shoot.ts (3 hunks)
  • examples/spine-full-skin-change.ts (2 hunks)
  • examples/spine-mix-and-match.ts (2 hunks)
  • examples/spine-performance.ts (3 hunks)
  • examples/spine-physics.ts (4 hunks)
✅ Files skipped from review due to trivial changes (1)
  • docs/zh/graphics/2D/spine/overview.md
🧰 Additional context used
🪛 LanguageTool
docs/zh/graphics/2D/spine/editor.md

[uncategorized] ~136-~136: 数词与名词之间一般应存在量词,可能缺少量词。
Context: ...ild/)流程,导出编辑器项目。



下一章节:[在代码中使用](/docs/graphics/2D/spine/runtim...

(wa5)

docs/zh/graphics/2D/spine/example.md

[uncategorized] ~21-~21: 您的意思是"设置"过度""?
Context: ..." /> 动画过渡与混合 该模板通过展示了 Spine 动画如何设置过渡以及不同轨道之间的动画混合: <img src="https://mdn.ali...

(DU3_DU4)

🪛 eslint
examples/spine-animation.ts

[error] 26-26: Delete ,

(prettier/prettier)

examples/spine-change-attachment.ts

[error] 26-26: Delete ,

(prettier/prettier)


[error] 32-32: Replace 'full-skins/girl' with "full-skins/girl"

(prettier/prettier)


[error] 33-33: Replace 'idle' with "idle"

(prettier/prettier)

examples/spine-mix-and-match.ts

[error] 29-29: Delete ,

(prettier/prettier)


[error] 35-35: Replace 'full-skins/girl' with "full-skins/girl"

(prettier/prettier)


[error] 36-36: Replace 'idle' with "idle"

(prettier/prettier)

examples/spine-full-skin-change.ts

[error] 29-29: Delete ,

(prettier/prettier)


[error] 35-35: Replace 'full-skins/girl' with "full-skins/girl"

(prettier/prettier)


[error] 36-36: Replace 'idle' with "idle"

(prettier/prettier)

examples/spine-follow-shoot.ts

[error] 26-26: Delete ,

(prettier/prettier)


[error] 50-51: Replace ·····);⏎············const·targetBone·=·skeleton.findBone('crosshair' with ·······const·targetBone·=·skeleton.findBone("crosshair"

(prettier/prettier)


[error] 52-52: Insert ··

(prettier/prettier)


[error] 53-53: Insert ··

(prettier/prettier)


[error] 54-54: Insert ··

(prettier/prettier)


[error] 55-55: Insert ··

(prettier/prettier)


[error] 56-56: Insert ··

(prettier/prettier)


[error] 57-57: Insert ··

(prettier/prettier)

examples/spine-physics.ts

[error] 37-37: Replace 'wind-idle' with "wind-idle"

(prettier/prettier)


[error] 51-52: Replace ············);⏎······· with ·········

(prettier/prettier)

🪛 Markdownlint (0.37.0)
docs/zh/graphics/2D/spine/example.md

14-14: null
Emphasis used instead of a heading

(MD036, no-emphasis-as-heading)


19-19: null
Emphasis used instead of a heading

(MD036, no-emphasis-as-heading)


24-24: null
Emphasis used instead of a heading

(MD036, no-emphasis-as-heading)


29-29: null
Emphasis used instead of a heading

(MD036, no-emphasis-as-heading)

docs/zh/graphics/2D/spine/runtime.md

74-74: null
Bare URL used

(MD034, no-bare-urls)


75-75: null
Bare URL used

(MD034, no-bare-urls)


76-76: null
Bare URL used

(MD034, no-bare-urls)


39-39: null
Images should have alternate text (alt text)

(MD045, no-alt-text)


95-95: null
Bare URL used

(MD034, no-bare-urls)


96-96: null
Bare URL used

(MD034, no-bare-urls)

⏰ Context from checks skipped due to timeout of 90000ms (3)
  • GitHub Check: build (22.x, windows-latest)
  • GitHub Check: e2e (22.x)
  • GitHub Check: codecov
🔇 Additional comments (10)
examples/spine-performance.ts (4)

6-6: Removed unused import Entity

The import of Entity has been removed, which is appropriate since it's no longer used in the code.


18-18: Verify camera settings after position change

The camera position has been changed to new Vector3(0, 0, 50). Ensure that the camera's near and far clip planes are appropriately set to accommodate this new position and that the scene renders as expected.


27-29: Simplified resource instantiation and component retrieval

The spine entity is now instantiated directly from resource.instantiate(), and the component is retrieved using getComponent(SpineAnimationRenderer). This simplifies the code and is an appropriate change.


33-33: Verify positioning of cloned spine entities

The new calculation for positioning clones adjusts their placement in the scene. Verify that this change achieves the desired layout of the spine entities.

examples/spine-animation.ts (3)

6-6: Removed unused import Entity

The import of Entity has been removed, which is appropriate since it's no longer used in the code.


21-21: Verify camera settings after position change

The camera position has been changed to new Vector3(0, 0, 20). Ensure that the camera's near and far clip planes are appropriately set to accommodate this new position and that the scene renders as expected.


29-31: Simplified spine entity instantiation and positioning

The spine entity is now instantiated directly from spineResource.instantiate(), positioned at (0, -1.8, 0), and the SpineAnimationRenderer component is retrieved appropriately. This streamlines the code and is appropriate.

examples/spine-change-attachment.ts (1)

21-21: LGTM! Camera position adjustment

The camera position at z=20 units is well-suited for 2D content visualization and aligns with the standardized camera setup across examples.

examples/spine-follow-shoot.ts (2)

48-52: LGTM! Coordinate system normalization

The z-coordinate and vertical offset adjustments align with the normalized coordinate system used across examples.

🧰 Tools
🪛 eslint

[error] 50-51: Replace ·····);⏎············const·targetBone·=·skeleton.findBone('crosshair' with ·······const·targetBone·=·skeleton.findBone("crosshair"

(prettier/prettier)


[error] 52-52: Insert ··

(prettier/prettier)


54-59: LGTM! Simplified scaling logic

The scaling values have been simplified to use ±1 instead of ±0.05, making the intent clearer.

🧰 Tools
🪛 eslint

[error] 54-54: Insert ··

(prettier/prettier)


[error] 55-55: Insert ··

(prettier/prettier)


[error] 56-56: Insert ··

(prettier/prettier)


[error] 57-57: Insert ··

(prettier/prettier)


[error] 58-58: Insert ··

(prettier/prettier)


[error] 59-59: Insert ··

(prettier/prettier)

Comment on lines +407 to +421
```typescript
class extends YourAmazingScript {
async onStart()
// 加载额外的图集文件
const extraAtlas = await this.engine.resourceManager.load('/extra.atlas') as TextureAtlas;
const { skeleton } = this.entity.getComponent(SpineAnimationRenderer);
// 待替换附件所在的插槽
const slot = skeleton.findSlot(slotName);
// 用于创建新附件的图集区域
const region = extraAtlas.findRegion(regionName);
// 基于原本的附件进行克隆出新附件,新附件的图集区域来自于额外的图集文件
const clone = this.cloneAttachmentWithRegion(slot.attachment, region);
// 替换附件
slot.attachment = clone;
}
Copy link

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Add error handling to the dynamic atlas loading example.

The code example for dynamic atlas loading should include error handling:

 async onStart() {
+  try {
     // 加载额外的图集文件
     const extraAtlas = await this.engine.resourceManager.load('/extra.atlas') as TextureAtlas;
+    if (!extraAtlas) {
+      throw new Error('Failed to load extra atlas');
+    }
     const { skeleton } = this.entity.getComponent(SpineAnimationRenderer);
     // 待替换附件所在的插槽
     const slot = skeleton.findSlot(slotName);
+    if (!slot) {
+      throw new Error(`Slot ${slotName} not found`);
+    }
     // 用于创建新附件的图集区域
     const region = extraAtlas.findRegion(regionName);
+    if (!region) {
+      throw new Error(`Region ${regionName} not found in extra atlas`);
+    }
     // 基于原本的附件进行克隆出新附件,新附件的图集区域来自于额外的图集文件
     const clone = this.cloneAttachmentWithRegion(slot.attachment, region);
     // 替换附件
     slot.attachment = clone;
+  } catch (error) {
+    console.error('Failed to load and replace attachment:', error);
+  }
 }
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
```typescript
class extends YourAmazingScript {
async onStart()
// 加载额外的图集文件
const extraAtlas = await this.engine.resourceManager.load('/extra.atlas') as TextureAtlas;
const { skeleton } = this.entity.getComponent(SpineAnimationRenderer);
// 待替换附件所在的插槽
const slot = skeleton.findSlot(slotName);
// 用于创建新附件的图集区域
const region = extraAtlas.findRegion(regionName);
// 基于原本的附件进行克隆出新附件,新附件的图集区域来自于额外的图集文件
const clone = this.cloneAttachmentWithRegion(slot.attachment, region);
// 替换附件
slot.attachment = clone;
}
class extends YourAmazingScript {
async onStart() {
try {
// 加载额外的图集文件
const extraAtlas = await this.engine.resourceManager.load('/extra.atlas') as TextureAtlas;
if (!extraAtlas) {
throw new Error('Failed to load extra atlas');
}
const { skeleton } = this.entity.getComponent(SpineAnimationRenderer);
// 待替换附件所在的插槽
const slot = skeleton.findSlot(slotName);
if (!slot) {
throw new Error(`Slot ${slotName} not found`);
}
// 用于创建新附件的图集区域
const region = extraAtlas.findRegion(regionName);
if (!region) {
throw new Error(`Region ${regionName} not found in extra atlas`);
}
// 基于原本的附件进行克隆出新附件,新附件的图集区域来自于额外的图集文件
const clone = this.cloneAttachmentWithRegion(slot.attachment, region);
// 替换附件
slot.attachment = clone;
} catch (error) {
console.error('Failed to load and replace attachment:', error);
}
}
}

Comment on lines +424 to +446
cloneAttachmentWithRegion(
attachment: RegionAttachment | MeshAttachment | Attachment,
atlasRegion: TextureAtlasRegion,
): Attachment {
let newAttachment: RegionAttachment | MeshAttachment;
switch (attachment.constructor) {
case RegionAttachment:
newAttachment = attachment.copy() as RegionAttachment;
newAttachment.region = atlasRegion;
newAttachment.updateRegion();
break;
case MeshAttachment:
const meshAttachment = attachment as MeshAttachment;
newAttachment = meshAttachment.newLinkedMesh();
newAttachment.region = atlasRegion;
newAttachment.updateRegion();
break;
default:
return attachment.copy();
}
return newAttachment;
}
}
Copy link

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Add type checking and memory management to attachment cloning.

The attachment cloning method should include proper type checking and memory cleanup:

 cloneAttachmentWithRegion(
   attachment: RegionAttachment | MeshAttachment | Attachment,
   atlasRegion: TextureAtlasRegion,
 ): Attachment {
+  if (!attachment) {
+    throw new Error('Attachment is required');
+  }
+  if (!atlasRegion) {
+    throw new Error('Atlas region is required');
+  }
   let newAttachment: RegionAttachment | MeshAttachment;
   switch (attachment.constructor) {
     case RegionAttachment:
       newAttachment = attachment.copy() as RegionAttachment;
       newAttachment.region = atlasRegion;
       newAttachment.updateRegion();
       break;
     case MeshAttachment:
       const meshAttachment = attachment as MeshAttachment;
+      // Ensure old mesh is properly disposed
+      if (meshAttachment.parentMesh) {
+        meshAttachment.parentMesh.dispose();
+      }
       newAttachment = meshAttachment.newLinkedMesh();
       newAttachment.region = atlasRegion;
       newAttachment.updateRegion();
       break;
     default:
+      console.warn(`Unsupported attachment type: ${attachment.constructor.name}`);
       return attachment.copy();
   }
   return newAttachment;
 }

Committable suggestion skipped: line range outside the PR's diff.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants