feat(web): studio worlds, camera-view/offscreen environment parity, material and undo coverage
Some checks failed
M6 deployable RC / quick (push) Has been cancelled
M6 deployable RC / chromium (push) Has been cancelled
M6 deployable RC / release (push) Has been cancelled

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>
This commit is contained in:
mes123456
2026-11-23 09:27:47 +08:00
parent f96654b158
commit 63db6caf1f
325 changed files with 20004 additions and 762 deletions

178
web/probes/accept1.mjs Normal file
View File

@@ -0,0 +1,178 @@
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();

134
web/probes/accept2.mjs Normal file
View File

@@ -0,0 +1,134 @@
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();

248
web/probes/accept3.mjs Normal file
View File

@@ -0,0 +1,248 @@
/* Bounded Chromium probe for the workbench-shading batch:
* A. `.sl` studio-light presets reach the shader
* B. MATCAP mode swaps the material and restores Studio
* C. cavity + curvature change the frame, and reverting changes it back
* D. `?offscreen=1` sculpt ring + stroke samples work through the worker
*
* Runs against the dev server on 5184 with the installed Chromium. Evidence only:
* a PASS here is a probe result, not acceptance.
*/
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'];
const res = [];
const rec = (m, o, s, d) => { res.push({ m, o, s, d }); console.log(`[${s}] ${m} :: ${o} :: ${d ?? ''}`); };
/* React reads `.value` off its own tracker, so a plain assignment is swallowed.
* Go through the prototype setter and dispatch the event React listens for. */
const SET_SELECT = `(label, value) => {
const el = document.querySelector('[aria-label="' + label + '"]');
if (!el) return 'missing';
const proto = Object.getPrototypeOf(el);
const setter = Object.getOwnPropertyDescriptor(proto, 'value').set;
setter.call(el, value);
el.dispatchEvent(new Event('change', { bubbles: true }));
return el.value;
}`;
const SET_CHECK = `(label, checked) => {
const el = document.querySelector('[aria-label="' + label + '"]');
if (!el) return 'missing';
const setter = Object.getOwnPropertyDescriptor(HTMLInputElement.prototype, 'checked').set;
setter.call(el, checked);
el.dispatchEvent(new Event('click', { bubbles: true }));
el.dispatchEvent(new Event('change', { bubbles: true }));
return el.checked;
}`;
/* Mean + spread of luminance across a horizontal scanline through the object.
* Cavity darkens creases, so it moves both statistics; a preset swap moves the
* distribution without touching the silhouette. */
const SAMPLE = `(y) => {
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 px = new Uint8Array(w * 4);
gl.readPixels(0, Math.round(h * (y ?? 0.5)), w, 1, gl.RGBA, gl.UNSIGNED_BYTE, px);
const lum = [];
for (let i = 0; i < w; i++) {
const a = 0.2126 * px[i * 4] + 0.7152 * px[i * 4 + 1] + 0.0722 * px[i * 4 + 2];
if (a > 3) lum.push(a); /* skip the flat background */
}
if (lum.length < 8) return { n: lum.length, mean: 0, sd: 0, min: 0, max: 0 };
const mean = lum.reduce((s, v) => s + v, 0) / lum.length;
const sd = Math.sqrt(lum.reduce((s, v) => s + (v - mean) ** 2, 0) / lum.length);
return {
n: lum.length, mean: Math.round(mean * 100) / 100, sd: Math.round(sd * 100) / 100,
min: Math.round(Math.min(...lum)), max: Math.round(Math.max(...lum)),
};
}`;
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, 240)));
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(800);
/* Get to SOLID however the app started: the button cycles WIREFRAME→SOLID→…,
* so poll the dataset rather than assuming a start mode. */
const shading = () => page.evaluate(() => {
const c = document.querySelector('canvas.viewport-canvas');
return c ? { shading: c.dataset.shadingMode ?? null, studio: c.dataset.studioLighting ?? null } : null;
});
for (let i = 0; i < 5; i++) {
const st = await shading();
if (st?.shading === 'solid') break;
await page.locator('[aria-label="着色模式"]').click().catch(() => {});
await page.waitForTimeout(900);
}
rec('setup', 'SOLID reached', (await shading())?.shading === 'solid' ? 'PASS' : 'FAIL', JSON.stringify(await shading()));
const sample = (y) => page.evaluate(`(${SAMPLE})(${y})`);
/* ---------- A. `.sl` presets ---------- */
const presetNames = await page.evaluate(() => {
const el = document.querySelector('[aria-label="工作室光照预设"]');
return el ? [...el.options].map((o) => o.value) : null;
});
rec('A-sl', 'preset list populated', Array.isArray(presetNames) && presetNames.length === 6 ? 'PASS' : 'FAIL',
JSON.stringify(presetNames));
const applyPreset = async (name) => {
const got = await page.evaluate(`(${SET_SELECT})('工作室光照预设', ${JSON.stringify(name)})`);
await page.waitForTimeout(1500);
return got;
};
const studioDefault = await sample(0.5);
await applyPreset('basic.sl');
const studioBasic = await sample(0.5);
await applyPreset('outdoor.sl');
const studioOutdoor = await sample(0.5);
await applyPreset('studio.sl');
const studioStudio = await sample(0.5);
rec('A-sl', 'basic.sl differs from Default',
studioBasic && studioBasic.mean !== studioDefault?.mean ? 'PASS' : 'FAIL',
`default=${JSON.stringify(studioDefault)} basic=${JSON.stringify(studioBasic)}`);
rec('A-sl', 'outdoor.sl differs from basic.sl',
studioOutdoor && studioOutdoor.sd !== studioBasic?.sd ? 'PASS' : 'FAIL',
`basic=${JSON.stringify(studioBasic)} outdoor=${JSON.stringify(studioOutdoor)}`);
rec('A-sl', 'studio.sl differs from outdoor.sl',
studioStudio && studioStudio.mean !== studioOutdoor?.mean ? 'PASS' : 'FAIL',
`outdoor=${JSON.stringify(studioOutdoor)} studio=${JSON.stringify(studioStudio)}`);
/* ---------- B. MATCAP ---------- */
await applyPreset('Default');
const beforeMatcap = await sample(0.5);
await page.evaluate(`(${SET_SELECT})('光照模式', 'MATCAP')`);
await page.waitForTimeout(1600);
const matcapList = await page.evaluate(() => {
const el = document.querySelector('[aria-label="Matcap"]');
return el ? [...el.options].length : null;
});
rec('B-matcap', 'matcap picker appears', matcapList === 27 ? 'PASS' : 'FAIL', `options=${matcapList}`);
await page.evaluate(`(${SET_SELECT})('Matcap', 'clay_studio')`);
await page.waitForTimeout(2200);
const matcapClay = await sample(0.5);
await page.evaluate(`(${SET_SELECT})('Matcap', 'fullmetal')`);
await page.waitForTimeout(2200);
const matcapMetal = await sample(0.5);
rec('B-matcap', 'clay_studio renders shaded', matcapClay && matcapClay.sd > 3 ? 'PASS' : 'FAIL', JSON.stringify(matcapClay));
rec('B-matcap', 'fullmetal differs from clay_studio',
matcapMetal && matcapClay && matcapMetal.mean !== matcapClay.mean ? 'PASS' : 'FAIL',
`clay=${JSON.stringify(matcapClay)} metal=${JSON.stringify(matcapMetal)}`);
await page.evaluate(`(${SET_SELECT})('光照模式', 'STUDIO')`);
await page.waitForTimeout(1800);
const backToStudio = await sample(0.5);
rec('B-matcap', 'studio restores after matcap',
backToStudio && beforeMatcap && backToStudio.mean === beforeMatcap.mean ? 'PASS' : 'INFO',
`before=${JSON.stringify(beforeMatcap)} after=${JSON.stringify(backToStudio)}`);
/* ---------- C. cavity + curvature ---------- */
const beforeCavity = await sample(0.5);
const setCheck = (label, on) => page.evaluate(`(${SET_CHECK})(${JSON.stringify(label)}, ${on})`);
await setCheck('空腔', true);
await page.waitForTimeout(2000);
const cavityOn = await sample(0.5);
rec('C-post', 'cavity changes the frame',
cavityOn && beforeCavity && (cavityOn.mean !== beforeCavity.mean || cavityOn.sd !== beforeCavity.sd) ? 'PASS' : 'FAIL',
`off=${JSON.stringify(beforeCavity)} on=${JSON.stringify(cavityOn)}`);
await setCheck('曲率', true);
await page.waitForTimeout(2000);
const curvatureOn = await sample(0.5);
rec('C-post', 'curvature adds on top of cavity',
curvatureOn && cavityOn && curvatureOn.sd !== cavityOn.sd ? 'PASS' : 'FAIL',
`cavity=${JSON.stringify(cavityOn)} +curv=${JSON.stringify(curvatureOn)}`);
await setCheck('曲率', false);
await setCheck('空腔', false);
await page.waitForTimeout(2000);
const reverted = await sample(0.5);
rec('C-post', 'toggling off reverts the frame',
reverted && beforeCavity && Math.abs(reverted.mean - beforeCavity.mean) < 0.6 ? 'PASS' : 'FAIL',
`before=${JSON.stringify(beforeCavity)} after=${JSON.stringify(reverted)}`);
/* ---------- D. offscreen sculpt ---------- */
const off = await browser.newPage({ viewport: { width: 1200, height: 800 } });
const offErrs = [];
off.on('pageerror', (e) => offErrs.push(String(e).slice(0, 240)));
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(() => {});
await off.waitForTimeout(1500);
rec('D-offscreen', 'worker backend attached', await off.evaluate(() =>
document.querySelector('canvas.viewport-canvas')?.dataset.rendererBackend) === 'offscreen-worker' ? 'PASS' : 'FAIL', '');
await off.evaluate(() => {
const b = [...document.querySelectorAll('button')].find((e) => (e.textContent || '').trim() === 'Sculpting');
b?.click();
});
await off.waitForTimeout(6000);
const ringSize = () => off.evaluate(() => {
const el = document.querySelector('[data-testid="sculpt-brush-cursor"]');
if (!el) return null;
const r = el.getBoundingClientRect();
return { w: Math.round(r.width), left: Math.round(r.left), top: Math.round(r.top) };
});
const box = await offCanvas.boundingBox();
const cx = box.x + box.width * 0.5, cy = box.y + box.height * 0.5;
/* The ring answers from a cache the previous pointermove filled, so move twice:
* the first move seeds the worker round-trip, the second reads it back. */
for (let i = 0; i < 3; i++) { await off.mouse.move(cx + i, cy); await off.waitForTimeout(500); }
const ringSmall = await ringSize();
rec('D-offscreen', 'ring appears over the mesh', ringSmall ? 'PASS' : 'FAIL', JSON.stringify(ringSmall));
await off.keyboard.press('t');
await off.waitForTimeout(1000);
await off.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 off.waitForTimeout(900);
for (let i = 0; i < 3; i++) { await off.mouse.move(cx + 2 + i, cy + 2); await off.waitForTimeout(500); }
const ringBig = await ringSize();
rec('D-offscreen', 'ring grows with brush radius',
ringSmall && ringBig && ringBig.w > ringSmall.w ? 'PASS' : 'FAIL',
`small=${ringSmall?.w} big=${ringBig?.w}`);
/* Stroke samples: the sculpt editor button prints the current sample count. */
const samples = () => off.evaluate(() => {
const b = [...document.querySelectorAll('button')].find((e) => (e.textContent || '').startsWith('Apply Sculpt Stroke'));
const m = b && (b.textContent || '').match(/(\d+)\s*samples/);
return m ? Number(m[1]) : null;
});
const before = await samples();
await off.mouse.move(cx, cy);
await off.mouse.down();
for (let i = 1; i <= 6; i++) { await off.mouse.move(cx + i * 8, cy + i * 3); await off.waitForTimeout(220); }
await off.mouse.up();
await off.waitForTimeout(1500);
const after = await samples();
rec('D-offscreen', 'drag produces stroke samples', before !== null && after !== null && after > before ? 'PASS' : 'FAIL',
`before=${before} after=${after}`);
console.log('\n=== SUMMARY ===');
const pass = res.filter((r) => r.s === 'PASS').length;
const fail = res.filter((r) => r.s === 'FAIL');
console.log(`${pass}/${res.length} PASS, ${fail.length} FAIL`);
fail.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();

