浏览代码

BufferGeometryUtils: show error if number of attributes is inconsistent.

Marquizzo 5 年之前
父节点
当前提交
802f1cad6e
共有 2 个文件被更改,包括 24 次插入0 次删除
  1. 12 0
      examples/js/utils/BufferGeometryUtils.js
  2. 12 0
      examples/jsm/utils/BufferGeometryUtils.js

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

@@ -194,6 +194,7 @@ THREE.BufferGeometryUtils = {
 		for ( var i = 0; i < geometries.length; ++ i ) {
 		for ( var i = 0; i < geometries.length; ++ i ) {
 
 
 			var geometry = geometries[ i ];
 			var geometry = geometries[ i ];
+			var attributesCount = 0;
 
 
 			// ensure that all geometries are indexed, or none
 			// ensure that all geometries are indexed, or none
 
 
@@ -219,6 +220,17 @@ THREE.BufferGeometryUtils = {
 
 
 				attributes[ name ].push( geometry.attributes[ name ] );
 				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
 			// 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 ) {
 		for ( var i = 0; i < geometries.length; ++ i ) {
 
 
 			var geometry = geometries[ i ];
 			var geometry = geometries[ i ];
+			var attributesCount = 0;
 
 
 			// ensure that all geometries are indexed, or none
 			// ensure that all geometries are indexed, or none
 
 
@@ -230,6 +231,17 @@ var BufferGeometryUtils = {
 
 
 				attributes[ name ].push( geometry.attributes[ name ] );
 				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
 			// gather morph attributes, exit early if they're different