Skip to content

@ue-too/dynamics / index / PinJoint

Class: PinJoint ​

Defined in: constraint.ts:149

Pin joint connecting two bodies together.

Remarks ​

Connects two bodies at specified anchor points. The bodies can rotate relative to each other around the joint.

Useful for creating chains, ragdolls, and mechanical linkages.

Example ​

Create a chain

typescript
const link1 = new Circle({ x: 0, y: 0 }, 10);
const link2 = new Circle({ x: 30, y: 0 }, 10);

const joint = new PinJoint(
  link1,
  link2,
  { x: 10, y: 0 },   // Right edge of link1
  { x: -10, y: 0 }   // Left edge of link2
);

world.addRigidBody('link1', link1);
world.addRigidBody('link2', link2);
world.addConstraint(joint);

Implements ​

Constructors ​

Constructor ​

new PinJoint(bodyA, bodyB, anchorA, anchorB): PinJoint

Defined in: constraint.ts:155

Parameters ​

bodyA ​

RigidBody

bodyB ​

RigidBody

anchorA ​

Point

anchorB ​

Point

Returns ​

PinJoint

Methods ​

enforce() ​

enforce(dt): void

Defined in: constraint.ts:167

Enforces the constraint for one timestep.

Parameters ​

dt ​

number

Timestep in seconds

Returns ​

void

Implementation of ​

Constraint.enforce


solvePinJointConstraint() ​

solvePinJointConstraint(dt): void

Defined in: constraint.ts:171

Parameters ​

dt ​

number

Returns ​

void