# [name]

一个包含 [page:BufferGeometry BufferGeometry] 实例的实用方法的类。

## 进口

[name] 是一个附加组件，必须显式导入。 See [link:#manual/introduction/Installation Installation / Addons].

`import * as BufferGeometryUtils from 'three/addons/utils/BufferGeometryUtils.js';`

## 方法

### [method:Object computeMikkTSpaceTangents]( [param:BufferGeometry geometry], [param:Object MikkTSpace], [param:Boolean negateSign] = true )

- geometry -- Instance of [page:BufferGeometry].
- MikkTSpace -- Instance of examples/jsm/libs/mikktspace.module.js, or mikktspace npm package. Await MikkTSpace.ready before use.
- negateSign -- Whether to negate the sign component (.w) of each tangent. Required for normal map conventions in some formats, including glTF.

Computes vertex tangents using the [link:http://www.mikktspace.com/ MikkTSpace] algorithm. MikkTSpace generates the same tangents consistently, and is used in most modelling tools and normal map bakers. Use MikkTSpace for materials with normal maps, because inconsistent tangents may lead to subtle visual issues in the normal map, particularly around mirrored UV seams.

In comparison to this method, [page:BufferGeometry.computeTangents] (a custom algorithm) generates tangents that probably will not match the tangents in other software. The custom algorithm is sufficient for general use with a [page:ShaderMaterial], and may be faster than MikkTSpace.

Returns the original [page:BufferGeometry]. Indexed geometries will be de-indexed. Requires position, normal, and uv attributes.

### [method:Object computeMorphedAttributes]( [param:Mesh | Line | Points object] )

object -- Instance of [page:Mesh Mesh] | [page:Line Line] | [page:Points Points].
Returns the current attributes (Position and Normal) of a morphed/skinned [page:Object3D Object3D] whose geometry is a [page:BufferGeometry BufferGeometry], together with the original ones: An Object with 4 properties: `positionAttribute`, `normalAttribute`, `morphedPositionAttribute` and `morphedNormalAttribute`. Helpful for Raytracing or Decals (i.e. a [page:DecalGeometry DecalGeometry] applied to a morphed Object with a [page:BufferGeometry BufferGeometry] will use the original BufferGeometry, not the morphed/skinned one, generating an incorrect result. Using this function to create a shadow Object3D the DecalGeometry can be correctly generated).

### [method:Number estimateBytesUsed]( [param:BufferGeometry geometry] )

geometry -- 通过 [page:BufferGeometry BufferGeometry] 的实例来估计内存使用情况。
返回所有用于表示几何体的属性所占用的字节数。

### [method:InterleavedBufferAttribute interleaveAttributes]( [param:Array attributes] )

attributes -- 由 [page:BufferAttribute BufferAttribute] 实例组成的数组。
交叉存储一组属性并返回一个新的对应属性数组，这些属性共享一个 InterleavedBuffer 实例。所有属性都必须兼容的该类型。如果合并不成功，则该方法返回 null 。

### [method:BufferAttribute mergeAttributes]( [param:Array attributes] )

attributes -- 由 [page:BufferAttribute BufferAttribute] 实例组成的数组。
将一组属性合并为一个单一的实例。所有几何体都必须兼容该属性，不支持 [page:InterleavedBufferAttribute InterleavedBufferAttributes] 。 如果合并不成功，则该方法返回 null 。

### [method:BufferGeometry mergeGeometries]( [param:Array geometries], [param:Boolean useGroups] )

geometries -- 由 [page:BufferGeometry BufferGeometry] 实例的数组。
useGroups -- 是否要为了合并几何体而产生组。
将一组几何体合并到一个实例中。所有几何体都必须兼容该属性。 如果合并不成功，则该方法返回 null。

### [method:BufferGeometry mergeGroups]( [param:BufferGeometry geometry] )

geometry -- Instance of [page:BufferGeometry BufferGeometry] to merge the groups of.
Merges the [page:BufferGeometry.groups groups] for the given geometry.

### [method:BufferGeometry mergeVertices]( [param:BufferGeometry geometry], [param:Number tolerance] )

geometry -- 用于合并顶点的 [page:BufferGeometry BufferGeometry] 实例。
tolerance -- 要合并的顶点属性之间允许的最大差异。 默认为 1e-4。
返回一个新的 [page:BufferGeometry BufferGeometry] ，其中包含将所有（在容差范围内的）具有相似属性的顶点合并而成的顶点。

### [method:BufferGeometry toCreasedNormals]( [param:BufferGeometry geometry], [param:Number creaseAngle] )

- geometry -- The input geometry.
- creaseAngle -- The crease angle in radians.

Modifies the supplied geometry if it is non-indexed, otherwise creates a new, non-indexed geometry.

Returns the geometry with smooth normals everywhere except faces that meet at an angle greater than the crease angle.

### [method:BufferGeometry toTrianglesDrawMode]( [param:BufferGeometry geometry], [param:TrianglesDrawMode drawMode] )

geometry -- Instance of [page:BufferGeometry BufferGeometry].
drawMode -- The draw mode of the given geometry. Valid inputs are `THREE.TriangleStripDrawMode` and `THREE.TriangleFanDrawMode`.
Returns a new indexed geometry based on `THREE.TrianglesDrawMode` draw mode. This mode corresponds to the `gl.TRIANGLES` WebGL primitive.

## Source

[link:https://github.com/mrdoob/three.js/blob/master/examples/jsm/utils/BufferGeometryUtils.js examples/jsm/utils/BufferGeometryUtils.js]