From db220e205c1810f5c8adecc6c18f442548544d63 Mon Sep 17 00:00:00 2001 From: mes123456 Date: Sat, 14 Nov 2026 06:50:25 +0800 Subject: [PATCH] test(web): record modifier parameter and shader node editing Co-Authored-By: Claude Code --- .../WBV2-P1425-001-web-operator-dispatch.md | 7 ++ .../continuation-20261113-web-export.json | 13 ++- tools/web/complete/probe-modifier-params.mjs | 84 +++++++++++++++++ .../web/complete/probe-shadergraph-canvas.mjs | 90 +++++++++++++++++++ 4 files changed, 193 insertions(+), 1 deletion(-) create mode 100644 tools/web/complete/probe-modifier-params.mjs create mode 100644 tools/web/complete/probe-shadergraph-canvas.mjs diff --git a/docs/status/WBV2-P1425-001-web-operator-dispatch.md b/docs/status/WBV2-P1425-001-web-operator-dispatch.md index de25c2955..a96d47388 100644 --- a/docs/status/WBV2-P1425-001-web-operator-dispatch.md +++ b/docs/status/WBV2-P1425-001-web-operator-dispatch.md @@ -410,6 +410,13 @@ - 界面偏好:“显示视图名称”原为 `supported: false` 隐藏,实际已接通视口标签。 已开放;复测标签 `用户 · 透视` → 取消勾选 ` · 透视` → 恢复;证据 `tools/web/complete/probe-viewname-preference.mjs`。 +- 修改器参数:SOLIDIFY 的 Thickness 字段 0.01→0.5 写入 Main;证据 + `tools/web/complete/probe-modifier-params.mjs`。 +- 着色器节点:Shading 的 `着色器编辑器` 添加 Math,节点 2→3, + `ShaderNodeMath` 进入材质节点树;证据 + `tools/web/complete/probe-shadergraph-canvas.mjs`。旧的内联 Shader Graph + 草稿面板因 `shaderGraphDraft` 始终为 null 而不可达,实际编辑走 + `WasmShaderEditor`。 ## 下一动作 diff --git a/tests/golden/WBV2-P1425-001/continuation-20261113-web-export.json b/tests/golden/WBV2-P1425-001/continuation-20261113-web-export.json index 5534bbd82..ca8713de5 100644 --- a/tests/golden/WBV2-P1425-001/continuation-20261113-web-export.json +++ b/tests/golden/WBV2-P1425-001/continuation-20261113-web-export.json @@ -1,7 +1,7 @@ { "schemaVersion": 1, "task": "WBV2-P1425-001", - "updatedAt": "2026-11-14T06:42:00+08:00", + "updatedAt": "2026-11-14T06:51:00+08:00", "status": "in_progress", "focus": "COMPLETE-TUTORIAL-001 backend export gap (USD/Alembic)", "breakpoint": "blender-5.2.0/source/blender/web_engine/CMakeLists.txt (USD wiring); WASM 6ee2b261", @@ -165,5 +165,16 @@ "result": "viewport label 用户 · 透视 → (unchecked) · 透视 → (checked) 用户 · 透视", "script": "tools/web/complete/probe-viewname-preference.mjs", "acceptance": "NOT_CLAIMED" + }, + "modifierParamsProbe": { + "result": "SOLIDIFY Thickness 0.01→0.5 in Main", + "script": "tools/web/complete/probe-modifier-params.mjs", + "acceptance": "NOT_CLAIMED" + }, + "shaderNodeProbe": { + "result": "Shader Editor add Math: 2→3 nodes, ShaderNodeMath in material tree", + "script": "tools/web/complete/probe-shadergraph-canvas.mjs", + "note": "legacy inline shader draft panel unreachable (shaderGraphDraft always null); WasmShaderEditor is the live path", + "acceptance": "NOT_CLAIMED" } } diff --git a/tools/web/complete/probe-modifier-params.mjs b/tools/web/complete/probe-modifier-params.mjs new file mode 100644 index 000000000..7dec13c47 --- /dev/null +++ b/tools/web/complete/probe-modifier-params.mjs @@ -0,0 +1,84 @@ +#!/usr/bin/env node +/** + * Focused case: edit mode -> select all -> UV -> 展开(角度) on a mesh. + * + * node tools/web/complete/probe-modifier-params.mjs --base-url http://127.0.0.1:5176 + */ +import { ASSETS, parseArgs, launchBrowser, newPage, openApp, openFile, waitScene } from "../course/lib/lesson-recorder.mjs"; + +const args = parseArgs(); +const BASE = args.baseUrl || "http://127.0.0.1:5176"; +const browser = await launchBrowser(args.gpu); +const { context, page, consoleErrors } = await newPage(browser, {}); +page.setDefaultTimeout(90_000); +await page.addInitScript(() => { + const NativeWorker = window.Worker; + window.__probeWorkers = []; + window.__probeMessages = []; + window.Worker = class extends NativeWorker { + constructor(...params) { + super(...params); + window.__probeWorkers.push(this); + this.addEventListener("message", (event) => window.__probeMessages.push(event.data)); + } + }; +}); +const log = (...parts) => console.log(new Date().toISOString().slice(11, 19), ...parts); +const python = async (source) => { + const requestId = `probe-${Date.now()}-${Math.random().toString(36).slice(2)}`; + return await page.evaluate(({ requestId, source }) => new Promise((resolve) => { + const started = Date.now(); + const read = () => { + const hit = window.__probeMessages.find((message) => message && message.requestId === requestId && message.kind === "result"); + if (hit) { clearInterval(timer); resolve(hit); return; } + if (Date.now() - started > 240000) { clearInterval(timer); resolve({ timeout: true }); } + }; + const timer = setInterval(read, 250); + for (const worker of window.__probeWorkers) worker.postMessage({ requestId, command: { type: "jsonCommand", cmd: "pythonExec", params: { source, filename: "ProbeModParam.py", console: false } } }); + }), { requestId, source }, { timeout: 300_000 }); +}; +const modState = async () => { + const result = await python(` +import bpy, json +obj = bpy.context.view_layer.objects.active +data = {'object': obj.name, 'modifiers': [{'name': m.name, 'type': m.type, 'thickness': getattr(m, 'thickness', None)} for m in obj.modifiers]} +if obj.type == 'MESH': data['vertices'] = len(obj.data.vertices) +print('MODPARAM ' + json.dumps(data)) +`); + const out = result?.result?.json; + const status = await page.evaluate(() => document.querySelector('[data-testid="engine-status"]')?.textContent ?? ""); + return { state: out?.state, output: out?.output, error: out?.error, status }; +}; +const menu = async (label, item) => { + await page.getByRole("button", { name: label, exact: true }).click(); + await page.getByRole("menuitem", { name: item, exact: true }).click(); +}; +try { + await openApp(page, BASE); + await openFile(page, ASSETS.studio); + await waitScene(page, { objects: 6, timeout: 240_000 }); + const authoring = page.locator('.modifier-stack-authoring').first(); + await authoring.waitFor({ timeout: 30_000 }); + await authoring.locator('[data-modifier-type-input]').fill("SOLIDIFY"); + await authoring.getByRole("button", { name: "Add", exact: true }).click(); + const row = page.locator('.modifier-row').filter({ hasText: "SOLIDIFY" }).first(); + await row.waitFor({ timeout: 30_000 }); + log("added", JSON.stringify(await modState())); + const inputs = row.locator('.modifier-parameter-controls input'); + log("inputs", await inputs.count()); + if (await inputs.count()) { + const first = inputs.first(); + log("field", await first.getAttribute('aria-label'), await first.inputValue()); + await first.fill("0.5"); + await first.press("Enter"); + await page.waitForTimeout(1500); + log("edited", JSON.stringify(await modState())); + } +} catch (error) { + log("probe error", error instanceof Error ? error.message : String(error)); + log("state", JSON.stringify(await modState().catch(() => null))); +} finally { + log("consoleErrors", JSON.stringify(consoleErrors.slice(-10))); + await context.close(); + await browser.close(); +} diff --git a/tools/web/complete/probe-shadergraph-canvas.mjs b/tools/web/complete/probe-shadergraph-canvas.mjs new file mode 100644 index 000000000..d424f2895 --- /dev/null +++ b/tools/web/complete/probe-shadergraph-canvas.mjs @@ -0,0 +1,90 @@ +#!/usr/bin/env node +/** + * Focused case: edit mode -> select all -> UV -> 展开(角度) on a mesh. + * + * node tools/web/complete/probe-shadergraph-canvas.mjs --base-url http://127.0.0.1:5176 + */ +import { ASSETS, parseArgs, launchBrowser, newPage, openApp, openFile, waitScene, switchWorkspace } from "../course/lib/lesson-recorder.mjs"; + +const args = parseArgs(); +const BASE = args.baseUrl || "http://127.0.0.1:5176"; +const browser = await launchBrowser(args.gpu); +const { context, page, consoleErrors } = await newPage(browser, {}); +page.setDefaultTimeout(90_000); +await page.addInitScript(() => { + const NativeWorker = window.Worker; + window.__probeWorkers = []; + window.__probeMessages = []; + window.Worker = class extends NativeWorker { + constructor(...params) { + super(...params); + window.__probeWorkers.push(this); + this.addEventListener("message", (event) => window.__probeMessages.push(event.data)); + } + }; +}); +const log = (...parts) => console.log(new Date().toISOString().slice(11, 19), ...parts); +const python = async (source) => { + const requestId = `probe-${Date.now()}-${Math.random().toString(36).slice(2)}`; + return await page.evaluate(({ requestId, source }) => new Promise((resolve) => { + const started = Date.now(); + const read = () => { + const hit = window.__probeMessages.find((message) => message && message.requestId === requestId && message.kind === "result"); + if (hit) { clearInterval(timer); resolve(hit); return; } + if (Date.now() - started > 240000) { clearInterval(timer); resolve({ timeout: true }); } + }; + const timer = setInterval(read, 250); + for (const worker of window.__probeWorkers) worker.postMessage({ requestId, command: { type: "jsonCommand", cmd: "pythonExec", params: { source, filename: "ProbeShaderCanvas.py", console: false } } }); + }), { requestId, source }, { timeout: 300_000 }); +}; +const shaderState = async () => { + const ui = await page.evaluate(() => { + const editor = document.querySelector('[aria-label="着色器编辑器"]'); + const select = editor?.querySelector('select[aria-label="材质"]'); + return { + material: select?.selectedOptions?.[0]?.textContent ?? null, + footer: editor?.querySelector('footer')?.textContent ?? null, + status: document.querySelector('[data-testid="engine-status"]')?.textContent ?? "", + }; + }); + const result = await python(` +import bpy, json +name = ${JSON.stringify(ui.material ?? "")} +mat = bpy.data.materials.get(name) +nodes = [node.bl_idname for node in mat.node_tree.nodes] if mat and mat.node_tree else [] +print('SHADERCANVAS ' + json.dumps({'material': name, 'nodes': nodes})) +`); + const out = result?.result?.json; + return { ...ui, state: out?.state, output: out?.output, error: out?.error }; +}; +const menu = async (label, item) => { + await page.getByRole("button", { name: label, exact: true }).click(); + await page.getByRole("menuitem", { name: item, exact: true }).click(); +}; +try { + await openApp(page, BASE); + await openFile(page, ASSETS.studio); + await waitScene(page, { objects: 6, timeout: 240_000 }); + await switchWorkspace(page, "Shading"); + await page.waitForTimeout(1500); + const editor = page.locator('[aria-label="着色器编辑器"]').first(); + await editor.waitFor({ timeout: 30_000 }); + log("before", JSON.stringify(await shaderState())); + await editor.getByRole("button", { name: "添加节点", exact: true }).click(); + const dialog = page.getByRole("dialog", { name: "添加节点" }); + await dialog.getByRole("textbox", { name: "搜索节点" }).fill("Math"); + await page.waitForTimeout(600); + log("menu", JSON.stringify(await dialog.getByRole("button").allTextContents())); + const item = dialog.getByRole("button").filter({ hasText: /^Math/ }).first(); + if (await item.count()) await item.click(); + else await dialog.getByRole("button").first().click(); + await page.waitForTimeout(2000); + log("after", JSON.stringify(await shaderState())); +} catch (error) { + log("probe error", error instanceof Error ? error.message : String(error)); + log("state", JSON.stringify(await shaderState().catch(() => null))); +} finally { + log("consoleErrors", JSON.stringify(consoleErrors.slice(-10))); + await context.close(); + await browser.close(); +}