# billiards
**Repository Path**: bababi/billiards
## Basic Information
- **Project Name**: billiards
- **Description**: 镜像自github, 值得学习的桌球游戏源码
GPL协议
- **Primary Language**: TypeScript
- **License**: GPL-3.0
- **Default Branch**: master
- **Homepage**: None
- **GVP Project**: No
## Statistics
- **Stars**: 0
- **Forks**: 0
- **Created**: 2024-05-07
- **Last Updated**: 2024-08-23
## Categories & Tags
**Categories**: Uncategorized
**Tags**: None
## README
# billiards
[](https://codecov.io/gh/tailuge/billiards)
[](https://www.codefactor.io/repository/github/tailuge/billiards)
[](https://sonarcloud.io/summary/new_code?id=tailuge_billiards)
[](https://github.com/tailuge/billiards/actions/workflows/main.yml)
[](https://gitpod.io/#https://github.com/tailuge/billiards)

[](https://tailuge.github.io/billiards/dist)
This is an open-source project bringing unsophisticated billiards physics written in typescript to a browser near you. Play pool, snooker, or 3-cushion online for free!
## Features
* Backspin and sidespin well modeled.
* Presentation using WebGL in any modern browser on mobile, linux, mac or windows.
* Record and playback breaks.
* Two player online mode with node websocket server.
* Nine ball, Snooker and three cushion billiards rules.
* Deploys to github pages, vercel.com and render.com with github actions.
## Online Demo
Demos run in all major desktop and mobile browsers and uses WebGL
* [Nine ball ⬀](https://tailuge.github.io/billiards/dist) make a break and share replay link with friends
* [Three cushion billiards ⬀](https://tailuge.github.io/billiards/dist?ruletype=threecushion) the ultimate test of physics and player (average on both counts)
* [Snooker ⬀](https://tailuge.github.io/billiards/dist?ruletype=snooker) we await the first 147 submission to the leaderboard.
* 4-ball [Straight pool ⬀](https://tailuge.github.io/billiards/dist?ruletype=fourteenone).
* Inspect physics and tweak constants using [diagrams](https://tailuge.github.io/billiards/dist/diagrams/diagrams.html).
* Try to get on the leaderboard of highest [breaks](https://scoreboard-tailuge.vercel.app/leaderboard.html) hosted on vercel.com
* Try [two player](https://tailuge.github.io/billiards/dist/lobby/lobby.html) online hosted on render.com
## Reference material
* Papers on ball mechanics [Han 2005](https://billiards.colostate.edu/physics_articles/Han_paper.pdf)
with important corrections by [Kiefl](https://ekiefl.github.io/2020/04/24/pooltool-theory/#3-han-2005").
* [cushions](https://billiards.colostate.edu/physics_articles/Mathavan_IMechE_2010.pdf), [max spin](https://billiards.colostate.edu/technical_proofs/new/TP_B-17.pdf),
simulation and constants [1](https://savoirs.usherbrooke.ca/bitstream/handle/11143/6598/MR91690.pdf?sequence=1)
[2](http://citeseerx.ist.psu.edu/viewdoc/download?doi=10.1.1.89.4627&rep=rep1&type=pdf)
[3](https://www.researchgate.net/publication/228634093_Bounce_of_a_spinning_ball_near_normal_incidence)
[4](https://billiards.colostate.edu/technical_proofs/new/TP_B-6.pdf)
[5](https://billiards.colostate.edu/faq/physics/physical-properties/)
* 3D graphics uses [three.js](https://threejs.org/docs/index.html#api/math/Vector3)
* Inline [LaTeX](https://www.codecogs.com/eqnedit.php?latex=\dot{a}) editor
for equations in README.md
### Key equations
Based on [Han 2005](https://billiards.colostate.edu/physics_articles/Han_paper.pdf) paper
#### surface velocity
)
#### sliding motion


)
#### rolling motion


where

,
#### cushion bounce
## Useful commands
### Install
```shell
nvm use v18.17.1
yarn install
yarn dev
yarn gltfpack
```
This generates artefacts in /dist for prod deployment (e.g. on github static pages)
### Run
```shell
yarn serve
```
Then open in your browser to play
### Test
```shell
yarn test
yarn coverage
```
### Maintain
```shell
yarn deps
yarn upgrade -L
yarn prettify
```
### Two player
```shell
yarn websocket
```
the client uses query parameter ``?websocketserver=wss://some-host`` to locate
a websocket server, open to see options
## Controls
Use mouse, touch screen or keyboard:
⇦
⇨ Aim
Control
⇦
⇨ Fine aim
⇧
⇩ Topspin and backspin
Shift
⇦
⇨ Side spin
Space Hit - hold for more power
## Progress snapshots
July 2018

July 2019

March 2021

August 2023 (mobile)
top | aim
:--:|:--:
 | 
Star History
[](https://star-history.com/#tailuge/billiards&Date)
## Licence
This project is open source and licensed under the GNU General Public License - see the [LICENSE](LICENSE) file for details. Contributions welcome.