How Matter.Body.scale Affects Properties in Matter.js

In Matter.js, the Matter.Body.scale(body, scaleX, scaleY, [point]) function alters both the visual footprint and the underlying physical characteristics of a rigid body. When a body is scaled, the physics engine does not simply stretch the render geometry; it recalculates geometric dimensions, mass-related attributes, and collision properties. Understanding these automatic updates is essential for maintaining realistic physics simulation and avoiding unexpected behaviors during runtime.

Geometric and Positional Updates

When Matter.Body.scale is invoked, it directly modifies the structural coordinates of the body:

Area and Mass Recalculation

By default, Matter.js assumes that a body's material composition remains constant when its size changes:

Moment of Inertia Updates

A change in size has a dramatic effect on a body's rotational behavior:

Compound Bodies

When scaling a compound body (a body consisting of multiple sub-parts):

Properties That Remain Unchanged

Matter.Body.scale modifies only geometric and mass-derived values. The following physical parameters remain completely unaffected: