Files
workinf_Blender_Wasm/tools/web/probe-wasm-engines.mjs
mes123456 63db6caf1f
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
feat(web): studio worlds, camera-view/offscreen environment parity, material and undo coverage
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>
2026-11-23 09:27:47 +08:00

63 lines
3.8 KiB
JavaScript

#!/usr/bin/env node
/** Probe: which engines produce real pixels on the WASM-embedded (default URL) path. */
import path from "node:path";
import fs from "node:fs";
import { REPO, parseArgs, waitForServer, launchBrowser, newPage, openFile, waitScene } from "./course/lib/lesson-recorder.mjs";
const args = parseArgs();
const BASE = `http://127.0.0.1:${args.port}`;
const SCENE = path.join(REPO, "web/app/public/tutorial/rendering/render-studio.blend");
const OUT = "/tmp/render-basics-probe";
fs.mkdirSync(OUT, { recursive: true });
await waitForServer(`${BASE}/`);
const browser = await launchBrowser(args.gpu);
const { context } = await newPage(browser, { baseUrl: null });
const page = context.pages()[0] ?? await context.newPage();
await page.goto(`${BASE}/`, { waitUntil: "domcontentloaded" });
await page.locator("main.blender-app").waitFor({ timeout: 120_000 });
await openFile(page, SCENE);
await waitScene(page, { objects: 7, timeout: 120_000 });
await page.waitForFunction(() => [...document.querySelectorAll(".workspace-tab")].some((t) => t.getAttribute("aria-current") !== null), null, { timeout: 90_000 });
await page.evaluate(() => { const t = [...document.querySelectorAll(".workspace-tab")].find((i) => i.textContent === "Rendering"); if (t instanceof HTMLElement) t.click(); });
await page.waitForTimeout(1500);
const toggle = page.getByTestId("native-web-tools-toggle");
if (await toggle.count() && await toggle.first().isVisible().catch(() => false)) { await toggle.first().click({ force: true }); await page.waitForTimeout(1500); }
// The React subtree holding the panel only mounts once a render hands the
// screen back (App.tsx clears gpuSurfaceOpen inside `if (stored.length)`), so
// the first F12 is what makes the panel reachable at all.
await page.evaluate(() => { if (document.activeElement instanceof HTMLElement) document.activeElement.blur(); });
await page.keyboard.press("F12");
await page.waitForFunction(() => document.querySelector(".native-render-panel") !== null, null, { timeout: 120_000 });
const details = page.locator("details.native-render-fallback").first();
await details.waitFor({ timeout: 120_000 });
if (!(await details.evaluate((e) => e.open))) await details.locator("summary").first().click({ force: true });
await page.locator(".native-render-panel").first().waitFor({ timeout: 60_000 });
for (const engine of ["SCENE", "BLENDER_WORKBENCH", "BLENDER_EEVEE"]) {
const started = Date.now();
try {
const panel = page.locator(".native-render-panel").first();
await panel.locator('select[aria-label="Engine"]').selectOption(engine);
await panel.getByRole("button", { name: "Render Frame", exact: true }).click();
await page.waitForFunction(() => {
const p = document.querySelector(".native-render-panel");
const text = p?.querySelector(".native-workflow-output")?.textContent ?? "";
if (/FAILED|CANCELLED/.test(text)) return true;
return /SUCCEEDED/.test(text) && p.querySelector(".native-workflow-artifacts a[download]") !== null;
}, null, { timeout: 240_000 });
const links = panel.locator(".native-workflow-artifacts a[download]");
const names = await links.evaluateAll((nodes) => nodes.map((n) => n.getAttribute("download") ?? ""));
const idx = names.findIndex((n) => /\.png$/i.test(n));
if (idx < 0) { console.log(engine, "no png", names); continue; }
const [dl] = await Promise.all([page.waitForEvent("download", { timeout: 60_000 }), links.nth(idx).click({ force: true })]);
const file = path.join(OUT, `wasm-${engine}.png`);
await dl.saveAs(file);
console.log(engine, "saved", file, fs.statSync(file).size, "ms", Date.now() - started);
}
catch (error) { console.log(engine, "FAIL", String(error?.message ?? error).split("\n")[0], Date.now() - started); }
}
await context.close();
await browser.close();