cannon_physics library

Classes

AABB
Axis aligned bounding box class.
ArrayCollisionMatrix
Collision "matrix". It's actually a triangular-shaped array of whether two bodies are touching this step, for reference next step
AxisAngle
Body
Base class for all body types. @example; final shape = CANNON.Sphere(1); final body = CANNON.Body({ 1 *mass; shape,; }) world.addBody(body);
BodyEvent
Box
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)
Broadphase
Base class for broadphase implementations @author schteppe
CollideEvent
ConeTwistConstraint
A Cone Twist constraint, useful for ragdolls.
Constraint
Constraint base class
ContactEquation
Contact/non-penetration constraint equation
ContactEvent
ContactMaterial
Defines what happens when two materials meet. @todo Refactor materials to materialA and materialB
ConvexOptions
ConvexPolyhedron
A set of polygons describing a convex shape.
ConvexPolyhedronContactPoint
Cylinder
Cylinder class. @example const radiusTop = 0.5 const radiusBottom = 0.5 const height = 2 const numSegments = 12 const cylinderShape = new CANNON.Cylinder(radiusTop, radiusBottom, height, numSegments) const cylinderBody = new CANNON.Body({ mass: 1, shape: cylinderShape }) world.addBody(cylinderBody)
DistanceConstraint
Constrains two bodies to be at a constant distance from each others center of mass.
Equation
Equation base class.
Event
EventTarget
Base class for objects that dispatches events.
FrictionEquation
Constrains the slipping in a contact along a tangent
GridBroadphase
Axis aligned uniform grid broadphase. @todo Needs support for more than just planes and spheres.
GSSolver
Constraint equation Gauss-Seidel solver. @todo The spook parameters should be specified for each constraint, not globally. @see https://www8.cs.umu.se/kurser/5DV058/VT09/lectures/spooknotes.pdf
Heightfield
Heightfield shape class. Height data is given as an array. These data points are spread out evenly with a given distance. @todo Should be possible to use along all axes, not just y @todo should be possible to scale along all axes @todo Refactor elementSize to elementSizeX and elementSizeY
HeightfieldPillar
HingeConstraint
Hinge constraint. Think of it as a door hinge. It tries to keep the door in the correct place and with the correct orientation.
JacobianElement
An element containing 6 entries, 3 spatial and 3 rotational degrees of freedom.
LockConstraint
Lock constraint. Will remove all degrees of freedom between the bodies.
Mat3
A 3x3 matrix. Authored by {@link http://github.com/schteppe/ schteppe}
Material
Defines a physics material.
NaiveBroadphase
Naive broadphase implementation, used in lack of better ones.
Narrowphase
Helper class for the World. Generates ContactEquations. @todo Sphere-ConvexPolyhedron contacts @todo Contact reduction @todo should move methods to prototype
ObjectCollisionMatrix
Records what objects are colliding with each other
Particle
Particle shape. @example const particleShape = new CANNON.Particle() const particleBody = new CANNON.Body({ mass: 1, shape: particleShape }) world.addBody(particleBody)
Plane
A plane, facing in the Z direction. The plane has its surface at z=0 and everything below z=0 is assumed to be solid plane. To make the plane face in some other direction than z, you must put it inside a Body and rotate that body. See the demos. @example const planeShape = new CANNON.Plane() const planeBody = new CANNON.Body({ mass: 0, shape: planeShape }) planeBody.quaternion.setFromEuler(-Math.PI / 2, 0, 0) // make it face up world.addBody(planeBody)
PointToPointConstraint
Connects two bodies at given offset points. @example const bodyA = Body({ mass: 1 }) const bodyB = Body({ mass: 1 }) bodyA.position.set(-1, 0, 0) bodyB.position.set(1, 0, 0) bodyA.addShape(shapeA) bodyB.addShape(shapeB) world.addBody(bodyA) world.addBody(bodyB) const localPivotA = Vec3(1, 0, 0) const localPivotB = Vec3(-1, 0, 0) const constraint = PointToPointConstraint(bodyA, localPivotA, bodyB, localPivotB) world.addConstraint(constraint)
Polygon
Pool
For pooling objects that can be reused.
Profile
Quaternion
A Quaternion describes a rotation in 3D space. The Quaternion is mathematically defined as Q = xi + yj + z*k + w, where (i,j,k) are imaginary basis vectors. (x,y,z) can be seen as a vector related to the axis of rotation, while the real multiplier, w, is related to the amount of rotation. @param x Multiplier of the imaginary basis vector i. @param y Multiplier of the imaginary basis vector j. @param z Multiplier of the imaginary basis vector k. @param w Multiplier of the real part. @see http://en.wikipedia.org/wiki/Quaternion
Ray
A line in 3D space that intersects bodies and return points.
RaycastResult
Storage for Ray casting data
RaycastVehicle
Vehicle helper class that casts rays from the wheel positions towards the ground and applies forces.
RayOptions
RayOptions
RigidVehicle
Simple vehicle helper class with spherical rigid body wheels.
RotationalEquation
Rotational constraint. Works to keep the local vectors orthogonal to each other in world space.
RotationalMotorEquation
Rotational motor constraint. Tries to keep the relative angular velocity of the bodies to a given value.
SAPBroadphase
Sweep and prune broadphase along one axis.
Shape
Base class for shapes
ShapeContactEvent
Solver
Constraint equation solver base class.
Sphere
Spherical shape @example const radius = 1 const sphereShape = new CANNON.Sphere(radius) const sphereBody = new CANNON.Body({ mass: 1, shape: sphereShape }) world.addBody(sphereBody)
SPHSystem
Smoothed-particle hydrodynamics system @todo Make parameters customizable in the constructor
SplitSolver
Splits the equations into islands and solves them independently. Can improve performance.
SplitSolverNode
Spring
A spring, connecting two bodies. @example const spring = Spring(boxBody, sphereBody, { restLength: 0, stiffness: 50, damping: 1, })
TorusGeometry
Transform
Transformation utilities.
Trimesh
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)
Vec3
3-dimensional vector @example final v = new Vec3(1, 2, 3) console.log('x=' + v.x) // x=1
Vec3Pool
WheelInfo
WheelInfo
WheelRaycastResult
World
The physics world

Enums

BodySleepStates
BodyTypes
CollisionType
Order
RayMode
RAY_MODES
ShapeType
The available shape types.

Properties

antipNeg Vec3
final
chassisVelocityAtContactPoint Vec3
final
vec3TangentsN Vec3
final
vec3TangentsRandVec Vec3
final

Typedefs

RaycastCallback = void Function(RaycastResult result)