A 2D rigid body physics engine for JavaScript with collision detection, contacts, friction, motors, springs, and advanced constraints.
p2.js is a feature-rich 2D rigid body physics engine written entirely in JavaScript. It provides realistic physics simulation for web and Node.js applications, enabling developers to create interactive games, simulations, and visualizations with accurate motion, collisions, and physical interactions.
JavaScript developers building 2D interactive web or Node.js applications requiring physics simulation, such as game developers, simulation creators, and data visualization engineers.
Developers choose p2.js for its comprehensive feature set including advanced constraints, various body types, and performance optimizations like island solving and CCD, all while being renderer-agnostic and easy to integrate.
JavaScript 2D physics library
Open-Awesome is built by the community, for the community. Submit a project, suggest an awesome list, or help improve the catalog on GitHub.
Includes motors, springs, and specialized constraints like GearConstraint and PrismaticConstraint, enabling complex mechanical simulations as shown in demos like car and ragdoll.
Features island solving, sleep states, and continuous collision detection (CCD) to optimize simulations, especially in scenes with many inactive bodies, as highlighted in the demos.
Designed to work with any JavaScript renderer, evidenced by examples with Canvas and Pixi.js, allowing flexibility in visualization without lock-in.
Supports multiple shape types including Circle, Box, Convex, and Heightfield, with detailed collision pair compatibility for realistic interactions.
The collision compatibility table shows 'todo' entries for several shape interactions, such as Line vs Box and Capsule vs Line, limiting certain simulations until implemented.
Requires developers to manually integrate a separate renderer, adding complexity and setup time compared to engines with integrated graphics, as seen in the separate demo framework.
While API docs are provided, the README lacks comprehensive tutorials or guides for common use cases, relying primarily on demos and examples for learning.