Skip to content

Latest commit

ย 

History

88 Commits

Folders and files

NameName
Last commit message
Last commit date
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

Virtual Steering

ย Virtual Steering

AAA Gesture-Controlled Racing โ€” The world's first browser-based gesture racing experience

Live Demo

TypeScript Three.js MediaPipe Hands Vite WebGL

Last Commit Repo Size AI Powered Open Source


Game Modes ยท Features ยท How It Works ยท Architecture ยท Tech Stack ยท Getting Started


Virtual Steering is a premium browser racing experience with a signature innovation: your hands are the steering wheel in Endless Survival mode. One cohesive game โ€” not four โ€” with a unified flow: PLAY โ†’ SELECT TRACK โ†’ SELECT MODE โ†’ RACE.

Race through three premium tracks (Cyber City, Mountain Highway, Space Highway) with dynamic weather, at 60 FPS on desktop and adaptive quality on mobile. Fall back to keyboard, touch, gyroscope, or phone-as-controller on any device.


๐ŸŽ๏ธ Game Modes

Mode Description Controls Track
Endless Survival Flagship gesture mode โ€” dodge traffic, chain combos, survive as long as possible โœ‹ Gesture (MediaPipe Hands) Cyber City / Mountain Highway / Space Highway
AI Race Competitive racing vs 5 named AI personalities with adaptive difficulty โŒจ๏ธ Keyboard / ๐ŸŽฎ Gamepad All 3 tracks (3 races per tournament)
You vs You (Time Trial) Race against your own best ghost โ€” delta timer, sector splits โŒจ๏ธ Keyboard / ๐ŸŽฎ Gamepad All 3 tracks
Multiplayer Up to 4 players online via WebRTC (PeerJS public cloud) โŒจ๏ธ Keyboard / ๐ŸŽฎ Gamepad / ๐Ÿ‘† Touch Endless Survival (no traffic)
Tournament Division ladder (Rookie โ†’ Pro โ†’ Elite โ†’ Champion), 3 races per division โŒจ๏ธ Keyboard / ๐ŸŽฎ Gamepad All 3 tracks

Control method is communicated on the Mode Select screen โ€” Endless Survival shows โœ‹ Gesture, others show โŒจ๏ธ Keyboard / ๐ŸŽฎ Gamepad.


โœจ Features

๐Ÿ–๏ธ Hand-Gesture Steering (Flagship โ€” Endless Survival Only)

  • Drive with both hands โ€” car accelerates when both hands detected; palm centers mapped to steering angle
  • Smooth tracking โ€” exponential landmark smoothing + dead zone + non-linear steering curve for natural feel
  • Live camera panel โ€” see your hand skeleton overlay while you play
  • Interactive calibration โ€” capture neutral center, dead zone, and EMA smoothing in Settings โ†’ Accessibility

๐ŸŽฎ Multi-Input System (All Other Modes)

  • Keyboard โ€” W gas ยท A/D steer ยท U auto-accelerate toggle
  • Touch controls โ€” on-screen buttons with one-hand mode (steering + throttle on one side)
  • Gyroscope mode โ€” tilt your phone/laptop to steer
  • Phone as controller โ€” scan QR, pair via PeerJS, use device orientation
  • Gamepad โ€” standard Gamepad API support (where browser supports it)
  • Unified InputFrame contract โ€” priority resolution: Replay โ†’ Phone โ†’ Auto โ†’ Gyro โ†’ Base (hand/keyboard/touch)

๐ŸŽจ Game Systems

  • 3 Premium Tracks โ€” Cyber City (neon/rain), Mountain Highway (fog/sunrise), Space Highway (stars/nebula)
  • Dynamic Weather โ€” per-track state machines (Clear โ†’ Fog โ†’ Rain โ†’ Storm), seeded for replay consistency
  • 3D Cockpit HUD โ€” speed gauge, gear indicator, position/lap, score, combo ring, boost bar, draft meter
  • AI Opponents โ€” 6 personalities (Blaze, Shield, Vector, Risky, Chameleon, Comet) with 7-parameter deterministic model, 5 difficulty tiers, adaptive Chameleon
  • Tournament Ladder โ€” 4 divisions, 3 races each, promotion on top-3 average, division-scaled rewards
  • Race Result Gate โ€” idempotent completion (dedupes by raceId), zero progression from replays
  • Procedural Engine Audio โ€” Web Audio API synth scaled to speed, adaptive music stems (menu โˆ’6dB, race layers)
  • Speed Lines & Vignette โ€” dynamic juice effects at high velocity
  • Collision Juice โ€” hit-stop + slow-mo crash sequence, screen shake

