nape-js API
    Preparing search index...

    Class LineJoint

    Line joint — constrains body2's anchor to slide along a line defined by body1's anchor and direction, within [jointMin, jointMax].

    The direction is specified in body1's local space. The joint allows one translational degree of freedom (along the line) and removes the other.

    // Allow body2 to slide vertically relative to body1
    const joint = new LineJoint(
    body1, body2,
    Vec2.weak(0, 0), // anchor on body1
    Vec2.weak(0, 0), // anchor on body2
    Vec2.weak(0, 1), // direction (local to body1)
    -50, 50, // allowed travel range
    );
    joint.space = space;

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

    Hierarchy (View Summary)

    Index

    Constructors

    • Parameters

      • body1: Body | null

        First body (defines the line), or null for a static world line.

      • body2: Body | null

        Second body (slides along the line), or null for a static anchor.

      • anchor1: Vec2

        Origin of the line in body1's local space (disposed if weak).

      • anchor2: Vec2

        Anchor on body2 in body2's local space (disposed if weak).

      • direction: Vec2

        Direction of the line in body1's local space (disposed if weak).

      • jointMin: number

        Minimum allowed displacement along the line.

      • jointMax: number

        Maximum allowed displacement along the line.

      Returns LineJoint

    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

    • 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

    • get userData(): Record<string, unknown>

      Arbitrary user data attached to this constraint. Lazily initialized to {} on first access.

      Returns Record<string, unknown>

    Methods