npm package: @gov.nasa.jpl.honeycomb/three-extensions
Description: Set of three.js math extensions and utilities.
Latest version: 0.0.6

# Three.js Math Extensions

Set of three.js math extensions and utilities.

# Use

TODO

# API

<!-- START_AUTOGENERATED_DOCS -->
## CircleArc

Mathematical description of an arc on the edge of a circle.

### startPoint<a name="CircleArc#startPoint"></a>

```js
startPoint : Vector2 = (0,0)
```


The start point along the arc.


### endPoint<a name="CircleArc#endPoint"></a>

```js
endPoint : Vector2 = (0,0)
```


The end point along the arc.


### deltaHeading<a name="CircleArc#deltaHeading"></a>

```js
deltaHeading : Number = 0
```


The change in heading along the arc.


### startHeading<a name="CircleArc#startHeading"></a>

```js
startHeading : Number = 0
```


The initial heading of the arc. This is only used for cases where the initial
heading cannot be inferred, such as when the arc length are 0.


### toShortestArc<a name="CircleArc#toShortestArc"></a>

```js
toShortestArc(  ) : void
```

Converts this arc to the shortest variant to get to the same point. If the arc
sweeps larger than PI / 2 then we invert the delta heading.

### getCircleCenter<a name="CircleArc#getCircleCenter"></a>

```js
getCircleCenter( target : Vector2 ) : Vector2
```

Gets the center of the circle that this arc is on.

### getCircleRadius<a name="CircleArc#getCircleRadius"></a>

```js
getCircleRadius(  ) : Number
```

Gets the radius of the circle that this arc is on.

### getChordLength<a name="CircleArc#getChordLength"></a>

```js
getChordLength(  ) : Number
```

Get the chord length from the start point to the end point of the arc.

### getArcLength<a name="CircleArc#getArcLength"></a>

```js
getArcLength(  ) : Number
```

Get the length of the arc.

### closestPointToPoint<a name="CircleArc#closestPointToPoint"></a>

```js
closestPointToPoint( point : Vector2, target : Vector2 ) : Vector2
```

Sets target to the point on the arc that is closest to the given point.
Returns the target vector.

### at<a name="CircleArc#at"></a>

```js
at( t : Number, target : Vector2 ) : Vector2
```

Sets the target vector to the point `t` along the arc where `t` is between 0 and 1.
Returns the target vector.

### forEachPoint<a name="CircleArc#forEachPoint"></a>

```js
forEachPoint(
	steps : Number, 
	cb : ( point : Vector2, tangent : Vector2, index : Number ) => void
) : void
```

Fires the callback for every `steps + 1` points along the arc. Callback takes
the point, the tangent, and the step index.

### generatePoints<a name="CircleArc#generatePoints"></a>

```js
generatePoints( steps : Number, target : Array ) : Array
```

Generate an array of x, y, z points along the the arc with z at 0.

### copy<a name="CircleArc#copy"></a>

```js
copy( source : CircleArc ) : void
```

Sets this CircleArc to have the same properties as `source`.

### clone<a name="CircleArc#clone"></a>

```js
clone(  ) : CircleArc
```

Creates a clone of this object.

## OptimizedPlaneBufferGeometry

A copy of three.js' [PlaneBufferGeometry](https://threejs.org/docs/#api/en/geometries/PlaneBufferGeometry)
modified to immediately write to 32 bit buffers and excludes uv and normal attributes to save
build and run time memory.

_extends BufferGeometry_

### constructor

```js
constructor(
	width : Number = 1, 
	height : Number = 1, 
	widthSegments : Number = 1, 
	heightSegments : Number = 1
) : void
```

Specifies the spatial width and height as well as the number of grid segments
in the plane on the x and y axis.

## InfiniteGrid

Mesh to render an infinite grid in size with grid lines every 10m and 1m by default
and thicker lines at 0.

_extends Mesh_

### constructor

```js
constructor(
	size1 : Number = 1, 
	size2 : Number = 10, 
	color : Color = 0xffffff, 
	distance : Number = 2000
) : void
```

Parameters for setting the grid line stride, color, and distance the grid
will fade out at.

## DisposableEventListeners

Class for registering and tracking events on an `EventListener`
so they can be easily disposed of and removed.

### addEventListener<a name="DisposableEventListeners#addEventListener"></a>

```js
addEventListener( target : EventDispatcher, name : String, callback : Function ) : void
```

Add an event listener on `target` for event `name`

