A React + Three.js application integrated with a C++ physics engine via WebAssembly.
- Node.js (v20 or later recommended)
- Docker (for building the physics engine) OR Emscripten SDK installed locally
Install the dependencies:
npm installThe project uses a C++ physics engine compiled to WebAssembly. You need to compile it before running the app.
Run the following command from the project root:
docker run --rm -v $(pwd):/src emscripten/emsdk emcc src/physics/engine.cpp -o public/wasm/physics.js -lembind -s MODULARIZE=1 -s EXPORT_NAME='createPhysicsModule' -s ALLOW_MEMORY_GROWTH=1 -s ENVIRONMENT=web -O3If you have emcc in your path, you can run the build script directly:
cd src/physics
./build.sh
cd ../..You can build and run the entire application (including the physics engine compilation) with a single command:
docker build -t physics-engine . && docker run -p 8080:8080 physics-engineThen open http://localhost:8080 in your browser.
Start the development server:
npm run devOpen your browser at http://localhost:5173 (or the URL shown in the terminal).
To create a production build:
npm run buildThe output will be in the dist directory.