BufferGeometryUtils - Verge3D 用户手册 - Soft8Soft
Description: 了解如何在使用 Verge3D 制作的交互式 3D 应用程序中使用 BufferGeometryUtils

# BufferGeometryUtils

A class containing utility functions for BufferGeometry instances.

## Methods

### # .batchMeshes(meshObjs : Array, batchParent : Object3D)

- meshObjs — array of Mesh objects to be joined together.
- batchParent — container (parent) object to store the batched mesh.

Merges the meshes together to form a batched mesh. This technique is used to reduce the number WebGL draw calls hence to improve rendering performance.

The batching will be performed among the meshes which have the same values of the following properties:

- `material.name`
- `visible`
- `disableChildRendering`
- `castShadow`
- `receiveShadow`
- `renderOrder`
- `groupNames`
- `geometry.attributes` (keys only)
- `geometry.morphAttributes` (keys only)

### # .computeMorphedAttributes(object : Mesh | Line | Points) → Object

object — instance of Mesh, Line, Points.

Returns the morphed attributes (position and normal) of a morphed/skinned object together with the original ones. The returned object includes 4 properties: `positionAttribute`, `normalAttribute`, `morphedPositionAttribute`, and `morphedNormalAttribute`. Can be helpful for raytracing or applying decals.

### # .deepCloneAttribute(attribute : BufferAttribute) → BufferAttribute

attribute — instance of BufferAttribute to perform deep clone.

Returns a deep clone of the given attribute.

### # .estimateBytesUsed(geometry : BufferGeometry) → Float

geometry — instance of BufferGeometry to estimate the memory use of.

Returns the amount of bytes used by all attributes to represent the geometry.

### # .mergeBufferAttributes(attributes : Array) → BufferAttribute

attributes — array of BufferAttribute instances.

Merges a set of attributes into a single instance. All attributes must have compatible properties and types. If merge does not succeed, the method returns `null`.

### # .mergeBufferGeometries(geometries : Array, useGroups : Boolean) → BufferGeometry

- geometries — array of BufferGeometry instances.
- useGroups — whether groups should be generated for the merged geometry or not.

Merges a set of geometries into a single instance. All geometries must have compatible attributes. If merge does not succeed, the method returns `null`.

### # .mergeGroups(geometry : BufferGeometry) → BufferGeometry

geometry — instance of BufferGeometry to merge the groups of.

Merges the groups for the given geometry.

### # .mergeVertices(geometry : BufferGeometry, tolerance : Float) → BufferGeometry

- geometry — instance of BufferGeometry to merge the vertices of.
- tolerance — the maximum allowable difference between vertex attributes to merge. Defaults to `1e-4`.

Returns a new BufferGeometry with vertices for which all similar vertex attributes (within tolerance) are merged.

### # .toCreasedNormals(geometry : BufferGeometry, creaseAngle : Float) → BufferGeometry

- geometry — the input geometry.
- creaseAngle — the crease angle.

Creates a new, non-indexed geometry with smooth normals everywhere except faces that meet at an angle greater than the crease angle.

### # .toTrianglesDrawMode(geometry : BufferGeometry, drawMode : TrianglesDrawMode) → BufferGeometry

- geometry — instance of BufferGeometry.
- drawMode — the draw mode of the given geometry. Valid inputs are `v3d.TriangleStripDrawMode` and `v3d.TriangleFanDrawMode`.

Returns a new indexed geometry based on `v3d.TrianglesDrawMode` draw mode. This mode corresponds to the `gl.TRIANGLES` WebGL primitive.

## 源代码

关于如何获取此模块的源代码，请查看 本页。