### dispose<a name="DisposableEventListeners#dispose"></a>

```js
dispose(  ) : void
```

Remove all event listeners that have been registered with this instance.

## ObjectPool

Class for dynamically growing and shrinking a pool of objects based on a dataset
and addin them to a three.js object.

### disposeImmediately<a name="ObjectPool#disposeImmediately"></a>

```js
disposeImmediately : Boolean = false
```


Whether the created pool objects should be deleted immediately when
shrinking the pool or if they should just be removed and disposed
when calling `dispose`.


### constructor

```js
constructor( parent : Object3D ) : void
```

Takes the Object3D to add all created pool objects to.

### updateData<a name="ObjectPool#updateData"></a>

```js
updateData( data : Array ) : void
```

Update the pool of objects based on the given data.

### dispose<a name="ObjectPool#dispose"></a>

```js
dispose(  ) : void
```

Disposes of all objects created in the pool.

### createObject<a name="ObjectPool#createObject"></a>

```js
createObject(  ) : Object3D
```

Called to create a new instance of the object to display when growing the pool.

Must be implemented.

### updateObject<a name="ObjectPool#updateObject"></a>

```js
updateObject( object : Object3D, data : any ) : void
```

Called to update object `object` based on the given data from the data array.

Must be implemented.

### disposeObject<a name="ObjectPool#disposeObject"></a>

```js
disposeObject( object : Object3D ) : void
```

Fully dispose of the object that was created for the pool.

Must be implemented.

## ExtMathUtils

Set of extended math utility functions.

### fitPlaneFromPoints<a name="ExtMathUtils.fitPlaneFromPoints"></a>

```js
static fitPlaneFromPoints(
	points : Array<Vector3>, 
	targetPos : Vector3, 
	targetDir : Vector3
) : void
```

Takes a set of points and derives a best fit plane from them. Puts the plane origin
in targetPos and the direction in targetDir.

## FlyOrbitControls

An extension of three.js' OrbitControls that allow for flying with the WASD keys.

WASD are used to move the camera forward, back, left, and right. QE are used to move
the camera up and down. And shift can be used to fly the camera faster.

_extends OrbitControls_

### enableFlight<a name="FlyOrbitControls#enableFlight"></a>

```js
enableFlight : Boolean = true
```


Whether to enable flight controls.


### baseSpeed<a name="FlyOrbitControls#baseSpeed"></a>

```js
baseSpeed : Number = 0.1
```


The base speed to fly at when shift is not held. Specified in units per second.


### fastSpeed<a name="FlyOrbitControls#fastSpeed"></a>

```js
fastSpeed : Number = 0.1
```


The fast speed to fly at when shift is held. Specified in units per second.


### constructor

```js
constructor( camera : Camera, domElement : Element ) : void
```

Takes the camera and renderer.domElement that would normally be passed to OrbitControls.

## MaterialReducer

Utility class for sharing equivelant textures and materials between objects
in a hierarchy of objects.

### ignoreKeys<a name="MaterialReducer#ignoreKeys"></a>

```js
ignoreKeys : Set = ['uuid']
```


A set of keys to ignore when comparing materials and textures. Defaults to
just include "uuid".


### shareTextures<a name="MaterialReducer#shareTextures"></a>

```js
shareTextures : Boolean = true
```


Whether to share texture instances between the final materials.


### process<a name="MaterialReducer#process"></a>

```js
process( object : Object3D ) : Number
```

Process the given hierarchy of objects to reduce the number of materials and textures.
Returns the number of materials removed. Materials and textures are shared over subsequent
runs of the function.

## GPUTimeSampler

Class for easily measuring the amount of time the GPU is taking to do work.

_extends EventDispatcher_

### Events

`query-complete`

Fired whenever new GPU timing data is available. Provides the latest time and average/
time over the max number of sample frames.

### isSupported<a name="GPUTimeSampler#isSupported"></a>

```js
isSupported : Boolean
```


Whether the required extension to use the class is supported.


### constructor

```js
constructor( context : WebGL2RenderingContext ) : void
```

### startQuery<a name="GPUTimeSampler#startQuery"></a>

```js
startQuery(  ) : void
```

Should be called at the beginning of the rendering work to be measured.

### endQuery<a name="GPUTimeSampler#endQuery"></a>

```js
endQuery(  ) : void
```

Should be called at the end of the rendering work to be measured. Once the
query finishes the `query-complete` event will fire.


<!-- END_AUTOGENERATED_DOCS -->