This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
This is a MuJoCo WebAssembly simulation project with a Next.js frontend that provides real-time physics simulation in the browser. The project integrates MuJoCo physics engine via WebAssembly with interactive 3D visualization using Three.js.
/frontend- Next.js 15 application with React 19/packages/mujoco-core- TypeScript wrapper for MuJoCo WASM runtime/mujoco_wasm- MuJoCo WebAssembly implementation and examples/de_dust2-cs-map- CS map assets for simulation environments
- Frontend: Next.js app with dynamic MuJoCo scene viewer at
/mujocoroute - MuJoCo Core Package: Provides TypeScript bindings and worker support for MuJoCo WASM
- MuJoCo Examples: Interactive demos with drone control (Skydio X2) and robot simulations (Boston Dynamics Spot)
cd frontend
npm install
npm run dev # Development server with Turbopack
npm run build # Production build with Turbopack
npm run start # Start production server
npm run lint # Run ESLintcd packages/mujoco-core
npm install
npm run build # Sync WASM files and compile TypeScript
npm run lint # Type check without building
npm run clean # Remove dist directory
npm run sync:wasm # Only sync WASM files from mujoco_wasm/dist- Build the core package first:
cd packages/mujoco-core && npm install && npm run build - Install frontend dependencies:
cd frontend && npm install - Start development:
npm run dev
The MuJoCo WASM files are built from C++ source. Pre-built artifacts are located in mujoco_wasm/dist/. The sync-wasm script automatically copies these files to the core package.
- Start the Next.js development server:
cd frontend && npm run dev - Access the simulation at
http://localhost:3000/mujoco
- Scene files are XML-based MuJoCo models located in
mujoco_wasm/examples/scenes/ - Current scenes include Skydio X2 drone and Boston Dynamics Spot robot
- Scene viewer uses Three.js for rendering and OrbitControls for camera navigation
Space: AscendZ: DescendW/S: Pitch forward/backwardA/D: Roll left/right
The frontend loads MuJoCo via the createMujocoModule function which:
- Locates WASM files at
/mujoco/public path - Mounts a working filesystem for scene assets
- Returns initialized module and filesystem access
Scenes are defined in mujoco_wasm/examples/scenes/index.json and loaded dynamically. Each scene includes:
- XML model definition
- Asset files (meshes, textures)
- Control parameters
- Base config at
/tsconfig.base.jsonwith strict mode enabled, ES2020 target, and NodeNext module resolution - Package-specific configs extend the base
- All packages use ES modules
Currently no automated tests are configured. Manual testing via the development server.
- WASM files must be synced from
mujoco_wasm/disttopackages/mujoco-core/distbefore building the core package (usenpm run sync:wasm) - The frontend uses dynamic imports for the scene viewer to avoid SSR issues with WebGL
- Control smoothing is applied to drone inputs for realistic physics behavior
- The frontend depends on the local mujoco-core package via
file:../packages/mujoco-core - MuJoCo WASM files are served from the
/mujoco/public path in the frontend