billiards
June 12, 2026 · View on GitHub
This is an open-source project bringing unsophisticated billiards physics written in typescript to the browser.
Online Demo
Demos run in all major desktop and mobile browsers and uses WebGL
- Nine ball ⬀ make a break and share replay link with friends
- Three cushion billiards ⬀ the ultimate test of physics and player (average on both counts). You need the beginner mode ⬀. Try the practice mode ⬀ to drill specific shots.
- Snooker ⬀ we await the first 147 submission to the leaderboard.
- 8-Ball ⬀ try it in Hi-Res mode!
- Play vs the Claw ⬀ and TheFarJaw ⬀.
- Try two player online lobby using nchan
- Try to get on the leaderboard of highest breaks hosted on vercel.com
- Inspect physics and tweak constants using diagrams.
- Set up trick shots and practice ⬀.
- Tune three cushion physics ⬀ and optimise ⬀ parameters
- Parallel parameter ⬀ tuning using web workers ⬀.
- Three cushion trainer and sensitivity analysis ⬀ from an excellent fork ⬀ of this project.
Features
- Backspin, sidespin and cushion bounces well modeled.
- Presentation using WebGL in any modern browser on mobile, linux, mac or windows.
- Record and playback breaks.
- Two player online mode with nchan nginx server.
- Nine ball, snooker and three cushion billiards rules.
- Deploys to github pages, vercel.com and render.com with github actions.
- Runs on and was developed mostly on a potato e.g. Raspberry pi 4.
Reference material
- Papers on ball mechanics Han 2005 with important corrections by Kiefl.
- cushions, max spin, simulation and constants 1 2 3 4 5
- 3D graphics uses three.js
- Inline LaTeX editor for equations in README.md
Key equations
Based on Han 2005 paper
surface velocity
sliding motion
rolling motion
where
,
collisions
Based on paper by Alciatore incorporating throw effect due to the small amount of friction between balls. Figures to prove consistency between the code and paper here.
For ball :
For ball :
Where:
The relative velocity at the point of contact is computed as:
and
: normal unit vector along the line of centers.
: tangential unit vector perpendicular to .
cushion bounce
This is based on a paper by Mathavan. Many of the figures from the paper are recreated to confirm correctness.
Slip velocity at cushion contact point I
Slip velocity at table contact point C
Numerical solutions for the centroid velocity of the ball during compression and resititution phases.
Numerical solutions for angular velocity of ball
is a constant of the angle of cushion contact above ball centre with . is the coefficient of sliding friction between the ball and table surface. is the coefficient of sliding friction between the ball and the cushion.
Work done by the normal force at contact point along the -axis which is aligned from the ball centre to I
The ball is assumed to be bouncing in the +y cushion. Compression phase iterates until
For the restitution phase the iteration continues until the work done is
Some of the Mathavan equations not supplied by the paper were inferred to bridge gaps for a complete numerical solution.
Stronge compliant cushion model
Based on the book Impact Mechanics by Stronge. This analytical model accounts for the compliant nature of cushion deformation and resolves the collision across three slip regimes.
Contact velocity at the cushion contact point:
Regime classification is determined by the ratio and thresholds involving the friction coefficient , restitution , and mass-matrix coefficients :
| Regime | Condition |
|---|---|
| Gross slip | |
| Initial stick | |
| Slip-stick-slip | neither of the above |
where is derived from the frequency ratio .
Velocity reconstruction from scalar solver results and :
Final updates:
Useful commands
Install
nvm use v24.11.0
corepack enable
yarn set version 4.9.1
yarn install
yarn build
yarn gltfpack
This generates artefacts in /dist for prod deployment (e.g. on github static pages)
Run
yarn serve
Then open http://localhost:8080/ in your browser to play
Test
yarn test
yarn coverage
Maintain
yarn deps
yarn upgrade -L
yarn prettify
Two player
yarn serve
then open http://localhost:8080/multi.html to see options, message server is public nchan.
Controls
Use mouse, touch screen or keyboard:
⇦ ⇨ Aim
Control ⇦ ⇨ Fine aim
⇧ ⇩ Topspin and backspin
Shift ⇦ ⇨ Side spin
Space Hit - hold for more power
A Toggle aim helper
M Masse angle
O Camera view
F Full screen
C Chat
H Help
+ - Camera height
Mouse
scroll Shot power
dbl click Hit
Progress snapshots
July 2018

July 2019

March 2021

August 2023 (mobile)
| top | aim |
|---|---|
![]() | ![]() |
Star History
Licence
This project is open source and licensed under the GNU General Public License - see the LICENSE file for details. Contributions welcome.



