nape-js API
    Preparing search index...

    Class PulleyJoint

    Pulley joint — constrains the weighted sum of two distances to remain within [jointMin, jointMax]:

    jointMin ≤ distance(anchor1, anchor2) + ratio * distance(anchor3, anchor4) ≤ jointMax

    This models a rope-and-pulley system where lifting one side lowers the other. All four anchors are in the local space of their respective bodies.

    // Classic pulley: as body2 moves away from anchor1, body4 moves toward anchor3
    const joint = new PulleyJoint(
    body1, body2, body3, body4,
    Vec2.weak(0,0), Vec2.weak(0,0),
    Vec2.weak(0,0), Vec2.weak(0,0),
    0, 200, // total rope length
    );
    joint.space = space;

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

    Hierarchy (View Summary)

    Index
    • Parameters

      • body1: Body | null

        First body (pulley side 1), or null for a static anchor.

      • body2: Body | null

        Second body (pulley side 1), or null for a static anchor.

      • body3: Body | null

        Third body (pulley side 2), or null for a static anchor.

      • body4: Body | null

        Fourth body (pulley side 2), or null for a static anchor.

      • anchor1: Vec2

        Anchor on body1 in local space (disposed if weak).

      • anchor2: Vec2

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

      • anchor3: Vec2

        Anchor on body3 in local space (disposed if weak).

      • anchor4: Vec2

        Anchor on body4 in local space (disposed if weak).

      • jointMin: number

        Minimum allowed total rope length (must be >= 0).

      • jointMax: number

        Maximum allowed total rope length (must be >= jointMin).

      • ratio: number = 1.0

        Weight of the second distance segment. Default 1.0.

      Returns PulleyJoint

    debugDraw: boolean = true
    • get damping(): number

      Damping ratio for soft constraints (stiff = false).

      0 = undamped (oscillates freely), 1 = critically damped. Values > 1 are overdamped. Must be >= 0. Ignored when stiff is true.

      Returns number

      1

    • set damping(value: number): void

      Parameters

      • value: number

      Returns void

    • get frequency(): number

      Spring frequency in Hz for soft constraints (stiff = false).

      Higher values make the spring stiffer; lower values make it bouncier. Must be > 0. Ignored when stiff is true.

      Returns number

      10

    • set frequency(value: number): void

      Parameters

      • value: number

      Returns void

    • 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>