#

API Docs for: 0.6.0
Show: Inherited Protected Private Deprecated

# ConvexPolyhedron Class

Extends Shape
Defined in: `src/shapes/ConvexPolyhedron.js:8`

A set of polygons describing a convex shape.

## Constructor

### `ConvexPolyhedron`

(

- `points`
- `faces`
- `normals`

)

Defined in `src/shapes/ConvexPolyhedron.js:8`

#### Parameters:

- `points` Array

  An array of Vec3's

- `faces` Array

  Array of integer arrays, describing which vertices that is included in each face.

- `normals` Array

  Deprecated. Normals are now automatically generated from polygons.

- Index
- Methods
- Properties

## Item Index

### Methods

- calculateLocalInertia
- calculateWorldAABB
- clipAgainstHull
- clipFaceAgainstHull
- clipFaceAgainstPlane
- computeEdges
- computeNormals
- computeWorldFaceNormals
- findSeparatingAxis
- getAveragePointLocal
- getFaceNormal
- getFaceNormal static
- getPlaneConstantOfFace
- pointIsInside
- project static
- testSepAxis
- transformAllPoints
- updateBoundingSphereRadius
- volume

### Properties

- boundingSphereRadius
- collisionResponse
- faceNormals
- faces
- type
- uniqueEdges
- vertices

## Methods

### `calculateLocalInertia`

(

- `mass`
- `target`

)

Inherited from Shape but overwritten in `src/shapes/ConvexPolyhedron.js:390`

#### Parameters:

- `mass` Number
- `target` Vec3

### `calculateWorldAABB`

(

- `pos`
- `quat`
- `min`
- `max`

)

Defined in `src/shapes/ConvexPolyhedron.js:722`

#### Parameters:

- `pos` Vec3
- `quat` Quaternion
- `min` Vec3
- `max` Vec3

### `clipAgainstHull`

(

- `posA`
- `quatA`
- `hullB`
- `posB`
- `quatB`
- `separatingNormal`
- `minDist`
- `maxDist`
- `result`

)

Defined in `src/shapes/ConvexPolyhedron.js:192`

#### Parameters:

- `posA` Vec3
- `quatA` Quaternion
- `hullB` ConvexPolyhedron
- `posB` Vec3
- `quatB` Quaternion
- `separatingNormal` Vec3
- `minDist` Number

  Clamp distance

- `maxDist` Number
- `result` Array

  The an array of contact point objects, see clipFaceAgainstHull

### `clipFaceAgainstHull`

(

- `separatingNormal`
- `posA`
- `quatA`
- `worldVertsB1`
- `minDist`
- `maxDist`
- `Array`

)

Defined in `src/shapes/ConvexPolyhedron.js:420`

Clip a face against a hull.

#### Parameters:

- `separatingNormal` Vec3
- `posA` Vec3
- `quatA` Quaternion
- `worldVertsB1` Array

  An array of Vec3 with vertices in the world frame.

- `minDist` Number

  Distance clamping

- `maxDist` Number
- `Array` Object

  result Array to store resulting contact points in. Will be objects with properties: point, depth, normal. These are represented in world coordinates.

### `clipFaceAgainstPlane`

(

- `inVertices`
- `outVertices`
- `planeNormal`
- `planeConstant`

)

Defined in `src/shapes/ConvexPolyhedron.js:574`

Clip a face in a hull against the back of a plane.

#### Parameters:

- `inVertices` Array
- `outVertices` Array
- `planeNormal` Vec3
- `planeConstant` Number

  The constant in the mathematical plane equation

### `computeEdges`

()

Defined in `src/shapes/ConvexPolyhedron.js:74`

Computes uniqueEdges

### `computeNormals`

()

Defined in `src/shapes/ConvexPolyhedron.js:127`

Compute the normals of the faces. Will reuse existing Vec3 objects in the .faceNormals array if they exist.

### `computeWorldFaceNormals`

(

- `quat`

)

Defined in `src/shapes/ConvexPolyhedron.js:684`

Updates .worldVertices and sets .worldVerticesNeedsUpdate to false.

#### Parameters:

- `quat` Quaternion

### `findSeparatingAxis`

(

- `hullB`
- `posA`
- `quatA`
- `posB`
- `quatB`
- `target`

)
Bool

Defined in `src/shapes/ConvexPolyhedron.js:251`

