Skip to content

fix: skip unsupported mesh attributes instead of throwing#80

Open
nixoletas wants to merge 1 commit intomagicien:masterfrom
nixoletas:fix/skip-unsupported-mesh-attributes
Open

fix: skip unsupported mesh attributes instead of throwing#80
nixoletas wants to merge 1 commit intomagicien:masterfrom
nixoletas:fix/skip-unsupported-mesh-attributes

Conversation

@nixoletas
Copy link

Summary

  • Skip unsupported mesh attributes (e.g. TEXCOORD_4+, custom attributes) gracefully instead of throwing GLTFUnarchiveError.NotSupported
  • Fixes the "unable to load renderable" error when loading standard glTF 2.0 GLB files that include attributes beyond what SceneKit supports

Problem

GLB files exported from tools like Sketchfab may include more than 4 texture coordinate sets (TEXCOORD_0 through TEXCOORD_4). The attributeMap in GLTFTypes.swift only maps up to TEXCOORD_3, so when loadAttributes() encounters TEXCOORD_4, it throws:

GLTFUnarchiveError.NotSupported("loadMesh: user defined semantic is not supported: TEXCOORD_4")

Since SceneKit only uses 2 UV sets anyway, these extra attributes can be safely ignored.

Fix

Changed loadAttributes() in GLTFUnarchiver.swift to continue (with a debug print) instead of throw when encountering unmapped attributes. This matches how other glTF loaders handle unsupported attributes — they skip gracefully rather than failing the entire mesh.

Also fixed the same pattern in the commented-out legacy code block for consistency.

Test plan

  • Tested with GLB files from Sketchfab containing TEXCOORD_4 attribute
  • Models load correctly on iOS with SceneKit after this fix
  • No visual difference since SceneKit ignores the extra UV sets anyway

🤖 Generated with Claude Code

GLB files exported from tools like Sketchfab may contain more than 4
texture coordinate sets (e.g. TEXCOORD_4). Since SceneKit only supports
a limited set of vertex attribute semantics, these extra attributes
should be gracefully skipped rather than causing the entire mesh load
to fail with a NotSupported error.

This fixes the "unable to load renderable" error when loading standard
glTF 2.0 files that happen to include attributes not mapped in
attributeMap (such as TEXCOORD_4+, custom attributes, etc.).

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
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