Sfoglia il codice sorgente

BufferGeometryUtils: show error if number of attributes is inconsistent.

Marquizzo 5 anni fa
parent
commit
802f1cad6e

+ 12 - 0
examples/js/utils/BufferGeometryUtils.js

@@ -194,6 +194,7 @@ THREE.BufferGeometryUtils = {
 		for ( var i = 0; i < geometries.length; ++ i ) {
 
 			var geometry = geometries[ i ];
+			var attributesCount = 0;
 
 			// ensure that all geometries are indexed, or none
 
@@ -219,6 +220,17 @@ THREE.BufferGeometryUtils = {
 
 				attributes[ name ].push( geometry.attributes[ name ] );
 
+				attributesCount ++;
+
+			}
+
+			// ensure geometries have the same number of attributes
+
+			if ( attributesCount !== attributesUsed.size ) {
+
+					console.error( 'THREE.BufferGeometryUtils: .mergeBufferGeometries() failed with geometry at index ' + i + '. Make sure all geometries have the same number of attributes.' );
+					return null;
+
 			}
 
 			// gather morph attributes, exit early if they're different

+ 12 - 0
examples/jsm/utils/BufferGeometryUtils.js

@@ -206,6 +206,7 @@ var BufferGeometryUtils = {
 		for ( var i = 0; i < geometries.length; ++ i ) {
 
 			var geometry = geometries[ i ];
+			var attributesCount = 0;
 
 			// ensure that all geometries are indexed, or none
 
@@ -230,6 +231,17 @@ var BufferGeometryUtils = {
 
 				attributes[ name ].push( geometry.attributes[ name ] );
 
+				attributesCount ++;
+
+			}
+
+			// ensure geometries have the same number of attributes
+
+			if ( attributesCount !== attributesUsed.size ) {
+
+					console.error( 'THREE.BufferGeometryUtils: .mergeBufferGeometries() failed with geometry at index ' + i + '. Make sure all geometries have the same number of attributes.' );
+					return null;
+
 			}
 
 			// gather morph attributes, exit early if they're different