Sfoglia il codice sorgente

GLTFLoader: Use .byteOffset and .count in sparse accessors.

Don McCurdy 7 anni fa
parent
commit
d890437b43
1 ha cambiato i file con 7 aggiunte e 3 eliminazioni
  1. 7 3
      examples/js/loaders/GLTFLoader.js

+ 7 - 3
examples/js/loaders/GLTFLoader.js

@@ -1545,10 +1545,14 @@ THREE.GLTFLoader = ( function () {
 				// https://github.com/KhronosGroup/glTF/blob/master/specification/2.0/README.md#sparse-accessors
 				if ( accessor.sparse !== undefined ) {
 
-					var TypedIndicesArray = WEBGL_COMPONENT_TYPES[ accessor.sparse.indices.componentType ];
+					var itemSizeIndices = WEBGL_TYPE_SIZES.SCALAR;
+					var TypedArrayIndices = WEBGL_COMPONENT_TYPES[ accessor.sparse.indices.componentType ];
 
-					var sparseIndices = new TypedIndicesArray( bufferViews[ 1 ] );
-					var sparseValues = new TypedArray( bufferViews[ 2 ] );
+					var byteOffsetIndices = accessor.sparse.indices.byteOffset || 0;
+					var byteOffsetValues = accessor.sparse.values.byteOffset || 0;
+
+					var sparseIndices = new TypedArrayIndices( bufferViews[ 1 ], byteOffsetIndices, accessor.sparse.count * itemSizeIndices );
+					var sparseValues = new TypedArray( bufferViews[ 2 ], byteOffsetValues, accessor.sparse.count * itemSize );
 
 					if ( bufferView !== null ) {