Free Three.js Article
Three.js Car Physics:
Why GTA-Style Driving Feels So Good
By Shane Brumback ·
Three.js car physics explained: weight transfer, suspension and drift, and why a GTA style car feels heavy and fun. The muscle car behind this page is the real demo.
The Short Answer
Three.js car physics feels "GTA-style" when the car has real mass, soft damped suspension that lets the body pitch and roll, and tyre grip that can run out. Three.js draws the car; a physics engine such as Rapier moves it with a raycast vehicle: one ray, one spring and one tyre per wheel.
Facts
- The demo car is a rear-wheel-drive 1971 muscle car of about 1,150 kg, driven by Rapier 0.14's raycast vehicle controller.
- Each rear wheel pushes with 3,000 N at full throttle. On flat ground that reaches about 82 km/h after 5 seconds.
- The springs sag about 8 cm under the car's weight (9.81 / (4 x 30) m), so the body has room to lean and pitch.
- The rear tyres get more grip than the front (3.2 against 2.6) to keep the car stable, and the handbrake drops the rear grip to 1.3 for drifting.
- The city is three CC BY models: the car, 18 downtown buildings and a road layout, with invisible walls generated from a 2 m scan of the roads.
Introduction
With GTA 6 on everyone's mind, I wanted to answer a question I get a lot from people building a threejs car game: why do some browser cars feel like a sliding box, while a GTA style car feels heavy, a bit floaty and fun to throw around? The answer is not graphics. It is a handful of physics choices you can make in an afternoon. The muscle car parked behind this text is the finished demo from my Three.js vehicle physics tutorial, sitting in a small downtown with barrels, cones and jersey barriers you can knock around.
To be clear, I have no idea how Rockstar writes its code, and I am not copying it. "GTA-style" here just means the feel most players know: weight, body roll, a car that slides when you ask it to and grips when you don't.
What Makes a GTA Style Car Feel Heavy?
One word: weight transfer. Brake hard and the nose dives, which loads the front tyres and lightens the rear. Accelerate and the nose lifts. Turn and the body rolls toward the outside of the corner. Your eyes read that motion as mass long before you notice the top speed.
In code that comes from two things. The chassis must be a real dynamic body with a believable mass, and the wheels must hang on springs that can compress. A car glued to the ground with no suspension can't pitch or roll, so it always feels like a toy, no matter how good the model looks. I also add a heavy, low collider under the floor as ballast. It drags the centre of mass down so the car leans in a hard corner but doesn't roll over.
Three JS Vehicle Physics With Raycast Wheels
The obvious way to build a car is four round wheel bodies joined to a chassis. It looks right on paper and behaves badly in practice: the wheels catch on triangle edges in the road mesh, the joints wobble at speed, and tuning is painful. Most games use a raycast vehicle instead, and so does Rapier's built-in vehicle controller.
Each wheel is just a ray fired down from the chassis. Where the ray hits the road, a spring pushes the body up, a tyre model pushes it forward or sideways, and the wheel mesh is drawn at the hit point. That makes rapier vehicle physics fast and stable even on a bumpy city mesh, and the numbers you tune map to things a car person understands: rest length, stiffness, damping, grip.
Suspension: Why the Car Leans and Settles
Rapier scales spring force by the car's mass, so the stiffness reads per kilogram. With four wheels and a stiffness of 30, the springs settle about 8 cm below their rest length when the car is parked. I use that number to place the springs so the wheels land exactly where the 3D model drew them.
Damping is the other half. Too little and the car bounces like a pogo stick after every curb. Too much and it feels stiff and dead. I run compression and rebound damping a little under critical, so the body takes one soft wobble and settles. That single wobble is a big part of the GTA feel.
Tyre Grip, Friction Slip and the Handbrake Drift
Every tyre can only push so hard before it slides. Rapier calls that limit friction slip, and it is tied to how much weight the spring is carrying, which is exactly why weight transfer matters. In my tests a rear-drive car with less grip at the rear than the front kept spinning out under full throttle after a slide. Giving the rear a bit more grip (3.2 against 2.6 at the front) fixed it: the car stays planted until you ask it to slide.
The ask is the handbrake. While Space is held I brake the rear wheels, drop their grip to 1.3 and cut their sideways stiffness to under half. The tail swings out, you steer into it, and when you let go the grip comes back and the car straightens. If you like drifting, my free game Drift Dash is built around exactly that feeling.
Steering, Speed and the Chase Camera
Full steering lock at 120 km/h throws any car into a spin. So the steering lock shrinks as speed rises, from 0.6 radians when parked to 0.18 at about 145 km/h, and the wheel eases toward the target instead of snapping. The camera matters as much as the physics: a chase camera that lags slightly behind the car and eases back after you orbit it lets you see the body roll and the slide angle. Lock the camera to the car and half the weight transfer disappears from view.
Building a Small City You Can Drive In
A gta like car game needs a place to drive. I used three free CC BY models (credited below): a road layout, a downtown building set and the car. The roads become one Rapier triangle mesh. Then the demo fires a ray straight down every 2 metres across the map. Cells with road get a road height; empty cells copy the height of the nearest road and become ground, and the empty cells that touch the road become invisible wall boxes. The car can bump up the curb onto the sidewalk, but it can't drive into a building or off the map. Barrels and cones along the curb are light physics bodies you can scatter; jersey barriers stay put.
How To Make a Three.js Car Feel GTA-Style, Step by Step
- Give the car real mass and a low centre of mass. A dynamic body of about 1,150 kg plus a heavy low collider as ballast.
- Use raycast wheels. One ray per wheel through Rapier's vehicle controller instead of four wheel bodies.
- Tune soft but damped suspension. A few centimetres of sag at rest and damping a little under critical.
- Give the rear tyres a bit more grip. Stable under throttle, with the handbrake as the way to break traction.
- Add a handbrake drift. Lock the rear wheels and cut their grip while the key is held.
- Cut steering at speed and add a chase camera. So the car stays drivable and you can see it lean.
In a Real Game: Drift Dash
Drift Dash is my free Three.js drift racer: hold to drift a sports car through the bends of a winding road over cliff islands. It is a one-touch arcade game rather than a full vehicle sim, but it chases the same thing this article is about: the moment the rear lets go and you catch it. Play it, then build the city car in the tutorial and compare how the two feel.
Frequently Asked Questions
How do I add car physics in Three.js?
Three.js only draws the car, so pair it with a physics engine. I use Rapier: a dynamic rigid body for the chassis, the built-in raycast vehicle controller for the four wheels, and then copy the body position and wheel suspension into the Three.js meshes every frame.
What makes a GTA style car feel heavy?
Weight transfer. When the car brakes, accelerates or turns, the body pitches and rolls on soft, damped springs and the grip moves between the tyres. A car that leans and settles reads as heavy; a car that snaps instantly reads as a toy.
Is the Rapier vehicle controller good for a threejs car game?
Yes for arcade and GTA-like driving. It is a raycast vehicle: each wheel is a ray with a spring, tyre friction and steering, which is fast, stable on bumpy road meshes and easy to tune. Full tyre models are only needed for racing sims.
How do I make a car drift in Three.js?
Lower the rear tyres' grip and sideways stiffness while a handbrake key is held and brake the rear wheels. The rear slides out, you steer into the slide, and when you let go the grip comes back and the car straightens.
Is the live demo free?
Yes. The live demo in the tutorial is free with Google sign-in. The step-by-step code and the full source file are for members.
Build It Yourself
The premium tutorial has the live demo (sign in free with Google), the step-by-step code and the one-click Launch. Or go drift in Drift Dash.
3D Model Credits
- Car: Phoenix 455 '71 by DanielZhabotinsky, licensed CC BY 4.0. I optimized it and split the wheels in code.
- Buildings: Downtown Buildings Set by DanielZhabotinsky, licensed CC BY 4.0. I optimized it and moved each building onto a city block.
- Roads: [FREE] City Road Layout Mockup by 99.Miles, licensed CC BY 4.0. I optimized it for the web.
- GTA is only used here as a style comparison. This demo has no Rockstar art, logos or code.