BufferGeometryUtils is an addon, and must be imported explicitly, see Installation#Addons.
import * as BufferGeometryUtils from 'three/addons/utils/BufferGeometryUtils.js';
Computes vertex tangents using the 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, 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 custom material, and may be faster than MikkTSpace.
Returns the original BufferGeometry. Indexed geometries will be de-indexed. Requires position, normal, and uv attributes.
geometry
The geometry to compute tangents for.
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.
Default is true.
Returns: The updated geometry.
Calculates the morphed attributes of a morphed/skinned BufferGeometry.
Helpful for Raytracing or Decals (i.e. a DecalGeometry applied to a morphed Object with a 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).
object
The 3D object to compute morph attributes for.
Returns: An object with original position/normal attributes and morphed ones.
Performs a deep clone of the given buffer attribute.
attribute
The attribute to clone.
Returns: The cloned attribute.
Returns a new, non-interleaved version of the given attribute.
attribute
The interleaved attribute.
Returns: The non-interleaved attribute.
Deinterleaves all attributes on the given geometry.
geometry
The geometry to deinterleave.
Returns the amount of bytes used by all attributes to represent the geometry.
geometry
The geometry.
Returns: The estimate bytes used.
Interleaves a set of attributes and returns a new array of corresponding attributes that share a single InterleavedBuffer instance. All attributes must have compatible types.
attributes
The attributes to interleave.
Returns: An array of interleaved attributes. If interleave does not succeed, the method returns null.
Merges a set of attributes into a single instance. All attributes must have compatible properties and types. Instances of InterleavedBufferAttribute are not supported.
attributes
The attributes to merge.
Returns: The merged attribute. Returns null if the merge does not succeed.
Merges a set of geometries into a single instance. All geometries must have compatible attributes.
geometries
The geometries to merge.
useGroups
Whether to use groups or not.
Default is false.
Returns: The merged geometry. Returns null if the merge does not succeed.
Merges the BufferGeometry#groups for the given geometry.
geometry
The geometry to modify.
Returns:
Returns a new geometry with vertices for which all similar vertex attributes (within tolerance) are merged.
geometry
The geometry to merge vertices for.
tolerance
The tolerance value.
Default is 1e-4.
Returns:
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.
geometry
The geometry to modify.
creaseAngle
The crease angle in radians.
Default is Math.PI/3.
Returns:
Returns a new indexed geometry based on TrianglesDrawMode draw mode. This mode corresponds to the gl.TRIANGLES primitive in WebGL.
geometry
The geometry to convert.
drawMode
The current draw mode.
Returns: The new geometry using TrianglesDrawMode.