A small playground for poking at three.js (via react-three-fiber)
- three.js + react-three-fiber — declarative scene graph,
useFrame-based per-system update loop, shared mutable state for transforms that shouldn't trigger React re-renders - GLB model loading with
useGLTF(F-35, ~6MB) - Procedural terrain — scattered noisy mesas + partial canyon walls generated at startup; AABB colliders extracted from the same meshes
- Free-flight controls — quaternion-composed pitch/roll/yaw in jet-local space, smoothed input, speed lerp, world wrap
- Chase camera with lerp lag and speed-shake
- Particle systems — countermeasure flares (F-key spherical burst), drifting dust
- State split — zustand for things that trigger re-renders (HUD, game phase), plain singleton object for per-frame mutable data (positions, quaternions, basis vectors, colliders)
| Key | Action |
|---|---|
| W / S | Pitch |
| A / D | Roll |
| Q / E | Turn |
| Space / Shift | Boost |
| F | Flares |
| P | Pause |
| Enter | Restart (on game over) |
yarn
yarn devsrc/
TrenchRun.tsx # <Canvas> tree wiring everything together
state/ # zustand store + mutable flight singleton + input hook
scene/ # Sky, Lights, Terrain
jet/ # F-35 GLB loader
systems/ # Flight, Collision, ChaseCamera, Flares, Dust, HudSync
hud/ # HUD + overlays
utils/constants.ts # tunable knobs