Find the separating axis between this hull and another

#### Parameters:

- `hullB` ConvexPolyhedron
- `posA` Vec3
- `quatA` Quaternion
- `posB` Vec3
- `quatB` Quaternion
- `target` Vec3

  The target vector to save the axis in

#### Returns:

Bool:

Returns false if a separation is found, else true

### `getAveragePointLocal`

(

- `target`

)
Vec3

Defined in `src/shapes/ConvexPolyhedron.js:768`

Get an average of all the vertices positions

#### Parameters:

- `target` Vec3

#### Returns:

Vec3:

### `getFaceNormal`

(

- `i`
- `target`

)

Defined in `src/shapes/ConvexPolyhedron.js:178`

Compute the normal of a face from its vertices

#### Parameters:

- `i` Number
- `target` Vec3

### `getFaceNormal`

(

- `va`
- `vb`
- `vc`
- `target`

)
static

Defined in `src/shapes/ConvexPolyhedron.js:158`

Get face normal given 3 vertices

#### Parameters:

- `va` Vec3
- `vb` Vec3
- `vc` Vec3
- `target` Vec3

### `getPlaneConstantOfFace`

(

- `face_i`

)
Number

Defined in `src/shapes/ConvexPolyhedron.js:407`

#### Parameters:

- `face_i` Number

  Index of the face

#### Returns:

Number:

### `pointIsInside`

(

- `p`

)
Boolean

Defined in `src/shapes/ConvexPolyhedron.js:824`

Checks whether p is inside the polyhedra. Must be in local coords. The point lies outside of the convex hull of the other points if and only if the direction of all the vectors from it to those other points are on less than one half of a sphere around it.

#### Parameters:

- `p` Vec3

  A point given in local coordinates

#### Returns:

Boolean:

### `project`

(

- `hull`
- `axis`
- `pos`
- `quat`
- `result`

)
static

Defined in `src/shapes/ConvexPolyhedron.js:866`

Get max and min dot product of a convex hull at position (pos,quat) projected onto an axis. Results are saved in the array maxmin.

#### Parameters:

- `hull` ConvexPolyhedron
- `axis` Vec3
- `pos` Vec3
- `quat` Quaternion
- `result` Array

  result[0] and result[1] will be set to maximum and minimum, respectively.

### `testSepAxis`

(

- `axis`
- `hullB`
- `posA`
- `quatA`
- `posB`
- `quatB`

)
Float

Defined in `src/shapes/ConvexPolyhedron.js:358`

Test separating axis against two hulls. Both hulls are projected onto the axis and the overlap size is returned if there is one.

#### Parameters:

- `axis` Vec3
- `hullB` ConvexPolyhedron
- `posA` Vec3
- `quatA` Quaternion
- `posB` Vec3
- `quatB` Quaternion

#### Returns:

Float:

The overlap depth, or FALSE if no penetration.

### `transformAllPoints`

(

- `offset`
- `quat`

)

Defined in `src/shapes/ConvexPolyhedron.js:785`

Transform all local points. Will change the .vertices

#### Parameters:

- `offset` Vec3
- `quat` Quaternion

### `updateBoundingSphereRadius`

()

Inherited from Shape but overwritten in `src/shapes/ConvexPolyhedron.js:704`

### `volume`

() Number

Inherited from Shape but overwritten in `src/shapes/ConvexPolyhedron.js:759`

Get approximate convex volume

#### Returns:

Number:

## Properties

### `boundingSphereRadius`

Number

Inherited from Shape: `src/shapes/Shape.js:25`

The local bounding sphere radius of this shape.

### `collisionResponse`

Boolean

Inherited from Shape: `src/shapes/Shape.js:31`

### `faceNormals`

Array

Defined in `src/shapes/ConvexPolyhedron.js:50`

Array of Vec3

### `faces`

Array

Defined in `src/shapes/ConvexPolyhedron.js:43`

Array of integer arrays, indicating which vertices each face consists of

### `type`

Number

Inherited from Shape: `src/shapes/Shape.js:17`

The type of this shape. Must be set to an int > 0 by subclasses.

### `uniqueEdges`

Array

Defined in `src/shapes/ConvexPolyhedron.js:61`

Array of Vec3

### `vertices`

Array

Defined in `src/shapes/ConvexPolyhedron.js:33`

Array of Vec3