Polar Games

A 3D 8-ball billiards game for the web · 1.0.0

Emerald Break

This guide explains how to install, play, customize and update the game. Pick your language at the top; screenshots stay in English.

Version 1.0.0 Edition Standalone buyer edition

This guide works without internet. Images, styles and scripts are already inside this file.

Contents
  1. Overview
  2. Installing on your website
  3. Requirements
  4. How to play
  5. Screens
  6. Files and folders
  7. Internal names in the code
  8. Customizing
  9. Languages
  10. Saving and resetting
  11. Development (optional)
  12. Updating and clearing the cache
  13. Licences and credits
  14. Common problems
  15. FAQ
  16. For AI assistants
  17. Support

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. 1. Extract emerald-break-static-1.0.0.zip on your computer.
  2. 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. 3. Upload only the contents of the game/ folder, so that index.html sits directly inside the target folder.
  4. 4. Keep assets/, css/, lib/ and src/ beside index.html, with names and letter case unchanged.
  5. 5. Open https://your-domain.example/games/emerald-break/ in a modern browser.
Warning Do not upload the 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.html directly 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

Start screen: tap or click to start. This first tap also turns the sound on.
Start screen: tap or click to start. This first tap also turns the sound on.

Marks on the screenshot

  1. Logo
  2. Start button
  3. Sound: music and effects volume
  4. Settings
Main menu: play against the computer, two players, practice and how to play. Sound and Settings stay in the top
corner of every screen.
Main menu: play against the computer, two players, practice and how to play. Sound and Settings stay in the top corner of every screen.

Marks on the screenshot

  1. Play against the computer
  2. Two players
  3. Practice
  4. How to play
Choose the opponent: Leo, Maya or Victor. The chosen card has a brighter golden frame, and the choice is
remembered.
Choose the opponent: Leo, Maya or Victor. The chosen card has a brighter golden frame, and the choice is remembered.

Marks on the screenshot

  1. Leo, easy
  2. Maya, medium
  3. Victor, hard
  4. Play
The break, in the 3D view behind the cue ball. The cue ball can be moved inside the lit area of the table.
The break, in the 3D view behind the cue ball. The cue ball can be moved inside the lit area of the table.
Aiming: the white line is the path of the cue ball, the golden line is where the target ball goes and the small
dots show where the cue ball goes next. The card at the top lights up for the player who has the turn.
Aiming: the white line is the path of the cue ball, the golden line is where the target ball goes and the small dots show where the cue ball goes next. The card at the top lights up for the player who has the turn.

Marks on the screenshot

  1. Players, groups and remaining balls
  2. Pause
  3. Power: pull down and let go
  4. Spin of the cue ball
  5. Change the view
A red line and a red X: this shot would hit a ball of the other player first, which is a foul.
A red line and a red X: this shot would hit a ball of the other player first, which is a foul.
The whole table, seen from above. The camera button changes between the two views, and the game remembers the
last one.
The whole table, seen from above. The camera button changes between the two views, and the game remembers the last one.
The pause panel: resume, start the match again or go back to the menu.
The pause panel: resume, start the match again or go back to the menu.

Marks on the screenshot

  1. Resume
  2. Restart
  3. Menu
The end of a match: the shots, the best run of balls pocketed in a row and the time.
The end of a match: the shots, the best run of balls pocketed in a row and the time.

Marks on the screenshot

  1. Numbers of the match
  2. Play again
  3. Menu
The Sound panel: one slider for the music and one for the effects.
The Sound panel: one slider for the music and one for the effects.

Marks on the screenshot

  1. Music volume
  2. Effects volume
Settings: reduced motion, aim guide, full screen (when the browser allows it) and language. Phones that can
vibrate also show a Vibration switch.
Settings: reduced motion, aim guide, full screen (when the browser allows it) and language. Phones that can vibrate also show a Vibration switch.

Marks on the screenshot

  1. Reduced motion
  2. Aim guide
  3. Language
  4. Close
A phone in portrait: the same game, with the power bar on the right and the spin ball in the lower left
corner.
A phone in portrait: the same game, with the power bar on the right and the spin ball in the lower left corner.

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. FEEL has every number that changes how the game feels (cue, aim, camera, pockets, effects, sound mix) and BALL_COLORS the colors of the effects of each ball.
  • src/core/: the game without any drawing. table.js is the size of the table, the cushions and the pockets, physics.js the movement of the balls, rules.js the rules, match.js a match, rack.js the rack and ai.js the three computer opponents.
  • src/main.js: starts everything. src/game/game.js: the turns of a match. input.js reads touch, mouse and keyboard, hud.js is the game screen, audio.js the sound, juice.js connects each event to its effects and shotinfo.js names bank shots, combinations and near misses.
  • src/render/: the 3D scene. stage.js has the lamp, the light and the camera, table.js the table, balls.js the balls, cue.js the cue, guide.js the aim guide and fx.js the particles and rings.
  • index.html: the page with every screen and panel, and the import map that points to lib/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.webp is the room on upright screens and fundo-deitado.webp the room on wide screens. The names are Portuguese words.
  • Portraits: ava-<name>-<mood>.webp in assets/ui/. The names are you, leo, maya and victor, and the moods are idle, hype, cheer and sad. Player 1 uses you, and player 2 uses maya.
  • Balls: assets/tex/ball-0.webp is the cue ball and ball-1.webp to ball-15.webp are the numbered balls, as they are wrapped around the 3D balls. The pictures with the same names in assets/ui/ are the small icons of the player cards.
  • In the code, kitchen is the area behind the line where the cue ball is placed for the break, pot is a pocketed ball and scratch is a pocketed cue ball. The opponents are called easy, medium and hard.

8 Customizing

Note Not a programmer? The Customization Guide shows the most common changes step by step. Open CUSTOMIZATION.html in the main folder of the download, or documentation/customization.html.

Customizing

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.

Warning Save key: the settings, the volumes and the language are saved under 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.

Note Troubleshooting: ENOENT or a missing package.json means the terminal is in the wrong folder. EBADENGINE, or the Node.js message printed before 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 to index.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 test before publishing.
  • The game feels slow on an old phone: turn on Reduced motion in Settings. You can also lower the shadow size, shadow.mapSize, in src/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?
No. It is a static website: HTML, CSS, JavaScript, pictures and sounds.
Does it use a game engine?
It uses the Three.js library for the 3D drawing (included, MIT License). The physics, the rules, the opponents and the screens are original code.
Is there online multiplayer?
No. Two people can play on the same device, taking turns, and one person can play against the computer.
Can I change how strong the opponents are?
Yes. Change the numbers of DIFFICULTY in src/core/ai.js (see the Customization Guide).
Does it work on phones?
Yes, in portrait and landscape, with touch. On a computer it works with the mouse, the wheel and the arrow keys.
Do the colors of the balls follow the usual ones?
Yes: solids from 1 to 7, the black 8 and stripes from 9 to 15. The rack always has the 8 in the middle.

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.