The Matter.Constraint module contains methods for creating and manipulating constraints. Constraints are used for specifying that a fixed distance must be maintained between two bodies (or a body and a fixed world-space position). The stiffness of constraints can be modified to create springs or elastic.

See the included usage examples.

Hierarchy

  • default

Constructors

Properties

_minLength: number = 0.000001
_torqueDampen: number = 1
_warming: number = 0.4

Methods

  • Creates a new constraint. All properties have default values, and many are pre-calculated automatically based on other properties. To simulate a revolute constraint (or pin joint) set length: 0 and a high stiffness value (e.g. 0.7 or above). If the constraint is unstable, try lowering the stiffness value and / or increasing engine.constraintIterations. For compound bodies, constraints must be applied to the parent body (not one of its parts). See the properties section below for detailed information on what you can pass via the options object.

    Parameters

    Returns IConstraint

    constraint

    Method

    create

  • Returns the current length of the constraint. This is the distance between both of the constraint's end points. See constraint.length for the target rest length.

    Parameters

    Returns number

    the current length

    Method

    currentLength

  • Performs body updates required after solving constraints.

    Parameters

    Returns void

    Method

    postSolveAll

Generated using TypeDoc