Contents
1 Overview
Emerald Break is a complete HTML5 3D 8-ball billiards game, set in a quiet private club with a green cloth and a brass lamp. The player aims, chooses the power and the spin, and pockets balls on a table with its own ball physics.
There are three ways to play: against the computer, with three opponents (Leo is easy, Maya is medium and Victor is hard); two players taking turns on the same device; and practice, alone on the table with no rules. Behind the menu, the computer plays a silent match.
The aim guide shows the path of the cue ball, the ball it will hit and where both go next, and a red X marks a ball that would be a foul. There is a 3D view behind the cue ball and a view of the whole table, call-outs for bank shots, combinations and long pots, a victory screen with the numbers of the match, sound effects and music, vibration on phones, 14 interface languages and layouts for phone, tablet and desktop. It is drawn in real 3D with Three.js, which is included in the download.
2 Installing on your website
Installing takes a few minutes if you have FTP access or a file manager in your hosting panel.
- 1. Extract
emerald-break-static-1.0.0.zipon your computer. -
2. Connect to your hosting by FTP or its file manager and open the folder where the game should live, for
example
public_html/games/emerald-break/. -
3. Upload only the contents of the
game/folder, so thatindex.htmlsits directly inside the target folder. -
4. Keep
assets/,css/,lib/andsrc/besideindex.html, with names and letter case unchanged. -
5. Open
https://your-domain.example/games/emerald-break/in a modern browser.
source/ folder, the documentation/ folder or the ZIP itself.
Players need no Node.js, PHP, database or account.
3 Requirements
-
Any static web hosting with HTTPS (or HTTP). Opening
index.htmldirectly from the disk (file://) does not work, because browsers block JavaScript modules there. - A current browser with WebGL 2: Chrome, Edge, Firefox, Safari or Opera, on desktop or mobile. The game draws in 3D, so a phone or computer from the last few years works best.
-
About 9 MB of space on the server. The game makes no request to other websites: the Three.js library,
fonts, pictures and sounds are all inside
game/. -
Node.js is only needed to run the tests or to rebuild the game from
source/(see the development section).
4 How to play
Aim: drag anywhere on the table to turn the cue, or tap a ball to aim straight at it. Slow drags turn less, for small corrections. With a mouse, the wheel turns the cue a little at a time. On a keyboard, the left and right arrows do the same, and Shift makes each step bigger.
Shoot: pull the bar on the right side down to choose the power and let go to shoot. Push it back to the top to cancel. The small white ball in the corner sets the spin: tap or drag on it to choose where the cue touches the cue ball. The camera button changes between the 3D view and the whole table.
Rules: after the break, the first ball pocketed without a foul decides who plays the solids (1 to 7) and who plays the stripes (9 to 15). Pocket your whole group and then the 8 to win, in any pocket. Pocketing the 8 too early, or together with a foul, loses the match. On the break, a pocketed 8 goes back to the table.
Fouls: pocketing the cue ball, hitting no ball, hitting the wrong ball first, or no ball reaching a cushion after the hit when none is pocketed. After a foul the other player gets the ball in hand: drag the cue ball to any free place on the table. Escape closes the open panel. Settings and volumes are saved automatically; a match in progress is not saved.
5 Screens
Marks on the screenshot
- Logo
- Start button
- Sound: music and effects volume
- Settings
Marks on the screenshot
- Play against the computer
- Two players
- Practice
- How to play
Marks on the screenshot
- Leo, easy
- Maya, medium
- Victor, hard
- Play
Marks on the screenshot
- Players, groups and remaining balls
- Pause
- Power: pull down and let go
- Spin of the cue ball
- Change the view
Marks on the screenshot
- Resume
- Restart
- Menu
Marks on the screenshot
- Numbers of the match
- Play again
- Menu
Marks on the screenshot
- Music volume
- Effects volume
Marks on the screenshot
- Reduced motion
- Aim guide
- Language
- Close
6 Files and folders
game/ is the ready-to-host game. source/ has the same editable files plus the
tests, a local preview server and the build command. The code is plain JavaScript ES modules with no compile
step and no npm dependency.
game/ upload these contents to your web host
index.html every screen and panel, and the import map of Three.js
css/base.css, css/ui.css layout and look of the interface
src/config.js START HERE: every game feel number (FEEL)
src/main.js starts everything
src/core/ table, physics, rules, match, rack and opponents (no drawing)
src/game/ turns, input, game screen, sound, effects of each event
src/render/ the 3D scene: table, balls, cue, aim guide, lamp, camera
src/app/ menus, panels and the confetti
src/lib/ languages, text fitting, full screen, saving, panel frames
src/lib/locales/ interface texts, one file per language
assets/ui/ buttons, panels, portraits and icons (WebP)
assets/tex/ balls, cloth, wood, steel, cue and effects (WebP)
assets/bg/ the room, upright and wide (WebP)
assets/audio/ sfx/ sound effects and music/ (MP3)
assets/fonts/ Fredoka, Rubik and their licenses
lib/three/ the Three.js library (MIT), unminified, and its license
DOCUMENTATION.txt short note that points to this guide
source/ the same editable files, plus:
package.json, package-lock.json
README.md, DO-NOT-UPLOAD.txt
tests/ npm test (15 checks)
tools/build.mjs copies the game into dist/
tools/serve.mjs local preview server (npm run dev, npm run preview)
tools/check-node.mjs checks the Node.js version before the commands
documentation/index.html this guide (offline, 14 languages)
documentation/customization.html step-by-step customization guide
documentation/img/ the screenshots of the guides
DOCUMENTATION.html shortcut to this guide
CUSTOMIZATION.html shortcut to the customization guide
START-HERE.txt, CHANGELOG.txt
THIRD-PARTY-LICENSES/ Three.js, Fredoka and Rubik licenses
-
src/config.js: the first file to edit.FEELhas every number that changes how the game feels (cue, aim, camera, pockets, effects, sound mix) andBALL_COLORSthe colors of the effects of each ball. -
src/core/: the game without any drawing.table.jsis the size of the table, the cushions and the pockets,physics.jsthe movement of the balls,rules.jsthe rules,match.jsa match,rack.jsthe rack andai.jsthe three computer opponents. -
src/main.js: starts everything.src/game/game.js: the turns of a match.input.jsreads touch, mouse and keyboard,hud.jsis the game screen,audio.jsthe sound,juice.jsconnects each event to its effects andshotinfo.jsnames bank shots, combinations and near misses. -
src/render/: the 3D scene.stage.jshas the lamp, the light and the camera,table.jsthe table,balls.jsthe balls,cue.jsthe cue,guide.jsthe aim guide andfx.jsthe particles and rings. -
index.html: the page with every screen and panel, and the import map that points tolib/three/.css/: the look of the interface.src/app/: menus, panels and the confetti.src/lib/: languages, text fitting, full screen, saving and the panel frames. -
assets/ui/: buttons, panels, portraits and icons.assets/tex/: balls, cloth, wood, steel, cue and effects of the 3D scene.assets/bg/: the room.assets/audio/: sounds and music in MP3.assets/fonts/: the fonts and their licenses.lib/three/: the Three.js library and its license.
7 Internal names in the code
Some names in the files are not the words on the screen. They are only names: players never see them. The table of this section tells you which file is which.
-
assets/bg/fundo-pe.webpis the room on upright screens andfundo-deitado.webpthe room on wide screens. The names are Portuguese words. -
Portraits:
ava-<name>-<mood>.webpinassets/ui/. The names areyou,leo,mayaandvictor, and the moods areidle,hype,cheerandsad. Player 1 usesyou, and player 2 usesmaya. -
Balls:
assets/tex/ball-0.webpis the cue ball andball-1.webptoball-15.webpare the numbered balls, as they are wrapped around the 3D balls. The pictures with the same names inassets/ui/are the small icons of the player cards. -
In the code,
kitchenis the area behind the line where the cue ball is placed for the break,potis a pocketed ball andscratchis a pocketed cue ball. The opponents are calledeasy,mediumandhard.
8 Customizing
CUSTOMIZATION.html in the main folder of the download, or
documentation/customization.html.
Brand: the name in the browser tab is the <title> line of index.html. The
logo is assets/ui/logo.webp (1097 x 520 pixels, transparent background). The page icon is
assets/ui/ball-8.webp.
Pictures: replace a file in assets/ with another WebP of the same name and the same size. The
cloth is assets/tex/felt.webp, the wood is assets/tex/wood.webp and the room is in
assets/bg/.
Opponents: their skill is in DIFFICULTY at the top of src/core/ai.js.
aimSigma is how much the aim misses and powerSigma how much the power misses:
bigger numbers make an easier opponent. Their names are in src/game/hud.js and
src/app/ui.js.
Feel: FEEL in src/config.js. aim is the aiming,
camera the two views, pocket the fall of a ball and its light,
slowmo the slow motion of the winning 8 and sound the volume of the pockets. The
brightness of the lamp is LAMP in src/render/stage.js.
Sounds and music
Every effect is an MP3 in assets/audio/sfx/. The sounds of the balls, the cushions, the cue and
the pockets have several versions, for example pocket0.mp3 to pocket3.mp3, and the
game picks one each time. Replace a file and keep its name. The sounds of the buttons are made by the code
in src/game/audio.js.
The music is assets/audio/music/lounge1.mp3 and lounge2.mp3, which play one after
the other. The list is TRACKS in src/game/audio.js, and the versions of each
effect are in BANKS in the same file. The first volumes are in DEFAULTS in
src/lib/store.js.
emerald-break.save.v1.
If you host two copies of the game on the same domain, change KEY in
src/lib/store.js of one of them.
9 Languages
The game has 14 languages: English, Portuguese, Spanish, French, German, Italian, Dutch, Polish, Turkish, Russian, Indonesian, Japanese, Korean and Chinese. The first visit uses the browser language; the player can change it in Settings.
To change a text, edit the same key in src/lib/locales/<code>.js. A key missing in
another language falls back to English. To add a language, copy en.js, translate it, and add it
to the imports, LANGS, LANG_NAMES and STRINGS in
src/lib/locales.js.
There is no address switch for the language: the first visit uses the language of the browser and the player changes it in Settings, where it is remembered. Russian uses the included Rubik font. Japanese, Korean and Chinese use the fonts of the device.
10 Saving and resetting
- The volumes, the settings, the language, the last opponent and the last camera view are saved automatically in the browser of each player (localStorage). Nothing is sent to a server.
- Everything is stored under one key, shown below. A match in progress is not saved.
- To start over, delete this key in the developer tools (F12), under Application, Local Storage, or clear the site data in the browser.
emerald-break.save.v1
11 Development (optional)
This section is only for changing the code. The game/ folder already contains the finished
game, so installing it needs no Node.js. The game has no npm dependencies and no compile step:
npm run build only copies the files into dist/.
1. Install Node.js. Open https://nodejs.org/en/download and choose the latest Node.js 26 LTS installer for your system (minimum 26.13.0). npm is included.
Windows: run the .msi installer, keep npm and Add to PATH enabled, finish the installation and reopen Command Prompt. macOS: run the official .pkg installer and reopen Terminal. Linux: follow the instructions on the same page for your distribution.
2. Check the installation. Run node --version and npm --version separately. Both
must print a version number, and Node.js must be 26.13.0 or newer. If a command is not found, reopen the
terminal and check that Node.js is in PATH.
node --version
npm --version
3. Extract the complete ZIP first and open its source/ folder, where
package.json is. Windows: type cmd in the address bar of that folder in File Explorer. macOS
and Linux: open Terminal and use cd with the path of the folder.
4. Run the commands below one by one. npm ci checks the lock file (nothing is downloaded, the
project has no dependencies). npm test runs 15 checks: the rack, complete matches between the
opponents, the aim guide against the physics, the 14 languages and the package.
npm ci
npm test
5. Preview: npm run dev starts a local server; open http://localhost:5180/ in your browser,
play for a while, and stop the server with Ctrl+C.
npm run dev
6. Build: npm run build empties source/dist/ and copies index.html,
css/, src/, assets/ and lib/ into it.
dist/ is what you publish; while the source is unchanged it is identical to game/.
npm run build
7. Publish: back up the game on your website, then upload the contents of dist/ in place of the
old files, keeping the folders. If you deleted or renamed a file, delete the old one on the server yourself.
Clear the cache afterwards.
npm test, means Node.js is too old. If PowerShell
blocks npm.ps1, use Command Prompt or run npm.cmd.
12 Updating and clearing the cache
Clearing the cache without losing progress
Progress is stored in this browser, not on the server. Clearing cached images and files, or doing a hard reload, keeps your progress.
Computer: press Ctrl+F5 on Windows and Linux, or Cmd+Shift+R on macOS. Phone: in the browser settings, choose the option to clear cached images and files.
Do not choose cookies and site data, or clear site data, for the game's address. That deletes the local save.
13 Licences and credits
The game code, the artwork, the sound effects and the music are supplied under the license of the item you purchased.
Third-party parts, with their complete license texts in THIRD-PARTY-LICENSES/: the Three.js
library, unminified in game/lib/three/ (MIT License), and the Fredoka and Rubik fonts (SIL Open
Font License 1.1, also in assets/fonts/).
14 Common problems
-
Blank page or a game that never opens: the game was opened from the disk or a file is missing. Use a web
host and keep every file and folder of
game/next toindex.html. - No sound: browsers start audio only after the first tap, click or key press. Check both volumes in the Sound panel and the volume of the device.
-
A blank page after you edit a code file: there is a typo in the file. Open the browser console (F12) to
see the line, and run
npm testbefore publishing. -
The game feels slow on an old phone: turn on Reduced motion in Settings. You can also lower the shadow
size,
shadow.mapSize, insrc/render/stage.js. - The old version still appears after an update: clear the cache (see the section above). Two copies on the same domain share their settings: give each copy its own save key.
- A black or empty 3D view: the browser has no WebGL 2 or the graphics acceleration is turned off. Turn hardware acceleration on in the browser settings or try another browser.
15 FAQ
Does the game need a database or a server language?
Does it use a game engine?
Is there online multiplayer?
Can I change how strong the opponents are?
DIFFICULTY in src/core/ai.js (see the Customization
Guide).
Does it work on phones?
Do the colors of the balls follow the usual ones?
16 For AI assistants
If you ask an AI assistant to help you change this game, give it the prompt below together with your request. It describes the project so the assistant works on the right files and does not break the rules of the game.
You are helping me change "Emerald Break", a finished HTML5 3D 8-ball billiards game (version 1.0.0). Read these facts before you edit anything.
PROJECT
- Plain JavaScript ES modules, HTML and CSS. No bundler, no compile step, no npm dependencies.
- The 3D drawing uses Three.js r186, unminified, in lib/three/ and loaded through the import map in index.html. Do not upgrade, minify or reformat it.
- The editable project is source/ (the same files as game/, plus tests and tools). Edit source/, never game/ or source/dist/.
- npm run build copies index.html, css/, src/, assets/ and lib/ into source/dist/ and nothing else. Upload the CONTENTS of dist/ (or game/) to a static web host.
- Node.js 26.13.0 or newer is needed only for: npm ci, npm test, npm run dev (http://localhost:5180/), npm run build, npm run preview.
GAME
- 8-ball: solids 1-7, stripes 9-15, the 8 last, any pocket. Modes: cpu (easy = Leo, medium = Maya, hard = Victor), 2p (two players on one device) and practice (no rules).
- src/core/ has no drawing and no time of its own: table.js (meters), physics.js (fixed step, same seed and shot = same result), rules.js, match.js, rack.js, ai.js (DIFFICULTY sets each opponent).
- Every shot is first simulated without drawing (readShot in src/game/shotinfo.js). That result drives the lights, the call-outs and the slow motion; effects must never change the physics.
- src/game/game.js runs the turns: intro, aim or cpu, stroke, roll, resolve. juice.js connects events to effects. All feel numbers are FEEL in src/config.js.
- Physics coordinates (x, y, z up) become (x, z, -y) in the 3D scene. The pockets are real holes cut by a shader (holed() in src/render/table.js).
- CSS entrance animations must never be switched off with "animation: none" by a class: use a 1ms duration, or the screen flashes when the class is removed.
- Texts: src/lib/locales/<code>.js, 14 languages, same keys in every file; English is the fallback. New text goes in all 14.
- Saving: one localStorage key, KEY in src/lib/store.js ('emerald-break.save.v1'). A match in progress is not saved.
- Sounds: assets/audio/sfx/ and assets/audio/music/, listed in BANKS and TRACKS in src/game/audio.js.
RULES FOR YOU
1. Make the smallest change that does what I ask. Do not rename or move files.
2. Run npm test after every change and fix what it reports. Run npm run build at the end.
3. Test through a web server (npm run dev), never from file://.
4. Add no network request, CDN, analytics, advertising or external font. Keep THIRD-PARTY-LICENSES/ and lib/three/LICENSE.
5. Keep comments in English and keep the last line of each own JavaScript and CSS file: // End of <path> (complete file).
MY REQUEST:
(write what you want here)
Replace the last line with what you want, for example: make Leo easier, change the color of the cloth or add
a fourth opponent. Always run npm test after the change.
17 Support
Questions or problems: write to willian@polargames.com.br with your purchase code, the browser
and a short description or screenshot.
Support request
When you write to support, include the browser and device, the game version, the page address, the steps that caused the problem, a screenshot and the first error shown in the browser console. Never send passwords, payment details or secret keys.