๐Ÿ“Š Progression & Cosmetics

  • Coins & XP โ€” earned every race (even losses), flat 1000 XP/level
  • Cosmetic Catalog โ€” car skins, neon trails, driver titles (visual-only, no stat impact)
  • High Scores โ€” local per track/mode, sanitized storage, XSS-hardened
  • Driver Profile โ€” level, XP, equipped cosmetics, completed races

๐ŸŽฌ Replay & Photo Mode

  • Deterministic Replay โ€” fixed 30Hz InputFrame recording, binary codec, seeded RNG
  • Ghost Racing โ€” holographic ghost car (45% transparent cyan, light trail), delta timer (green/red), 3 sector splits
  • Replay Viewer โ€” 4 camera modes (Chase, Orbit, Cinematic, Free), slow-mo (toggle + hold-Shift), Depth of Field (FOCUS slider)
  • Photo Mode โ€” screenshot capture with baked filters (grain, contrast, focus), Web Share API + download fallback
  • Session-Only Persistence โ€” replays never leave the session (by design)

โ™ฟ Accessibility (Complete Surface)

  • Colorblind Presets โ€” Deuteranopia / Protanopia / Tritanopia (CSS token overrides)
  • One-Hand Mode โ€” steering + throttle composed on single touch side
  • Reduced Motion โ€” disables camera fly-through, screen shake, particles, shortens cinematic intros
  • High Contrast HUD Theme โ€” CSS token overrides
  • Hold-to-Confirm โ€” destructive actions (Quit, Leave Lobby) require hold
  • Touch Targets โ‰ฅ 48px โ€” WCAG 2.1 AA compliant

โšก Performance (Adaptive)

  • Quality Tiers โ€” Performance (1.0ร—, no post/shadows/weather), Balanced (1.5ร—, light bloom), Quality (2.0ร—, full effects)
  • Auto-Tier Selection โ€” device-based initial tier
  • Dynamic Resolution โ€” rolling 2s frame budget: sustained >18ms โ†’ step down ร—0.8, <16ms โ†’ recover, floor 0.6ร—
  • GPU Resource Lifecycle โ€” full disposal of geometries/materials on object removal
  • Menu Render Gating โ€” game renders only during race phases (idle menus skip GPU)

๐Ÿ•น๏ธ How It Works

flowchart LR
    A[Webcam] --> B[MediaPipe Hands]
    B --> C[Palm Center Extraction]
    C --> D[Smoothing Filter (EMA + Dead Zone)]
    D --> E[Steering Mapping]
    E --> F[InputFrame (Unified Contract)]
    F --> G[InputManager (Priority Resolution)]
    G --> H[Game Simulation]
    H --> I[Three.js Rendering]
    I --> J[HUD / Feedback / Audio]

    K[Keyboard] --> F
    L[Touch] --> F
    M[Gyroscope] --> F
    N[Phone Controller] --> F
    O[Gamepad] --> F
    P[Replay Playback] -.->|Highest Priority| F
Loading
  1. MediaPipe extracts 21 hand landmarks per frame (up to 2 hands)
  2. Palm center (wrist + index MCP + middle MCP) mapped to 0โ€“1 steering axis
  3. Exponential smoothing removes jitter; dead zone prevents drift
  4. InputFrame normalized (steering โˆˆ [โˆ’1,1], throttle โˆˆ [0,1], brake โˆˆ [0,1])
  5. InputManager resolves priority layers โ€” Replay > Phone > Auto > Gyro > Base
  6. Game simulation runs at 60Hz, Three.js renders, HUD/audio update