View File

@@ -0,0 +1,49 @@
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'];
const browser=await chromium.launch({headless:false,args,executablePath:'/usr/bin/google-chrome'});
const page=await browser.newPage({viewport:{width:1500,height:950}});
const cdp=await page.context().newCDPSession(page);
await cdp.send('Network.enable');
await cdp.send('Network.setCacheDisabled',{cacheDisabled:true});
const seen=[]; page.on('response',async r=>{ if(r.url().includes('workbench-post')) seen.push({url:r.url().slice(-60),status:r.status()}); });
const errs=[]; page.on('pageerror',e=>errs.push(String(e).slice(0,240)));
await page.goto(BASE+'/?ui=web',{waitUntil:'domcontentloaded'});
await page.waitForTimeout(22000);
const canvas=page.locator('canvas.viewport-canvas').first();
await canvas.click({position:{x:420,y:320}}).catch(()=>{});
await page.waitForTimeout(900);
for(let i=0;i<5;i++){
const s=await page.evaluate(()=>document.querySelector('canvas.viewport-canvas')?.dataset.shadingMode);
if(s==='solid')break;
await page.locator('[aria-label="着色模式"]').click().catch(()=>{});
await page.waitForTimeout(900);
}
const ROW=`(y)=>{
const c=document.querySelector('canvas.viewport-canvas');
const gl=c.getContext('webgl2',{preserveDrawingBuffer:true});
const w=gl.drawingBufferWidth,h=gl.drawingBufferHeight;
const px=new Uint8Array(w*4);
gl.readPixels(0,Math.round(h*(y??0.5)),w,1,gl.RGBA,gl.UNSIGNED_BYTE,px);
const out=[];
for(let x=0;x<w;x+=Math.max(1,Math.round(w/40))){
out.push([x,px[x*4],px[x*4+1],px[x*4+2]]);
}
return {w,h,px:out};
}`;
const row=(y)=>page.evaluate(`(${ROW})(${y})`);
const off=await row(0.5);
await page.evaluate(`(()=>{const el=document.querySelector('[aria-label="空腔"]');const s=Object.getOwnPropertyDescriptor(HTMLInputElement.prototype,'checked').set;s.call(el,true);el.dispatchEvent(new Event('click',{bubbles:true}));el.dispatchEvent(new Event('change',{bubbles:true}));})()`);
await page.waitForTimeout(2500);
const on=await row(0.5);
console.log('drawingBuffer', off.w, off.h);
console.log('x OFF r,g,b ON r,g,b');
for(let i=0;i<off.px.length;i++){
const [x,r1,g1,b1]=off.px[i], [,r2,g2,b2]=on.px[i];
console.log(String(x).padStart(4), `depth r=${r2} g=${g2} b=${b2}`);
}
console.log('workbench-post fetches:',JSON.stringify(seen));
console.log('errors:',errs.slice(0,4));
await browser.close();

