Environment lighting: - ship all eight desktop studiolights/world datasets (WBENV1 float32) and a shared loader used by both the main viewport and the offscreen worker - add the N-panel "studio 环境" selector - rotate the world background together with the environment (backgroundRotation/backgroundIntensity), so camera view and offscreen renders match the desktop Mapping-node behaviour Verification (Chromium, OPFS, NOT_CLAIMED): - environment lighting + 8 world pixel identity - camera-view rotation correspondence (camera matrices, 207 samples) - offscreen vs on-screen background parity after hiding geometry (1305 samples) - metals case extended with material-field OPFS roundtrip - material Principled edits and rename undo/redo - eight studio worlds: pairwise frame differences + luminance rank correlation - undo history depth capped at 64 steps and undo across OPFS save/reopen Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
135 lines
6.5 KiB
JavaScript
135 lines
6.5 KiB
JavaScript
import { createRequire } from 'node:module';
|
|
const WEB='/home/mes123456/workinf_Blender_Wasm/web';
|
|
const { chromium }=createRequire(WEB+'/package.json')('playwright');
|
|
const BASE='http://127.0.0.1:5184';
|
|
const args=['--no-sandbox','--use-gl=angle','--use-angle=gl','--ignore-gpu-blocklist',
|
|
'--enable-gpu-rasterization','--enable-zero-copy','--enable-unsafe-webgpu'];
|
|
|
|
const res=[];
|
|
const rec=(m,o,s,d)=>{res.push({m,o,s,d});console.log(`[${s}] ${m} :: ${o} :: ${d??''}`)};
|
|
|
|
const browser=await chromium.launch({headless:false,args,executablePath:'/usr/bin/google-chrome'});
|
|
const page=await browser.newPage({viewport:{width:1500,height:950}});
|
|
const errs=[]; page.on('pageerror',e=>errs.push(String(e).slice(0,220)));
|
|
await page.goto(BASE+'/?ui=web',{waitUntil:'domcontentloaded'});
|
|
await page.waitForTimeout(22000);
|
|
rec('boot','app mounted',await page.locator('main.blender-app').count()?'PASS':'FAIL','');
|
|
|
|
const canvas=page.locator('canvas.viewport-canvas').first();
|
|
await canvas.click({position:{x:420,y:320}}).catch(()=>{});
|
|
await page.waitForTimeout(600);
|
|
|
|
// ---------- A. SOLID uses the studio material ----------
|
|
const readShading=()=>page.evaluate(()=>{
|
|
const c=document.querySelector('canvas.viewport-canvas');
|
|
return {studio:c?.dataset.studioLighting??null, shading:c?.dataset.shadingMode??null};
|
|
});
|
|
await page.keyboard.press('z'); // MATERIAL -> RENDERED? cycle: MATERIAL->RENDERED
|
|
await page.waitForTimeout(1200);
|
|
let st=await readShading();
|
|
rec('A-solid','cycle to rendered',st.shading==='rendered'?'PASS':'INFO',JSON.stringify(st));
|
|
await page.keyboard.press('z'); // -> WIREFRAME
|
|
await page.waitForTimeout(1200);
|
|
st=await readShading();
|
|
rec('A-solid','wireframe uses studio',st.studio==='studio-mvp'?'PASS':'FAIL',JSON.stringify(st));
|
|
await page.keyboard.press('z'); // -> SOLID
|
|
await page.waitForTimeout(1400);
|
|
st=await readShading();
|
|
rec('A-solid','SOLID uses studio',st.studio==='studio-mvp'&&st.shading==='solid'?'PASS':'FAIL',JSON.stringify(st));
|
|
|
|
/* Prove the mesh material is no longer MeshPhysicalMaterial and that the clay
|
|
* is lit (not a flat colour): sample pixels across the object silhouette. */
|
|
const pixelStats=await page.evaluate(()=>{
|
|
const c=document.querySelector('canvas.viewport-canvas');
|
|
if(!c)return null;
|
|
const gl=c.getContext('webgl2',{preserveDrawingBuffer:true});
|
|
if(!gl)return null;
|
|
const w=gl.drawingBufferWidth,h=gl.drawingBufferHeight;
|
|
const read=(x,y)=>{const p=new Uint8Array(4);gl.readPixels(Math.round(x),Math.round(y),1,1,gl.RGBA,gl.UNSIGNED_BYTE,p);return p;};
|
|
const pts=[];
|
|
for(let i=1;i<=8;i++)pts.push(read(w*0.45+i*6,h*0.5));
|
|
const lum=pts.map(p=>0.2126*p[0]+0.7152*p[1]+0.0722*p[2]);
|
|
const min=Math.min(...lum),max=Math.max(...lum);
|
|
return {w,h,lum:lum.map(v=>Math.round(v)),spread:Math.round(max-min)};
|
|
});
|
|
rec('A-solid','clay is shaded not flat',pixelStats&&pixelStats.spread>6?'PASS':'INFO',JSON.stringify(pixelStats));
|
|
|
|
// ---------- B. switching back to MATERIAL restores PBR ----------
|
|
await page.keyboard.press('z'); // SOLID -> MATERIAL? order is WIREFRAME,SOLID,MATERIAL,RENDERED
|
|
await page.waitForTimeout(1400);
|
|
st=await readShading();
|
|
rec('B-restore','back to MATERIAL restores pbr',st.studio==='pbr'?'PASS':'INFO',JSON.stringify(st));
|
|
|
|
// ---------- C. sculpt brush cursor ----------
|
|
await page.evaluate(()=>{const b=[...document.querySelectorAll('button')].find(e=>(e.textContent||'').trim()==='Sculpting');b?.click();});
|
|
await page.waitForTimeout(5500);
|
|
const box=await canvas.boundingBox();
|
|
if(box){
|
|
await page.mouse.move(box.x+box.width*0.5, box.y+box.height*0.5);
|
|
await page.waitForTimeout(900);
|
|
}
|
|
const ringSmall=await page.evaluate(()=>{
|
|
const el=document.querySelector('[data-testid="sculpt-brush-cursor"]');
|
|
if(!el)return null;
|
|
const r=el.getBoundingClientRect();
|
|
return {w:Math.round(r.width),h:Math.round(r.height)};
|
|
});
|
|
rec('C-cursor','ring appears over mesh',ringSmall?'PASS':'FAIL',JSON.stringify(ringSmall));
|
|
|
|
// change radius in the tool shelf, ring diameter must grow
|
|
await page.keyboard.press('t');
|
|
await page.waitForTimeout(900);
|
|
await page.evaluate(()=>{
|
|
const input=document.querySelector('[aria-label="工具架 笔刷半径"]');
|
|
if(!input)return;
|
|
const setter=Object.getOwnPropertyDescriptor(HTMLInputElement.prototype,'value').set;
|
|
setter.call(input,'0.9');
|
|
input.dispatchEvent(new Event('input',{bubbles:true}));
|
|
});
|
|
await page.waitForTimeout(700);
|
|
if(box){
|
|
await page.mouse.move(box.x+box.width*0.5+4, box.y+box.height*0.5+4);
|
|
await page.waitForTimeout(900);
|
|
}
|
|
const ringBig=await page.evaluate(()=>{
|
|
const el=document.querySelector('[data-testid="sculpt-brush-cursor"]');
|
|
if(!el)return null;
|
|
const r=el.getBoundingClientRect();
|
|
return {w:Math.round(r.width),h:Math.round(r.height)};
|
|
});
|
|
rec('C-cursor','ring grows with brush radius',
|
|
ringSmall&&ringBig&&ringBig.w>ringSmall.w?'PASS':'FAIL',
|
|
`small=${ringSmall?.w} big=${ringBig?.w}`);
|
|
|
|
// leaving the viewport hides the ring
|
|
await page.mouse.move(20,20);
|
|
await page.waitForTimeout(700);
|
|
rec('C-cursor','ring hidden off-mesh',await page.locator('[data-testid="sculpt-brush-cursor"]').count()===0?'PASS':'INFO','');
|
|
|
|
// ---------- D. worker path ----------
|
|
const off=await browser.newPage({viewport:{width:1200,height:800}});
|
|
const offErrs=[]; off.on('pageerror',e=>offErrs.push(String(e).slice(0,220)));
|
|
await off.goto(BASE+'/?ui=web&offscreen=1',{waitUntil:'domcontentloaded'});
|
|
await off.waitForTimeout(22000);
|
|
const offCanvas=off.locator('canvas.viewport-canvas').first();
|
|
await offCanvas.click({position:{x:320,y:260}}).catch(()=>{});
|
|
/* The fresh page starts at MATERIAL; cycle MATERIAL -> RENDERED -> WIREFRAME
|
|
* -> SOLID so the worker genuinely receives the SOLID studio material. */
|
|
await off.keyboard.press('z'); await off.waitForTimeout(1100);
|
|
await off.keyboard.press('z'); await off.waitForTimeout(1100);
|
|
await off.keyboard.press('z'); await off.waitForTimeout(1300);
|
|
const offState=await off.evaluate(()=>{
|
|
const c=document.querySelector('canvas.viewport-canvas');
|
|
return c?{backend:c.dataset.rendererBackend,studio:c.dataset.studioLighting??null,shading:c.dataset.shadingMode??null}:null;
|
|
});
|
|
rec('D-worker','worker SOLID uses studio',offState?.studio==='studio-mvp'?'PASS':'FAIL',JSON.stringify(offState));
|
|
|
|
console.log('\n=== SUMMARY ===');
|
|
const p=res.filter(r=>r.s==='PASS').length;
|
|
const f=res.filter(r=>r.s==='FAIL');
|
|
console.log(`${p}/${res.length} PASS, ${f.length} FAIL`);
|
|
f.forEach(r=>console.log(` FAIL ${r.m} :: ${r.o} :: ${r.d}`));
|
|
console.log('pageerrors:',errs.slice(0,6));
|
|
console.log('worker pageerrors:',offErrs.slice(0,6));
|
|
await browser.close();
|