# Class InstancedPrefabBufferGeometry

#### Hierarchy

- InstancedBufferGeometry
  - InstancedPrefabBufferGeometry

- Defined in lib/plugins/thirdParty/instancedPrefabBufferGeometry.ts:3

##### Index

### Constructors

constructor

### Properties

prefabCount
prefabGeometry

### Methods

createAttribute
setPrefabData

## Constructors

### constructor

- new InstancedPrefabBufferGeometry(
  prefab: BufferGeometry,
  count: number,
  ): InstancedPrefabBufferGeometry

  A wrapper around THREE.InstancedBufferGeometry, which is more memory efficient than PrefabBufferGeometry, but requires the ANGLE_instanced_arrays extension.

  #### Parameters

  - prefab: BufferGeometry

    The Geometry instance to repeat.

  - count: number

    The number of times to repeat the geometry.

  #### Returns InstancedPrefabBufferGeometry

  Overrides InstancedBufferGeometry.constructor

  - Defined in lib/plugins/thirdParty/instancedPrefabBufferGeometry.ts:13

## Properties

### prefabCount

prefabCount: number

- Defined in lib/plugins/thirdParty/instancedPrefabBufferGeometry.ts:5

### prefabGeometry

prefabGeometry: BufferGeometry

- Defined in lib/plugins/thirdParty/instancedPrefabBufferGeometry.ts:4

## Methods

### createAttribute

- createAttribute(
  name: string,
  itemSize: number,
  factory?: (data: any[], index: number, prefabCount: number) => void,
  ): InstancedBufferAttribute

  Creates a BufferAttribute on this geometry instance.

  #### Parameters

  - name: string

    Name of the attribute.

  - itemSize: number

    Number of floats per vertex (typically 1, 2, 3 or 4).

  - `Optional` factory: (data: any[], index: number, prefabCount: number) => void

    Function that will be called for each prefab upon creation. Accepts 3 arguments: data[], index and prefabCount. Calls setPrefabData.

  #### Returns InstancedBufferAttribute

  - Defined in lib/plugins/thirdParty/instancedPrefabBufferGeometry.ts:32

### setPrefabData

- setPrefabData(
  attribute: string | InstancedBufferAttribute,
  prefabIndex: number,
  data: any[],
  ): void

  Sets data for a prefab at a given index. Usually called in a loop.

  #### Parameters

  - attribute: string | InstancedBufferAttribute

    The attribute or attribute name where the data is to be stored.

  - prefabIndex: number

    Index of the prefab in the buffer geometry.

  - data: any[]

    Array of data. Length should be equal to item size of the attribute.

  #### Returns void

  - Defined in lib/plugins/thirdParty/instancedPrefabBufferGeometry.ts:58