Draw the map with WebGL2 by default, with the 2D canvas as fallback

- Sea, land, waves, clouds, cables, tubes and packets are drawn by the
  graphics card; the land is geometry built once, so panning and zooming
  repaint nothing.
- Cities, labels and markers are painted once into a sprite atlas and drawn
  in one call (with drawImage in 2D, which speeds up the 2D map too).
- Settings > Map drawing: Auto or Always 2D, per device. Browsers without
  WebGL2, a lost context and puzzles keep the 2D map.
- npm run bench:gpu compares 2D and WebGL in a real browser on a real GPU;
  ?fps shows a frame meter.
This commit is contained in:
Antoine 2026-11-04 11:37:27 +01:00
parent 7aa6506e70
commit cf9ab5e774
No known key found for this signature in database
GPG key ID: 728FF1CE15732B05
36 changed files with 862 additions and 83 deletions

View file

@ -6,7 +6,7 @@ const { load } = require('./harness');
// land on another is left out, unless the cable touches the selected city.
const labels = (ev, sel) => JSON.parse(ev(`(()=>{ACT.start({});S.nextFail=1e9;S.nextEvent=1e9;UI.sel=${sel ? `{type:'city',id:'${sel}'}` : 'null'};
cam.x=(CITY.mnl.x+CITY.dvo.x)/2;cam.y=(CITY.mnl.y+CITY.dvo.y)/2;cam.z=4.5;const out=[];
ctx.fillText=(t,x,y)=>out.push({t,x,y,w:ctx.measureText(t).width});ctx.strokeText=()=>{};drawCables([0]);return JSON.stringify(out);})()`));
const ts=textStamp;textStamp=(t,f,px,w,c,sk,lw,x,y)=>out.push({t,x,y,w});try{drawCables([0]);}finally{textStamp=ts;}return JSON.stringify(out);})()`));
test('cable names never sit on top of each other', () => {
const { ev, errors } = load();