# StaticGeometryGenerator

class in `three-mesh-bvh`

```js
import { StaticGeometryGenerator } from 'three-mesh-bvh';
```

A utility class for taking a set of SkinnedMeshes or morph target geometry and baking it into
a single, static geometry that a BVH can be generated for.

## Constructor

```js
new StaticGeometryGenerator( meshes: Object3D | Array<Object3D> )
```

Takes an array of object hierarchies to bake into a single static geometry.

- `meshes`, `Object3D | Array<Object3D>`

## Properties

### .meshes: Array<Mesh>

### .useGroups: boolean

If true then groups are used to support an array of materials on the mesh.

### .applyWorldTransforms: boolean

Whether to transform the vertices of the geometry by the world transforms of each mesh when generating.

### .attributes: Array<string>

The set of attributes to copy onto the static geometry.

## Methods

### .getMaterials

```js
.getMaterials(  ): Array<Material>
```

Returns an array of materials for the meshes to be merged. These can be used alongside the
generated geometry when creating a mesh: `new Mesh( geometry, generator.getMaterials() )`.

### .generate

```js
.generate( targetGeometry?: BufferGeometry ): BufferGeometry
```

Generates a single, static geometry for the passed meshes. When generating for the first
time an empty target geometry is expected. The same generated geometry can be passed into
the function on subsequent calls to update the geometry in place to save memory. An error
will be thrown if the attributes or geometry on the meshes to bake has been changed and
are incompatible lengths, types, etc.

On subsequent calls the "index" buffer will not be modified so any BVH generated for the
geometry is unaffected. Once the geometry is updated the `MeshBVH.refit` function can be
called to update the BVH.

- `targetGeometry`, `BufferGeometry`, optional
