What Are the Three Main Types of Bodies Available in planck.js?

Planck.js, a popular 2D JavaScript physics engine ported from Box2D, provides three main body types to define how objects move and interact within a simulated physics world: static, kinematic, and dynamic. Choosing the correct body type for each object in your environment is essential for optimizing performance and achieving realistic simulation behavior.

Static Bodies

A static body does not move under the influence of simulation forces and behaves as if it has infinite mass. In planck.js, static bodies are treated with zero mass, zero inverse mass, and zero velocity.

Kinematic Bodies

A kinematic body is a hybrid type that moves according to its assigned velocity but remains unaffected by external forces or collisions. Like static bodies, they behave as though they have infinite mass.

Dynamic Bodies

A dynamic body is a fully simulated physical object that responds dynamically to the environment. It always possesses a finite, non-zero mass. If you attempt to assign a mass of zero to a dynamic body, planck.js automatically defaults its mass to one kilogram and prevents it from rotating.