nape-js API
    Preparing search index...

    Class Constraint

    Base class for all physics constraints (joints).

    Constraints restrict the relative motion of two bodies. This class provides properties common to all joint types: active, stiff, frequency, damping, maxForce, maxError, breakUnderForce, breakUnderError, removeOnBreak, isSleeping, space, compound, cbTypes, and userData.

    Cannot be instantiated directly — use one of the concrete joint subclasses: AngleJoint, DistanceJoint, LineJoint, MotorJoint, PivotJoint, PulleyJoint, WeldJoint, or UserConstraint.

    Soft vs. stiff constraints:

    • stiff = true (default): the constraint is enforced rigidly.
    • stiff = false: uses a spring model with frequency (Hz) and damping (ratio).

    Fully modernized — uses ZPP_Constraint directly (extracted to TypeScript).

    Hierarchy (View Summary)

    Index
    debugDraw: boolean = true
    • get isSleeping(): boolean

      Whether the constraint's simulation component is currently sleeping.

      Only valid when the constraint is active and in a space — throws otherwise.

      Returns boolean

    • get maxForce(): number

      Maximum force (in Newtons) the constraint may apply per step.

      When the required force exceeds this value the constraint becomes slack. If breakUnderForce is true the constraint breaks instead. Must be >= 0. Infinity disables the limit.

      Returns number

      Infinity

    • set maxForce(value: number): void

      Parameters

      • value: number

      Returns void

    • The impulse applied by this constraint in the last simulation step.

      The shape of the returned MatMN depends on the constraint's degrees of freedom (e.g., 1×1 for AngleJoint/MotorJoint, 2×1 for PivotJoint/LineJoint, 3×1 for WeldJoint).

      Returns MatMN | null