Trimesh Class
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);
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
Methods
_getUnscaledVertex
-
i
-
out
Get raw vertex i
Parameters:
-
i
Number -
out
Vec3
Returns:
The "out" vector object
calculateLocalInertia
-
mass
-
target
Parameters:
-
mass
Number -
target
Vec3
Returns:
The "target" vector object
computeNormal
-
va
-
vb
-
vc
-
target
Get face normal given 3 vertices
createTorus
-
[radius=1]
-
[tube=0.5]
-
[radialSegments=8]
-
[tubularSegments=6]
-
[arc=6.283185307179586]
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:
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
Number0 or 1, depending on which one of the vertices you need.
-
vertexStore
Vec3Where to store the result
getNormal
-
i
-
target
Compute the normal of triangle i.
Parameters:
-
i
Number -
target
Vec3
Returns:
The "target" vector object
getTrianglesInAABB
-
aabb
-
result
Get triangles in a local AABB from the trimesh.
Parameters:
-
aabb
AABB -
result
ArrayAn array of integers, referencing the queried triangles.
getTriangleVertices
-
i
-
a
-
b
-
c
Get the three vertices for triangle i.
getVertex
-
i
-
out
Get vertex i.
Parameters:
-
i
Number -
out
Vec3
Returns:
The "out" vector object
getWorldVertex
-
i
-
pos
-
quat
-
out
Get a vertex from the trimesh,transformed by the given position and quaternion.
Parameters:
-
i
Number -
pos
Vec3 -
quat
Quaternion -
out
Vec3
Returns:
The "out" vector object
updateAABB
()
Update the .aabb property
updateBoundingSphereRadius
()
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
Get approximate volume
Returns:
Properties
aabb
Array
The local AABB of the mesh.
boundingSphereRadius
Number
The local bounding sphere radius of this shape.
collisionResponse
Boolean
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
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.
normals
Array
The normals data.
type
Number
The type of this shape. Must be set to an int > 0 by subclasses.