whatisgithub

What is verlet-js?

subprotocol/verlet-js — explained in plain English

Analysis updated 2026-06-26

3,784JavaScriptAudience · developerComplexity · 2/5LicenseSetup · easy

In one sentence

A small JavaScript physics engine for 2D browser simulations, combine particles and constraints to create cloth, ropes, rigid shapes, or spiderwebs that move and interact realistically on a canvas.

Mindmap

mindmap
  root((verlet-js))
    What it does
      2D physics
      Browser-based
      Particle system
    Primitives
      Particles
      Distance constraints
      Angular constraints
    Examples
      Cloth simulation
      Fractal trees
      Spiderweb
    Tech
      Plain JavaScript
      npm package
Click or tap to explore — scroll the page freely

Code map

Detail Auto

An interactive map of this repo's files and how they connect — its source is parsed live in your browser. Click Visualize to build it.

filefunction / class

What do people build with it?

USE CASE 1

Build a cloth or rope physics simulation in the browser using particles connected by distance constraints.

USE CASE 2

Add interactive physics-based animations to a web page, like objects that swing, bounce, or sag naturally.

USE CASE 3

Create fractal tree or spiderweb visualizations in a browser canvas using the included example scenes.

What is it built with?

JavaScript

How does it compare?

subprotocol/verlet-js0hq/webgptxotahal/react-native-material-ui
Stars3,7843,7853,785
LanguageJavaScriptJavaScriptJavaScript
Setup difficultyeasymoderateeasy
Complexity2/53/52/5
Audiencedeveloperdevelopervibe coder

Figures from each repo's GitHub metadata at analysis time.

How do you get it running?

Difficulty · easy Time to first run · 30min
Free to use in any project, personal or commercial, as long as you keep the copyright notice.

So what is it?

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.

Copy-paste prompts

Prompt 1
Using verlet-js, write JavaScript code to create a cloth simulation made of a grid of particles connected by distance constraints.
Prompt 2
How do I add a swinging rope made of particles to a browser canvas using verlet-js?
Prompt 3
Modify the verlet-js circle object to bounce off the edges of the canvas instead of falling off screen.
Prompt 4
How does Verlet integration work in verlet-js, and why does it produce stable physics without explicitly tracking velocity?
Prompt 5
Create an interactive verlet-js demo where the user can click to pin or release individual particles in a cloth simulation.

Frequently asked questions

What is verlet-js?

A small JavaScript physics engine for 2D browser simulations, combine particles and constraints to create cloth, ropes, rigid shapes, or spiderwebs that move and interact realistically on a canvas.

What language is verlet-js written in?

Mainly JavaScript. The stack also includes JavaScript.

What license does verlet-js use?

Free to use in any project, personal or commercial, as long as you keep the copyright notice.

How hard is verlet-js to set up?

Setup difficulty is rated easy, with roughly 30min to a first successful run.

Who is verlet-js for?

Mainly developer.

Open on GitHub → Ask about another repo

This repo across BitVibe Labs

Verify against the repo before relying on details.