浏览代码

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 );
 		var shiftMultiplier = Math.pow( 10, decimalShift );
 		for ( var i = 0; i < vertexCount; i ++ ) {
 		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'
 			// Generate a hash for the vertex attributes at the current index 'i'
 			var hash = '';
 			var hash = '';
 			for ( var j = 0, l = attributeNames.length; j < l; j ++ ) {
 			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 ++ ) {
 				for ( var k = 0; k < itemSize; k ++ ) {
 
 
 					// double tilde truncates the decimal value
 					// 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 ];
 					var newarray = attrArrays[ name ];
 					for ( var k = 0; k < itemSize; k ++ ) {
 					for ( var k = 0; k < itemSize; k ++ ) {
 
 
-						newarray.push( attribute[ getters[ k ] ]( i ) );
+						newarray.push( attribute[ getters[ k ] ]( index ) );
 
 
 					}
 					}