Terravroom
<p align="center"> <img src="https://img.shields.io/badge/Three.js-r185+-black?style=for-the-badge&logo=three.js" alt="Three.js" /> <img src="https://img.shields.io/badge/Vite-8.2+-646CFF?style=fo
About the Project
Drive anywhere on planet Earth in full 3D. Terravroom is a high-performance, browser-based 3D driving simulation built with Three.js and Vite. It streams real-world road networks, architectural buildings, bridges, elevated transit viaducts, terrain elevations, street furniture, vegetation, and live traffic dynamically using real OpenStreetMap (OSM) data worldwide.
ð Highlights & Key Features
ð Real-World Global Streaming & Multi-Mirror Failover
- Live OpenStreetMap Ingestion: Procedurally generates 3D road ribbons, complex junctions, multi-tier buildings, multipolygon architectural landmarks, parks, and waterways on-the-fly via high-speed Overpass API endpoints.
- Ultra-Fast Multi-Mirror Network: High-availability mirror failover (
maps.mail.ru,overpass-api.de,lz4,kumi,private.coffee) ensuring instantaneous ingestion worldwide (e.g., Lahore, Tokyo, Monaco, New York, Paris, London, Nürburgring). - Persistent IndexedDB Cache: Downloaded regions are stored in browser IndexedDB for zero-latency instant replays and offline capability.
- Infinite Procedural Fallback: Seamlessly generates structured procedural cities if unmapped terrain is encountered.
ðºï¸ Vector World Map & Neon Road Cartography
- Interactive Global Location Picker: Seamless Leaflet-powered world map with Nominatim geocoding search and custom latitude/longitude teleportation.
- True Neon Roads Tile Engine: Custom raster-to-neon tile processor (
NeonTileProcessor.js&NeonMapRenderer.js) transforming standard dark OpenStreetMap tiles into luminous electric cyan road vectors on obsidian black backdrops. - Real-Time Active Country Highlight: Built-in vector world map background (
WorldMapBackground.js) with point-in-polygon country boundary detection and pulsing neon country highlights for the active spawn point.
ðï¸ 3D Garage Showroom & 4 Iconic Vehicle Classes
Explore authentic .glb 3D vehicle models rendered in a dedicated 360° turntable showroom with floor reflections, detailed vehicle specification sheets, interactive audio rev previews, and real-time paint customization via the CyberColorPicker:
| Vehicle | Class / Badge | Top Speed | Nitro Speed | 0â100 km/h | Drivetrain | Sound Profile | Handling & Dynamics |
| :--- | :--- | :---: | :---: | :---: | :---: | :---: | :--- | :--- |
| Mazda RX-7 FD3S | ROTARY | 255 km/h | 320 km/h | 3.2s | RWD | 13B Twin-Rotor Turbo | 50:50 balance, featherweight chassis, high downforce, razor-sharp touge drift tuning. |
| Lamborghini Aventador | V12 BULL | 350 km/h | 420 km/h | 2.8s | AWD (Haldex IV) | 6.5L Naturally Aspirated V12 | Carbon monocoque, 8,500 RPM scream, active aero vectoring, 50ms ISR gearbox shifts. |
| Nissan Skyline R34 | GODZILLA | 315 km/h | 395 km/h | 2.7s | AWD (ATTESA E-TS) | 2.6L RB26DETT Twin-Turbo | Legendary twin-turbo inline-6, active torque-vectoring AWD, circuit-dominating grip. |
| Nova 396 Big Block | V8 MUSCLE | 235 km/h | 300 km/h | 3.8s | RWD (Positraction) | 6.5L 396ci Big Block V8 | Raw American muscle, massive low-end torque, thunderous rumble, tire-shredding power-slides. |
- CyberColorPicker & Swatches: Select from 9 curated gloss presets (Crimson Red, Sunset Orange, Cyber Yellow, Emerald Green, Neon Cyan, Electric Blue, Deep Purple, Pure White, Midnight Black) or pick any custom hex shade with live 3D preview.
ð¦ Autonomous Dynamic Road Traffic
- OSM Spline-Based AI Traffic: Autonomous vehicles (sedans, vans, city buses) procedurally spawned and navigating along real OSM road centerlines.
- Day/Night Lighting Integration: Traffic vehicles automatically activate glowing Xenon headlights and red taillight ground illumination in sunset, night, and cyberpunk lighting conditions.
- Configurable Density: Adjust traffic density from Off to Low, Realistic, or High directly from the Settings menu.
ð§ Warm Harmonic Procedural Audio Synthesizer
- Harmonic Additive Engine Synth: Powered by the Web Audio API using filtered sub-bass sine waves and warm low-pass triangle waves with soft-clipping saturation (no harsh square-wave buzzing).
- Acoustic Signatures per Vehicle: Unique audio profiles matching each car (screaming twin-rotor turbo, high-revving 8,500 RPM V12, twin-turbo inline-6 purr, and deep throaty V8 rumble).
- Dynamic Sound Effects: Progressive engine RPM pitch modulation, turbo blow-off valve hiss, pink-noise tire screech on drifts, metallic obstacle crash impacts, horn (
H), and in-menu audio rev testing.
ð£ï¸ Multi-Tier Roadways & Elevated Viaduct Architecture
- Expressways & Highways: Dark high-grip asphalt with realistic aggregate noise, yellow inner shoulder line, solid white outer shoulder, and proportional dashed white lane divider markings.
- City Streets & Avenues: Multi-lane urban roads with double solid yellow centerlines and sidewalk curbs.
- Local Streets & Alleys: Clean paving without intrusive markings.
- Elevated Viaducts & Metro Lines: Dynamic clearances for elevated transit systems (e.g. Lahore Orange Line Metro viaduct) supported by structural concrete columns so vehicles drive cleanly underneath without clipping.
- Anti-Clipping Road Filter: Automatically detects and removes ground-level building footprints that intersect drivable road surfaces.
ð¢ 4 Architectural Building Facade Styles
Procedurally textured building extrusions classified by height, type, and location:
- Modern Reflective Glass Skyscraper: Deep sapphire/cyan curtain-wall glass with steel mullions.
- Commercial High-Rise: Slate cladding with tinted office windows and horizontal floor louvers.
- Residential Sandstone & Brick Apartments: Warm natural stone facade with window casings and balcony trims.
- Contemporary Concrete / Civic: Architectural precast concrete panels with expansion seams and ribbon windows.
ð¡ Interactive Street Furniture & Physical Obstacle Collisions
- Roadside Streetlamps: Correctly aligned streetlamps whose fixture arms extend directly inward over the asphalt surface from both curbs. Includes realistic nighttime light pools and dynamic spot lights that actively react to the time of day.
- Obstacle Collisions: Physical collision detection for streetlamp posts and tree trunks with realistic momentum deceleration and bounceback.
ð³ Lush Procedural Vegetation System
- Roadside Boulevards: Tree-lined sidewalks featuring leafy oaks, tropical date palms, and roadside shrubs placed at natural intervals along all drivable streets.
- Park Groves: Natural clusters of 3D oak, pine, and palm trees throughout parks, grass polygons, and recreational spaces.
ð Checkpoint Street Race Mode
- Generates procedural multi-checkpoint street racing circuits using the surrounding real-world road topology.
- Real-time race timer, animated 3D checkpoint arches, dynamic minimap course route visualization, and victory celebration overlays.
â Dynamic 24-Hour Lighting & Real-World Timezone Presets
Press N or click the atmospheric lighting toggle to switch between 7 rich lighting and timezone configurations:
- âï¸ Day: Crisp sunlight with realistic soft shadows and natural ambient skylight.
- ð Sunset: Warm golden-hour orange and purple horizon glow.
- ð Night: Pitch-dark realistic night atmosphere with forward Xenon LED headlight beams and dynamic red taillight / brake light ground projections.
- ð® Cyberpunk: Neon cyan and magenta atmospheric illumination with high-contrast reflections.
- ð«ï¸ Foggy: Dense moody atmospheric mist.
- ð» System Time (
Sys Time): Dynamically calculates your local computer system clock and applies Day, Sunset, or Night accordingly. - ð City Solar Time (
City Time): Dynamically calculates real solar time at the selected city's longitude (spawnLon / 15.0). Teleporting to Tokyo, Monaco, Lahore, or New York sets the true real-world local time of that city!
ð¥ 6 Advanced Camera Perspectives
Press C to cycle or press keys 1 through 6 to switch instantly:
- Chase Cam (
1): Dynamic third-person camera with smooth spring physics and speed-dependent FOV expansion. - Roof Cam (
2): Elevated chase perspective anchored above the vehicle roofline. - Hood Cam (
3): Fixed bonnet camera anchored above the front splitter with zero lag at high speeds. - Bumper / 1st Person Cam (
4): Pure front nose camera with vehicle body hidden for 100% clean forward visibility. - Interior Cockpit Cam (
5): Driver seat point of view looking out over the dashboard and windscreen. - Free / Orbit Cam (
6): Free 360° mouse-drag inspection view around the vehicle.
ð Telemetry Bento Overlay & TerraAI Copilot
- Dark Bento Telemetry Grid (
T/B): Fullscreen spotlight telemetry grid with live sparklines, G-force gauges, tire temperature, surface grip %, and OSM node counters. - Mini Telemetry Bar: Compact HUD widgets displayed directly above the GPS radar showing Lateral G, Surface Grip %, Tire Temp (°C), and Active Roads Count.
- TerraAI Driving Copilot: Slide-out AI assistant drawer offering contextual driving tips, city history, car tuning suggestions, and Web Speech voice output.
- Driver.js Tour Guide: Interactive onboarding walk-through introducing HUD elements, radar controls, and telemetry features.
- Driver Profile & Stats: Driver license dashboard tracking total distance traveled (km), top speed achieved, drift points, and completed races stored in
localStorage.
ð® Controls & Keybindings
| Key / Control | Action |
| :--- | :--- |
| W / â / Z | Accelerate Throttle |
| S / â | Brake / Reverse |
| A / D or â / â / Q | Steer Left / Right |
| Shift | Engage Nitro Boost ð¥ |
| Space | Handbrake Power-Slide Drift |
| C | Cycle Camera Mode (Chase â Roof â Hood â Bumper â Interior â Free) |
| 1 â 6 | Jump Directly to Camera Mode (1: Chase, 2: Roof, 3: Hood, 4: Bumper, 5: Interior, 6: Free) |
| L | Toggle Vehicle Headlights (Day / Night Xenon Beams) |
| R | Reset Vehicle to Nearest Drivable Road |
| N | Cycle Lighting & Weather (Day â Sunset â Night â Cyberpunk â Foggy â Sys Time â City Time) |
| M | Toggle & Expand Live 2D GPS Radar Minimap |
| T / B | Toggle Telemetry Bento Grid & Mini HUD Bar |
| H | Sound Vehicle Horn / Cycle HUD Visibility Mode |
| X | Toggle 3D Skeleton / Wireframe Mesh Inspection |
| Right Mouse Drag | Orbit Camera Angle (in Orbit / Free Mode) |
| Mouse Wheel | Zoom Camera In / Out |
ð Getting Started
Prerequisites
- Node.js (v18 or higher recommended)
npm(bundled with Node.js)
Installation & Run
-
Clone the repository:
git clone https://github.com/RasikhAli/Terravroom.git cd Terravroom -
Install dependencies:
npm install -
Start the local development server:
npm run dev -
Open in browser: Navigate to
http://localhost:5173/in your browser. -
Build for production:
npm run build -
Preview production build locally:
npm run preview
ð Popular Preset Locations
Choose any custom coordinate on Earth via the interactive world map and search bar, or jump directly into built-in presets:
| Location | Country | Coordinates | Highlights |
| :--- | :---: | :---: | :--- |
| Lahore | ðµð° Pakistan | 31.5204° N, 74.3587° E | Multan Road, Mall Road, Orange Line elevated viaduct, and historic city grid. |
| Monaco | ð²ð¨ Monte Carlo | 43.7384° N, 7.4246° E | Famous tight harbor hairpin corners, coastal elevation, and seaside boulevard. |
| Shibuya Crossing | ð¯ðµ Tokyo, Japan | 35.6595° N, 139.7005° E | Dense skyscraper canyon, crosswalks, and Japanese city road layout. |
| Times Square | ðºð¸ New York, USA | 40.7580° N, -73.9855° W | Iconic Manhattan grid with massive high-rise architecture and avenues. |
| Nürburgring Nordschleife | ð©ðª Germany | 50.3356° N, 6.9475° E | Famous 20+ km forest circuit curves, elevation changes, and high-speed straights. |
| Eiffel Tower | ð«ð· Paris, France | 48.8584° N, 2.2945° E | Wide Parisian boulevards, roundabouts, and Seine river bridges. |
ð ï¸ Project Architecture
Terravroom/
âââ index.html # Main HTML entry point with modern typography & viewport configuration
âââ package.json # Dependencies (Three.js r185, Vite 8, Leaflet, Anime.js, Driver.js, Lucide)
âââ style.css # Comprehensive cyber-glassmorphic styling system & UI components
âââ vite.config.js # Vite configuration with server host rules
âââ public/
â âââ favicon.svg # Vector favicon
â âââ icons.svg # Icon sprites
â âââ models/ # High-quality 3D .glb vehicle models
â âââ mazda-rx7.glb # Mazda RX-7 FD3S model
â âââ lamborghini.glb # Lamborghini Aventador model
â âââ nissan-skyline.glb # Nissan Skyline R34 model
â âââ muscle-car.glb # Nova 396 Big Block muscle car model
â âââ audi-e-tron.glb # Electric performance model
âââ src/
âââ main.js # Main orchestrator, Game lifecycle loop & hotkey bindings
âââ assets/
â âââ world-countries.json # GeoJSON vector boundaries for global country highlighting
âââ config/
â âââ vehicles.js # Vehicle configs, specs, sound profiles, paint swatches & presets
âââ engine/
â âââ Elevation.js # Simplex noise topographical elevation engine
â âââ LabelManager.js # 3D floating street & district name labels
â âââ PlayerStats.js # Driver license mileage, high speed & race statistics tracker
â âââ RaceManager.js # Procedural checkpoint race circuit builder & timer
â âââ SceneManager.js # WebGL renderer, 6 cameras, post-processing & 7 lighting modes
â âââ Showroom.js # Interactive 3D garage turntable showroom
â âââ StreetProps.js # Instanced streetlamps, night light pools & physical colliders
â âââ TileManager.js # Concentric geographical chunking, Overpass streaming & tile caching
â âââ TrafficManager.js # Autonomous multi-vehicle AI traffic on OSM road splines
â âââ VegetationProps.js # Procedural roadside boulevards, palms, oaks & park foliage
â âââ VehicleVisualFactory.js # 3D GLB model loader & procedural fallback generator
âââ osm/
â âââ GeometryBuilder.js # 3D procedural roads, ribbons, viaducts, junctions & facades
â âââ OverpassClient.js # Multi-mirror Overpass API fetcher with IndexedDB caching
âââ physics/
â âââ CarController.js # Raycast suspension, drift physics, nitro & collision dynamics
â âââ SoundEngine.js # Web Audio API harmonic additive synthesizer & acoustic profiles
âââ ui/
â âââ AssistantUI.js # TerraAI conversational copilot drawer & voice assistant
â âââ BentoGrid.js # Spotlight telemetry dashboard & live sparklines
â âââ CyberColorPicker.js # Interactive hex color picker with 3D live preview
â âââ HUD.js # Driving dashboard, tachometer, speedometer & radar minimap
â âââ LocationPicker.js # Leaflet world map with Nominatim geocoder
â âââ MainMenu.js # Next-gen 3D garage showroom, vehicle picker & neon map selector
â âââ NeonMapRenderer.js # Canvas neon cartography renderer with glowing beacons
â âââ NeonTileProcessor.js # Dark OSM vector tile to electric neon road transformer
â âââ SettingsModal.js # Comprehensive settings modal (Graphics, Audio, Camera, Traffic)
â âââ SoundPreview.js # In-menu audio rev preview synthesizer
â âââ ThumbnailRenderer.js # Offscreen vehicle thumbnail snapshot generator
â âââ TourGuide.js # Interactive Driver.js tour guide onboarding
â âââ WorldMapBackground.js# Vector world map canvas with real-time country boundary highlight
âââ utils/
âââ GeoUtils.js # WGS84 geodesy, Mercator meter projections & coordinate math
ð¢ Deployment
Terravroom is a static client-side WebGL application that can be deployed to any static host, CDN, or cloud server (Render, Vercel, Netlify, Hostinger, Ubuntu VPS with Nginx, or Docker).
For complete, step-by-step deployment instructions, refer to DEPLOYMENT.md.
ð License & Attribution
- Source Code: Released under the MIT License.
- Map Data: OpenStreetMap data is licensed under the Open Data Commons Open Database License (ODbL) © OpenStreetMap contributors.
- Map Tiles: CartoDB Dark Matter tiles © CARTO © OpenStreetMap contributors.
Project Timeline
Technologies
External Links
Related Projects
Projects built with similar technologies.
Online Html Editor And Viewer
The Online HTML Editor and Viewer is a simple web application built with Flask that allows users to write and preview HTML code in real-time.
Qrgen
A premium, feature-rich QR Code Generator engineered with Python (Flask) and a pristine Glassmorphism frontend.
Examina Ai
Using AI, It transforms raw study materials into structured, verified examination sets with support for institutional export formats like Moodle XML.