Skip to content
Boris Truyens

A conversation with the air

Table tennis in the browser with real topspin and backspin, a trail-survival duel, and online matches without a server.

Spin Pong 3D, table tennis on a regulation-size table.
Spin Pong 3D, table tennis on a regulation-size table.

Pong is the oldest video game everyone knows: two bars and a square. I wanted to make the opposite. Not the simplest version, but the most honest one: a ball that behaves like a real table-tennis ball.

Why a ball curves

A spinning ball drags a thin layer of air with it. On the side that turns with the airflow, the air moves faster; on the other side, slower. Faster air has lower pressure, so the ball is pushed towards that side. This is the Magnus effect, the same physics that curls a free kick around a wall.

With topspin the top of the ball turns forward. The force then points down: the ball dives. With backspin it points up: the ball floats. Try it:

A table-tennis ball weighs 2.7 grams. That makes drag and Magnus force large compared to its weight, so you see the effect better than with almost any other ball. In the game, a custom fixed-step integrator computes gravity, drag and Magnus force hundreds of times per second.

Everything from code

There is not a single sound file in the game. Every tap on the table, every stroke, every menu sound: all of it is synthesised live with the Web Audio API. The 3D models are procedural too, built in Three.js from maths instead of loaded from files.

There is also a second game: Curve Battle. You steer a line that leaves a trail, slip through gaps and box your opponent in. With obstacles, and portals that teleport you while keeping your heading.

Online without a server

Online play goes straight from browser to browser over WebRTC. There is no game server and no account. The host’s browser is the referee: it decides points and crashes, and the other player’s screen follows. That way both screens always agree on the score. For networks that do not allow a direct connection, traffic goes through a relay.

The phone as a paddle

On a phone or tablet you can tilt the device to steer, and a tap, swipe or flick becomes a stroke. “Level” is re-measured at every serve, so you hold the phone however is comfortable. There is also an experimental webcam mode that tracks your hand: swipe up for topspin, down for a slice. The video never leaves your device.

What I learned

A game that “feels right” is usually a game that calculates right. People sense physics flawlessly, even when they don’t know the formula. Every time the ball did something odd, the fault was in the forces, not the graphics.

It is the same in machining. The chip tells you whether your cutting speed is right, long before you look it up in a table.

Play Spin Pong 3D →

Where this leads

This project shares threads with others. Follow one.