API Docs for: 0.6.1
Show:

Trimesh Class

Extends Shape

Constructor

Trimesh

(
  • vertices
  • indices
)

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);
        

Methods

_getUnscaledVertex

(
  • i
  • out
)
Vec3 private

Get raw vertex i

Parameters:

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
)

Parameters:

computeLocalAABB

(
  • aabb
)

Compute the local AABB for the trimesh

Parameters:

computeNormal

(
  • va
  • vb
  • vc
  • target
)
static

Get face normal given 3 vertices

Parameters:

createTorus

(
  • [radius=1]
  • [tube=0.5]
  • [radialSegments=8]
  • [tubularSegments=6]
  • [arc=6.283185307179586]
)
Trimesh static

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
)

Get a vector along an edge.

Parameters:

  • edgeIndex Number
  • vectorStore Vec3

getEdgeVertex

(
  • edgeIndex
  • firstOrSecond
  • vertexStore
)

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

Compute the normal of triangle i.

Parameters:

  • i Number
  • target Vec3

Returns:

Vec3:

The "target" vector object

getTrianglesInAABB

(
  • aabb
  • result
)

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
)

Get the three vertices for triangle i.

Parameters:

getVertex

(
  • i
  • out
)
Vec3

Get vertex i.

Parameters:

Returns:

Vec3:

The "out" vector object

getWorldVertex

(
  • i
  • pos
  • quat
  • out
)
Vec3

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

Parameters:

Returns:

Vec3:

The "out" vector object

setScale

(
  • scale
)

Parameters:

updateAABB

()

Update the .aabb property

updateBoundingSphereRadius

()

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

Will update the .boundingSphereRadius property

updateEdges

()

Update the .edges property

updateNormals

()

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

updateTree

()

volume

() Number

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

Get approximate volume

Returns:

Number:

Properties

aabb

Array

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

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

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

The normals data.

scale

Vec3

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

tree

Octree

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