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>
179 lines
9.7 KiB
JavaScript
179 lines
9.7 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 st=(p)=>p.evaluate(()=>{const m=document.querySelector('main.blender-app');const d=m?{...m.dataset}:{};
|
||
return{rev:+d.currentMainRevision||0,ws:d.workspace,engine:(document.body.innerText.match(/Engine:[^\n]{0,70}/)||[])[0]||''}});
|
||
|
||
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,200)));
|
||
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', JSON.stringify(await st(page)));
|
||
|
||
// ---------- A. preferences: 8 rows now editable ----------
|
||
/* Preferences live in the 编辑 top menu, not a top-level button. */
|
||
await page.evaluate(()=>{const b=[...document.querySelectorAll('.menu-bar button')].find(e=>(e.textContent||'').trim()==='编辑');b?.click();});
|
||
await page.waitForTimeout(800);
|
||
await page.evaluate(()=>{const b=[...document.querySelectorAll('button')].find(e=>(e.textContent||'').trim()==='偏好设置');b?.click();});
|
||
await page.waitForTimeout(1800);
|
||
const prefOpen=await page.locator('.preferences-body').count();
|
||
rec('A-pref','preferences window',prefOpen?'PASS':'FAIL',`body=${prefOpen}`);
|
||
/* The panel renders one tab at a time, so collect rows by walking every tab. */
|
||
const TABS=['界面','视口','动画','输入与导航','键位','保存与加载','文件','主题','系统'];
|
||
const rows={};
|
||
for(const tabLabel of TABS){
|
||
const ok=await page.evaluate((label)=>{
|
||
const b=[...document.querySelectorAll('.preferences-tabs button')].find(e=>(e.textContent||'').trim()===label);
|
||
if(!b)return false;
|
||
b.click();return true;
|
||
},tabLabel);
|
||
if(!ok)continue;
|
||
await page.waitForTimeout(350);
|
||
const tabRows=await page.evaluate(()=>{
|
||
const out={};
|
||
for(const el of document.querySelectorAll('[data-setting]'))
|
||
out[el.getAttribute('data-setting')]=el.getAttribute('data-unsupported')==='true'?'unsupported':'editable';
|
||
return out;
|
||
});
|
||
Object.assign(rows,tabRows);
|
||
}
|
||
const expectEditable=['interface.recentFiles','saveLoad.autoSaveTimeMinutes','navigation.orbitSensitivity',
|
||
'navigation.zoomSensitivity','navigation.invertZoom','viewport.gizmoSize','viewport.gizmoSizeNavigate','viewport.miniAxis'];
|
||
for(const path of expectEditable)
|
||
rec('A-pref',path,rows[path]==='editable'?'PASS':'FAIL',rows[path]??'missing');
|
||
const stillUnsupported=Object.entries(rows).filter(([,v])=>v==='unsupported').length;
|
||
const total=Object.keys(rows).length;
|
||
rec('A-pref','unsupported count',stillUnsupported===13?'PASS':'INFO',`${stillUnsupported}/${total} still unsupported`);
|
||
|
||
// change a value and confirm it persists into the main app (switch back to 视口 first)
|
||
await page.evaluate(()=>{const b=[...document.querySelectorAll('.preferences-tabs button')].find(e=>(e.textContent||'').trim()==='视口');b?.click();});
|
||
await page.waitForTimeout(400);
|
||
const changed=await page.evaluate(()=>{
|
||
const row=document.querySelector('[data-setting="viewport.gizmoSize"] input[type=number]');
|
||
if(!row)return null;
|
||
const setter=Object.getOwnPropertyDescriptor(HTMLInputElement.prototype,'value').set;
|
||
setter.call(row,'120');
|
||
row.dispatchEvent(new Event('input',{bubbles:true}));
|
||
return row.value;
|
||
});
|
||
await page.waitForTimeout(1500);
|
||
const gizmoVar=await page.evaluate(()=>{
|
||
const el=document.querySelector('.viewport-placeholder');
|
||
return el?getComputedStyle(el).getPropertyValue('--gizmo-size').trim():null;
|
||
});
|
||
rec('A-pref','gizmoSize -> CSS var',String(gizmoVar)==='120'?'PASS':'FAIL',`input=${changed} var=${gizmoVar}`);
|
||
|
||
// close preferences
|
||
await page.evaluate(()=>{const b=[...document.querySelectorAll('button')].find(e=>e.getAttribute('aria-label')==='关闭偏好设置');b?.click();});
|
||
await page.waitForTimeout(1200);
|
||
|
||
// ---------- B. tool shelf ----------
|
||
const canvas=page.locator('canvas.viewport-canvas').first();
|
||
await canvas.click({position:{x:400,y:300}}).catch(()=>{});
|
||
await page.waitForTimeout(600);
|
||
const beforeShelf=await page.locator('.viewport-tool-shelf').count();
|
||
await page.keyboard.press('t');
|
||
await page.waitForTimeout(900);
|
||
const afterShelf=await page.locator('.viewport-tool-shelf').count();
|
||
rec('B-shelf','T opens shelf',beforeShelf===0&&afterShelf===1?'PASS':'FAIL',`before=${beforeShelf} after=${afterShelf}`);
|
||
|
||
const objectMode=await page.evaluate(()=>{
|
||
const shelf=document.querySelector('.viewport-tool-shelf');
|
||
if(!shelf)return null;
|
||
return {mode:shelf.getAttribute('data-tool-shelf-mode'),
|
||
buttons:[...shelf.querySelectorAll('button')].map(b=>b.getAttribute('aria-label')).filter(Boolean)};
|
||
});
|
||
rec('B-shelf','object mode contents',objectMode?.mode==='Object'&&objectMode.buttons.length>8?'PASS':'FAIL',
|
||
`${objectMode?.mode} · ${objectMode?.buttons.length} buttons`);
|
||
|
||
// T closes it
|
||
await page.keyboard.press('t');
|
||
await page.waitForTimeout(700);
|
||
rec('B-shelf','T closes shelf',await page.locator('.viewport-tool-shelf').count()===0?'PASS':'FAIL','');
|
||
|
||
// N toggles the N panel
|
||
await canvas.click({position:{x:400,y:300}}).catch(()=>{});
|
||
await page.keyboard.press('n');
|
||
await page.waitForTimeout(700);
|
||
const sideClosed=await page.evaluate(()=>document.querySelector('.viewport-placeholder')?.getAttribute('data-side-panel'));
|
||
await page.keyboard.press('n');
|
||
await page.waitForTimeout(700);
|
||
const sideOpen=await page.evaluate(()=>document.querySelector('.viewport-placeholder')?.getAttribute('data-side-panel'));
|
||
rec('B-shelf','N toggles N-panel',sideClosed==='closed'&&sideOpen==='open'?'PASS':'FAIL',`${sideClosed} -> ${sideOpen}`);
|
||
|
||
// ---------- C. sculpt inline params ----------
|
||
await page.evaluate(()=>{const b=[...document.querySelectorAll('button')].find(e=>(e.textContent||'').trim()==='Sculpting');b?.click();});
|
||
await page.waitForTimeout(5000);
|
||
await canvas.click({position:{x:400,y:300}}).catch(()=>{});
|
||
await page.waitForTimeout(500);
|
||
await page.keyboard.press('t');
|
||
await page.waitForTimeout(900);
|
||
const sculptShelf=await page.evaluate(()=>{
|
||
const shelf=document.querySelector('.viewport-tool-shelf');
|
||
if(!shelf)return null;
|
||
return {mode:shelf.getAttribute('data-tool-shelf-mode'),
|
||
brush:!!shelf.querySelector('[aria-label="工具架 雕刻笔刷"]'),
|
||
radius:!!shelf.querySelector('[aria-label="工具架 笔刷半径"]'),
|
||
strength:!!shelf.querySelector('[aria-label="工具架 笔刷强度"]'),
|
||
symmetry:!!shelf.querySelector('[aria-label="工具架 X 对称"]'),
|
||
remesh:!!shelf.querySelector('[aria-label="工具架 体素尺寸"]')||!!shelf.querySelector('[aria-label="工具架 体素重构"]')};
|
||
});
|
||
rec('C-sculpt','shelf mode',sculptShelf?.mode==='Sculpt'?'PASS':'INFO',JSON.stringify(sculptShelf));
|
||
|
||
// changing radius in the shelf must reach the Properties sculpt editor (one store)
|
||
const shared=await page.evaluate(()=>{
|
||
const shelfInput=document.querySelector('[aria-label="工具架 笔刷半径"]');
|
||
if(!shelfInput)return {skipped:true};
|
||
const setter=Object.getOwnPropertyDescriptor(HTMLInputElement.prototype,'value').set;
|
||
setter.call(shelfInput,'1.25');
|
||
shelfInput.dispatchEvent(new Event('input',{bubbles:true}));
|
||
return {wrote:'1.25'};
|
||
});
|
||
await page.waitForTimeout(1200);
|
||
const propsRadius=await page.evaluate(()=>{
|
||
/* Properties › Sculpt uses the English aria-labels (Sculpt radius). */
|
||
const el=document.querySelector('[data-testid="sculpt-editor"] input[aria-label="Sculpt radius"]');
|
||
return el?el.value:null;
|
||
});
|
||
rec('C-sculpt','shelf -> Properties shared state',propsRadius==='1.25'?'PASS':(shared.skipped?'SKIP':'FAIL'),`props=${propsRadius}`);
|
||
|
||
// ---------- D. offscreen worker path ----------
|
||
const off=await browser.newPage({viewport:{width:1200,height:800}});
|
||
const offErrs=[]; off.on('pageerror',e=>offErrs.push(String(e).slice(0,200)));
|
||
await off.goto(BASE+'/?ui=web&offscreen=1',{waitUntil:'domcontentloaded'});
|
||
|
||
await off.waitForTimeout(20000);
|
||
const offState=await off.evaluate(()=>{
|
||
const c=document.querySelector('canvas.viewport-canvas');
|
||
return c?{backend:c.dataset.rendererBackend,shading:c.dataset.shadingMode??null,xray:c.dataset.xray??null,status:c.dataset.deviceStatus}:null;
|
||
});
|
||
rec('D-offscreen','worker backend',offState?.backend==='offscreen-worker'?'PASS':'INFO',JSON.stringify(offState));
|
||
|
||
// toggle shading on the worker path
|
||
const offCanvas=off.locator('canvas.viewport-canvas').first();
|
||
await offCanvas.click({position:{x:300,y:250}}).catch(()=>{});
|
||
await off.keyboard.press('z');
|
||
await off.waitForTimeout(2500);
|
||
const offShading=await off.evaluate(()=>document.querySelector('canvas.viewport-canvas')?.dataset.shadingMode??null);
|
||
rec('D-offscreen','Z cycles shading (worker)',offShading&&offShading!=='material'?'PASS':'FAIL',`shading=${offShading}`);
|
||
await off.keyboard.press('Alt+z').catch(()=>{});
|
||
await off.waitForTimeout(1200);
|
||
const offXray=await off.evaluate(()=>document.querySelector('canvas.viewport-canvas')?.dataset.xray??null);
|
||
rec('D-offscreen','Alt+Z toggles xray (worker)',offXray==='1'?'PASS':'INFO',`xray=${offXray}`);
|
||
|
||
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('offscreen pageerrors:',offErrs.slice(0,6));
|
||
await browser.close();
|