# Class GeometryBuffer

Represents a block of reusable geometry memory. It is expensive to allocate memory for geometry arrays (vertices, normals, indices) for each mesh. By using this class we can allocate a large block of memory and then allocate smaller slices from this block to write geometry data to. For example during mesh merging.

##### Index

### Constructors

constructor

### Accessors

byteLength

### Methods

free
malloc
maximizeLength

## Constructors

### constructor

- new GeometryBuffer(): GeometryBuffer

  #### Returns GeometryBuffer

## Accessors

### byteLength

- get byteLength(): number

  Total size in bytes of geometry memory.

  #### Returns number

## Methods

### free

- free(): void

  Frees the memory used by the geometry buffer.

  #### Returns void

### malloc

- malloc(primitiveCount: number, indiceCount: number): GeometryArrays

  Allocate a block of geometry arrays (GeometryArrays). Only one allocation at a time may exist Therefore next call to this method will invalidate contents of previous GeometryArrays instances.

  #### Parameters

  - primitiveCount: number

    Number of primitives to allocate.

  - indiceCount: number

    Number of indices to allocate.

  #### Returns GeometryArrays

### maximizeLength

- maximizeLength(primitiveCount: number, indiceCount: number): GeometryBuffer

  Updates the maximum length of the geometry buffer to accommodate the given primitive count and indice count. If the given counts are greater than the current maximum lengths, then the maximum size will be updated.

  #### Parameters

  - primitiveCount: number

    The desired primitive count.

  - indiceCount: number

    The desired indice count.

  #### Returns GeometryBuffer

  This GeometryBuffer instance.