Difference Between pointA and offsetA in Matter.js

This article provides a concise overview of how anchor points and offsets function within Matter.js constraints. It clarifies the exact role of the native pointA property, explains why offsetA is commonly referenced in physics setups, and breaks down how coordinates are calculated depending on whether a constraint is attached to a moving body or fixed to the world canvas.

Understanding pointA in Matter.js

In standard Matter.js, pointA is a native property of a Constraint. It defines where the constraint connects relative to the first body (bodyA).

The behavior of pointA depends entirely on whether bodyA is provided:

// Native Matter.js constraint
const constraint = Matter.Constraint.create({
    bodyA: myBody,
    pointA: { x: 10, y: 0 }, // Local offset 10px to the right of myBody.position
    pointB: { x: 400, y: 200 } // Fixed world anchor if bodyB is omitted/null
});

What is offsetA?

offsetA is not an official property in the native Matter.js core engine. Instead, it appears in engine wrappers (such as game engines using Matter.js as their backend, like Phaser), custom utility libraries, or developer code.

Because pointA dynamically shifts between world coordinates and local offsets depending on the presence of bodyA, developers and wrapper libraries often introduce offsetA to make intentions explicit. When present in an API or custom implementation, offsetA strictly represents the relative vector from the center of bodyA, preventing accidental interpretation as a global world coordinate.

Summary of Differences