๐Ÿ—๏ธ System Architecture

src/
โ”œโ”€โ”€ main.ts                    # Game bootstrap, game loop, state machine wiring
โ”œโ”€โ”€ game/
โ”‚   โ”œโ”€โ”€ Game.ts                # Main simulation (road, obstacles, physics, rendering)
โ”‚   โ”œโ”€โ”€ GameModeConfig.ts      # Declarative mode/track config (4 modes, 3 tracks)
โ”‚   โ”œโ”€โ”€ RaceDirector.ts        # Race standings, timing, lap counting
โ”‚   โ”œโ”€โ”€ TournamentManager.ts   # Division ladder (Rookieโ†’Proโ†’Eliteโ†’Champion)
โ”‚   โ””โ”€โ”€ p4/                    # Survival mechanics (boost, combo, near-miss, collision juice)
โ”œโ”€โ”€ ai/                        # AI Race subsystem
โ”‚   โ”œโ”€โ”€ AICar.ts               # Individual AI car (perceptionโ†’decisionโ†’action)
โ”‚   โ”œโ”€โ”€ AIPersonality.ts       # Personality profiles + Chameleon adapter
โ”‚   โ”œโ”€โ”€ AIRuntime.ts           # Race orchestrator (grid, tick loop, HUD telemetry)
โ”‚   โ””โ”€โ”€ CatchUp.ts             # Rubber-band catch-up logic
โ”œโ”€โ”€ input/                     # Unified input system
โ”‚   โ”œโ”€โ”€ HandTracker.ts         # MediaPipe Hands pipeline
โ”‚   โ”œโ”€โ”€ GestureCalibration.ts  # Neutral center + dead-zone + EMA
โ”‚   โ”œโ”€โ”€ InputFrame.ts          # Normalized input contract
โ”‚   โ”œโ”€โ”€ InputManager.ts        # Priority resolution (replayโ†’phoneโ†’autoโ†’gyroโ†’base)
โ”‚   โ””โ”€โ”€ sources/               # Adapters: Hand, Keyboard, Touch, Gyro, Phone
โ”œโ”€โ”€ replay/                    # Replay + Ghost system
โ”‚   โ”œโ”€โ”€ recorder.ts            # Fixed 30Hz race state recording
โ”‚   โ”œโ”€โ”€ player.ts              # Deterministic playback
โ”‚   โ”œโ”€โ”€ ghost.ts               # Holographic ghost renderer
โ”‚   โ”œโ”€โ”€ hud.ts                 # Ghost duel HUD (delta, sectors)
โ”‚   โ”œโ”€โ”€ viewer.ts              # Free camera + slow-mo + DoF
โ”‚   โ””โ”€โ”€ store.ts               # IndexedDB best-replay storage
โ”œโ”€โ”€ progression/               # XP/coins, cosmetic catalog, rewards, completion gate
โ”œโ”€โ”€ network/                   # PeerJS multiplayer (lobby, WebRTC mesh, remote ghosts)
โ”œโ”€โ”€ graphics/                  # PostProcessor (bloom/DoF/grain), WeatherSystem, ParticlePool
โ”œโ”€โ”€ managers/                  # Singletons: Audio, Profile, Quality, Save, Scene, UI
โ”œโ”€โ”€ screens/                   # All 11 screens + navigation flow
โ”œโ”€โ”€ ui/                        # Component library + core systems (focus, nav, transitions, theming)
โ””โ”€โ”€ core/                      # Architecture spine: StateMachine, NavigationSystem, EventBus, RaceStartPipeline

Design Principles:

  • Single authoritative flow โ€” NavigationSystem owns all screen transitions
  • Replay at input boundary โ€” ReplayInputSource has highest priority, zero progression
  • Determinism by default โ€” seeded RNG for AI, weather, traffic, replay
  • Cosmetics are visual-only โ€” ContentCatalog is sole authority, no stat-bearing items

๐Ÿงฐ Tech Stack

