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

    Properties

    debugDraw: boolean = true

    Accessors

    • 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

    Methods

    • 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