First body, or null for a static world anchor.
Second body, or null for a static world anchor.
Anchor point in body1's local space (disposed if weak).
Anchor point in body2's local space (disposed if weak).
Minimum allowed distance (must be >= 0).
Maximum allowed distance (must be >= jointMin).
The set of CbTypes assigned to this constraint. Used to filter which listeners respond to this constraint's events.
Whether the constraint's simulation component is currently sleeping.
Only valid when the constraint is active and in a space — throws otherwise.
Maximum allowed distance between anchors (pixels, must be >= jointMin).
Minimum allowed distance between anchors (pixels, must be >= 0).
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.
The clamp only applies to soft constraints (stiff = false): a stiff
constraint ignores maxForce unless breakUnderForce is set.
MotorJoint and SpringJoint are the exception and always clamp.
Must be >= 0. Infinity disables the limit.
Arbitrary user data attached to this constraint.
Lazily initialized to {} on first access.
Creates and returns a copy of this constraint with the same parameters. The copy is not automatically added to a space.
Invokes fn once for each distinct body linked to this constraint.
Constrains the distance between two anchor points (one on each body) within a range.
Enforces:
jointMin ≤ distance(anchor1, anchor2) ≤ jointMaxWhen
jointMin === jointMaxthe distance is fixed (like a rigid rod). WhenjointMin < jointMaxthe joint acts as a slack rope / elastic band.Anchors are specified in each body's local coordinate space.
Example
Fully modernized — uses ZPP_DistanceJoint directly (extracted to TypeScript).