浏览代码

BufferGeometryUtils: Simplify function names (#25652)

* Simplify function names

* Simplify function names

* Update BufferGeometryUtils.js

* Update BufferGeometryUtils.js

---------

Co-authored-by: Michael Herzog <[email protected]>
WestLangley 2 年之前
父节点
当前提交
ee9a686374

+ 2 - 2
docs/examples/en/utils/BufferGeometryUtils.html

@@ -84,7 +84,7 @@
 
 
 		</p>
 		</p>
 
 
-		<h3>[method:BufferAttribute mergeBufferAttributes]( [param:Array attributes] )</h3>
+		<h3>[method:BufferAttribute mergeAttributes]( [param:Array attributes] )</h3>
 		<p>
 		<p>
 		attributes -- Array of [page:BufferAttribute BufferAttribute] instances.<br /><br />
 		attributes -- Array of [page:BufferAttribute BufferAttribute] instances.<br /><br />
 
 
@@ -94,7 +94,7 @@
 
 
 		</p>
 		</p>
 
 
-		<h3>[method:BufferGeometry mergeBufferGeometries]( [param:Array geometries], [param:Boolean useGroups] )</h3>
+		<h3>[method:BufferGeometry mergeGeometries]( [param:Array geometries], [param:Boolean useGroups] )</h3>
 		<p>
 		<p>
 		geometries -- Array of [page:BufferGeometry BufferGeometry] instances.<br />
 		geometries -- Array of [page:BufferGeometry BufferGeometry] instances.<br />
 		useGroups -- Whether groups should be generated for the merged geometry or not.<br /><br />
 		useGroups -- Whether groups should be generated for the merged geometry or not.<br /><br />

+ 2 - 2
docs/examples/zh/utils/BufferGeometryUtils.html

@@ -84,7 +84,7 @@
 
 
 		</p>
 		</p>
 
 
-		<h3>[method:BufferAttribute mergeBufferAttributes]( [param:Array attributes] )</h3>
+		<h3>[method:BufferAttribute mergeAttributes]( [param:Array attributes] )</h3>
 		<p>
 		<p>
 		attributes -- 由 [page:BufferAttribute BufferAttribute] 实例组成的数组。<br /><br />
 		attributes -- 由 [page:BufferAttribute BufferAttribute] 实例组成的数组。<br /><br />
 
 
@@ -93,7 +93,7 @@
 
 
 		</p>
 		</p>
 
 
-		<h3>[method:BufferGeometry mergeBufferGeometries]( [param:Array geometries], [param:Boolean useGroups] )</h3>
+		<h3>[method:BufferGeometry mergeGeometries]( [param:Array geometries], [param:Boolean useGroups] )</h3>
 		<p>
 		<p>
 		geometries -- 由 [page:BufferGeometry BufferGeometry] 实例的数组。<br />
 		geometries -- 由 [page:BufferGeometry BufferGeometry] 实例的数组。<br />
 		useGroups -- 是否要为了合并几何体而产生组。<br /><br />
 		useGroups -- 是否要为了合并几何体而产生组。<br /><br />

+ 32 - 16
examples/jsm/utils/BufferGeometryUtils.js

@@ -104,7 +104,7 @@ function computeMikkTSpaceTangents( geometry, MikkTSpace, negateSign = true ) {
  * @param  {Boolean} useGroups
  * @param  {Boolean} useGroups
  * @return {BufferGeometry}
  * @return {BufferGeometry}
  */
  */
-function mergeBufferGeometries( geometries, useGroups = false ) {
+function mergeGeometries( geometries, useGroups = false ) {
 
 
 	const isIndexed = geometries[ 0 ].index !== null;
 	const isIndexed = geometries[ 0 ].index !== null;
 
 
@@ -129,7 +129,7 @@ function mergeBufferGeometries( geometries, useGroups = false ) {
 
 
 		if ( isIndexed !== ( geometry.index !== null ) ) {
 		if ( isIndexed !== ( geometry.index !== null ) ) {
 
 
-			console.error( 'THREE.BufferGeometryUtils: .mergeBufferGeometries() failed with geometry at index ' + i + '. All geometries must have compatible attributes; make sure index attribute exists among all geometries, or in none of them.' );
+			console.error( 'THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index ' + i + '. All geometries must have compatible attributes; make sure index attribute exists among all geometries, or in none of them.' );
 			return null;
 			return null;
 
 
 		}
 		}
@@ -140,7 +140,7 @@ function mergeBufferGeometries( geometries, useGroups = false ) {
 
 
 			if ( ! attributesUsed.has( name ) ) {
 			if ( ! attributesUsed.has( name ) ) {
 
 
-				console.error( 'THREE.BufferGeometryUtils: .mergeBufferGeometries() failed with geometry at index ' + i + '. All geometries must have compatible attributes; make sure "' + name + '" attribute exists among all geometries, or in none of them.' );
+				console.error( 'THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index ' + i + '. All geometries must have compatible attributes; make sure "' + name + '" attribute exists among all geometries, or in none of them.' );
 				return null;
 				return null;
 
 
 			}
 			}
@@ -157,7 +157,7 @@ function mergeBufferGeometries( geometries, useGroups = false ) {
 
 
 		if ( attributesCount !== attributesUsed.size ) {
 		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.' );
+			console.error( 'THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index ' + i + '. Make sure all geometries have the same number of attributes.' );
 			return null;
 			return null;
 
 
 		}
 		}
@@ -166,7 +166,7 @@ function mergeBufferGeometries( geometries, useGroups = false ) {
 
 
 		if ( morphTargetsRelative !== geometry.morphTargetsRelative ) {
 		if ( morphTargetsRelative !== geometry.morphTargetsRelative ) {
 
 
-			console.error( 'THREE.BufferGeometryUtils: .mergeBufferGeometries() failed with geometry at index ' + i + '. .morphTargetsRelative must be consistent throughout all geometries.' );
+			console.error( 'THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index ' + i + '. .morphTargetsRelative must be consistent throughout all geometries.' );
 			return null;
 			return null;
 
 
 		}
 		}
@@ -175,7 +175,7 @@ function mergeBufferGeometries( geometries, useGroups = false ) {
 
 
 			if ( ! morphAttributesUsed.has( name ) ) {
 			if ( ! morphAttributesUsed.has( name ) ) {
 
 
-				console.error( 'THREE.BufferGeometryUtils: .mergeBufferGeometries() failed with geometry at index ' + i + '.  .morphAttributes must be consistent throughout all geometries.' );
+				console.error( 'THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index ' + i + '.  .morphAttributes must be consistent throughout all geometries.' );
 				return null;
 				return null;
 
 
 			}
 			}
@@ -200,7 +200,7 @@ function mergeBufferGeometries( geometries, useGroups = false ) {
 
 
 			} else {
 			} else {
 
 
-				console.error( 'THREE.BufferGeometryUtils: .mergeBufferGeometries() failed with geometry at index ' + i + '. The geometry must have either an index or a position attribute' );
+				console.error( 'THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index ' + i + '. The geometry must have either an index or a position attribute' );
 				return null;
 				return null;
 
 
 			}
 			}
@@ -242,11 +242,11 @@ function mergeBufferGeometries( geometries, useGroups = false ) {
 
 
 	for ( const name in attributes ) {
 	for ( const name in attributes ) {
 
 
-		const mergedAttribute = mergeBufferAttributes( attributes[ name ] );
+		const mergedAttribute = mergeAttributes( attributes[ name ] );
 
 
 		if ( ! mergedAttribute ) {
 		if ( ! mergedAttribute ) {
 
 
-			console.error( 'THREE.BufferGeometryUtils: .mergeBufferGeometries() failed while trying to merge the ' + name + ' attribute.' );
+			console.error( 'THREE.BufferGeometryUtils: .mergeGeometries() failed while trying to merge the ' + name + ' attribute.' );
 			return null;
 			return null;
 
 
 		}
 		}
@@ -276,11 +276,11 @@ function mergeBufferGeometries( geometries, useGroups = false ) {
 
 
 			}
 			}
 
 
-			const mergedMorphAttribute = mergeBufferAttributes( morphAttributesToMerge );
+			const mergedMorphAttribute = mergeAttributes( morphAttributesToMerge );
 
 
 			if ( ! mergedMorphAttribute ) {
 			if ( ! mergedMorphAttribute ) {
 
 
-				console.error( 'THREE.BufferGeometryUtils: .mergeBufferGeometries() failed while trying to merge the ' + name + ' morphAttribute.' );
+				console.error( 'THREE.BufferGeometryUtils: .mergeGeometries() failed while trying to merge the ' + name + ' morphAttribute.' );
 				return null;
 				return null;
 
 
 			}
 			}
@@ -299,7 +299,7 @@ function mergeBufferGeometries( geometries, useGroups = false ) {
  * @param {Array<BufferAttribute>} attributes
  * @param {Array<BufferAttribute>} attributes
  * @return {BufferAttribute}
  * @return {BufferAttribute}
  */
  */
-function mergeBufferAttributes( attributes ) {
+function mergeAttributes( attributes ) {
 
 
 	let TypedArray;
 	let TypedArray;
 	let itemSize;
 	let itemSize;
@@ -312,7 +312,7 @@ function mergeBufferAttributes( attributes ) {
 
 
 		if ( attribute.isInterleavedBufferAttribute ) {
 		if ( attribute.isInterleavedBufferAttribute ) {
 
 
-			console.error( 'THREE.BufferGeometryUtils: .mergeBufferAttributes() failed. InterleavedBufferAttributes are not supported.' );
+			console.error( 'THREE.BufferGeometryUtils: .mergeAttributes() failed. InterleavedBufferAttributes are not supported.' );
 			return null;
 			return null;
 
 
 		}
 		}
@@ -320,7 +320,7 @@ function mergeBufferAttributes( attributes ) {
 		if ( TypedArray === undefined ) TypedArray = attribute.array.constructor;
 		if ( TypedArray === undefined ) TypedArray = attribute.array.constructor;
 		if ( TypedArray !== attribute.array.constructor ) {
 		if ( TypedArray !== attribute.array.constructor ) {
 
 
-			console.error( 'THREE.BufferGeometryUtils: .mergeBufferAttributes() failed. BufferAttribute.array must be of consistent array types across matching attributes.' );
+			console.error( 'THREE.BufferGeometryUtils: .mergeAttributes() failed. BufferAttribute.array must be of consistent array types across matching attributes.' );
 			return null;
 			return null;
 
 
 		}
 		}
@@ -328,7 +328,7 @@ function mergeBufferAttributes( attributes ) {
 		if ( itemSize === undefined ) itemSize = attribute.itemSize;
 		if ( itemSize === undefined ) itemSize = attribute.itemSize;
 		if ( itemSize !== attribute.itemSize ) {
 		if ( itemSize !== attribute.itemSize ) {
 
 
-			console.error( 'THREE.BufferGeometryUtils: .mergeBufferAttributes() failed. BufferAttribute.itemSize must be consistent across matching attributes.' );
+			console.error( 'THREE.BufferGeometryUtils: .mergeAttributes() failed. BufferAttribute.itemSize must be consistent across matching attributes.' );
 			return null;
 			return null;
 
 
 		}
 		}
@@ -336,7 +336,7 @@ function mergeBufferAttributes( attributes ) {
 		if ( normalized === undefined ) normalized = attribute.normalized;
 		if ( normalized === undefined ) normalized = attribute.normalized;
 		if ( normalized !== attribute.normalized ) {
 		if ( normalized !== attribute.normalized ) {
 
 
-			console.error( 'THREE.BufferGeometryUtils: .mergeBufferAttributes() failed. BufferAttribute.normalized must be consistent across matching attributes.' );
+			console.error( 'THREE.BufferGeometryUtils: .mergeAttributes() failed. BufferAttribute.normalized must be consistent across matching attributes.' );
 			return null;
 			return null;
 
 
 		}
 		}
@@ -1318,9 +1318,25 @@ function toCreasedNormals( geometry, creaseAngle = Math.PI / 3 /* 60 degrees */
 
 
 }
 }
 
 
+function mergeBufferGeometries( geometries, useGroups = false ) {
+
+	console.warn( 'THREE.BufferGeometryUtils: mergeBufferGeometries() has been renamed to mergeGeometries().' ); // @deprecated, r151
+	return mergeGeometries( geometries, useGroups );
+
+}
+
+function mergeBufferAttributes( attributes ) {
+
+	console.warn( 'THREE.BufferGeometryUtils: mergeBufferAttributes() has been renamed to mergeAttributes().' ); // @deprecated, r151
+	return mergeAttributes( attributes );
+
+}
+
 export {
 export {
 	computeMikkTSpaceTangents,
 	computeMikkTSpaceTangents,
+	mergeGeometries,
 	mergeBufferGeometries,
 	mergeBufferGeometries,
+	mergeAttributes,
 	mergeBufferAttributes,
 	mergeBufferAttributes,
 	interleaveAttributes,
 	interleaveAttributes,
 	estimateBytesUsed,
 	estimateBytesUsed,