#

API Docs for: 0.6.1
Show: Inherited Protected Private Deprecated

# Trimesh Class

Extends Shape
Defined in: `src/shapes/Trimesh.js:10`

## Constructor

### `Trimesh`

(

- `vertices`
- `indices`

)

Defined in `src/shapes/Trimesh.js:10`

#### Parameters:

- `vertices` Array
- `indices` Array

#### Example:

    // How to make a mesh with a single triangle
            var vertices = [
                0, 0, 0, // vertex 0
                1, 0, 0, // vertex 1
                0, 1, 0  // vertex 2
            ];
            var indices = [
                0, 1, 2  // triangle 0
            ];
            var trimeshShape = new Trimesh(vertices, indices);

- Index
- Methods
- Properties

## Item Index

### Methods

- _getUnscaledVertex
- calculateLocalInertia
- calculateWorldAABB
- computeLocalAABB
- computeNormal static
- createTorus static
- getEdgeVector
- getEdgeVertex
- getNormal
- getTrianglesInAABB
- getTriangleVertices
- getVertex
- getWorldVertex
- setScale
- updateAABB
- updateBoundingSphereRadius
- updateEdges
- updateNormals
- updateTree
- volume

### Properties

- aabb
- boundingSphereRadius
- collisionResponse
- edges
- id
- indices
- material
- normals
- scale
- tree
- type
- vertices

## Methods

### `_getUnscaledVertex`

(

- `i`
- `out`

)
Vec3 private

Defined in `src/shapes/Trimesh.js:295`

Get raw vertex i

#### Parameters:

- `i` Number
- `out` Vec3

#### Returns:

Vec3:

The "out" vector object

### `calculateLocalInertia`

(

- `mass`
- `target`

)
Vec3

Inherited from Shape but overwritten in `src/shapes/Trimesh.js:361`

#### Parameters:

- `mass` Number
- `target` Vec3

#### Returns:

Vec3:

The "target" vector object

### `calculateWorldAABB`

(

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

)

Defined in `src/shapes/Trimesh.js:454`

#### Parameters:

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

### `computeLocalAABB`

(

- `aabb`

)

Defined in `src/shapes/Trimesh.js:383`

Compute the local AABB for the trimesh

#### Parameters:

- `aabb` AABB

### `computeNormal`

(

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

)
static

Defined in `src/shapes/Trimesh.js:255`

Get face normal given 3 vertices

#### Parameters:

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

### `createTorus`

(

- `[radius=1]`
- `[tube=0.5]`
- `[radialSegments=8]`
- `[tubularSegments=6]`
- `[arc=6.283185307179586]`

)
Trimesh static

Defined in `src/shapes/Trimesh.js:513`

Create a Trimesh instance, shaped as a torus.

#### Parameters:

- `[radius=1]` Number optional
- `[tube=0.5]` Number optional
- `[radialSegments=8]` Number optional
- `[tubularSegments=6]` Number optional
- `[arc=6.283185307179586]` Number optional

#### Returns:

Trimesh:

A torus

### `getEdgeVector`

(

- `edgeIndex`
- `vectorStore`

)

Defined in `src/shapes/Trimesh.js:241`

Get a vector along an edge.

#### Parameters:

- `edgeIndex` Number
- `vectorStore` Vec3

### `getEdgeVertex`

(

- `edgeIndex`
- `firstOrSecond`
- `vertexStore`

)

Defined in `src/shapes/Trimesh.js:226`

Get an edge vertex

#### Parameters:

- `edgeIndex` Number
- `firstOrSecond` Number

  0 or 1, depending on which one of the vertices you need.

- `vertexStore` Vec3

  Where to store the result

### `getNormal`

(

- `i`
- `target`

)
Vec3

Defined in `src/shapes/Trimesh.js:343`

Compute the normal of triangle i.

#### Parameters:

- `i` Number
- `target` Vec3

#### Returns:

Vec3:

The "target" vector object

### `getTrianglesInAABB`

(

- `aabb`
- `result`

)

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

Get triangles in a local AABB from the trimesh.

#### Parameters:

- `aabb` AABB
- `result` Array

  An array of integers, referencing the queried triangles.

### `getTriangleVertices`

(

- `i`
- `a`
- `b`
- `c`

)

Defined in `src/shapes/Trimesh.js:328`

Get the three vertices for triangle i.

#### Parameters:

- `i` Number
- `a` Vec3
- `b` Vec3
- `c` Vec3

### `getVertex`

(

- `i`
- `out`

)
Vec3

Defined in `src/shapes/Trimesh.js:279`

Get vertex i.

#### Parameters:

- `i` Number
- `out` Vec3

#### Returns:

Vec3:

The "out" vector object

### `getWorldVertex`

(

- `i`
- `pos`
- `quat`
- `out`

)
Vec3

Defined in `src/shapes/Trimesh.js:313`

Get a vertex from the trimesh,transformed by the given position and quaternion.

#### Parameters:

- `i` Number
- `pos` Vec3
- `quat` Quaternion
- `out` Vec3

#### Returns:

Vec3:

The "out" vector object

### `setScale`

(

- `scale`

)

Defined in `src/shapes/Trimesh.js:153`

#### Parameters:

- `scale` Vec3

### `updateAABB`

()

Defined in `src/shapes/Trimesh.js:423`

Update the .aabb property

### `updateBoundingSphereRadius`

()

Inherited from Shape but overwritten in `src/shapes/Trimesh.js:431`

Will update the .boundingSphereRadius property

### `updateEdges`

()

Defined in `src/shapes/Trimesh.js:198`

Update the .edges property

### `updateNormals`

()

Defined in `src/shapes/Trimesh.js:170`

Compute the normals of the faces. Will save in the .normals array.

### `updateTree`

()

Defined in `src/shapes/Trimesh.js:88`

### `volume`

() Number

Inherited from Shape but overwritten in `src/shapes/Trimesh.js:504`

Get approximate volume

#### Returns:

Number:

## Properties

### `aabb`

Array

Defined in `src/shapes/Trimesh.js:52`

The local AABB of the mesh.

### `boundingSphereRadius`

Number

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

The local bounding sphere radius of this shape.

### `collisionResponse`

Boolean

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

Whether to produce contact forces when in contact with other bodies. Note that contacts will be generated, but they will be disabled.

### `edges`

Array

Defined in `src/shapes/Trimesh.js:59`

References to vertex pairs, making up all unique edges in the trimesh.

### `id`

Number

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

Identifyer of the Shape.

### `indices`

Array

Defined in `src/shapes/Trimesh.js:38`

Array of integers, indicating which vertices each triangle consists of. The length of this array is thus 3 times the number of triangles.

### `material`

Material

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

### `normals`

Array

Defined in `src/shapes/Trimesh.js:45`

The normals data.

### `scale`

Vec3

Defined in `src/shapes/Trimesh.js:65`

Local scaling of the mesh. Use .setScale() to set it.

### `tree`

Octree

Defined in `src/shapes/Trimesh.js:71`

The indexed triangles. Use .updateTree() to update it.

### `type`

Number

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

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

### `vertices`

Array

Defined in `src/shapes/Trimesh.js:32`