Box class

A 3d box shape. @example const size = 1 const halfExtents = CANNON.Vec3(size, size, size) const boxShape = CANNON.Box(halfExtents) const boxBody = CANNON.Body({ mass: 1, shape: boxShape }) world.addBody(boxBody)

Inheritance

Constructors

Box(Vec3 halfExtents)

Properties

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
convexPolyhedronRepresentation ConvexPolyhedron
Used by the contact generator to make contacts with other convex polyhedra for example.
getter/setter pair
halfExtents Vec3
The half extents of the box.
getter/setter pair
hashCode int
The hash code for this object.
no setterinherited
id int
Identifier of the Shape.
getter/setter pairinherited
material Material?
Optional material of the shape that regulates contact properties.
getter/setter pairinherited
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
type ShapeType
The type of this shape. Must be set to an int > 0 by subclasses.
getter/setter pairinherited

Methods

calculateLocalInertia(num mass, [Vec3? target]) Vec3
Calculate the inertia of the box.
override
calculateWorldAABB(Vec3 pos, Quaternion quat, Vec3 min, Vec3 max) → void
@todo use abstract for these kind of methods
override
forEachWorldCorner(Vec3 pos, Quaternion quat, void callback(num x, num y, num z)) → void
getSideNormals(List<Vec3> sixTargetVectors, [Quaternion? quat]) List<Vec3>
Get the box 6 side normals @param sixTargetVectors An array of 6 vectors, to store the resulting side normals in. @param quat Orientation to apply to the normal vectors. If not provided, the vectors will be in respect to the local frame.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toString() String
A string representation of this object.
inherited
updateBoundingSphereRadius() → void
Computes the bounding sphere radius. The result is stored in the property .boundingSphereRadius
override
updateConvexPolyhedronRepresentation() → void
Updates the local convex polyhedron representation used for some collisions.
volume() double
Returns the volume of the box.
override

Operators

operator ==(Object other) bool
The equality operator.
inherited

Static Methods

calculateInertia(Vec3 halfExtents, num mass, Vec3 target) Vec3