未验证 提交 bc8720f6 编写于 作者: M Mr.doob 提交者: GitHub

Merge pull request #16989 from zeux/gltf-fixibcache

GLTFLoader: Fix incorrect accessor count caching
......@@ -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 {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册