# ProjectionGenerator

class in `three-edge-projection`

```js
import { ProjectionGenerator } from 'three-edge-projection';
```

Utility for generating 2D projections of 3D geometry.

Example: Projecting a mesh's visible edges

```js
import { Color, Mesh, TorusKnotGeometry, MeshNormalMaterial, LineSegments, LineBasicMaterial } from 'three';
import { ProjectionGenerator } from 'three-edge-projection';

// scene, camera and renderer are initialized here

// a drawing on light paper
scene.background = new Color( 0xeeeeee );

const mesh = new Mesh( new TorusKnotGeometry( 0.8, 0.25, 100, 16 ), new MeshNormalMaterial() );
mesh.position.y = 1;
mesh.updateMatrixWorld();
scene.add( mesh );

// the edges visible from above, flattened onto the ground below the knot
const task = new ProjectionGenerator().generate( mesh );
let step = task.next();
while ( ! step.done ) step = task.next();

const lines = new LineSegments( step.value.visibleEdges.getLineGeometry(), new LineBasicMaterial( { color: 0x030303 } ) );
lines.position.y = - 1;
scene.add( lines );
```

## Properties

### .iterationTime: number

How long to spend trimming edges before yielding.

### .angleThreshold: number

The threshold angle in degrees at which edges are generated.

### .includeIntersectionEdges: boolean

Whether to generate edges representing the intersections between triangles.

## Methods

### .generateAsync

```js
async .generateAsync( geometry: Object3D | BufferGeometry | Array<Object3D>, options?: Object ): ProjectionResult
```

Generate the geometry with a promise-style API.

- `geometry`, `Object3D | BufferGeometry | Array<Object3D>`
- `options`, `Object`, optional
  - `onProgress`, `ProjectionProgressCallback`, optional
  - `signal`, `AbortSignal`, optional

### .generate

```js
.generate( scene: Object3D | BufferGeometry | Array<Object3D>, options?: Object ): ProjectionResult
```

Generate the edge geometry result using a generator function.

- `scene`, `Object3D | BufferGeometry | Array<Object3D>`
- `options`, `Object`, optional
  - `onProgress`, `ProjectionProgressCallback`, optional
