Trimesh class
Trimesh.
@example
// How to make a mesh with a single triangle
final vertices =
0, 0, 0, // vertex 0
1, 0, 0, // vertex 1
0, 1, 0 // vertex 2
final indices =
0, 1, 2 // triangle 0
final trimeshShape = CANNON.Trimesh(vertices, indices)
Constructors
-
Trimesh.new(List<
double> vertices, List<int> indices, [List<double> ? normals, List<double> ? uvs]) - Trimesh.createTorus(TorusGeometry torus)
- Create a Trimesh instance, shaped as a torus.
Properties
- aabb → AABB
-
The local AABB of the mesh.
final
- body ↔ Body?
-
The body to which the shape is added to.
getter/setter pairinherited
- boundingSphereRadius ↔ double
-
The local bounding sphere radius of this shape.
getter/setter pairinherited
- collisionFilterGroup ↔ int
-
getter/setter pairinherited
- collisionFilterMask ↔ int
-
getter/setter pairinherited
- collisionResponse ↔ bool
-
Whether to produce contact forces when in contact with other bodies. Note that contacts will be generated, but they will be disabled.
getter/setter pairinherited
-
edges
↔ List<
int> -
References to vertex pairs, making up all unique edges in the trimesh.
getter/setter pair
-
faceNormals
↔ List<
double> -
latefinal
- hashCode → int
-
The hash code for this object.
no setterinherited
- id ↔ int
-
Identifier of the Shape.
getter/setter pairinherited
-
indices
↔ List<
int> -
Array of integers, indicating which vertices each triangle consists of. The length of this array is thus 3 times the number of triangles.
latefinal
- material ↔ Material?
-
Optional material of the shape that regulates contact properties.
getter/setter pairinherited
-
normals
↔ List<
double> ? -
latefinal
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- scale → Vector3
-
Local scaling of the mesh. Use .setScale() to set it.
final
- torus ↔ TorusGeometry
-
latefinal
- tree → Octree
-
The indexed triangles. Use .updateTree() to update it.
final
- type ↔ ShapeType
-
The type of this shape. Must be set to an int > 0 by subclasses.
getter/setter pairinherited
- unscaledAABB → AABB
-
final
-
uvs
↔ List<
double> ? -
latefinal
-
vertices
↔ List<
double> -
latefinal
Methods
-
calculateLocalInertia(
double mass, Vector3 target) → Vector3 -
@return The "target" vector object
override
-
calculateWorldAABB(
Vector3 pos, Quaternion quat, Vector3 min, Vector3 max) → void -
calculateWorldAABB
override
-
computeLocalAABB(
AABB aabb) → void - Compute the local AABB for the trimesh
-
getEdgeVector(
int edgeIndex, Vector3 vectorStore) → void - Get a vector along an edge.
-
getEdgeVertex(
int edgeIndex, int firstOrSecond, Vector3 vertexStore) → void - Get an edge vertex @param firstOrSecond 0 or 1, depending on which one of the vertices you need. @param vertexStore Where to store the result
-
getFaceNormal(
int i, Vector3 target) → Vector3 -
getIndicesNormal(
int i, Vector3 target) → Vector3 - Compute the normal of triangle i. @return The "target" vector object Compute the normal of triangle i. @return The "target" vector object
-
getTriangleNormals(
int i, Vector3 a, Vector3 b, Vector3 c) → void - Get the three vertices for triangle i.
-
getTrianglesInAABB(
AABB aabb, List< int> result) → List<int> - Get triangles in a local AABB from the trimesh. @param result An array of integers, referencing the queried triangles.
-
getTriangleVertices(
int i, Vector3 a, Vector3 b, Vector3 c) → void - Get the three vertices for triangle i.
-
getVertex(
int i, [Vector3? out]) → Vector3 - Get vertex i. @return The "out" vector object
-
getWorldVertex(
int i, Vector3 pos, Quaternion quat, Vector3 out) → Vector3 - Get a vertex from the trimesh,transformed by the given position and quaternion. @return The "out" vector object
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
setScale(
Vector3 scale) → void -
toString(
) → String -
A string representation of this object.
inherited
-
updateAABB(
) → void -
Update the
.aabb
property -
updateBoundingSphereRadius(
) → void -
Will update the
.boundingSphereRadius
propertyoverride -
updateEdges(
) → void -
updateNormals(
) → void -
Compute the normals of the faces. Will save in the
.normals
array. -
updateTree(
) → void -
volume(
) → double -
Get approximate volume
override
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited
Static Methods
-
computeNormal(
Vector3 va, Vector3 vb, Vector3 vc, Vector3 target) → void - Get face normal given 3 vertices