소스 검색

Make mergeVertices work if an index array already exists

Garrett Johnson 7 년 전
부모
커밋
ee7c54ac30
1개의 변경된 파일4개의 추가작업 그리고 2개의 파일을 삭제
  1. 4 2
      src/core/BufferGeometry.js

+ 4 - 2
src/core/BufferGeometry.js

@@ -940,6 +940,8 @@ BufferGeometry.prototype = Object.assign( Object.create( EventDispatcher.prototy
 		var shiftMultiplier = Math.pow( 10, decimalShift );
 		for ( var i = 0; i < vertexCount; i ++ ) {
 
+			var index = indices ? indices.getX( i ) : i;
+
 			// Generate a hash for the vertex attributes at the current index 'i'
 			var hash = '';
 			for ( var j = 0, l = attributeNames.length; j < l; j ++ ) {
@@ -951,7 +953,7 @@ BufferGeometry.prototype = Object.assign( Object.create( EventDispatcher.prototy
 				for ( var k = 0; k < itemSize; k ++ ) {
 
 					// double tilde truncates the decimal value
-					hash += `${ ~ ~ ( attribute[ getters[ k ] ]( i ) * shiftMultiplier ) },`;
+					hash += `${ ~ ~ ( attribute[ getters[ k ] ]( index ) * shiftMultiplier ) },`;
 
 				}
 
@@ -976,7 +978,7 @@ BufferGeometry.prototype = Object.assign( Object.create( EventDispatcher.prototy
 					var newarray = attrArrays[ name ];
 					for ( var k = 0; k < itemSize; k ++ ) {
 
-						newarray.push( attribute[ getters[ k ] ]( i ) );
+						newarray.push( attribute[ getters[ k ] ]( index ) );
 
 					}