diff --git a/examples/js/utils/BufferGeometryUtils.js b/examples/js/utils/BufferGeometryUtils.js index d4b96d033e73a8..da127a1c6ddb70 100644 --- a/examples/js/utils/BufferGeometryUtils.js +++ b/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 diff --git a/examples/jsm/utils/BufferGeometryUtils.js b/examples/jsm/utils/BufferGeometryUtils.js index 038dde2962e698..75867696907b16 100644 --- a/examples/jsm/utils/BufferGeometryUtils.js +++ b/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