Options
All
  • Public
  • Public/Protected
  • All
Menu

Interface BufferGeometry

A representation of mesh, line, or point geometry. Includes vertex positions, face indices, normals, colors, UVs, and custom attributes within buffers, reducing the cost of passing all this data to the GPU. To read and edit data in BufferGeometry attributes, see BufferAttribute documentation.

Examples

Mesh with non-indexed faces | Mesh with indexed faces | Lines | Indexed Lines | Particles | Raw Shaders

Code Example

const geometry = new THREE.BufferGeometry();
// create a simple square shape. We duplicate the top left and bottom right // vertices because each vertex needs to appear once per triangle.
const vertices = new Float32Array( [
-1.0, -1.0, 1.0,
1.0, -1.0, 1.0,
1.0, 1.0, 1.0,
1.0, 1.0, 1.0,
-1.0, 1.0, 1.0,
-1.0, -1.0, 1.0
] );
// itemSize = 3 because there are 3 values (components) per vertex
geometry.setAttribute( 'position', new THREE.BufferAttribute( vertices, 3 ) );
const material = new THREE.MeshBasicMaterial( { color: 0xff0000 } );
const mesh = new THREE.Mesh( geometry, material );

Hierarchy

Index

Constructors

constructor

Properties

MaxIndex

MaxIndex: number

attributes

attributes: {}

This hashmap has as id the name of the attribute to be set and as value the buffer to set it to. Rather than accessing this property directly, use .setAttribute and .getAttribute to access attributes of this geometry.

default

{}

Type declaration

boundingBox

boundingBox: I3JS.Box3

Bounding box for the bufferGeometry, which can be calculated with .computeBoundingBox(). Default is null.

default

null

boundingSphere

boundingSphere: I3JS.Sphere

Bounding sphere for the bufferGeometry, which can be calculated with .computeBoundingSphere(). Default is null.

default

null

drawRange

drawRange: { count: number; start: number }

Determines the part of the geometry to render. This should not be set directly, instead use .setDrawRange. Default is { start: 0, count: Infinity } For non-indexed BufferGeometry, count is the number of vertices to render. For indexed BufferGeometry, count is the number of indices to render.

default

{ start: 0, count: Infinity }

Type declaration

  • count: number
  • start: number

groups

groups: { count: number; materialIndex?: number; start: number }[]

Split the geometry into groups, each of which will be rendered in a separate WebGL draw call. This allows an array of materials to be used with the bufferGeometry. Each group is an object of the form: { start: Integer, count: Integer, materialIndex: Integer } where start specifies the first element in this draw call – the first vertex for non-indexed geometry, otherwise the first triangle index. Count specifies how many vertices (or indices) are included, and materialIndex specifies the material array index to use. Use .addGroup to add groups, rather than modifying this array directly.

default

[]

id

id: number

Unique number for this bufferGeometry instance.

index

Allows for vertices to be re-used across multiple triangles; this is called using "indexed triangles". Each triangle is associated with the indices of three vertices. This attribute therefore stores the index of each vertex for each triangular face. If this attribute is not set, the renderer assumes that each three contiguous positions represent a single triangle. Default is null.

default

null

Readonly isBufferGeometry

isBufferGeometry: true

morphAttributes

morphAttributes: {}

Hashmap of BufferAttributes holding details of the geometry's morph targets.

default

{}

Type declaration

morphTargetsRelative

morphTargetsRelative: boolean

Used to control the morph target behavior; when set to true, the morph target data is treated as relative offsets, rather than as absolute positions/normals. Default is false.

default

false

name

name: string

Optional name for this bufferGeometry instance. Default is an empty string.

default

''

Optional parameters

parameters?: any

An object with a property for each of the constructor parameters. Any modification after instantiation does not change the geometry.

type

type: string
default

'BufferGeometry'

userData

userData: {}

An object that can be used to store custom data about the BufferGeometry. It should not hold references to functions as these will not be cloned.

default

{}

Type declaration

  • [key: string]: any

uuid

uuid: string

UUID of this object instance. This gets automatically assigned and shouldn't be edited.

Methods

addAttribute

  • addAttribute(name: any, array: any, itemSize: any): any

addEventListener

addGroup

  • addGroup(start: number, count: number, materialIndex?: number): void

applyMatrix4

applyQuaternion

center

clearGroups

  • clearGroups(): void

clone

computeBoundingBox

  • computeBoundingBox(): void
  • Computes bounding box of the geometry, updating .boundingBox attribute. Bounding boxes aren't computed by default. They need to be explicitly computed, otherwise they are null.

    Returns void

computeBoundingSphere

  • computeBoundingSphere(): void
  • Computes bounding sphere of the geometry, updating .boundingSphere attribute. Bounding spheres aren't computed by default. They need to be explicitly computed, otherwise they are null.

    Returns void

computeTangents

  • computeTangents(): void
  • Calculates and adds a tangent attribute to this geometry. The computation is only supported for indexed geometries and if position, normal, and uv attributes are defined.

    Returns void

computeVertexNormals

  • computeVertexNormals(): void

copy

deleteAttribute

dispatchEvent

  • dispatchEvent(event: Event): void

dispose

  • dispose(): void

getAttribute

getIndex

hasAttribute

hasEventListener

lookAt

merge

normalizeNormals

  • normalizeNormals(): void

removeEventListener

rotateX

rotateY

rotateZ

scale

setAttribute

setDrawRange

  • setDrawRange(start: number, count: number): void
  • Set the .drawRange property. For non-indexed BufferGeometry, count is the number of vertices to render. For indexed BufferGeometry, count is the number of indices to render.

    Parameters

    • start: number
    • count: number

    Returns void

setFromPoints

setIndex

toJSON

  • toJSON(): any

toNonIndexed

translate

Generated using TypeDoc