Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BufferGeometryUtils: Simplify function names #25652

Merged
merged 4 commits into from
Mar 11, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions docs/examples/en/utils/BufferGeometryUtils.html
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ <h3>[method:InterleavedBufferAttribute interleaveAttributes]( [param:Array attri

</p>

<h3>[method:BufferAttribute mergeBufferAttributes]( [param:Array attributes] )</h3>
<h3>[method:BufferAttribute mergeAttributes]( [param:Array attributes] )</h3>
<p>
attributes -- Array of [page:BufferAttribute BufferAttribute] instances.<br /><br />

Expand All @@ -94,7 +94,7 @@ <h3>[method:BufferAttribute mergeBufferAttributes]( [param:Array attributes] )</

</p>

<h3>[method:BufferGeometry mergeBufferGeometries]( [param:Array geometries], [param:Boolean useGroups] )</h3>
<h3>[method:BufferGeometry mergeGeometries]( [param:Array geometries], [param:Boolean useGroups] )</h3>
<p>
geometries -- Array of [page:BufferGeometry BufferGeometry] instances.<br />
useGroups -- Whether groups should be generated for the merged geometry or not.<br /><br />
Expand Down
4 changes: 2 additions & 2 deletions docs/examples/zh/utils/BufferGeometryUtils.html
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ <h3>[method:InterleavedBufferAttribute interleaveAttributes]( [param:Array attri

</p>

<h3>[method:BufferAttribute mergeBufferAttributes]( [param:Array attributes] )</h3>
<h3>[method:BufferAttribute mergeAttributes]( [param:Array attributes] )</h3>
<p>
attributes -- 由 [page:BufferAttribute BufferAttribute] 实例组成的数组。<br /><br />

Expand All @@ -93,7 +93,7 @@ <h3>[method:BufferAttribute mergeBufferAttributes]( [param:Array attributes] )</

</p>

<h3>[method:BufferGeometry mergeBufferGeometries]( [param:Array geometries], [param:Boolean useGroups] )</h3>
<h3>[method:BufferGeometry mergeGeometries]( [param:Array geometries], [param:Boolean useGroups] )</h3>
<p>
geometries -- 由 [page:BufferGeometry BufferGeometry] 实例的数组。<br />
useGroups -- 是否要为了合并几何体而产生组。<br /><br />
Expand Down
48 changes: 32 additions & 16 deletions examples/jsm/utils/BufferGeometryUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ function computeMikkTSpaceTangents( geometry, MikkTSpace, negateSign = true ) {
* @param {Boolean} useGroups
* @return {BufferGeometry}
*/
function mergeBufferGeometries( geometries, useGroups = false ) {
function mergeGeometries( geometries, useGroups = false ) {

const isIndexed = geometries[ 0 ].index !== null;

Expand All @@ -129,7 +129,7 @@ function mergeBufferGeometries( geometries, useGroups = false ) {

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;

}
Expand All @@ -140,7 +140,7 @@ function mergeBufferGeometries( geometries, useGroups = false ) {

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;

}
Expand All @@ -157,7 +157,7 @@ function mergeBufferGeometries( geometries, useGroups = false ) {

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;

}
Expand All @@ -166,7 +166,7 @@ function mergeBufferGeometries( geometries, useGroups = false ) {

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;

}
Expand All @@ -175,7 +175,7 @@ function mergeBufferGeometries( geometries, useGroups = false ) {

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;

}
Expand All @@ -200,7 +200,7 @@ function mergeBufferGeometries( geometries, useGroups = false ) {

} 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;

}
Expand Down Expand Up @@ -242,11 +242,11 @@ function mergeBufferGeometries( geometries, useGroups = false ) {

for ( const name in attributes ) {

const mergedAttribute = mergeBufferAttributes( attributes[ name ] );
const mergedAttribute = mergeAttributes( attributes[ name ] );

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;

}
Expand Down Expand Up @@ -276,11 +276,11 @@ function mergeBufferGeometries( geometries, useGroups = false ) {

}

const mergedMorphAttribute = mergeBufferAttributes( morphAttributesToMerge );
const mergedMorphAttribute = mergeAttributes( morphAttributesToMerge );

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;

}
Expand All @@ -299,7 +299,7 @@ function mergeBufferGeometries( geometries, useGroups = false ) {
* @param {Array<BufferAttribute>} attributes
* @return {BufferAttribute}
*/
function mergeBufferAttributes( attributes ) {
function mergeAttributes( attributes ) {

let TypedArray;
let itemSize;
Expand All @@ -312,31 +312,31 @@ function mergeBufferAttributes( attributes ) {

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;

}

if ( TypedArray === undefined ) 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;

}

if ( itemSize === undefined ) 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;

}

if ( normalized === undefined ) 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;

}
Expand Down Expand Up @@ -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 {
computeMikkTSpaceTangents,
mergeGeometries,
mergeBufferGeometries,
mergeAttributes,
mergeBufferAttributes,
interleaveAttributes,
estimateBytesUsed,
Expand Down