nape-js API
    Preparing search index...

    Class WeldJoint

    Weld joint — constrains two bodies to maintain a fixed relative position and relative angle, effectively gluing them together while still treating them as separate physics objects.

    The phase parameter sets the desired relative angle offset in radians. When phase = 0 both bodies maintain the angle difference they had at the time the joint was created.

    const joint = new WeldJoint(
    body1, body2,
    Vec2.weak(10, 0), // attach point on body1
    Vec2.weak(-10, 0), // attach point on body2
    );
    joint.space = space;

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

    Hierarchy (View Summary)

    Index

    Constructors

    • Parameters

      • body1: Body | null

        First body, or null for a static world anchor.

      • body2: Body | null

        Second body, or null for a static world anchor.

      • anchor1: Vec2

        Anchor point in body1's local space (disposed if weak).

      • anchor2: Vec2

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

      • phase: number = 0.0

        Target relative angle offset in radians. Default 0.0.

      Returns WeldJoint

    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