I've been building a browser version of the Royal Game of Ur (Mesopotamia, ~2500 BC) in three.js r128, and wanted to share some of the techniques. There are no model files and no image textures: the board, stones, pyramid dice, braziers and temple are all built from geometry in code, and the surfaces (wood, lapis, shell) are drawn on canvases at startup. The whole game is about 270 KB of code plus three.js.
Some things that might be interesting:
Rendering
- ACES Filmic tone mapping, PCF soft shadows from one directional light, and point lights in the braziers that flicker.
- Bloom and FXAA through EffectComposer, on the highest quality setting only. Phones default one level lower, and the lowest level turns off shadows.
- Particles (embers and dust) using Points.
Making it work on any screen
- The camera framing isn't fixed: it projects the corners of the board, trays and dice into screen space and moves in until everything fits between the top bar and the throw panel. Ultra-wide monitors get a tight frame; phones don't get a tiny board.
- Phones held upright: the camera turns 90° to look down the board's length, and the stone trays move beside the board, so the 3x8 board fills the width of the screen (squares go from ~36 px to ~45 px on a typical phone).
- Fog density is scaled by the camera's distance. A fixed density made the scene almost black on phones in portrait, where the camera sits much further back.
- Taps on touch screens snap to the nearest movable stone (or the square it would land on) within ~7 mm, since a fingertip is bigger than a stone seen from above.
Materials
- The stones were washing out under the overhead light. Switching from glossy to a satin finish (higher roughness, no metalness) fixed the bright patches without making them look flat.
Not three.js, but in the same spirit: the music is also made in code, with Web Audio. The lyre uses Karplus-Strong string synthesis.
Play it (free, no sign-up): https://goarcade.games/ur/
I'd especially like feedback on performance on your devices, and on the lighting and materials: does it read as stone and wood, or as plastic?
I built it with an AI coding assistant; the techniques above are what ended up in the code.