# LapMachine

LapMachine is a browser-based racing game built with Three.js. The simulation runs entirely in the browser. A `requestAnimationFrame` loop drives the simulation, and Three.js renders each frame. React handles the menus and heads-up display (HUD). Separate systems handle Ammo.js physics, vehicle movement, track generation, race rules, and engine sound.

## Links

- Website at [lapmachine.com](https://lapmachine.com)
- Source code at [github.com/freecattle/lapmachine](https://github.com/freecattle/lapmachine)

## Features

- Race on a new, randomly generated track every session, with plenty of turns and elevation changes.
- Drive a raycast vehicle with stability and traction assists.
- Choose between automatic and manual shifting.
- Pick from three engines, each with a distinct sound.
- Race against the ghost of your fastest valid lap.
- Cross enough forward validation sectors to record a valid lap.
- Play on desktop or mobile using keyboard or touch controls.
- Drag to adjust the camera.

## Controls

| Key       | Action                                 |
| --------- | -------------------------------------- |
| `W`       | Accelerate                             |
| `S`       | Brake or reverse                       |
| `A` / `D` | Steer left or right                    |
| `Q` / `E` | Shift down or up (manual transmission) |
| `R`       | Restart                                |

You can also use `↓` / `↑` or `-` / `+` to shift gears. Touch controls are available on mobile devices.