BIN
web/probes/out-depth.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 66 KiB

23
web/probes/shot-depth.mjs Normal file
View File

@@ -0,0 +1,23 @@
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'];
const browser=await chromium.launch({headless:false,args,executablePath:'/usr/bin/google-chrome'});
const page=await browser.newPage({viewport:{width:1400,height:900}});
await page.goto(BASE+'/?ui=web',{waitUntil:'domcontentloaded'});
await page.waitForTimeout(22000);
const canvas=page.locator('canvas.viewport-canvas').first();
await canvas.click({position:{x:420,y:320}}).catch(()=>{});
await page.waitForTimeout(900);
for(let i=0;i<5;i++){
const s=await page.evaluate(()=>document.querySelector('canvas.viewport-canvas')?.dataset.shadingMode);
if(s==='solid')break;
await page.locator('[aria-label="着色模式"]').click().catch(()=>{});
await page.waitForTimeout(900);
}
await page.evaluate(`(()=>{const el=document.querySelector('[aria-label="空腔"]');const s=Object.getOwnPropertyDescriptor(HTMLInputElement.prototype,'checked').set;s.call(el,true);el.dispatchEvent(new Event('click',{bubbles:true}));el.dispatchEvent(new Event('change',{bubbles:true}));})()`);
await page.waitForTimeout(2500);
await canvas.screenshot({path:WEB+'/probes/out-depth.png'});
console.log('shot saved');
await browser.close();