Summary
The glTF importer corrupts meshes whose vertex attributes use an interleaved buffer view. Imported geometry appears as exploded or stretched triangles, and UVs are also scrambled.
@mr0x13f
Steps to reproduce
- Import a valid glTF 2.0 asset where
POSITION, NORMAL, and TEXCOORD_0 share one buffer view with byteStride: 32.
- The bundled
GLTFLoader creates THREE.InterleavedBufferAttribute instances for these attributes.
- Complete the import into a Blockbench generic model.
Expected behavior
The editable Blockbench mesh matches the glTF geometry and UVs.
Actual behavior
Most vertices are read from normal/UV slots instead of position slots, producing long spikes and scrambled faces.
Root cause
importMeshPrimitives() reads attribute storage as tightly packed arrays:
position.array[vertexIndex * 3]
uv.array[vertexIndex * 2]
For an InterleavedBufferAttribute, .array is the shared interleaved storage and these offsets ignore both the attribute offset and buffer stride. The loader already exposes stride-safe getX(), getY(), and getZ() methods.
Index access should also use geometry.getIndex().getX() for consistency across BufferAttribute implementations.
Proposed fix
Read position, UV, and index components through the BufferAttribute getter API rather than indexing .array directly. This supports both tightly packed and interleaved glTF buffers.
I have a focused fix and regression coverage ready for a pull request.
Summary
The glTF importer corrupts meshes whose vertex attributes use an interleaved buffer view. Imported geometry appears as exploded or stretched triangles, and UVs are also scrambled.
@mr0x13f
Steps to reproduce
POSITION,NORMAL, andTEXCOORD_0share one buffer view withbyteStride: 32.GLTFLoadercreatesTHREE.InterleavedBufferAttributeinstances for these attributes.Expected behavior
The editable Blockbench mesh matches the glTF geometry and UVs.
Actual behavior
Most vertices are read from normal/UV slots instead of position slots, producing long spikes and scrambled faces.
Root cause
importMeshPrimitives()reads attribute storage as tightly packed arrays:For an
InterleavedBufferAttribute,.arrayis the shared interleaved storage and these offsets ignore both the attribute offset and buffer stride. The loader already exposes stride-safegetX(),getY(), andgetZ()methods.Index access should also use
geometry.getIndex().getX()for consistency across BufferAttribute implementations.Proposed fix
Read position, UV, and index components through the BufferAttribute getter API rather than indexing
.arraydirectly. This supports both tightly packed and interleaved glTF buffers.I have a focused fix and regression coverage ready for a pull request.