RUBBLE-X is a browser-based 3D simulation of a hexapod rescue robot that stitches itself into an armoured sphere. It was built for the Kiroween 2026 Frankenstein category, and it's a deep dive into what you can do with React Three Fiber, TypeScript, and a well-structured state machine.

The core idea: a six-legged robot crawls through a disaster zone, senses a survivor, transforms into a rolling armoured sphere, and performs rescue operations using swappable magnetic mission pods. All simulated, all in the browser.

🎮 Live Demo: https://rubble-x.vercel.app/

The 3D Scene

The scene is built with React Three Fiber and features:

  • Concrete slabs, fractured beams, and a low-clearance tunnel
  • Unstable debris and hazard perimeter rings
  • A survivor beacon with a pulsing glow
  • A tactical grid overlay

Three camera presets are available: Follow Robot, Tactical Orbit, and Top-Down Map. The camera system uses smooth lerping between targets, so switching feels cinematic rather than jarring.

The Robot Rig

The robot is a single hierarchical model with:

  • A titanium chassis and cyan sensor turret
  • Six legs, each with coxa, femur, and tibia segments
  • Six hinged armour shells with lock rings
  • A rear magnetic module bay for mission pods

The gait system uses a tripod gait in CRAWLING mode, switching to a wide-splay low crouch in ADAPTIVE mode for tight spaces. The transformation sequence takes about 3 seconds across five stages, with each armour shell rotating and locking in sequence.

Operating Modes

The state machine drives four modes:

  1. CRAWLING - Standard tripod gait, full speed
  2. ADAPTIVE - Low crouch, wide splay for tunnels
  3. TRANSFORMING - 3-second, 5-stage shell closure
  4. SPHERICAL - Rolling armoured sphere, no leg animation

Mode transitions are gated by the state machine. You can't start a rescue op while transforming, and the sphere can't crawl. This is enforced in code, not just in the UI.

Sensors and Confidence Scoring

Five sensor channels react to proximity:

  • Optical (visual detection)
  • Thermal (°C)
  • Acoustic (dB)
  • CO₂ (ppm)
  • LiDAR (m)

Survivor confidence is computed from a weighted combination of these sensors, clamped to 0–100 and capped at 95% to reflect the uncertainty of real-world detection. The clamping logic handles edge cases like NaN and Infinity inputs, which is tested explicitly with fast-check property-based tests.

Rescue Operations and Safety Rules

This is where the project gets interesting from an engineering perspective. Every rescue action follows a strict approval flow:

  1. The operator selects an action (e.g., "Clear loose debris")
  2. The system checks preconditions (correct pod docked, in range, not in emergency stop)
  3. The operator explicitly approves
  4. The clock attempts the action
  5. Only COMPLETED status changes the world

Preconditions are re-checked on approval AND throughout the attempt. Approving with nothing pending is a no-op. This pattern comes from real safety-critical systems where you never trust a single check.

Emergency stop sets velocity to exactly 0 in all four modes, blocks motion until release, rejects any pending approval, and fails any action under way. Releasing the stop does not auto-resume the failed action.

Medical Reachback

Unlocks at 50% simulated confidence. The flow:

  1. Simulated triage (vitals, injury classification)
  2. Doctor-relay toggle (simulated telemedicine)
  3. First-aid delivery (requires Medical Pod docked + operator approval)

The medical pod is one of two swappable modules. The other is the Debris Gripper Pod. Only one can be docked at a time, and the bay physically shows which pod is installed.

Fault Simulation

Two fault modes are available:

  • Motor Fault - One leg goes limp, the gait compensates
  • Comms Loss - HUD goes stale, sensors freeze, a "NO LINK" banner appears

These aren't just visual effects. The fault state propagates through the simulation clock and affects which actions are available.

Project Structure

src/ app/ - Shell, header, view filters, keyboard hook components/ - RobotMesh, simulation/ (3D viewport), hud/ simulation/ - State machine, clock, mode logic sensors/ - Sensor model, confidence scoring, advisory rules types/ - Shared contracts (rubblex.ts) __tests__/ - Vitest + fast-check property-based tests 

The type contracts in src/types/rubblex.ts are the backbone. Every module imports from there, and the tests validate that the state machine respects those contracts.
@sumit0rn

What's Not Done

Honesty section:

  • No browser end-to-end test. Tests cover logic only. The 3D visuals were checked by hand in headless Edge.
  • No demo recording yet. A shot list with the required simulation disclosure is in docs/DEMO_SCRIPT.md.

Why This Matters

Building a simulation like this forced me to think about:

  • How to structure a real-time state machine in React without fighting the framework
  • How to make 3D transforms feel physical (lerping, easing, staged sequences)
  • How to enforce safety invariants in a system that's "just a simulation" but models real safety patterns
  • How to write property-based tests for continuous values (confidence scores, sensor readings)

The code is MIT licensed and open on GitHub. If you're working with React Three Fiber or building simulation UIs, the patterns here around state machine gating, approval flows, and fault injection might save you some headaches.

Built for Kiroween 2026, Frankenstein category. All rescue data is simulated. No actual robots were harmed.