Skip to content

Conversation

@querielo
Copy link
Contributor

@querielo querielo commented Dec 22, 2025

This PR fixes an issue in GLTFExporter where skinIndex (JOINTS_0) attributes were being exported incorrectly if they were stored as an InterleavedBufferAttribute.

The issue can cause this exception:

Screenshot 2025-12-22 at 15 11 07

When skinIndex data needed to be converted to UNSIGNED_SHORT (e.g. if the source was Uint32Array), the exporter was creating a new Uint16Array directly from the underlying attribute.array.

For InterleavedBufferAttribute, attribute.array refers to the entire shared buffer containing data for multiple attributes. This resulted in the exported skinIndex accessor containing mixed data from other interleaved attributes, ignoring the stride and offset.

Copilot AI review requested due to automatic review settings December 22, 2025 13:48
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR fixes a bug in GLTFExporter where skinIndex (JOINTS_0) attributes stored as InterleavedBufferAttribute were being exported incorrectly. The fix ensures that type conversion from Uint32Array/Int32Array to Uint16Array properly handles interleaved data by using element-by-element copying instead of direct array copying.

Key Changes:

  • Modified the JOINTS_0 type conversion logic to use getComponent/setComponent for element-by-element copying
  • Ensures correct handling of InterleavedBufferAttribute by respecting offset and stride during conversion

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copy link
Collaborator

@donmccurdy donmccurdy left a comment

Choose a reason for hiding this comment

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

One minor comment suggested, otherwise this fix looks good to me -- thanks @querielo!


}

}
Copy link
Collaborator

Choose a reason for hiding this comment

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

To match the 'else if' block below, do you mind moving this loop to a new utility function like GLTFExporter.Utils.toUint16BufferAttribute( attribute )? Or the existing utility function could be extended and renamed as:

modifiedAttribute = GLTFExporter.Utils.toTypedBufferAttribute( attribute, Uint16Array );

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.

2 participants