39. Appendix: GPU Billiards
This appendix is a browser showcase, not the games chapter. The language contract is 28.9–28.10; the catalog is 35.3. It hosts the compiled JavaScript for Examples/Games/three_shader_billiards.malda. The kernel is still @shader() GLSL; host MALDA steps 2D physics and pushes ball and cue uniforms. Print omits the playable frame.
39.1 Playable table
Needs WebGL. Click inside the frame so mouse and keyboard reach the demo. Hold click or Space to charge, then release to shoot. The demo UI stays in English.
Chapter 39 is screen-only: the interactive table is omitted from print. Open this chapter in a browser, or compile the source below.
39.2 Controls
- Mouse on the table aims the cue; A/D fine-tunes.
- Hold click or Space to charge; release to shoot.
- R reracks. Arrow keys orbit. C or Stop camera zeros orbit speed.
[]or+−zoom. Sliders set cushion e, ball e, and felt friction.
39.3 Rebuild the committed script
Do not hand-edit ReferenceManual/three_shader_billiards.js. Change the .malda source and compile into a throwaway folder — malda compile --mode js -o also writes index.html beside the script, so do not target ReferenceManual/ directly:
malda compile Examples/Games/three_shader_billiards.malda --mode js -o artifacts/billiards-appendix/three_shader_billiards.js
cp artifacts/billiards-appendix/three_shader_billiards.js ReferenceManual/three_shader_billiards.js
A content guard fails if that file drifts from a fresh transpile (the source-map comment the CLI appends is ignored). Local browsing from the repo root loads three.min.js and malda-js-runtime.js from Examples/Web/wwwroot/. GitHub Pages copies those two files next to this chapter.