Skip to content

@ue-too/dynamics / index / PinJoint

類別: PinJoint

定義於: constraint.ts:149

Pin joint connecting two bodies together.

備註

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.

範例

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);

實作

建構函式

建構函式

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

定義於: constraint.ts:155

參數

bodyA

RigidBody

bodyB

RigidBody

anchorA

Point

anchorB

Point

回傳

PinJoint

方法

enforce()

enforce(dt): void

定義於: constraint.ts:167

Enforces the constraint for one timestep.

參數

dt

number

Timestep in seconds

回傳

void

實作了

Constraint.enforce


solvePinJointConstraint()

solvePinJointConstraint(dt): void

定義於: constraint.ts:171

參數

dt

number

回傳

void