From 150c864fe1550c8cb137fb3fe5c9971d7bb6419c Mon Sep 17 00:00:00 2001 From: mes123456 Date: Sat, 14 Nov 2026 07:11:24 +0800 Subject: [PATCH] test(web): record rigid body physics panel evidence Co-Authored-By: Claude Code --- .../WBV2-P1425-001-web-operator-dispatch.md | 2 + .../continuation-20261113-web-export.json | 7 +- tools/web/complete/probe-physics.mjs | 85 +++++++++++++++++++ 3 files changed, 93 insertions(+), 1 deletion(-) create mode 100644 tools/web/complete/probe-physics.mjs diff --git a/docs/status/WBV2-P1425-001-web-operator-dispatch.md b/docs/status/WBV2-P1425-001-web-operator-dispatch.md index 333e6e0ae..253f227ef 100644 --- a/docs/status/WBV2-P1425-001-web-operator-dispatch.md +++ b/docs/status/WBV2-P1425-001-web-operator-dispatch.md @@ -423,6 +423,8 @@ `tools/web/complete/probe-geometry-nodes.mjs`。 - 变换工具:`g` location 0→0.1、`r` rotation z→0.3142、`s` scale x→1.1, 撤销恢复 scale;证据 `tools/web/complete/probe-transform.mjs`。 +- 物理:Physics 面板 Add 创建 RIGID_BODY(ACTIVE,场景 rigidbody_world), + Mass 1.0→5.0 写入 Main;证据 `tools/web/complete/probe-physics.mjs`。 ## 下一动作 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 24e70ac45..f09a87db7 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:53:00+08:00", + "updatedAt": "2026-11-14T07:11: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", @@ -186,5 +186,10 @@ "result": "g → location x 0.1; r → rotation z 0.3142; s → scale x 1.1; undo restores scale", "script": "tools/web/complete/probe-transform.mjs", "acceptance": "NOT_CLAIMED" + }, + "physicsProbe": { + "result": "Add RIGID_BODY → ACTIVE + rigidbody_world; Mass 1.0→5.0", + "script": "tools/web/complete/probe-physics.mjs", + "acceptance": "NOT_CLAIMED" } } diff --git a/tools/web/complete/probe-physics.mjs b/tools/web/complete/probe-physics.mjs new file mode 100644 index 000000000..d9990a712 --- /dev/null +++ b/tools/web/complete/probe-physics.mjs @@ -0,0 +1,85 @@ +#!/usr/bin/env node +/** + * Focused case: edit mode -> select all -> UV -> 展开(角度) on a mesh. + * + * node tools/web/complete/probe-physics.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: "ProbePhysics.py", console: false } } }); + }), { requestId, source }, { timeout: 300_000 }); +}; +const physicsState = 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} for m in obj.modifiers]} +cloth = next((m for m in obj.modifiers if m.type == 'CLOTH'), None) +data['cloth_mass'] = cloth.settings.mass if cloth else None +data['particles'] = [system.name for system in obj.particle_systems] +data['rigid_body'] = obj.rigid_body.type if obj.rigid_body else None +data['rigid_world'] = bool(bpy.context.scene.rigidbody_world) +data['rigid_mass'] = obj.rigid_body.mass if obj.rigid_body else None +print('PHYS ' + 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 workbench = page.locator('[data-testid="physics-workbench"]').first(); + await workbench.waitFor({ timeout: 30_000 }); + log("before", JSON.stringify(await physicsState())); + await workbench.getByRole("button", { name: "Add", exact: true }).first().click(); + await page.waitForTimeout(2000); + log("after", JSON.stringify(await physicsState())); + const mass = workbench.locator('[aria-label="RIGID_BODY Mass"]'); + if (await mass.count()) { + await mass.first().fill("5"); + await mass.first().press("Enter"); + await page.waitForTimeout(1500); + log("mass", JSON.stringify(await physicsState())); + } +} catch (error) { + log("probe error", error instanceof Error ? error.message : String(error)); + log("state", JSON.stringify(await physicsState().catch(() => null))); +} finally { + log("consoleErrors", JSON.stringify(consoleErrors.slice(-10))); + await context.close(); + await browser.close(); +}