import puppeteer from 'puppeteer'; import sharp from 'sharp'; const b = await puppeteer.launch({ args:['--no-sandbox','--disable-setuid-sandbox','--use-gl=angle','--enable-unsafe-swiftshader','--ignore-gpu-blocklist'] }); const p = await b.newPage(); await p.setViewport({width:1280,height:1200}); const errs=[]; p.on('console',m=>{if(m.type()==='error')errs.push(m.text())}); p.on('pageerror',e=>errs.push('PE '+e.message)); await p.goto('http://10.200.201.3:4175/_lab/neu-card.html',{waitUntil:'load',timeout:60000}); await new Promise(r=>setTimeout(r,1200)); const demo = await p.$('[data-shader-demo]'); await demo.evaluate(el=>el.scrollIntoView({block:'center'})); await new Promise(r=>setTimeout(r,400)); async function probe(key){ if(key){ await p.click(`[data-shader-switch="${key}"]`); await new Promise(r=>setTimeout(r,700)); } const el = await p.$('[data-shader-demo]'); const box = await el.boundingBox(); await el.screenshot({path:'/tmp/demo.png'}); const {data,info}=await sharp('/tmp/demo.png').raw().toBuffer({resolveWithObject:true}); let n=info.width*info.height, rs=0,gs=0,bs=0; const cols=new Set(); for(let i=0;i>5},${data[i+1]>>5},${data[i+2]>>5}`); } return { key: key||'mesh', avg:[Math.round(rs/n),Math.round(gs/n),Math.round(bs/n)], distinct: cols.size }; } const r1=await probe(); const r2=await probe('grain'); const r3=await probe('voronoi'); const r4=await probe('staticMesh'); console.log(JSON.stringify({r1,r2,r3,r4,errs},null,1)); await b.close();