Skip to content

theshanergy/4x4builder

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

4x4 Builder

Live Demo GitHub Stars

4x4 Builder Screenshot

4x4 Builder is a browser-based 3D off-road vehicle customization and simulation app. Build your dream 4x4, customize every detail from suspension lift to tire size, then drive it through procedurally generated terrain with realistic physics. Features multiplayer support, VR compatibility, and real-time engine audio synthesis.

๐ŸŒ Try it live at 4x4builder.com


โœจ Features

๐Ÿš— Vehicle Customization

  • Vehicles โ€” Toyota 4Runner (3rdโ€“5th gen), Land Cruiser (J80, J250), Tacoma, Jeep Wrangler (YJ, JK), Cherokee XJ, Ford Bronco
  • Suspension โ€” Adjustable lift height from stock to 6"
  • Wheels โ€” Various rim options from brands like XD Wheels, American Racing, Konig, Cragar, and OEM
  • Tires โ€” Multiple tire models including BFGoodrich KM2/KM3/AT, Nitto Mud Grappler, Maxxis Trepador
  • Customizable sizing โ€” Rim diameter (15"โ€“22"), tire diameter (28"โ€“40"), rim width, wheel offset
  • Paint & Finish โ€” Any body color with adjustable metallic/matte finish
  • Accessories โ€” Bumpers, rock sliders, roof racks (vehicle-specific)

๐ŸŽฎ Driving Simulation

  • Realistic physics โ€” Powered by Rapier physics engine with suspension, torque curves, and transmission simulation
  • Procedural terrain โ€” Infinite, dynamically generated terrain with varied elevation and flat regions
  • Dynamic grass โ€” GPU-instanced grass with wind animation that responds to terrain
  • Engine audio โ€” Real-time synthesized engine sounds using Web Audio API AudioWorklet
  • Tire tracks โ€” Persistent tire marks in the terrain
  • Dust particles โ€” Wheel dust effects when driving

๐ŸŽฅ Camera Modes

  • Orbit camera โ€” Third-person view with smooth follow and terrain collision avoidance
  • First-person โ€” Driver's seat perspective
  • Auto-rotate โ€” Showcase mode for screenshots

๐ŸŒ Multiplayer

  • Real-time multiplayer โ€” See other players' vehicles and drive together
  • Room-based โ€” Create or join rooms to play with friends
  • In-game chat โ€” Communicate with other players
  • Vehicle sync โ€” Your customizations are visible to others

๐Ÿฅฝ VR Support

  • WebXR compatible โ€” Works with VR headsets via @react-three/xr
  • Teleport locomotion โ€” Navigate with VR controllers
  • Immersive experience โ€” Sit inside your custom vehicle in VR

๐Ÿ“ธ Extras

  • Screenshot export โ€” Download high-quality PNG images
  • URL sharing โ€” Vehicle configuration URLs for easy sharing
  • Local storage โ€” Save multiple vehicle builds
  • Mobile support โ€” Touch controls with virtual joysticks
  • Responsive UI โ€” Works on desktop, tablet, and mobile

๐Ÿ› ๏ธ Tech Stack

Category Technologies
Frontend React 19, Zustand, Tailwind CSS 4
3D Engine Three.js, React Three Fiber, Drei
Physics Rapier via @react-three/rapier
VR/XR @react-three/xr
Audio Web Audio API with custom AudioWorklet
Build Tool Vite
Multiplayer Server Node.js with ws WebSocket library
Shaders Custom GLSL for terrain, grass, and sky

๐Ÿš€ Quick Start

Prerequisites

  • Node.js 20.0.0 or higher
  • npm or yarn

Installation

# Clone the repository
git clone https://github.com/theshanergy/4x4builder.git
cd 4x4builder

# Install dependencies
npm install

# Start the development server
npm run dev

Open https://localhost:5173 in your browser.

Note: The dev server uses HTTPS with a self-signed certificate for WebXR compatibility. You may need to accept the security warning in your browser.

Build for Production

npm run build
npm run preview

๐ŸŒ Multiplayer Server

The multiplayer server is a separate Node.js application located in the server/ directory.

# Navigate to server directory
cd server

# Install server dependencies
npm install

# Start the server (development with auto-reload)
npm run dev

# Or start for production
npm start

The server runs on port 8080 by default and provides:

  • WebSocket connections for real-time multiplayer
  • Health check endpoint: http://localhost:8080/health
  • Stats endpoint: http://localhost:8080/stats

Environment Variables

Variable Description Default
VITE_MULTIPLAYER_SERVER_URL WebSocket server URL for multiplayer ws://localhost:8080

๐Ÿ“ Project Structure

4x4builder/
โ”œโ”€โ”€ components/
โ”‚   โ”œโ”€โ”€ scene/          # 3D scene components (Vehicle, Terrain, Camera, etc.)
โ”‚   โ””โ”€โ”€ ui/             # React UI components (Editor, Sidebar, Chat, etc.)
โ”œโ”€โ”€ hooks/              # Custom React hooks (physics, audio, materials)
โ”œโ”€โ”€ network/            # Multiplayer networking (WebSocket client)
โ”œโ”€โ”€ public/assets/      # Static assets (3D models, textures, audio)
โ”‚   โ””โ”€โ”€ models/
โ”‚       โ”œโ”€โ”€ vehicles/   # Vehicle GLB models by make/model
โ”‚       โ””โ”€โ”€ wheels/     # Rim and tire GLB models
โ”œโ”€โ”€ server/             # Multiplayer WebSocket server
โ”œโ”€โ”€ shaders/            # GLSL vertex and fragment shaders
โ”œโ”€โ”€ store/              # Zustand state stores
โ”œโ”€โ”€ utils/              # Utility functions
โ””โ”€โ”€ vehicleConfigs.js   # Vehicle, wheel, and tire definitions

๐ŸŽฎ Controls

Desktop

Key Action
โ†‘ / W Accelerate
โ†“ / S Brake / Reverse
โ† / โ†’ or A / D Steer
Shift Drift mode
R Reset vehicle position
C Cycle camera mode
T Open chat (multiplayer)
Esc Close chat / menus

Mobile

  • Left joystick โ€” Steering
  • Right joystick โ€” Throttle/brake
  • Drift button โ€” Enable drift mode
  • Reset button โ€” Reset vehicle position

Gamepad

Full controller support with analog steering and triggers.


๐Ÿค Contributing

Contributions are welcome! Here are some ways you can help:

  • ๐Ÿ› Report bugs โ€” Open an issue with details and reproduction steps
  • ๐Ÿ’ก Request features โ€” Suggest new vehicles, parts, or functionality
  • ๐Ÿ”ง Submit PRs โ€” Fix bugs or implement new features
  • ๐ŸŽจ Create 3D models โ€” Contribute new vehicles, wheels, or accessories
  • ๐Ÿ“ Improve docs โ€” Help make the documentation clearer

Development Guidelines

  1. Fork the repository
  2. Create a feature branch: git checkout -b feature/my-feature
  3. Make your changes and test thoroughly
  4. Submit a pull request with a clear description

๐Ÿ™ Acknowledgements

Libraries & Frameworks


๐Ÿ“Š Stats

GitHub last commit GitHub issues GitHub pull requests