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)

Inheritance

Constructors

Trimesh(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 Vec3
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
uvs List<double>?
latefinal
vertices List<double>
latefinal

Methods

calculateLocalInertia(double mass, Vec3 target) Vec3
@return The "target" vector object
override
calculateWorldAABB(Vec3 pos, Quaternion quat, Vec3 min, Vec3 max) → void
calculateWorldAABB
override
computeLocalAABB(AABB aabb) → void
Compute the local AABB for the trimesh
getEdgeVector(int edgeIndex, Vec3 vectorStore) → void
Get a vector along an edge.
getEdgeVertex(int edgeIndex, int firstOrSecond, Vec3 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, Vec3 target) Vec3
Compute the normal of triangle i. @return The "target" vector object
getNormal(int i, Vec3 target) Vec3
Compute the normal of triangle i. @return The "target" vector object
getTriangleNormals(int i, Vec3 a, Vec3 b, Vec3 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, Vec3 a, Vec3 b, Vec3 c) → void
Get the three vertices for triangle i.
getVertex(int i, [Vec3? out]) Vec3
Get vertex i. @return The "out" vector object
getWorldVertex(int i, Vec3 pos, Quaternion quat, Vec3 out) Vec3
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(Vec3 scale) → void
toString() String
A string representation of this object.
inherited
updateAABB() → void
Update the .aabb property
updateBoundingSphereRadius() → void
Will update the .boundingSphereRadius property
override
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(Vec3 va, Vec3 vb, Vec3 vc, Vec3 target) → void
Get face normal given 3 vertices