explaingit

monteslu/box3d-wasm

Analysis updated 2026-05-18

15C++Audience · developerComplexity · 3/5LicenseSetup · easy

TLDR

A WebAssembly build of the Box3D physics engine that runs the same code in browsers and Node.js.

Mindmap

mindmap
  root((box3d-wasm))
    What it does
      Wraps Box3D physics engine
      Compiles to WebAssembly
      Runs in browser and Node
    Tech stack
      C++
      WebAssembly
      CMake
      Emscripten
    Use cases
      Game physics
      3D scene simulation
      Ragdolls and vehicles
    Audience
      Web developers
      Game developers
    Features
      Bodies and shapes
      Joints and motors
      Collision events
    Setup
      npm install
      Threaded or single threaded

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

Add realistic falling, colliding, and bouncing objects to a browser based 3D scene or game.

USE CASE 2

Simulate ragdolls, dominoes, or a drivable vehicle alongside a renderer like three.js.

USE CASE 3

Run physics simulations server side in Node.js without a browser.

What is it built with?

C++WebAssemblyJavaScriptNode.jsCMakeEmscripten

How does it compare?

monteslu/box3d-wasmhighdelay/activate-watermarkpaullagier/pala-one-firmware
Stars151515
LanguageC++C++C++
Setup difficultyeasymoderatehard
Complexity3/52/54/5
Audiencedevelopergeneraldeveloper

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

How do you get it running?

Difficulty · easy Time to first run · 30min

Threaded build needs cross origin isolation headers, otherwise plain npm install works.

Use freely for any purpose, including commercial use, as long as you keep the copyright notice.

In plain English

This project takes Box3D, a 3D physics engine originally written by Erin Catto (the same author behind the well known Box2D engine), and compiles it to WebAssembly so it can run inside a web browser or a Node.js app. The wrapper and build scripts are made by a different author, but the physics engine itself, including its design and behavior, comes entirely from Erin Catto's work, which is credited clearly in the project. You install it as a normal npm package called box3d-wasm. Once installed, you can create a physics world, add a ground and a falling box, and step the simulation forward in time to see objects move and collide, all using plain JavaScript objects for positions, rotations, and velocities. Because those objects use the same simple shape as libraries like three.js, results from the physics engine can be passed straight into a 3D rendering scene without extra conversion work. The package ships in two versions. One uses multiple worker threads for faster simulation when the browser or environment supports it, and the other runs single threaded everywhere else. The library automatically detects which one to use, though a developer can also choose a specific version directly. Using the threaded version in a browser requires setting two specific server headers so the page qualifies for the security mode that threads need. Beyond the basics, the engine supports different body types such as static, moving, and fully simulated objects, several shape types like boxes, spheres, capsules, and custom hull shapes, and a range of joints for connecting bodies together, such as hinges and motors. It also reports events for collisions and sensor triggers, and includes a way to apply an explosion force to nearby objects. Building the project from source requires the Emscripten toolchain, CMake, and a recent version of Node, and is only necessary for contributors who want to modify the underlying build rather than just use the published package. The wrapper code is MIT licensed, and the Box3D engine it wraps is also MIT licensed by its original author, with that license included in the package.

Copy-paste prompts

Prompt 1
Show me how to set up a box3d-wasm world with a ground plane and one falling box.
Prompt 2
Help me connect box3d-wasm physics output to a three.js scene so objects render where the physics engine places them.
Prompt 3
Explain how to enable the multithreaded deluxe build of box3d-wasm and what server headers it needs.
Prompt 4
Write a joint example using box3d-wasm that creates a motorized hinge between two bodies.

Frequently asked questions

What is box3d-wasm?

A WebAssembly build of the Box3D physics engine that runs the same code in browsers and Node.js.

What language is box3d-wasm written in?

Mainly C++. The stack also includes C++, WebAssembly, JavaScript.

What license does box3d-wasm use?

Use freely for any purpose, including commercial use, as long as you keep the copyright notice.

How hard is box3d-wasm to set up?

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

Who is box3d-wasm for?

Mainly developer.

Open on GitHub → Explain another repo

This repo across BitVibe Labs

Verify against the repo before relying on details.