Open World Racing Setup with Three.js and Cannon.js

Sharing this as a technical resource for anyone exploring large scale driving experiences in the browser using Three.js and Cannon.js.


The Starting Point

Most projects begin with a car on a flat plane.
The real learning starts when you try to scale that into an actual open world.


Rendering Layer Three.js

Three.js handles:

Large terrain
GLTF vehicle models
Dynamic lighting and shadows
Environment maps

Once the scene is structured properly with LOD and controlled asset loading, the renderer is rarely the main limitation. The challenge becomes scene management, not drawing triangles.


Physics Layer Cannon.js

Cannon.js gives you enough control to shape the driving feel through:

Suspension stiffness and damping
Wheel friction
Mass distribution
Center of gravity

Small parameter changes completely alter handling. With a stable timestep, RaycastVehicle can support both arcade style driving and more simulation oriented behavior.

The key is consistency between physics stepping and the render loop.


Scaling Problems

When the map grows, new issues appear:

Floating point precision
Physics jitter at higher speeds
Memory growth during long sessions
Object cleanup when streaming terrain

Chunked terrain tied to player position helps maintain stability. A floating origin strategy becomes useful once distances get large.

Another simple but effective improvement is surface based friction. Switching grip dynamically for asphalt, dirt, and grass adds realism without heavy visual complexity.


Reference Demo

Here is a working example for exploration and reference:

https://theneoverse.web.app/#threeviewer&&redrock-ridge

It is not a finished product, but it demonstrates open world driving structure, physics integration, and larger map handling directly in the browser.


If others are building similar systems, especially with world streaming or floating origin approaches, it would be great to compare patterns and stability strategies.

2 Likes