Layer Technology
Language TypeScript 5 (strict)
3D Rendering Three.js 0.170 ยท WebGL 2
Vision AI MediaPipe Hands (CDN)
Build Vite 6
Audio Web Audio API (procedural synthesis)
Multiplayer PeerJS 1.5 (WebRTC mesh, public cloud signaling)
Testing Vitest (unit), Playwright (E2E: Chromium + Pixel 5)
Lint/Format ESLint + TypeScript-Eslint + Prettier
CI GitHub Actions (typecheck, lint, test, build)
Deployment Vercel (static + SPA fallback)

๐Ÿš€ Getting Started

Prerequisites

  • Node.js 18+
  • A webcam (for Endless Survival gesture mode)
  • HTTPS or localhost (required for camera access)

Installation

# 1. Clone & install
git clone https://github.com/Manthan-13521/GestureKart-AI-Racing.git
cd GestureKart-AI-Racing
npm install

# 2. Run the dev server
npm run dev

# 3. Open the game
# http://localhost:5173

Scripts

Script Description
npm run dev Start Vite dev server
npm run build Type-check + production build (dist/)
npm run preview Preview production build locally
npm run typecheck TypeScript compile check (tsc --noEmit)
npm run lint ESLint check
npm run format Prettier write
npm run format:check Prettier check
npm run test Vitest watch mode
npm run test:coverage Vitest run with coverage

๐Ÿงช Testing

# Unit tests (626 tests, 46 files)
npm run test -- --run

# E2E tests (Chromium + Mobile Pixel 5)
# Requires dev server running: npm run dev
npx playwright test

# E2E against production preview
npm run build && npm run preview
# In another terminal: npx playwright test -c playwright.prod.config.ts

๐Ÿ“ฆ Deployment

Vercel (recommended):

  1. Connect GitHub repo
  2. Framework preset: Vite
  3. Build command: npm run build
  4. Output directory: dist
  5. Deploy โ€” SPA fallback handles client-side routing

The build produces:

  • dist/index.html โ€” Main game (Virtual Steering)
  • dist/phone-controller.html โ€” Phone-as-controller page
  • dist/kart-racing/ โ€” Legacy arcade kart racing game (standalone)

No environment variables required โ€” all external services (MediaPipe, PeerJS, Google Fonts) use public CDNs.


๐Ÿ”’ Security & Privacy

  • No server, no database โ€” pure static frontend
  • Camera access โ€” only for MediaPipe hand landmarks; frames never leave the browser
  • PeerJS โ€” uses public signaling server; WebRTC is encrypted; no identity stored
  • localStorage/IndexedDB โ€” settings, high scores, profile, replays (all local)
  • XSS hardening โ€” sanitized storage boundaries + HTML escaping at render
  • No secrets, no API keys, no tokens in the codebase

๐Ÿ“Š Test & Quality Status

Gate Status
TypeScript compile โœ… PASS
ESLint โœ… PASS
Prettier โœ… PASS
Production build โœ… PASS
Unit tests โœ… 626 passed (46 files)
E2E Chromium โœ… 14 passed / 6 skipped
E2E Mobile (Pixel 5) โœ… 13 passed / 7 skipped
Production browser test โœ… Both projects green

๐Ÿ—บ๏ธ Roadmap (Post-Launch)

  • Local multiplayer (split-screen, same device)
  • Garage UI (turntable preview, cosmetic purchase flow)
  • Achievements screen (badge grid, progress rings)
  • Daily / Weekly challenges (return loops)
  • Profile screen (level ring, XP bar, stats, best laps)
  • Leaderboard screen (global/friends/track tabs)
  • How to Play / Tutorial screen
  • Friend ghost sync (cloud)
  • Cloud leaderboards (serverless)
  • SFU upgrade for larger multiplayer lobbies

๐Ÿค Contributing

Contributions, issues, and feature requests are welcome. Fork the repo, make your change, and open a pull request.


๐Ÿ“„ License

All rights reserved.


ยฉ 2026 Manthan Jaiswal โ€” Built with Three.js, MediaPipe & TypeScript.


๐ŸŽ๏ธ Play Virtual Steering

About

๐ŸŽ๏ธ AI Gesture Controlled Racing Game using MediaPipe

Topics

Resources

Stars

4 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages