|
@@ -1875,13 +1875,15 @@ THREE.GLTFLoader = ( function () {
|
|
|
// The buffer is not interleaved if the stride is the item size in bytes.
|
|
|
if ( byteStride && byteStride !== itemBytes ) {
|
|
|
|
|
|
- var ibCacheKey = 'InterleavedBuffer:' + accessorDef.bufferView + ':' + accessorDef.componentType;
|
|
|
+ // Each "slice" of the buffer, as defined by 'count' elements of 'byteStride' bytes, gets its own InterleavedBuffer
|
|
|
+ // This makes sure that IBA.count reflects accessor.count properly
|
|
|
+ var ibSlice = Math.floor( byteOffset / byteStride );
|
|
|
+ var ibCacheKey = 'InterleavedBuffer:' + accessorDef.bufferView + ':' + accessorDef.componentType + ':' + ibSlice + ':' + accessorDef.count;
|
|
|
var ib = parser.cache.get( ibCacheKey );
|
|
|
|
|
|
if ( ! ib ) {
|
|
|
|
|
|
- // Use the full buffer if it's interleaved.
|
|
|
- array = new TypedArray( bufferView );
|
|
|
+ array = new TypedArray( bufferView, ibSlice * byteStride, accessorDef.count * byteStride / elementBytes );
|
|
|
|
|
|
// Integer parameters to IB/IBA are in array elements, not bytes.
|
|
|
ib = new THREE.InterleavedBuffer( array, byteStride / elementBytes );
|
|
@@ -1890,7 +1892,7 @@ THREE.GLTFLoader = ( function () {
|
|
|
|
|
|
}
|
|
|
|
|
|
- bufferAttribute = new THREE.InterleavedBufferAttribute( ib, itemSize, byteOffset / elementBytes, normalized );
|
|
|
+ bufferAttribute = new THREE.InterleavedBufferAttribute( ib, itemSize, (byteOffset % byteStride) / elementBytes, normalized );
|
|
|
|
|
|
} else {
|
|
|
|