Class PointToPointConstraint

Connects two bodies at given offset points.

Example

const bodyA = new Body({ mass: 1 })
const bodyB = new 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 = new Vec3(1, 0, 0)
const localPivotB = new Vec3(-1, 0, 0)
const constraint = new PointToPointConstraint(bodyA, localPivotA, bodyB, localPivotB)
world.addConstraint(constraint)

Hierarchy (view full)

Constructors

  • Parameters

    • bodyA: Body
    • pivotA: Vec3

      The point relative to the center of mass of bodyA which bodyA is constrained to.

    • bodyB: Body

      Body that will be constrained in a similar way to the same point as bodyA. We will therefore get a link between bodyA and bodyB. If not specified, bodyA will be constrained to a static point.

    • Optional pivotB: Vec3

      The point relative to the center of mass of bodyB which bodyB is constrained to.

    • Optional maxForce: number

      The maximum force that should be applied to constrain the bodies.

    Returns PointToPointConstraint

Properties

bodyA: Body

Body A.

bodyB: Body

Body B.

collideConnected: boolean

Set to false if you don't want the bodies to collide when they are connected.

equationX: ContactEquation
equationY: ContactEquation
equationZ: ContactEquation
equations: Equation[]

Equations to be solved in this constraint.

id: number
pivotA: Vec3

Pivot, defined locally in bodyA.

pivotB: Vec3

Pivot, defined locally in bodyB.

idCounter: number

Methods

  • Disables all equations in the constraint.

    Returns void

  • Enables all equations in the constraint.

    Returns void

  • Update all the equations with data.

    Returns void