Build a cloth or rope physics simulation in the browser using particles connected by distance constraints.
Add interactive physics-based animations to a web page, like objects that swing, bounce, or sag naturally.
Create fractal tree or spiderweb visualizations in a browser canvas using the included example scenes.
verlet-js is a small physics engine written in JavaScript that simulates how objects move and interact in two dimensions. It is based on a technique called Verlet integration, a mathematical method for calculating the positions of particles over time that tends to produce stable, believable results without requiring complex velocity tracking. The engine works by giving you three basic building blocks: particles, distance constraints, and angular constraints. A particle is a point in space with a position. A distance constraint keeps two particles a fixed distance apart. An angular constraint controls the angle between connected particles. By combining these primitives in different arrangements, you can build a wide range of physical simulations, from rigid geometric shapes to flexible structures like cloth or rope. The repository includes four example simulations: a basic shapes demo that serves as a starting point, fractal trees where branches are connected by constraints, a cloth simulation made of a grid of particles, and a spiderweb. These examples show the range of what the engine can produce from its simple component set. The code is organized into four files: a 2D vector math implementation, the constraint logic, the main engine, and a collection of pre-built objects like triangles, circles, and tires. It is available as an npm package. The README is short, and the project appears to be a self-contained demonstration rather than a production physics library with active development. The README is brief and the project description is sparse beyond what the examples demonstrate. It is released under the MIT license.
← subprotocol on gitmyhub — every repo by this author, as a profile.
Verify against the repo before relying on details.