Project
three
An open-world fantasy MMO in the browser, in the style of World of Warcraft. The client is Three.js; the server is boxlang-express, which owns the world: monsters, combat, loot and every player's stats are decided there and sent to each client over one WebSocket.
A shared world
Everyone connected sees the same scenery, the same monsters and each other. Remote players and monsters are interpolated between server updates, and animated as they move.
Server-authoritative combat
The client picks a target; the server checks range, facing and cooldowns against its own record of where the player is, then applies damage, XP, gold and drops.
Abilities and an action bar
Four abilities unlock as a character levels, each with its own cooldown. Empty action-bar slots take a usable item by drag and drop, for one-key use.
Loot, gear and a vendor
Monsters drop items by zone, the harder zone's being rarer and stronger. Four equipment slots raise attack damage and health, and a shop NPC sells the basics.
Tech stack
| Layer | What |
|---|---|
| Client | Three.js, built with Vite. Plain JavaScript modules, no UI framework. |
| Server | BoxLang on boxlang-express. app.bxs wires things together; game logic is in server/game/, REST routes in server/routes/ and database access in server/models/. |
| Realtime | app.ws( "/game" ), with the monster AI on an app.schedule() tick. No SocketBox or CommandBox. |
| Database | MySQL. |
| Assets | CC0 models from KayKit, Quaternius and Kenney's Nature Kit. |
What's in it
- Accounts with PBKDF2-hashed passwords, and up to three characters each. Signing in somewhere else ends the earlier session and closes its connection.
- A third-person character with WASD movement, strafing and a mouse-look camera.
- Two zones, the Meadow and the harder Ashen Highlands, with passive and aggressive monsters that wander, chase, die and respawn on the server.
- Levels, XP, gold, and death with a respawn timer and a small XP penalty.
- Four abilities: Heroic Strike, Cleave, Execute and Rampage.
- An inventory, weapon, helmet, chest and trinket slots, and a vendor who checks your gold and how close you are standing.
- Chat over the same WebSocket as the game.
Run it
Needs the BoxLang CLI, CommandBox, Node and a local MySQL server. Set the server up once:
bashgit clone https://github.com/robertz/three.git
cd three/server
box install
mysql -uroot -e "CREATE DATABASE IF NOT EXISTS three"
mysql -uroot three < db/schema.sql
cp .env.example .env
Then build the client and start the server, which serves the built client too:
bashcd ../client && npm install && npm run build
cd ../server && ./start.sh
Open http://localhost:3001. Without .env, ./start.sh hangs with no output instead of failing, so check that first if nothing appears.
Tests
TestBox specs for the game logic and the account routes. They use the real three database, and each spec removes the accounts it creates:
bashcd server
box install testbox --saveDev
boxlang --bx-config boxlang.json run-tests.bxs