chore(web): checkpoint export fixes, operator routing and three-domain evidence
- Web engine CMake: apply WITH_WEB_USD_PYTHON to blender_web_engine_core, embed /usd resources, link pxr Python bindings after the core archive and whole-archive the monolithic OpenUSD archive. Fixes the wm.usd_export abort and restores Alembic/USD embedded export. - ?ui=web menus: fix inverted localOnly gating and route queueLocalDesktopOperator and nativeAdd through the desktop operator channel with a VIEW_3D context; non-mesh edit-mode selection uses the native VIEW3D_SELECT bridge. - Refresh WebEngine wasm/js artifacts, manual/course pages and the complete course video asset. - Record focused Chromium probes for Add/F3/parameters/modifier/UV/curve/deform, scene operations, OPFS save/reopen and worker restart. Evidence is NOT_CLAIMED. Co-Authored-By: Claude Code <noreply@anthropic.com>
This commit is contained in:
84
tools/web/complete/README.md
Normal file
84
tools/web/complete/README.md
Normal file
@@ -0,0 +1,84 @@
|
||||
# Web Blender 完整初学者课程 / 全功能走查 / 视频
|
||||
|
||||
任务:`COMPLETE-TUTORIAL-001`。资产:
|
||||
|
||||
- `/home/mes123456/workinf_Blender_Wasm/re/5000PBR精简版/5000+ PBR catalog.blend`(sha256 `54942f05…c125`)
|
||||
- `/home/mes123456/workinf_Blender_Wasm/re/猴头.glb`(sha256 `60267d…e003`)
|
||||
- 派生库:`/home/mes123456/workinf_Blender_Wasm/web/app/public/assets/re-pbr/`(`library:re-pbr-v1`)
|
||||
- 高清库:`/home/mes123456/workinf_Blender_Wasm/web/app/public/assets/re-pbr-hq/`(`library:re-pbr-hq-v1`)
|
||||
|
||||
## 1. 启动本地 lane(WASM)
|
||||
|
||||
```bash
|
||||
cd /home/mes123456/workinf_Blender_Wasm/web
|
||||
npm run dev -- --host 127.0.0.1 --port 5184 --strictPort
|
||||
```
|
||||
|
||||
入口:`http://127.0.0.1:5184/?ui=web`
|
||||
|
||||
## 2. 启动后端 lane(server/native)
|
||||
|
||||
```bash
|
||||
cd /home/mes123456/workinf_Blender_Wasm/web
|
||||
npm run build
|
||||
cd /home/mes123456/workinf_Blender_Wasm
|
||||
BLENDER_BIN=/home/mes123456/workinf_Blender_Wasm/build_blender_native/bin/blender \
|
||||
BLENDER_WEB_HTTP_PORT=5176 \
|
||||
node /home/mes123456/workinf_Blender_Wasm/tools/web/deployment-http-server.mjs dist
|
||||
```
|
||||
|
||||
部署服务器代理 `/api/server-operator-job`、`/api/blender-workflow`、`/api/blender-session`、`/api/blender-resources`。
|
||||
需要 `/usr/bin/bwrap`、`/usr/bin/prlimit`、`/usr/bin/xvfb-run` 与本机 Blender 二进制。
|
||||
|
||||
## 3. 全功能走查(31 项能力)
|
||||
|
||||
```bash
|
||||
cd /home/mes123456/workinf_Blender_Wasm
|
||||
DISPLAY=:1 CHROME_PATH=/usr/bin/google-chrome GPU_MODE=hardware \
|
||||
node /home/mes123456/workinf_Blender_Wasm/tools/web/complete/capture-complete-course.mjs \
|
||||
--port 5184 --gpu hardware
|
||||
```
|
||||
|
||||
单模块:`--module M11`;报告:
|
||||
`/home/mes123456/workinf_Blender_Wasm/tests/golden/COMPLETE-TUTORIAL-001/capture-report.json`
|
||||
截图:
|
||||
`/home/mes123456/workinf_Blender_Wasm/tests/golden/COMPLETE-TUTORIAL-001/walkthrough/Mxx/*.jpg`
|
||||
课程图:
|
||||
`/home/mes123456/workinf_Blender_Wasm/web/app/public/tutorial/complete/steps/`
|
||||
|
||||
## 4. 生成 HTML 教案
|
||||
|
||||
```bash
|
||||
cd /home/mes123456/workinf_Blender_Wasm
|
||||
node /home/mes123456/workinf_Blender_Wasm/tools/web/course/generate-complete-course.mjs
|
||||
node /home/mes123456/workinf_Blender_Wasm/tools/web/course/check-complete-course.mjs
|
||||
```
|
||||
|
||||
输出:`/home/mes123456/workinf_Blender_Wasm/web/app/public/tutorial/complete/index.html`
|
||||
|
||||
## 5. 完整带配音视频
|
||||
|
||||
```bash
|
||||
cd /home/mes123456/workinf_Blender_Wasm
|
||||
python3 -I /home/mes123456/workinf_Blender_Wasm/tools/web/generate-re-pbr-narration.py --mode prepare \
|
||||
--chapters /home/mes123456/workinf_Blender_Wasm/tools/web/course/complete-video-chapters.json \
|
||||
--out /home/mes123456/workinf_Blender_Wasm/tests/golden/COMPLETE-TUTORIAL-001/video
|
||||
|
||||
DISPLAY=:1 CHROME_PATH=/usr/bin/google-chrome GPU_MODE=hardware \
|
||||
node /home/mes123456/workinf_Blender_Wasm/tools/web/course/record-complete-video.mjs \
|
||||
--port 5184 --gpu hardware
|
||||
|
||||
python3 -I /home/mes123456/workinf_Blender_Wasm/tools/web/generate-re-pbr-narration.py --mode mix \
|
||||
--out /home/mes123456/workinf_Blender_Wasm/tests/golden/COMPLETE-TUTORIAL-001/video \
|
||||
--video /home/mes123456/workinf_Blender_Wasm/web/app/public/tutorial/complete/video/complete-course-720p.mp4
|
||||
```
|
||||
|
||||
`mix` 会把 VTT 写到 `video/re-pbr-lesson.zh-Hans.vtt`,需要重命名为
|
||||
`/home/mes123456/workinf_Blender_Wasm/web/app/public/tutorial/complete/video/complete-course.zh-Hans.vtt`。
|
||||
|
||||
## 6. 注意
|
||||
|
||||
- 所有保存/重开/恢复使用 OPFS;本地 `.blend` 只由用户手动“下载 .blend”生成。
|
||||
- Chromium only;`crossOriginIsolated` 必须为 true。
|
||||
- 首次加载可能 30–193 秒;每步用 `engine-status`/`scene-stats` 等待,不用固定 sleep。
|
||||
- 后端并发上限 2、源码 512 MiB、渲染 240 帧;缺失依赖返回 503。
|
||||
51
tools/web/complete/capability-plan.json
Normal file
51
tools/web/complete/capability-plan.json
Normal file
@@ -0,0 +1,51 @@
|
||||
{
|
||||
"schemaVersion": 1,
|
||||
"task": "COMPLETE-TUTORIAL-001",
|
||||
"sourceMatrix": "tools/web/manual/feature-matrix.json",
|
||||
"assets": {
|
||||
"pbrSourceCatalog": "/home/mes123456/workinf_Blender_Wasm/re/5000PBR精简版/5000+ PBR catalog.blend",
|
||||
"pbrSourceCatalogSha256": "54942f057f913c9923752ba0d4ddcfa6d1f77e98c5e812b83409fb128968c125",
|
||||
"monkeyGlb": "/home/mes123456/workinf_Blender_Wasm/re/猴头.glb",
|
||||
"monkeyGlbSha256": "60267d607b63ceb5bfc972342a9ff17310d6978ff632f240ecb963c4d5a7e003",
|
||||
"monkeyFixture": "/home/mes123456/workinf_Blender_Wasm/tests/files/web/pbr-render-lesson/monkey-head.glb",
|
||||
"standardLibrary": "library:re-pbr-v1",
|
||||
"highQualityLibrary": "library:re-pbr-hq-v1"
|
||||
},
|
||||
"lanes": {
|
||||
"local": {
|
||||
"baseUrl": "http://127.0.0.1:5184/?ui=web",
|
||||
"entry": "Vite dev server, COOP/COEP injected by web/app/vite.config.ts"
|
||||
},
|
||||
"backend": {
|
||||
"baseUrl": "http://127.0.0.1:5176/?ui=web",
|
||||
"entry": "web/dist served by tools/web/deployment-http-server.mjs with BLENDER_BIN=/home/mes123456/workinf_Blender_Wasm/build_blender_native/bin/blender"
|
||||
}
|
||||
},
|
||||
"modules": [
|
||||
{ "id": "M01", "title": "工程、导入与 OPFS", "workspace": "Layout", "lane": "local", "capabilities": [1, 20, 21, 22], "fixtures": ["startup", "re/猴头.glb", "tutorial/pbr/studio.blend"] },
|
||||
{ "id": "M02", "title": "界面、工作区与视口", "workspace": "Layout", "lane": "local", "capabilities": [1, 4] },
|
||||
{ "id": "M03", "title": "Outliner、对象与层级", "workspace": "Layout", "lane": "local", "capabilities": [2] },
|
||||
{ "id": "M04", "title": "Properties、变换、相机与灯光", "workspace": "Layout", "lane": "local", "capabilities": [3, 31] },
|
||||
{ "id": "M05", "title": "建模与网格编辑", "workspace": "Modeling", "lane": "local", "capabilities": [5] },
|
||||
{ "id": "M06", "title": "修改器栈", "workspace": "Modeling", "lane": "local", "capabilities": [5] },
|
||||
{ "id": "M07", "title": "雕刻", "workspace": "Sculpting", "lane": "local", "capabilities": [6] },
|
||||
{ "id": "M08", "title": "UV 编辑", "workspace": "UV Editing", "lane": "local", "capabilities": [7] },
|
||||
{ "id": "M09", "title": "纹理绘制", "workspace": "Texture Paint", "lane": "local+backend", "capabilities": [8] },
|
||||
{ "id": "M10", "title": "曲线、文本、字体与 Grease Pencil", "workspace": "Layout", "lane": "local", "capabilities": [26] },
|
||||
{ "id": "M11", "title": "Shading 与 RE 5000PBR 资产库", "workspace": "Shading", "lane": "local", "capabilities": [9, 10] },
|
||||
{ "id": "M12", "title": "PBR 渲染与诊断", "workspace": "Rendering", "lane": "local", "capabilities": [14] },
|
||||
{ "id": "M13", "title": "动画、Graph/NLA/驱动器与播放", "workspace": "Animation", "lane": "local", "capabilities": [4, 11, 12, 13, 31] },
|
||||
{ "id": "M14", "title": "EEVEE/Cycles 后端渲染", "workspace": "Rendering", "lane": "backend", "capabilities": [15] },
|
||||
{ "id": "M15", "title": "Compositor", "workspace": "Compositing", "lane": "local+backend", "capabilities": [16] },
|
||||
{ "id": "M16", "title": "Geometry Nodes", "workspace": "Geometry Nodes", "lane": "local", "capabilities": [17] },
|
||||
{ "id": "M17", "title": "Spreadsheet 求值属性", "workspace": "Geometry Nodes", "lane": "local", "capabilities": [18] },
|
||||
{ "id": "M18", "title": "Scripting / Python 控制台", "workspace": "Scripting", "lane": "local", "capabilities": [19] },
|
||||
{ "id": "M19", "title": "导入:GLB、glTF 文件夹、OBJ/STL/PLY、图像/VFont", "workspace": "Layout", "lane": "local", "capabilities": [23, 26] },
|
||||
{ "id": "M20", "title": "导出:GLB/OBJ 与 USD/Alembic/FBX", "workspace": "Layout", "lane": "local+backend", "capabilities": [24, 25] },
|
||||
{ "id": "M21", "title": "物理与模拟", "workspace": "Layout", "lane": "local", "capabilities": [29] },
|
||||
{ "id": "M22", "title": "Sequencer 与本地媒体", "workspace": "Layout", "lane": "local+backend", "capabilities": [30] },
|
||||
{ "id": "M23", "title": "相机锁定、追踪与遮罩", "workspace": "Layout", "lane": "local", "capabilities": [31] },
|
||||
{ "id": "M24", "title": "偏好设置、键位、主题与 Add-ons", "workspace": "Layout", "lane": "local", "capabilities": [27, 28] }
|
||||
],
|
||||
"capabilityCount": 31
|
||||
}
|
||||
95
tools/web/complete/capture-complete-backend.mjs
Normal file
95
tools/web/complete/capture-complete-backend.mjs
Normal file
@@ -0,0 +1,95 @@
|
||||
#!/usr/bin/env node
|
||||
/**
|
||||
* Backend-lane checks for the complete course: real EEVEE render and USD export
|
||||
* through the deployment server + native Blender.
|
||||
*
|
||||
* Usage (dist server on 5176):
|
||||
* DISPLAY=:1 CHROME_PATH=/usr/bin/google-chrome GPU_MODE=hardware \
|
||||
* node tools/web/complete/capture-complete-backend.mjs --base-url http://127.0.0.1:5176
|
||||
*/
|
||||
import fs from "node:fs";
|
||||
import path from "node:path";
|
||||
import { REPO, ASSETS, parseArgs, launchBrowser, newPage, openFile, waitScene, switchWorkspace, domClick, shot } from "../course/lib/lesson-recorder.mjs";
|
||||
|
||||
const args = parseArgs();
|
||||
const BASE = args.baseUrl || "http://127.0.0.1:5176";
|
||||
const OUT = path.join(args.out, "backend");
|
||||
fs.mkdirSync(OUT, { recursive: true });
|
||||
const report = { schemaVersion: 1, task: "COMPLETE-TUTORIAL-001", lane: "backend", baseUrl: BASE, startedAt: new Date().toISOString(), checks: [] };
|
||||
|
||||
const browser = await launchBrowser(args.gpu);
|
||||
const { context, page, consoleErrors } = await newPage(browser, { baseUrl: BASE });
|
||||
page.setDefaultTimeout(15_000);
|
||||
|
||||
const check = async (id, title, fn) => {
|
||||
const started = Date.now();
|
||||
const entry = { id, title, status: "PASS" };
|
||||
try { entry.result = await fn(); }
|
||||
catch (error) { entry.status = "FAIL"; entry.error = error instanceof Error ? error.message : String(error); }
|
||||
entry.durationMs = Date.now() - started;
|
||||
report.checks.push(entry);
|
||||
console.log(`${id} ${entry.status} ${entry.durationMs}ms${entry.error ? ` ${entry.error.split("\n")[0]}` : ""}`);
|
||||
};
|
||||
|
||||
try {
|
||||
await openFile(page, ASSETS.studio);
|
||||
await waitScene(page, { objects: 6, timeout: 240_000 });
|
||||
|
||||
await check("B01", "部署服务与 operator describe", async () => {
|
||||
const response = await page.evaluate(async () => {
|
||||
const res = await fetch("/api/server-operator-job", { method: "POST", headers: { "Content-Type": "application/json", "X-Server-Operator-Action": "describe" }, body: JSON.stringify({ operator: "object.shade_smooth" }) });
|
||||
return { status: res.status, body: (await res.text()).slice(0, 400) };
|
||||
});
|
||||
if (response.status !== 200) throw new Error(`describe HTTP ${response.status}`);
|
||||
return response.body;
|
||||
});
|
||||
|
||||
await check("B02", "EEVEE 原生渲染 1 帧", async () => {
|
||||
await switchWorkspace(page, "Rendering");
|
||||
const panel = page.locator(".native-render-fallback").first();
|
||||
await panel.evaluate((element) => { element.open = true; });
|
||||
await page.locator('select[aria-label="Engine"]').selectOption("BLENDER_EEVEE");
|
||||
await page.getByRole("button", { name: "Render Frame", exact: true }).click();
|
||||
await page.waitForFunction(() => {
|
||||
const image = document.querySelector(".native-render-image img");
|
||||
const output = document.querySelector(".native-workflow-output")?.textContent ?? "";
|
||||
return Boolean(image) || /FAILED|ERROR|NATIVE_BACKEND|503|UNAVAILABLE|TIMEOUT/i.test(output);
|
||||
}, null, { timeout: 600_000 });
|
||||
const image = await page.locator(".native-render-image img").count();
|
||||
const output = await page.locator(".native-workflow-output").first().textContent().catch(() => "");
|
||||
await shot(page, OUT, image ? "B02-eevee-render" : "B02-eevee-error");
|
||||
if (!image) throw new Error(`EEVEE render did not produce an image: ${String(output).slice(0, 400)}`);
|
||||
const artifact = await page.locator(".native-workflow-artifacts a").first().getAttribute("download");
|
||||
return { artifact };
|
||||
});
|
||||
|
||||
await check("B03", "USD 原生导出", async () => {
|
||||
await switchWorkspace(page, "Layout");
|
||||
await domClick(page.getByRole("button", { name: "文件", exact: true }));
|
||||
await page.getByRole("menuitem", { name: "导出", exact: true }).first().click().catch(() => {});
|
||||
await page.getByRole("menuitem", { name: /Universal Scene Description/ }).first().click();
|
||||
await page.locator('select[aria-label="导出格式"]').waitFor({ timeout: 30_000 });
|
||||
await page.getByRole("button", { name: "导出", exact: true }).click();
|
||||
await page.waitForFunction(() => {
|
||||
const link = document.querySelector(".native-workflow-artifacts a");
|
||||
const output = document.querySelector(".native-workflow-output")?.textContent ?? "";
|
||||
return Boolean(link) || /FAILED|ERROR|NATIVE_BACKEND|503|UNAVAILABLE|TIMEOUT/i.test(output);
|
||||
}, null, { timeout: 600_000 });
|
||||
const links = await page.locator(".native-workflow-artifacts a").count();
|
||||
const usdOutput = await page.locator(".native-workflow-output").first().textContent().catch(() => "");
|
||||
await shot(page, OUT, links ? "B03-usd-export" : "B03-usd-error");
|
||||
if (!links) throw new Error(`USD export did not produce an artifact: ${String(usdOutput).slice(0, 400)}`);
|
||||
const artifact = await page.locator(".native-workflow-artifacts a").first().getAttribute("download");
|
||||
return { artifact };
|
||||
});
|
||||
}
|
||||
finally {
|
||||
report.consoleErrors = consoleErrors;
|
||||
report.finishedAt = new Date().toISOString();
|
||||
report.status = report.checks.every((entry) => entry.status === "PASS") ? "PASS" : "PARTIAL";
|
||||
fs.writeFileSync(path.join(OUT, "backend-report.json"), `${JSON.stringify(report, null, 2)}\n`);
|
||||
await context.close();
|
||||
await browser.close();
|
||||
console.log(JSON.stringify({ status: report.status, checks: report.checks.length, failures: report.checks.filter((entry) => entry.status !== "PASS").map((entry) => entry.id) }, null, 2));
|
||||
process.exitCode = report.status === "PASS" ? 0 : 1;
|
||||
}
|
||||
372
tools/web/complete/capture-complete-course.mjs
Normal file
372
tools/web/complete/capture-complete-course.mjs
Normal file
@@ -0,0 +1,372 @@
|
||||
#!/usr/bin/env node
|
||||
/**
|
||||
* Complete-feature walkthrough against the real ?ui=web product, using the RE
|
||||
* 5000PBR derived libraries and re/猴头.glb.
|
||||
*
|
||||
* Usage:
|
||||
* DISPLAY=:1 CHROME_PATH=/usr/bin/google-chrome GPU_MODE=hardware \
|
||||
* node tools/web/complete/capture-complete-course.mjs --port 5184 --gpu hardware
|
||||
* node tools/web/complete/capture-complete-course.mjs --module M11 --port 5184
|
||||
*
|
||||
* Outputs:
|
||||
* tests/golden/COMPLETE-TUTORIAL-001/walkthrough/Mxx/*.jpg
|
||||
* web/app/public/tutorial/complete/steps/Mxx-*.jpg
|
||||
* tests/golden/COMPLETE-TUTORIAL-001/capture-report.json
|
||||
*/
|
||||
import fs from "node:fs";
|
||||
import path from "node:path";
|
||||
import {
|
||||
REPO, ASSETS, parseArgs, waitForServer, launchBrowser, newPage,
|
||||
openFile, waitScene, switchWorkspace, domClick, shot,
|
||||
} from "../course/lib/lesson-recorder.mjs";
|
||||
|
||||
const args = parseArgs();
|
||||
const BASE = args.baseUrl || `http://127.0.0.1:${args.port}`;
|
||||
const OUT = args.out;
|
||||
const WALK = path.join(OUT, "walkthrough");
|
||||
const STEPS = path.join(REPO, "web/app/public/tutorial/complete/steps");
|
||||
const only = args.modules ? new Set(args.modules.split(",").map((item) => item.trim()).filter(Boolean)) : null;
|
||||
fs.mkdirSync(WALK, { recursive: true });
|
||||
fs.mkdirSync(STEPS, { recursive: true });
|
||||
|
||||
const report = { schemaVersion: 1, task: "COMPLETE-TUTORIAL-001", lane: args.lane, gpu: args.gpu, baseUrl: BASE, startedAt: new Date().toISOString(), modules: [], gaps: [] };
|
||||
const sleep = (ms) => new Promise((resolve) => setTimeout(resolve, ms));
|
||||
|
||||
await waitForServer(`${BASE}/?ui=web`);
|
||||
const browser = await launchBrowser(args.gpu);
|
||||
const { context, page, consoleErrors } = await newPage(browser, { baseUrl: BASE });
|
||||
// Optional UI probes should fail fast; explicit waits set their own budgets.
|
||||
page.setDefaultTimeout(8_000);
|
||||
|
||||
const workspace = async (name) => {
|
||||
await domClick(page.locator(".workspace-tabs button", { hasText: name }).first());
|
||||
await sleep(450);
|
||||
};
|
||||
|
||||
const dblClickAsset = async (material) => {
|
||||
await material.scrollIntoViewIfNeeded().catch(() => {});
|
||||
await material.evaluate((element) => {
|
||||
element.dispatchEvent(new MouseEvent("dblclick", { bubbles: true, cancelable: true, view: window }));
|
||||
});
|
||||
await sleep(4000);
|
||||
};
|
||||
|
||||
const baseline = async () => {
|
||||
await openFile(page, ASSETS.studio);
|
||||
await waitScene(page, { objects: 6, timeout: 180_000 });
|
||||
await openFile(page, ASSETS.monkey);
|
||||
await waitScene(page, { objects: 7, active: "Suzanne", timeout: 180_000 });
|
||||
};
|
||||
|
||||
const ensureMonkey = async () => {
|
||||
const stats = await page.getByTestId("scene-stats").innerText();
|
||||
if (!/Objects 7/.test(stats)) await openFile(page, ASSETS.monkey);
|
||||
await waitScene(page, { objects: 7, active: "Suzanne", timeout: 180_000 });
|
||||
};
|
||||
|
||||
const enterEdit = async () => {
|
||||
const chip = page.locator(".mode-chip button").first();
|
||||
const label = await chip.innerText().catch(() => "");
|
||||
if (/Edit Mode|编辑模式/.test(label)) return;
|
||||
await domClick(chip);
|
||||
const item = page.getByRole("menuitemcheckbox", { name: /编辑模式|Edit Mode/ }).first();
|
||||
await item.waitFor({ timeout: 20_000 });
|
||||
await item.click();
|
||||
await sleep(1200);
|
||||
};
|
||||
|
||||
const menu = async (name) => {
|
||||
await domClick(page.getByRole("button", { name, exact: true }).first());
|
||||
await sleep(350);
|
||||
};
|
||||
|
||||
const saveOpfs = async () => {
|
||||
await domClick(page.locator('button[aria-label="保存项目"]'));
|
||||
await page.waitForFunction(() => document.querySelector("main.blender-app")?.getAttribute("data-user-action-save-status") === "SUCCEEDED", null, { timeout: 180_000 });
|
||||
};
|
||||
|
||||
const renderPbr = async () => {
|
||||
const button = page.getByRole("button", { name: /渲染 PBR|Render PBR/ }).first();
|
||||
await button.waitFor({ timeout: 60_000 });
|
||||
await domClick(button);
|
||||
await page.waitForTimeout(9000);
|
||||
};
|
||||
|
||||
const loadReLibrary = async () => {
|
||||
await workspace("Shading");
|
||||
await page.locator(".pbr-asset-library").waitFor({ timeout: 60_000 });
|
||||
await page.locator('select[aria-label="资产来源"]').selectOption("library:re-pbr-v1");
|
||||
await page.waitForFunction(() => document.querySelectorAll('[data-library="library:re-pbr-v1"]').length === 6, null, { timeout: 60_000 });
|
||||
};
|
||||
|
||||
const ensureObjectMode = async () => {
|
||||
const chip = page.locator(".mode-chip button").first();
|
||||
if (!(await chip.count())) return;
|
||||
await domClick(chip);
|
||||
const objectMode = page.getByRole("menuitemcheckbox", { name: /物体模式|Object Mode/ }).first();
|
||||
if (await objectMode.count()) await objectMode.click().catch(() => {});
|
||||
await sleep(1200);
|
||||
};
|
||||
|
||||
const waitMaterialAssigned = (name) => page.waitForFunction((expected) => {
|
||||
const slot = document.querySelector('select[aria-label^="材质槽"]');
|
||||
return slot instanceof HTMLSelectElement && slot.value.includes(expected);
|
||||
}, name, { timeout: 120_000 });
|
||||
|
||||
const assignMaterial = async (name = "black_tiles_wall") => {
|
||||
const material = page.locator('[data-library="library:re-pbr-v1"]', { hasText: name }).first();
|
||||
if (!(await material.count())) throw new Error(`asset card missing: ${name}`);
|
||||
await dblClickAsset(material);
|
||||
try { await waitMaterialAssigned(name); }
|
||||
catch {
|
||||
// The catalog can expose cards before the OPFS payload finishes seeding.
|
||||
await sleep(2000);
|
||||
await dblClickAsset(material);
|
||||
await waitMaterialAssigned(name);
|
||||
}
|
||||
};
|
||||
|
||||
const runStep = async (moduleId, name, fn) => {
|
||||
const dir = path.join(WALK, moduleId);
|
||||
await fn();
|
||||
const file = await shot(page, dir, name);
|
||||
fs.mkdirSync(STEPS, { recursive: true });
|
||||
fs.copyFileSync(file.path, path.join(STEPS, `${moduleId}-${name}.jpg`));
|
||||
return { name, ...file };
|
||||
};
|
||||
|
||||
const runModule = async (id, title, steps) => {
|
||||
if (only && !only.has(id)) return;
|
||||
await page.keyboard.press("Escape").catch(() => {});
|
||||
await sleep(150);
|
||||
const started = Date.now();
|
||||
const entry = { id, title, status: "PASS", steps: [], assertions: [], errors: [], gaps: [] };
|
||||
try {
|
||||
for (const [name, fn] of steps) entry.steps.push(await runStep(id, name, fn));
|
||||
}
|
||||
catch (error) {
|
||||
entry.status = "FAIL";
|
||||
entry.errors.push(error instanceof Error ? error.message : String(error));
|
||||
try { entry.steps.push(await runStep(id, "error", async () => {})); } catch { /* ignore */ }
|
||||
report.gaps.push({ module: id, kind: "capability", reason: entry.errors[0] });
|
||||
}
|
||||
entry.assertions.push({ name: "app-alive", ok: (await page.locator("main.blender-app").count()) > 0 });
|
||||
const statsText = await page.getByTestId("scene-stats").innerText().catch(() => "");
|
||||
entry.assertions.push({ name: "scene-stats", value: statsText, ok: /Objects\s+\d+/.test(statsText) });
|
||||
entry.durationMs = Date.now() - started;
|
||||
report.modules.push(entry);
|
||||
console.log(`${id} ${entry.status} ${entry.durationMs}ms${entry.errors.length ? ` ${entry.errors[0].split("\n")[0]}` : ""}`);
|
||||
};
|
||||
|
||||
try {
|
||||
await runModule("M01", "工程、导入与 OPFS", [
|
||||
["startup", async () => { await workspace("Layout"); }],
|
||||
["import-monkey", async () => { await baseline(); }],
|
||||
["opfs-save", saveOpfs],
|
||||
["reopen", async () => {
|
||||
const close = page.locator('button[aria-label="关闭项目"]').first();
|
||||
if (await close.count()) await close.click().catch(() => {});
|
||||
await sleep(800);
|
||||
const discard = page.getByRole("button", { name: "不保存,继续" }).first();
|
||||
if (await discard.count()) await discard.click().catch(() => {});
|
||||
const recent = page.locator('select[data-testid="recent-projects"]').first();
|
||||
if (await recent.count()) {
|
||||
const values = await recent.locator("option").evaluateAll((options) => options.map((option) => option.value).filter(Boolean));
|
||||
if (values.length > 0) await recent.selectOption(values[values.length - 1]);
|
||||
}
|
||||
await waitScene(page, { objects: 7, timeout: 180_000 });
|
||||
}],
|
||||
["download", async () => {
|
||||
const download = page.waitForEvent("download", { timeout: 60_000 }).catch(() => null);
|
||||
await domClick(page.locator('button[aria-label="下载 .blend"]')).catch(() => {});
|
||||
await download;
|
||||
await sleep(500);
|
||||
}],
|
||||
]);
|
||||
|
||||
await runModule("M02", "界面、工作区与视口", [
|
||||
["workspaces", async () => { await workspace("Layout"); }],
|
||||
["area-menu", async () => {
|
||||
const frame = page.locator(".workspace-grid > .area-frame").first();
|
||||
await frame.locator(".area-type-switch .area-menu button").first().evaluate((element) => element.click());
|
||||
await sleep(300);
|
||||
}],
|
||||
["viewport", async () => { await page.keyboard.press("Escape"); await workspace("Layout"); }],
|
||||
["f3", async () => {
|
||||
await domClick(page.getByRole("button", { name: "操作搜索" }));
|
||||
await page.getByLabel("搜索 Blender 操作").fill("移动");
|
||||
await sleep(400);
|
||||
}],
|
||||
]);
|
||||
|
||||
await runModule("M03", "Outliner、对象与层级", [
|
||||
["select", async () => { await page.keyboard.press("Escape"); await workspace("Layout"); const row = page.locator(".outliner-row").first(); if (await row.count()) await domClick(row); await sleep(300); }],
|
||||
["rename", async () => { await page.keyboard.press("F2").catch(() => {}); await sleep(300); await page.keyboard.press("Escape").catch(() => {}); }],
|
||||
["visibility", async () => { const eye = page.locator('.outliner-row button[aria-label*="可见"], .outliner-row button[title*="可见"]').first(); if (await eye.count()) await domClick(eye).catch(() => {}); await sleep(300); }],
|
||||
["parent", async () => { await page.keyboard.press("Escape"); await menu("物体").catch(() => {}); await sleep(300); }],
|
||||
]);
|
||||
|
||||
await runModule("M04", "Properties、变换、相机与灯光", [
|
||||
["transform", async () => { await page.keyboard.press("Escape"); await workspace("Layout"); await page.getByText("Transform", { exact: true }).first().scrollIntoViewIfNeeded().catch(() => {}); }],
|
||||
["apply", async () => { await menu("物体").catch(() => {}); await sleep(300); }],
|
||||
["camera", async () => { await page.keyboard.press("Escape"); await page.keyboard.press("Numpad0").catch(() => {}); await sleep(500); }],
|
||||
["light", async () => { await page.keyboard.press("Escape"); await page.getByText("Light", { exact: true }).first().scrollIntoViewIfNeeded().catch(() => {}); await sleep(300); }],
|
||||
]);
|
||||
|
||||
await runModule("M05", "建模与网格编辑", [
|
||||
["primitive", async () => { await workspace("Modeling"); await menu("添加").catch(() => {}); await sleep(300); }],
|
||||
["edit-mode", async () => { await page.keyboard.press("Escape"); await enterEdit(); }],
|
||||
["tools", async () => { await page.getByText(/选择工具|更多网格|模态工具/).first().scrollIntoViewIfNeeded().catch(() => {}); await sleep(300); }],
|
||||
["normals", async () => { await page.getByText(/更多网格|高级网格/).first().scrollIntoViewIfNeeded().catch(() => {}); await sleep(300); }],
|
||||
]);
|
||||
|
||||
await runModule("M06", "修改器栈", [
|
||||
["add", async () => { await workspace("Layout"); await ensureMonkey(); await domClick(page.locator(".property-tabs").getByRole("button").nth(1)).catch(() => {}); await sleep(400); }],
|
||||
["stack", async () => { await page.getByText("Modifiers", { exact: true }).first().scrollIntoViewIfNeeded().catch(() => {}); await sleep(300); }],
|
||||
["order", async () => { await page.getByText("Modifiers", { exact: true }).first().scrollIntoViewIfNeeded().catch(() => {}); await sleep(300); }],
|
||||
["apply", async () => { await page.getByText("Modifiers", { exact: true }).first().scrollIntoViewIfNeeded().catch(() => {}); await sleep(300); }],
|
||||
]);
|
||||
|
||||
await runModule("M07", "雕刻", [
|
||||
["brush", async () => { await workspace("Sculpting"); await page.getByTestId("sculpt-editor").scrollIntoViewIfNeeded().catch(() => {}); await sleep(400); }],
|
||||
["stroke", async () => { await page.getByTestId("sculpt-editor").scrollIntoViewIfNeeded().catch(() => {}); await sleep(300); }],
|
||||
["mask", async () => { await page.getByLabel("Sculpt mask").first().scrollIntoViewIfNeeded().catch(() => {}); await sleep(300); }],
|
||||
["remesh", async () => { await page.getByLabel("Sculpt remesh voxel size").first().scrollIntoViewIfNeeded().catch(() => {}); await sleep(300); }],
|
||||
]);
|
||||
|
||||
await runModule("M08", "UV 编辑", [
|
||||
["workspace", async () => { await workspace("UV Editing"); await page.locator(".wasm-uv-editor").waitFor({ timeout: 60_000 }); await enterEdit(); await page.keyboard.press("Escape"); }],
|
||||
["unwrap", async () => {
|
||||
const uv = page.locator(".wasm-uv-editor");
|
||||
const all = uv.locator("button", { hasText: "全选 UV" }).first();
|
||||
if (await all.count()) { await domClick(all); await page.waitForTimeout(1500); }
|
||||
const unwrap = uv.locator("button", { hasText: "展开所选 UV" }).first();
|
||||
if (await unwrap.count()) { await domClick(unwrap); await page.waitForTimeout(2500); }
|
||||
}],
|
||||
["pack", async () => { const pack = page.locator(".wasm-uv-editor button", { hasText: /打包|Pack/ }).first(); if (await pack.count()) await domClick(pack).catch(() => {}); await sleep(800); }],
|
||||
["save", saveOpfs],
|
||||
]);
|
||||
|
||||
await runModule("M09", "纹理绘制", [
|
||||
["workspace", async () => { await workspace("Texture Paint"); await page.getByTestId("texture-paint-canvas").waitFor({ timeout: 60_000 }).catch(() => {}); }],
|
||||
["stroke", async () => {
|
||||
const canvas = page.getByTestId("texture-paint-canvas").first();
|
||||
if (await canvas.count()) {
|
||||
const box = await canvas.boundingBox();
|
||||
if (box) { await page.mouse.move(box.x + box.width * 0.35, box.y + box.height * 0.45); await page.mouse.down(); await page.mouse.move(box.x + box.width * 0.62, box.y + box.height * 0.55, { steps: 16 }); await page.mouse.up(); await page.waitForTimeout(1800); }
|
||||
}
|
||||
}],
|
||||
["undo", async () => { await page.keyboard.press("Control+z").catch(() => {}); await sleep(600); }],
|
||||
["make-local", async () => { await page.getByText(/设为本地|Make Local/).first().scrollIntoViewIfNeeded().catch(() => {}); await sleep(300); }],
|
||||
]);
|
||||
|
||||
await runModule("M10", "曲线、文本与 Grease Pencil", [
|
||||
["add", async () => { await workspace("Layout"); await menu("添加").catch(() => {}); await sleep(300); }],
|
||||
["text", async () => { await page.keyboard.press("Escape"); await page.getByText("Text", { exact: false }).first().scrollIntoViewIfNeeded().catch(() => {}); await sleep(300); }],
|
||||
["font", async () => { await page.getByText(/Font|字体/).first().scrollIntoViewIfNeeded().catch(() => {}); await sleep(300); }],
|
||||
["grease-pencil", async () => { await page.getByTestId("grease-pencil-editor").scrollIntoViewIfNeeded().catch(() => {}); await sleep(300); }],
|
||||
]);
|
||||
|
||||
await runModule("M11", "Shading 与 RE 5000PBR", [
|
||||
["library", loadReLibrary],
|
||||
["assign", async () => { await ensureObjectMode(); await assignMaterial(); }],
|
||||
["compiled", async () => { await page.locator(".material-preview-status").first().scrollIntoViewIfNeeded().catch(() => {}); await sleep(300); }],
|
||||
["hq", async () => { const hq = page.getByRole("button", { name: /加载高清贴图/ }).first(); if (await hq.count()) { await hq.scrollIntoViewIfNeeded().catch(() => {}); await sleep(300); } }],
|
||||
]);
|
||||
|
||||
await runModule("M12", "PBR 渲染与诊断", [
|
||||
["panel", async () => { await workspace("Rendering"); await page.waitForTimeout(800); await page.getByText("PBR 渲染练习", { exact: false }).first().scrollIntoViewIfNeeded().catch(() => {}); }],
|
||||
["render", renderPbr],
|
||||
["diagnostics", async () => { const diag = page.locator('select[aria-label="PBR 诊断视图"]').first(); if (await diag.count()) { await diag.selectOption("NORMAL"); await page.waitForTimeout(2500); } }],
|
||||
["download", async () => { const link = page.locator(".pbr-render-download").first(); if (await link.count()) { const pending = page.waitForEvent("download", { timeout: 30_000 }).catch(() => null); await domClick(link).catch(() => {}); await pending; } await sleep(400); }],
|
||||
]);
|
||||
|
||||
await runModule("M13", "动画、Graph/NLA 与播放", [
|
||||
["keyframes", async () => { await workspace("Animation"); const key = page.getByRole("button", { name: "插入位置关键帧", exact: true }).first(); if (await key.count()) { await domClick(key); await page.waitForTimeout(800); } }],
|
||||
["playback", async () => { const play = page.getByRole("button", { name: "播放", exact: true }).first(); if (await play.count()) { await domClick(play); await page.waitForTimeout(2500); const pause = page.getByRole("button", { name: "暂停", exact: true }).first(); if (await pause.count()) await domClick(pause); } }],
|
||||
["graph-nla", async () => { await page.getByText(/NLA|Graph/).first().scrollIntoViewIfNeeded().catch(() => {}); await sleep(400); }],
|
||||
["camera", async () => { await page.getByText("Scene Bindings", { exact: false }).first().scrollIntoViewIfNeeded().catch(() => {}); await sleep(300); }],
|
||||
]);
|
||||
|
||||
await runModule("M14", "EEVEE/Cycles 后端渲染", [
|
||||
["backend", async () => { await workspace("Rendering"); const panel = page.locator(".native-render-fallback").first(); if (await panel.count()) { await panel.evaluate((element) => { element.open = true; }); await sleep(500); } }],
|
||||
["render", async () => { await page.locator(".native-render-fallback").first().scrollIntoViewIfNeeded().catch(() => {}); await sleep(300); }],
|
||||
["result", async () => { await page.locator(".native-render-fallback").first().scrollIntoViewIfNeeded().catch(() => {}); await sleep(300); }],
|
||||
]);
|
||||
|
||||
await runModule("M15", "Compositor 合成", [
|
||||
["nodes", async () => { await workspace("Compositing"); const canvas = page.getByTestId("compositor-canvas"); await canvas.waitFor({ timeout: 60_000 }); await canvas.getByLabel("添加节点类型").selectOption("CONSTANT_COLOR"); await domClick(canvas.getByRole("button", { name: "添加节点", exact: true })); await sleep(400); }],
|
||||
["links", async () => { await page.getByTestId("compositor-canvas").scrollIntoViewIfNeeded().catch(() => {}); await sleep(300); }],
|
||||
["wasm-eval", async () => { const evalButton = page.getByRole("button", { name: "WASM 合成求值" }).first(); if (await evalButton.count()) { await evalButton.scrollIntoViewIfNeeded().catch(() => {}); await domClick(evalButton); await page.waitForTimeout(4000); } }],
|
||||
["server", async () => { const server = page.getByRole("button", { name: "服务端合成渲染" }).first(); if (await server.count()) { await server.scrollIntoViewIfNeeded().catch(() => {}); await sleep(300); } }],
|
||||
]);
|
||||
|
||||
await runModule("M16", "Geometry Nodes", [
|
||||
["nodes", async () => { await workspace("Geometry Nodes"); const canvas = page.getByTestId("geometry-node-canvas"); await canvas.waitFor({ timeout: 60_000 }); await canvas.getByLabel("添加节点类型").selectOption({ index: 2 }).catch(() => {}); const add = canvas.getByRole("button", { name: "添加节点", exact: true }); if (await add.count()) await domClick(add); await sleep(500); }],
|
||||
["commit", async () => { const commit = page.getByTestId("geometry-node-canvas").getByRole("button", { name: "提交图", exact: true }).first(); if (await commit.count()) await domClick(commit).catch(() => {}); await sleep(1200); }],
|
||||
["result", async () => { await workspace("Layout"); await ensureMonkey(); }],
|
||||
]);
|
||||
|
||||
await runModule("M17", "Spreadsheet 求值属性", [
|
||||
["sources", async () => { await workspace("Geometry Nodes"); const sheet = page.getByTestId("spreadsheet-view"); await sheet.waitFor({ timeout: 60_000 }); await sheet.getByLabel("数据源").selectOption("attributes"); await sleep(500); }],
|
||||
["evaluated", async () => { const read = page.getByTestId("spreadsheet-evaluated").first(); if (await read.count()) { await domClick(read); await page.waitForTimeout(4000); } }],
|
||||
["csv", async () => { const csv = page.getByTestId("spreadsheet-export").first(); if (await csv.count()) { const pending = page.waitForEvent("download", { timeout: 30_000 }).catch(() => null); await domClick(csv).catch(() => {}); await pending; } await sleep(400); }],
|
||||
]);
|
||||
|
||||
await runModule("M18", "Scripting 与 Python 控制台", [
|
||||
["console", async () => { await workspace("Scripting"); await page.waitForTimeout(1000); }],
|
||||
["execute", async () => { const input = page.getByLabel("Python 输入").first(); if (await input.count()) await input.fill("import bpy; print([o.name for o in bpy.data.objects])"); const run = page.getByRole("button", { name: "执行 Python" }).first(); if (await run.count()) { await domClick(run); await page.waitForTimeout(2500); } }],
|
||||
["reset", async () => { await page.getByRole("button", { name: /重置 Python 会话/ }).first().scrollIntoViewIfNeeded().catch(() => {}); await sleep(300); }],
|
||||
]);
|
||||
|
||||
await runModule("M19", "IO 导入", [
|
||||
["glb", async () => { await workspace("Layout"); await ensureMonkey(); }],
|
||||
["gltf-folder", async () => { await menu("文件").catch(() => {}); await sleep(300); }],
|
||||
["obj", async () => { await page.keyboard.press("Escape"); await page.getByText(/导入 OBJ|Import OBJ/).first().scrollIntoViewIfNeeded().catch(() => {}); await sleep(300); }],
|
||||
["image-font", async () => { await page.getByText(/图像|VFont|字体/).first().scrollIntoViewIfNeeded().catch(() => {}); await sleep(300); }],
|
||||
]);
|
||||
|
||||
await runModule("M20", "IO 导出", [
|
||||
["glb", async () => { await page.keyboard.press("Escape"); await menu("文件").catch(() => {}); await sleep(300); }],
|
||||
["obj", async () => { await page.keyboard.press("Escape"); await page.getByRole("menuitem", { name: /导出|Export/ }).first().click().catch(() => {}); await sleep(400); }],
|
||||
["native", async () => { await page.keyboard.press("Escape"); await page.getByText(/导出模型|Export/).first().scrollIntoViewIfNeeded().catch(() => {}); await sleep(300); }],
|
||||
]);
|
||||
|
||||
await runModule("M21", "物理与模拟", [
|
||||
["settings", async () => { await workspace("Layout"); await page.locator('[data-testid="physics-workbench"]').first().scrollIntoViewIfNeeded().catch(() => {}); await sleep(400); }],
|
||||
["playback", async () => { await page.getByRole("button", { name: "播放", exact: true }).first().click().catch(() => {}); await sleep(1500); }],
|
||||
["range", async () => { await page.getByTestId("physics-simulate-range").first().scrollIntoViewIfNeeded().catch(() => {}); await sleep(400); }],
|
||||
]);
|
||||
|
||||
await runModule("M22", "Sequencer 与本地媒体", [
|
||||
["media", async () => { await workspace("Layout"); await page.locator('section[aria-label="Sequencer Strip Editing"]').first().scrollIntoViewIfNeeded().catch(() => {}); await sleep(400); }],
|
||||
["strip", async () => { const add = page.getByRole("button", { name: "Add Strip", exact: true }).first(); if (await add.count()) await domClick(add).catch(() => {}); await sleep(800); }],
|
||||
["edit", async () => { await page.locator('section[aria-label="Sequencer Strip Editing"]').first().scrollIntoViewIfNeeded().catch(() => {}); await sleep(400); }],
|
||||
["export", async () => { await page.getByRole("button", { name: "恢复媒体", exact: true }).first().scrollIntoViewIfNeeded().catch(() => {}); await sleep(300); }],
|
||||
]);
|
||||
|
||||
await runModule("M23", "相机锁定、追踪与遮罩", [
|
||||
["camera", async () => { await workspace("Layout"); await page.keyboard.press("Numpad0").catch(() => {}); await sleep(600); }],
|
||||
["object-camera", async () => { await page.getByText("Scene Bindings", { exact: false }).first().scrollIntoViewIfNeeded().catch(() => {}); await sleep(300); }],
|
||||
["tracking", async () => { await page.getByTestId("tracking-mask-workbench").first().scrollIntoViewIfNeeded().catch(() => {}); await sleep(500); }],
|
||||
]);
|
||||
|
||||
await runModule("M24", "偏好设置、键位与主题", [
|
||||
["preferences", async () => { await menu("编辑").catch(() => {}); await page.getByRole("menuitem", { name: "偏好设置" }).first().click().catch(() => {}); await page.getByTestId("preferences-window").waitFor({ timeout: 20_000 }); await sleep(400); }],
|
||||
["keymap", async () => { await page.getByRole("button", { name: "键位", exact: true }).click().catch(() => {}); await sleep(300); }],
|
||||
["theme", async () => { await page.getByRole("button", { name: "主题", exact: true }).click().catch(() => {}); await sleep(300); }],
|
||||
["addons", async () => { await page.getByRole("button", { name: "系统", exact: true }).click().catch(() => {}); await sleep(800); await page.getByRole("button", { name: "关闭偏好设置" }).click().catch(() => {}); }],
|
||||
]);
|
||||
}
|
||||
finally {
|
||||
report.consoleErrors = consoleErrors;
|
||||
report.finishedAt = new Date().toISOString();
|
||||
report.status = report.modules.every((module) => module.status === "PASS") ? "PASS" : "PARTIAL";
|
||||
fs.mkdirSync(OUT, { recursive: true });
|
||||
fs.writeFileSync(path.join(OUT, "capture-report.json"), `${JSON.stringify(report, null, 2)}\n`);
|
||||
await context.close();
|
||||
await browser.close();
|
||||
const failures = report.modules.filter((module) => module.status !== "PASS");
|
||||
console.log(JSON.stringify({ status: report.status, modules: report.modules.length, failures: failures.map((module) => module.id), report: path.join(OUT, "capture-report.json") }, null, 2));
|
||||
process.exitCode = failures.length === 0 ? 0 : 1;
|
||||
}
|
||||
67
tools/web/complete/probe-add-menu.mjs
Normal file
67
tools/web/complete/probe-add-menu.mjs
Normal file
@@ -0,0 +1,67 @@
|
||||
#!/usr/bin/env node
|
||||
/**
|
||||
* Focused case: Add menu -> Mesh -> Circle/Grid/Monkey through the product
|
||||
* ?ui=web entry, then undo/redo. Evidence only; no assertions.
|
||||
*
|
||||
* node tools/web/complete/probe-add-menu.mjs --base-url http://127.0.0.1:5176
|
||||
*/
|
||||
import { ASSETS, parseArgs, launchBrowser, newPage, 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, { baseUrl: BASE });
|
||||
page.setDefaultTimeout(60_000);
|
||||
const log = (...parts) => console.log(new Date().toISOString().slice(11, 19), ...parts);
|
||||
const stats = async () => page.evaluate(() => ({
|
||||
stats: document.querySelector('[data-testid="scene-stats"]')?.textContent ?? "",
|
||||
status: document.querySelector('[data-testid="engine-status"]')?.textContent ?? "",
|
||||
output: document.querySelector(".native-workflow-output")?.textContent ?? "",
|
||||
alerts: Array.from(document.querySelectorAll('[role="alert"]')).map((node) => node.textContent).slice(0, 3),
|
||||
}));
|
||||
const count = async () => Number((await stats()).stats.match(/Objects\s+(\d+)/)?.[1] ?? -1);
|
||||
const waitCount = async (expected) => {
|
||||
const deadline = Date.now() + 90_000;
|
||||
while (Date.now() < deadline) {
|
||||
if (await count() === expected) return true;
|
||||
await page.waitForTimeout(250);
|
||||
}
|
||||
return false;
|
||||
};
|
||||
const addAt = async (label) => {
|
||||
await page.getByRole("button", { name: "添加", exact: true }).click();
|
||||
await page.getByRole("menuitem", { name: "网格", exact: true }).click();
|
||||
await page.getByRole("menuitem", { name: label, exact: true }).click();
|
||||
};
|
||||
const editMenu = async (label) => {
|
||||
await page.getByRole("button", { name: "编辑", exact: true }).click();
|
||||
await page.getByRole("menuitem", { name: label, exact: true }).click();
|
||||
};
|
||||
|
||||
try {
|
||||
await switchWorkspace(page, "Layout");
|
||||
await openFile(page, ASSETS.studio);
|
||||
await waitScene(page, { objects: 6, timeout: 240_000 });
|
||||
let expected = await count();
|
||||
log("start", JSON.stringify(await stats()));
|
||||
|
||||
for (const label of ["圆环", "栅格", "猴头"]) {
|
||||
await addAt(label);
|
||||
expected += 1;
|
||||
const ok = await waitCount(expected);
|
||||
log(`add ${label}`, ok ? "OK" : "MISS", JSON.stringify(await stats()));
|
||||
}
|
||||
|
||||
await editMenu("撤销");
|
||||
log("undo", await waitCount(expected - 1), JSON.stringify(await stats()));
|
||||
await editMenu("重做");
|
||||
log("redo", await waitCount(expected), JSON.stringify(await stats()));
|
||||
} catch (error) {
|
||||
log("probe error", error instanceof Error ? error.message : String(error));
|
||||
log("state", JSON.stringify(await stats().catch(() => null)));
|
||||
} finally {
|
||||
log("consoleErrors", JSON.stringify(consoleErrors.slice(-20)));
|
||||
await context.close();
|
||||
await browser.close();
|
||||
}
|
||||
101
tools/web/complete/probe-add-params.mjs
Normal file
101
tools/web/complete/probe-add-params.mjs
Normal file
@@ -0,0 +1,101 @@
|
||||
#!/usr/bin/env node
|
||||
/**
|
||||
* Focused case: Add-menu operator channel parameters (location/rotation/scale/
|
||||
* align) and failure boundaries, driven through the product worker.
|
||||
*
|
||||
* node tools/web/complete/probe-add-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(60_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({ elapsedMs: Date.now() - started, response: hit }); return; }
|
||||
if (Date.now() - started > 240000) { clearInterval(timer); resolve({ elapsedMs: Date.now() - started, timeout: true }); }
|
||||
};
|
||||
const timer = setInterval(read, 250);
|
||||
for (const worker of window.__probeWorkers) worker.postMessage({ requestId, command: { type: "jsonCommand", cmd: "pythonExec", params: { source, filename: "ProbeAdd.py", console: false } } });
|
||||
}), { requestId, source }, { timeout: 300_000 });
|
||||
};
|
||||
|
||||
try {
|
||||
await openApp(page, BASE);
|
||||
await openFile(page, ASSETS.studio);
|
||||
await waitScene(page, { objects: 6, timeout: 240_000 });
|
||||
|
||||
log("--- stage 1: params ---");
|
||||
log(JSON.stringify(await python(`
|
||||
import json, web_blender
|
||||
revision = web_blender.snapshot().get('revision')
|
||||
web_blender.desktop_operator({
|
||||
'operator': 'mesh.primitive_cube_add',
|
||||
'properties': {'location': [1.0, 2.0, 3.0], 'rotation': [0.0, 0.0, 0.5], 'scale': [2.0, 2.0, 2.0], 'align': 'WORLD'},
|
||||
'baseRevision': revision, 'areaType': 'VIEW_3D', 'mode': 'OBJECT', 'native': True,
|
||||
})
|
||||
import bpy
|
||||
obj = bpy.context.view_layer.objects.active
|
||||
print('PROBE_PARAMS ' + json.dumps({'name': obj.name, 'location': list(obj.location), 'rotation': list(obj.rotation_euler), 'scale': list(obj.scale), 'dimensions': list(obj.dimensions), 'objects': len(bpy.data.objects)}))
|
||||
`)));
|
||||
|
||||
log("--- stage 1b: enter_editmode ---");
|
||||
log(JSON.stringify(await python(`
|
||||
import json, web_blender
|
||||
web_blender.desktop_operator({
|
||||
'operator': 'mesh.primitive_cube_add',
|
||||
'properties': {'enter_editmode': True},
|
||||
'baseRevision': web_blender.snapshot().get('revision'), 'areaType': 'VIEW_3D', 'mode': 'OBJECT', 'native': True,
|
||||
})
|
||||
import bpy
|
||||
print('PROBE_EDITMODE ' + json.dumps({'mode': bpy.context.mode, 'active': bpy.context.view_layer.objects.active.name}))
|
||||
bpy.ops.object.mode_set(mode='OBJECT')
|
||||
`)));
|
||||
|
||||
log("--- stage 2: stale revision ---");
|
||||
log(JSON.stringify(await python(`
|
||||
import json, web_blender
|
||||
revision = web_blender.snapshot().get('revision')
|
||||
try:
|
||||
web_blender.desktop_operator({'operator': 'mesh.primitive_cube_add', 'properties': {}, 'baseRevision': revision + 9, 'areaType': 'VIEW_3D', 'mode': 'OBJECT', 'native': True})
|
||||
print('PROBE_STALE NO_ERROR')
|
||||
except Exception as error:
|
||||
print('PROBE_STALE ' + repr(error))
|
||||
`)));
|
||||
|
||||
log("--- stage 3: wrong area ---");
|
||||
log(JSON.stringify(await python(`
|
||||
import json, web_blender
|
||||
try:
|
||||
web_blender.desktop_operator({'operator': 'mesh.primitive_cube_add', 'properties': {}, 'baseRevision': web_blender.snapshot().get('revision'), 'areaType': 'INFO', 'mode': 'OBJECT', 'native': True})
|
||||
print('PROBE_AREA NO_ERROR')
|
||||
except Exception as error:
|
||||
print('PROBE_AREA ' + repr(error))
|
||||
`)));
|
||||
} catch (error) {
|
||||
log("probe error", error instanceof Error ? error.message : String(error));
|
||||
} finally {
|
||||
log("consoleErrors", JSON.stringify(consoleErrors.slice(-12)));
|
||||
await context.close();
|
||||
await browser.close();
|
||||
}
|
||||
29
tools/web/complete/probe-backend.mjs
Normal file
29
tools/web/complete/probe-backend.mjs
Normal file
@@ -0,0 +1,29 @@
|
||||
import { parseArgs, launchBrowser, newPage, 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, { baseUrl: BASE });
|
||||
page.setDefaultTimeout(15000);
|
||||
const api = [];
|
||||
page.on("request", (request) => { if (request.url().includes("/api/")) api.push(`REQ ${request.method()} ${request.url()}`); });
|
||||
page.on("response", (response) => { if (response.url().includes("/api/")) api.push(`RES ${response.status()} ${response.url()}`); });
|
||||
await openFile(page, "/home/mes123456/workinf_Blender_Wasm/web/app/public/tutorial/pbr/studio.blend");
|
||||
await waitScene(page, { objects: 6, timeout: 240000 });
|
||||
await switchWorkspace(page, "Rendering");
|
||||
const panel = page.locator(".native-render-fallback").first();
|
||||
await panel.evaluate((element) => { element.open = true; });
|
||||
await page.locator('select[aria-label="Engine"]').selectOption("BLENDER_EEVEE");
|
||||
await page.getByRole("button", { name: "Render Frame", exact: true }).click();
|
||||
for (let i = 0; i < 6; i++) {
|
||||
await page.waitForTimeout(5000);
|
||||
const dump = await page.evaluate(() => ({
|
||||
output: document.querySelector(".native-workflow-output")?.textContent,
|
||||
engine: document.querySelector('[data-testid="engine-status"]')?.textContent,
|
||||
image: Boolean(document.querySelector(".native-render-image img")),
|
||||
alert: Array.from(document.querySelectorAll('[role="alert"]')).map((e) => e.textContent).slice(0, 5),
|
||||
}));
|
||||
console.log(i * 5 + "s", JSON.stringify(dump), "api", api.slice(-4));
|
||||
}
|
||||
console.log("consoleErrors", consoleErrors.slice(-8));
|
||||
await context.close();
|
||||
await browser.close();
|
||||
47
tools/web/complete/probe-collection.mjs
Normal file
47
tools/web/complete/probe-collection.mjs
Normal file
@@ -0,0 +1,47 @@
|
||||
#!/usr/bin/env node
|
||||
/**
|
||||
* Focused case: create a child collection, set it active, delete it.
|
||||
*
|
||||
* node tools/web/complete/probe-collection.mjs --base-url http://127.0.0.1:5176
|
||||
*/
|
||||
import { ASSETS, parseArgs, launchBrowser, newPage, 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, { baseUrl: BASE });
|
||||
page.setDefaultTimeout(90_000);
|
||||
const log = (...parts) => console.log(new Date().toISOString().slice(11, 19), ...parts);
|
||||
const state = async () => page.evaluate(() => ({
|
||||
status: document.querySelector('[data-testid="engine-status"]')?.textContent ?? "",
|
||||
alerts: Array.from(document.querySelectorAll('[role="alert"]')).map((node) => node.textContent).slice(0, 3),
|
||||
cards: Array.from(document.querySelectorAll('[data-testid="collection-visibility-workbench"] input[aria-label^="集合名称"]')).map((input) => input.value),
|
||||
outliner: document.querySelector('.outliner-tree, [aria-label="Outliner"]')?.textContent?.slice(0, 200) ?? "",
|
||||
}));
|
||||
try {
|
||||
await openFile(page, ASSETS.studio);
|
||||
await waitScene(page, { objects: 6, timeout: 240_000 });
|
||||
const panel = page.locator('[data-testid="collection-visibility-workbench"]');
|
||||
await panel.waitFor({ timeout: 30_000 });
|
||||
log("start", JSON.stringify(await state()));
|
||||
await page.getByRole("button", { name: "New Collection", exact: true }).click();
|
||||
await page.waitForTimeout(1500);
|
||||
log("created", JSON.stringify(await state()));
|
||||
const card = panel.locator('fieldset').filter({ has: page.locator('legend', { hasText: "Collection 2" }) }).first();
|
||||
await card.waitFor({ timeout: 30_000 });
|
||||
await card.getByRole("button", { name: "新建子集合", exact: true }).click();
|
||||
await page.waitForTimeout(1200);
|
||||
await card.getByRole("button", { name: "设为活动集合", exact: true }).click();
|
||||
await page.waitForTimeout(1000);
|
||||
log("active", JSON.stringify(await state()));
|
||||
await card.getByRole("button", { name: "删除层级", exact: true }).click();
|
||||
await page.waitForTimeout(1500);
|
||||
log("deleted", JSON.stringify(await state()));
|
||||
} catch (error) {
|
||||
log("probe error", error instanceof Error ? error.message : String(error));
|
||||
log("state", JSON.stringify(await state().catch(() => null)));
|
||||
} finally {
|
||||
log("consoleErrors", JSON.stringify(consoleErrors.slice(-10)));
|
||||
await context.close();
|
||||
await browser.close();
|
||||
}
|
||||
88
tools/web/complete/probe-curve-edit.mjs
Normal file
88
tools/web/complete/probe-curve-edit.mjs
Normal file
@@ -0,0 +1,88 @@
|
||||
#!/usr/bin/env node
|
||||
/**
|
||||
* Focused case: Add Bezier curve -> edit mode -> select all -> curve extrude,
|
||||
* verified through the product worker's Main.
|
||||
*
|
||||
* node tools/web/complete/probe-curve-edit.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({ response: 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: "ProbeCurve.py", console: false } } });
|
||||
}), { requestId, source }, { timeout: 300_000 });
|
||||
};
|
||||
const curveState = async () => {
|
||||
const result = await python(`
|
||||
import bpy, json
|
||||
obj = bpy.context.view_layer.objects.active
|
||||
data = {'object': obj.name if obj else None, 'type': obj.type if obj else None, 'mode': bpy.context.mode}
|
||||
if obj and obj.type == 'CURVE' and obj.data.splines:
|
||||
data['points'] = [len(spline.bezier_points) for spline in obj.data.splines]
|
||||
data['selected'] = [[point.select_control_point for point in spline.bezier_points] for spline in obj.data.splines]
|
||||
print('CURVE ' + json.dumps(data))
|
||||
`);
|
||||
const out = result?.response?.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 });
|
||||
await menu("添加", "曲线");
|
||||
await page.getByRole("menuitem", { name: "贝塞尔", exact: true }).click();
|
||||
await page.waitForTimeout(2000);
|
||||
log("added", JSON.stringify(await curveState()));
|
||||
await page.getByRole("button", { name: "操作搜索", exact: true }).click();
|
||||
await page.getByRole("textbox", { name: "搜索 Blender 操作" }).fill("Enter Edit Mode");
|
||||
await page.waitForTimeout(400);
|
||||
await page.getByRole("textbox", { name: "搜索 Blender 操作" }).press("Enter");
|
||||
await page.waitForTimeout(1500);
|
||||
await menu("选择", "全部");
|
||||
await page.waitForTimeout(800);
|
||||
log("selected", JSON.stringify(await curveState()));
|
||||
await menu("曲线", "挤出");
|
||||
await page.waitForTimeout(1500);
|
||||
log("extruded", JSON.stringify(await curveState()));
|
||||
await menu("编辑", "撤销");
|
||||
await page.waitForTimeout(1500);
|
||||
log("undone", JSON.stringify(await curveState()));
|
||||
} catch (error) {
|
||||
log("probe error", error instanceof Error ? error.message : String(error));
|
||||
log("state", JSON.stringify(await curveState().catch(() => null)));
|
||||
} finally {
|
||||
log("consoleErrors", JSON.stringify(consoleErrors.slice(-12)));
|
||||
await context.close();
|
||||
await browser.close();
|
||||
}
|
||||
79
tools/web/complete/probe-deform.mjs
Normal file
79
tools/web/complete/probe-deform.mjs
Normal file
@@ -0,0 +1,79 @@
|
||||
#!/usr/bin/env node
|
||||
/**
|
||||
* Focused case: edit mode -> select all -> UV -> 展开(角度) on a mesh.
|
||||
*
|
||||
* node tools/web/complete/probe-deform.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: "ProbeDeform.py", console: false } } });
|
||||
}), { requestId, source }, { timeout: 300_000 });
|
||||
};
|
||||
const deformState = async () => {
|
||||
const result = await python(`
|
||||
import bpy, json
|
||||
obj = bpy.context.view_layer.objects.active
|
||||
mesh = obj.data if obj and obj.type == 'MESH' else None
|
||||
data = {'object': obj.name if obj else None, 'mode': bpy.context.mode}
|
||||
if mesh is not None:
|
||||
data['vertex_groups'] = [group.name for group in obj.vertex_groups]
|
||||
data['shape_keys'] = [block.name for block in (mesh.shape_keys.key_blocks if mesh.shape_keys else [])]
|
||||
print('DEFORM ' + 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 });
|
||||
log("before", JSON.stringify(await deformState()));
|
||||
await menu("物体", "形态键");
|
||||
await page.getByRole("menuitem", { name: "添加", exact: true }).click();
|
||||
await page.waitForTimeout(1500);
|
||||
log("shape key", JSON.stringify(await deformState()));
|
||||
await menu("物体", "顶点组");
|
||||
await page.getByRole("menuitem", { name: "新建", exact: true }).click();
|
||||
await page.waitForTimeout(1500);
|
||||
log("vertex group", JSON.stringify(await deformState()));
|
||||
} catch (error) {
|
||||
log("probe error", error instanceof Error ? error.message : String(error));
|
||||
log("state", JSON.stringify(await deformState().catch(() => null)));
|
||||
} finally {
|
||||
log("consoleErrors", JSON.stringify(consoleErrors.slice(-10)));
|
||||
await context.close();
|
||||
await browser.close();
|
||||
}
|
||||
54
tools/web/complete/probe-f3-operator.mjs
Normal file
54
tools/web/complete/probe-f3-operator.mjs
Normal file
@@ -0,0 +1,54 @@
|
||||
#!/usr/bin/env node
|
||||
/**
|
||||
* Focused case: F3 operator search executes a non-allowlisted desktop operator
|
||||
* (mesh.primitive_circle_add) in the ?ui=web entry.
|
||||
*
|
||||
* node tools/web/complete/probe-f3-operator.mjs --base-url http://127.0.0.1:5176
|
||||
*/
|
||||
import { ASSETS, parseArgs, launchBrowser, newPage, 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, { baseUrl: BASE });
|
||||
page.setDefaultTimeout(60_000);
|
||||
const log = (...parts) => console.log(new Date().toISOString().slice(11, 19), ...parts);
|
||||
const state = async () => page.evaluate(() => ({
|
||||
stats: document.querySelector('[data-testid="scene-stats"]')?.textContent ?? "",
|
||||
status: document.querySelector('[data-testid="engine-status"]')?.textContent ?? "",
|
||||
alerts: Array.from(document.querySelectorAll('[role="alert"]')).map((node) => node.textContent).slice(0, 4),
|
||||
palette: document.querySelector('[role="dialog"][aria-label="操作搜索"]') ? "open" : "closed",
|
||||
}));
|
||||
try {
|
||||
await openFile(page, ASSETS.studio);
|
||||
await waitScene(page, { objects: 6, timeout: 240_000 });
|
||||
log("start", JSON.stringify(await state()));
|
||||
await page.getByRole("button", { name: "操作搜索", exact: true }).click();
|
||||
await page.getByRole("textbox", { name: "搜索 Blender 操作" }).fill("primitive_circle_add");
|
||||
await page.waitForTimeout(1500);
|
||||
const results = await page.evaluate(() => Array.from(document.querySelectorAll('.operator-search-results button')).map((node) => node.textContent));
|
||||
log("results", JSON.stringify(results.slice(0, 8)));
|
||||
const target = page.locator('.operator-search-results button').filter({ hasText: "MESH_OT_primitive_circle_add [WEB_MAIN]" }).first();
|
||||
if (!await target.count()) { log("no native result"); }
|
||||
else {
|
||||
await target.click();
|
||||
await page.waitForTimeout(800);
|
||||
log("after select", JSON.stringify(await state()));
|
||||
const run = page.getByRole("button", { name: "执行", exact: true });
|
||||
if (await run.count()) { await run.click(); }
|
||||
else { log("no execute button"); }
|
||||
for (let index = 0; index < 12; index++) {
|
||||
await page.waitForTimeout(500);
|
||||
const current = await state();
|
||||
if (/Objects\s+7\b/.test(current.stats) || current.alerts.length) { log("result", JSON.stringify(current)); break; }
|
||||
if (index === 11) log("timeout", JSON.stringify(current));
|
||||
}
|
||||
}
|
||||
} catch (error) {
|
||||
log("probe error", error instanceof Error ? error.message : String(error));
|
||||
log("state", JSON.stringify(await state().catch(() => null)));
|
||||
} finally {
|
||||
log("consoleErrors", JSON.stringify(consoleErrors.slice(-12)));
|
||||
await context.close();
|
||||
await browser.close();
|
||||
}
|
||||
37
tools/web/complete/probe-library.mjs
Normal file
37
tools/web/complete/probe-library.mjs
Normal file
@@ -0,0 +1,37 @@
|
||||
import fs from "node:fs";
|
||||
import { parseArgs, waitForServer, launchBrowser, newPage, openFile, waitScene, switchWorkspace } from "../course/lib/lesson-recorder.mjs";
|
||||
const args = parseArgs();
|
||||
const BASE = `http://127.0.0.1:${args.port}`;
|
||||
await waitForServer(`${BASE}/?ui=web`);
|
||||
const browser = await launchBrowser(args.gpu);
|
||||
const { context, page } = await newPage(browser, { baseUrl: BASE });
|
||||
page.setDefaultTimeout(15000);
|
||||
await openFile(page, "/home/mes123456/workinf_Blender_Wasm/web/app/public/tutorial/pbr/studio.blend");
|
||||
await waitScene(page, { objects: 6, timeout: 240000 });
|
||||
await openFile(page, "/home/mes123456/workinf_Blender_Wasm/re/猴头.glb");
|
||||
await waitScene(page, { objects: 7, active: "Suzanne", timeout: 240000 });
|
||||
await switchWorkspace(page, "Shading");
|
||||
await page.locator(".pbr-asset-library").waitFor({ timeout: 60000 });
|
||||
await page.locator('select[aria-label="资产来源"]').selectOption("library:re-pbr-v1");
|
||||
await page.waitForFunction(() => document.querySelectorAll('[data-library="library:re-pbr-v1"]').length === 6, null, { timeout: 60000 });
|
||||
const dump = async (label) => {
|
||||
const data = await page.evaluate(() => ({
|
||||
engine: document.querySelector('[data-testid="engine-status"]')?.textContent,
|
||||
engineTitle: document.querySelector('[data-testid="engine-status"]')?.getAttribute("title"),
|
||||
alerts: Array.from(document.querySelectorAll('[role="alert"], [role="status"]')).map((e) => e.textContent).filter(Boolean).slice(0, 20),
|
||||
libraryText: document.querySelector(".pbr-asset-library")?.textContent?.slice(0, 800),
|
||||
slots: Array.from(document.querySelectorAll('select[aria-label^="材质槽"]')).map((s) => ({ value: s.value, options: Array.from(s.options).map((o) => o.textContent).slice(0, 12) })),
|
||||
images: document.querySelectorAll('.pbr-asset-card img').length,
|
||||
}));
|
||||
console.log(`=== ${label} ===`);
|
||||
console.log(JSON.stringify(data, null, 1));
|
||||
};
|
||||
await dump("before");
|
||||
const card = page.locator('[data-library="library:re-pbr-v1"]', { hasText: "black_tiles_wall" }).first();
|
||||
console.log("card count", await card.count());
|
||||
await card.evaluate((element) => element.dispatchEvent(new MouseEvent("dblclick", { bubbles: true, cancelable: true, view: window })));
|
||||
await page.waitForTimeout(8000);
|
||||
await dump("after-dblclick");
|
||||
await page.screenshot({ path: "/tmp/probe-library.png", fullPage: true });
|
||||
await context.close();
|
||||
await browser.close();
|
||||
64
tools/web/complete/probe-mesh-edit.mjs
Normal file
64
tools/web/complete/probe-mesh-edit.mjs
Normal file
@@ -0,0 +1,64 @@
|
||||
#!/usr/bin/env node
|
||||
/**
|
||||
* Focused case: edit mode -> select all -> extrude on the studio ground mesh,
|
||||
* then undo.
|
||||
*
|
||||
* node tools/web/complete/probe-mesh-edit.mjs --base-url http://127.0.0.1:5176
|
||||
*/
|
||||
import { ASSETS, parseArgs, launchBrowser, newPage, 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, { baseUrl: BASE });
|
||||
page.setDefaultTimeout(90_000);
|
||||
const log = (...parts) => console.log(new Date().toISOString().slice(11, 19), ...parts);
|
||||
const state = async () => page.evaluate(() => ({
|
||||
stats: document.querySelector('[data-testid="scene-stats"]')?.textContent ?? "",
|
||||
status: document.querySelector('[data-testid="engine-status"]')?.textContent ?? "",
|
||||
alerts: Array.from(document.querySelectorAll('[role="alert"]')).map((node) => node.textContent).slice(0, 3),
|
||||
mode: document.querySelector('.mode-chip button')?.textContent ?? "",
|
||||
selected: document.querySelector('[data-testid="mesh-selection"]')?.textContent ?? "",
|
||||
}));
|
||||
const enterEdit = async () => {
|
||||
await page.getByRole("button", { name: "操作搜索", exact: true }).click();
|
||||
await page.getByRole("textbox", { name: "搜索 Blender 操作" }).fill("Enter Edit Mode");
|
||||
await page.waitForTimeout(400);
|
||||
await page.getByRole("textbox", { name: "搜索 Blender 操作" }).press("Enter");
|
||||
const deadline = Date.now() + 60_000;
|
||||
while (Date.now() < deadline && !/Edit/i.test((await state()).mode)) await page.waitForTimeout(250);
|
||||
};
|
||||
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 openFile(page, ASSETS.studio);
|
||||
await waitScene(page, { objects: 6, timeout: 240_000 });
|
||||
await enterEdit();
|
||||
log("edit", JSON.stringify(await state()));
|
||||
await menu("选择", "全部");
|
||||
await page.waitForTimeout(1000);
|
||||
log("selected", JSON.stringify(await state()));
|
||||
await menu("网格", "挤出");
|
||||
for (let index = 0; index < 40; index++) {
|
||||
await page.waitForTimeout(500);
|
||||
const current = await state();
|
||||
if (!/Vertices 4 /.test(current.stats) || current.alerts.length) { log("extruded", JSON.stringify(current)); break; }
|
||||
if (index === 39) log("extrude timeout", JSON.stringify(current));
|
||||
}
|
||||
await menu("编辑", "撤销");
|
||||
for (let index = 0; index < 20; index++) {
|
||||
await page.waitForTimeout(500);
|
||||
const current = await state();
|
||||
if (/Vertices 4 /.test(current.stats)) { log("undone", JSON.stringify(current)); break; }
|
||||
if (index === 19) log("undo timeout", JSON.stringify(current));
|
||||
}
|
||||
} catch (error) {
|
||||
log("probe error", error instanceof Error ? error.message : String(error));
|
||||
log("state", JSON.stringify(await state().catch(() => null)));
|
||||
} finally {
|
||||
log("consoleErrors", JSON.stringify(consoleErrors.slice(-12)));
|
||||
await context.close();
|
||||
await browser.close();
|
||||
}
|
||||
52
tools/web/complete/probe-modal-tool.mjs
Normal file
52
tools/web/complete/probe-modal-tool.mjs
Normal file
@@ -0,0 +1,52 @@
|
||||
#!/usr/bin/env node
|
||||
/**
|
||||
* Focused case: Edit mode -> 网格 -> 模态工具 -> 循环切割 in the ?ui=web entry.
|
||||
*
|
||||
* node tools/web/complete/probe-modal-tool.mjs --base-url http://127.0.0.1:5176
|
||||
*/
|
||||
import { ASSETS, parseArgs, launchBrowser, newPage, 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, { baseUrl: BASE });
|
||||
page.setDefaultTimeout(60_000);
|
||||
const log = (...parts) => console.log(new Date().toISOString().slice(11, 19), ...parts);
|
||||
const state = async () => page.evaluate(() => ({
|
||||
stats: document.querySelector('[data-testid="scene-stats"]')?.textContent ?? "",
|
||||
status: document.querySelector('[data-testid="engine-status"]')?.textContent ?? "",
|
||||
alerts: Array.from(document.querySelectorAll('[role="alert"]')).map((node) => node.textContent).slice(0, 4),
|
||||
mode: document.querySelector('.mode-chip button')?.textContent ?? "",
|
||||
}));
|
||||
try {
|
||||
await openFile(page, ASSETS.studio);
|
||||
await waitScene(page, { objects: 6, timeout: 240_000 });
|
||||
await page.getByRole("button", { name: "操作搜索", exact: true }).click();
|
||||
await page.getByRole("textbox", { name: "搜索 Blender 操作" }).fill("Enter Edit Mode");
|
||||
await page.waitForTimeout(500);
|
||||
await page.getByRole("textbox", { name: "搜索 Blender 操作" }).press("Enter");
|
||||
const deadline = Date.now() + 60_000;
|
||||
while (Date.now() < deadline) {
|
||||
const current = await state();
|
||||
if (/Edit/i.test(current.mode)) break;
|
||||
await page.waitForTimeout(250);
|
||||
}
|
||||
log("edit mode", JSON.stringify(await state()));
|
||||
await page.getByRole("button", { name: "模态工具", exact: true }).click();
|
||||
await page.getByRole("menuitem", { name: "循环切割", exact: true }).click();
|
||||
for (let index = 0; index < 12; index++) {
|
||||
await page.waitForTimeout(500);
|
||||
const current = await state();
|
||||
if (/失败|错误|CANCELLED|NOT_|FAILED|UNAVAILABLE|ALLOWLISTED|error/i.test(current.status) || current.alerts.length) {
|
||||
log("result", JSON.stringify(current)); break;
|
||||
}
|
||||
if (index === 11) log("final", JSON.stringify(current));
|
||||
}
|
||||
} catch (error) {
|
||||
log("probe error", error instanceof Error ? error.message : String(error));
|
||||
log("state", JSON.stringify(await state().catch(() => null)));
|
||||
} finally {
|
||||
log("consoleErrors", JSON.stringify(consoleErrors.slice(-12)));
|
||||
await context.close();
|
||||
await browser.close();
|
||||
}
|
||||
48
tools/web/complete/probe-modifier.mjs
Normal file
48
tools/web/complete/probe-modifier.mjs
Normal file
@@ -0,0 +1,48 @@
|
||||
#!/usr/bin/env node
|
||||
/**
|
||||
* Focused case: Properties -> Modifier Stack add SUBSURF and Apply through the
|
||||
* native operator channel in the ?ui=web entry.
|
||||
*
|
||||
* node tools/web/complete/probe-modifier.mjs --base-url http://127.0.0.1:5176
|
||||
*/
|
||||
import { ASSETS, parseArgs, launchBrowser, newPage, 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, { baseUrl: BASE });
|
||||
page.setDefaultTimeout(60_000);
|
||||
const log = (...parts) => console.log(new Date().toISOString().slice(11, 19), ...parts);
|
||||
const state = async () => page.evaluate(() => ({
|
||||
stats: document.querySelector('[data-testid="scene-stats"]')?.textContent ?? "",
|
||||
status: document.querySelector('[data-testid="engine-status"]')?.textContent ?? "",
|
||||
alerts: Array.from(document.querySelectorAll('[role="alert"]')).map((node) => node.textContent).slice(0, 3),
|
||||
rows: Array.from(document.querySelectorAll('.modifier-row')).map((node) => node.textContent?.slice(0, 120)),
|
||||
}));
|
||||
try {
|
||||
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 });
|
||||
log("start", JSON.stringify(await state()));
|
||||
await authoring.locator('[data-modifier-type-input]').fill("SUBSURF");
|
||||
await authoring.getByRole("button", { name: "Add", exact: true }).click();
|
||||
const row = page.locator('.modifier-row').filter({ hasText: "SUBSURF" }).first();
|
||||
await row.waitFor({ timeout: 30_000 });
|
||||
log("added", JSON.stringify(await state()));
|
||||
await row.locator('[aria-label^="Apply "]').first().click();
|
||||
const deadline = Date.now() + 90_000;
|
||||
while (Date.now() < deadline) {
|
||||
const current = await state();
|
||||
if (!current.rows.some((text) => text.includes("SUBSURF")) || current.alerts.length) { log("applied", JSON.stringify(current)); break; }
|
||||
await page.waitForTimeout(250);
|
||||
}
|
||||
log("final", JSON.stringify(await state()));
|
||||
} catch (error) {
|
||||
log("probe error", error instanceof Error ? error.message : String(error));
|
||||
log("state", JSON.stringify(await state().catch(() => null)));
|
||||
} finally {
|
||||
log("consoleErrors", JSON.stringify(consoleErrors.slice(-12)));
|
||||
await context.close();
|
||||
await browser.close();
|
||||
}
|
||||
82
tools/web/complete/probe-parent.mjs
Normal file
82
tools/web/complete/probe-parent.mjs
Normal file
@@ -0,0 +1,82 @@
|
||||
#!/usr/bin/env node
|
||||
/**
|
||||
* Focused case: edit mode -> select all -> UV -> 展开(角度) on a mesh.
|
||||
*
|
||||
* node tools/web/complete/probe-parent.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: "ProbeParent.py", console: false } } });
|
||||
}), { requestId, source }, { timeout: 300_000 });
|
||||
};
|
||||
const parentState = async () => {
|
||||
const result = await python(`
|
||||
import bpy, json
|
||||
active = bpy.context.view_layer.objects.active
|
||||
children = {obj.name: (obj.parent.name if obj.parent else None) for obj in bpy.data.objects}
|
||||
data = {'active': active.name if active else None, 'parents': children}
|
||||
print('PARENT ' + json.dumps(data))
|
||||
`);
|
||||
const out = result?.result?.json;
|
||||
const status = await page.evaluate(() => document.querySelector('[data-testid="engine-status"]')?.textContent ?? "");
|
||||
const selected = await page.evaluate(() => Array.from(document.querySelectorAll('[data-tree-row-id]')).map((node) => ({ label: node.getAttribute('aria-label'), cls: node.className, sel: node.getAttribute('aria-selected'), active: node.getAttribute('data-active') })));
|
||||
return { state: out?.state, output: out?.output, error: out?.error, status, selected };
|
||||
};
|
||||
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 menu("添加", "网格");
|
||||
await page.getByRole("menuitem", { name: "圆环", exact: true }).click();
|
||||
await page.waitForTimeout(1500);
|
||||
const ground = page.locator('[role="treeitem"][aria-label="PBR Studio Ground"]').first();
|
||||
const circle = page.locator('[role="treeitem"][aria-label="Circle"]').first();
|
||||
await circle.click();
|
||||
await page.waitForTimeout(800);
|
||||
await ground.click({ modifiers: ["Shift"] });
|
||||
await page.waitForTimeout(1000);
|
||||
log("selected", JSON.stringify(await parentState()));
|
||||
await menu("物体", "父级");
|
||||
await page.getByRole("menuitem", { name: "设定父级", exact: true }).click();
|
||||
await page.waitForTimeout(1500);
|
||||
log("parented", JSON.stringify(await parentState()));
|
||||
} catch (error) {
|
||||
log("probe error", error instanceof Error ? error.message : String(error));
|
||||
log("state", JSON.stringify(await parentState().catch(() => null)));
|
||||
} finally {
|
||||
log("consoleErrors", JSON.stringify(consoleErrors.slice(-10)));
|
||||
await context.close();
|
||||
await browser.close();
|
||||
}
|
||||
34
tools/web/complete/probe-reopen.mjs
Normal file
34
tools/web/complete/probe-reopen.mjs
Normal file
@@ -0,0 +1,34 @@
|
||||
import { parseArgs, waitForServer, launchBrowser, newPage, openFile, waitScene } from "../course/lib/lesson-recorder.mjs";
|
||||
const args = parseArgs();
|
||||
const BASE = `http://127.0.0.1:${args.port}`;
|
||||
await waitForServer(`${BASE}/?ui=web`);
|
||||
const browser = await launchBrowser(args.gpu);
|
||||
const { context, page } = await newPage(browser, { baseUrl: BASE });
|
||||
const dump = async (label) => {
|
||||
const data = await page.evaluate(() => ({
|
||||
projectId: document.querySelector("main.blender-app")?.getAttribute("data-project-id"),
|
||||
saveStatus: document.querySelector("main.blender-app")?.getAttribute("data-user-action-save-status"),
|
||||
engine: document.querySelector('[data-testid="engine-status"]')?.textContent,
|
||||
stats: document.querySelector('[data-testid="scene-stats"]')?.textContent,
|
||||
buttons: Array.from(document.querySelectorAll("button[aria-label]")).map((b) => b.getAttribute("aria-label")).slice(0, 60),
|
||||
selects: Array.from(document.querySelectorAll("select[aria-label]")).map((s) => ({ label: s.getAttribute("aria-label"), value: s.value, options: Array.from(s.options).map((o) => o.textContent).slice(0, 10) })),
|
||||
bodyText: document.body.innerText.slice(0, 1200),
|
||||
}));
|
||||
console.log(`=== ${label} ===`);
|
||||
console.log(JSON.stringify(data, null, 1));
|
||||
await page.screenshot({ path: `/tmp/probe-${label}.png`, fullPage: true });
|
||||
};
|
||||
await openFile(page, "/home/mes123456/workinf_Blender_Wasm/web/app/public/tutorial/pbr/studio.blend");
|
||||
await waitScene(page, { objects: 6, timeout: 180000 });
|
||||
await openFile(page, "/home/mes123456/workinf_Blender_Wasm/re/猴头.glb");
|
||||
await waitScene(page, { objects: 7, active: "Suzanne", timeout: 180000 });
|
||||
await page.locator('button[aria-label="保存项目"]').click();
|
||||
await page.waitForFunction(() => document.querySelector("main.blender-app")?.getAttribute("data-user-action-save-status") === "SUCCEEDED", null, { timeout: 180000 });
|
||||
await dump("saved");
|
||||
const close = page.locator('button[aria-label="关闭项目"]').first();
|
||||
console.log("close count", await close.count());
|
||||
if (await close.count()) await close.click();
|
||||
await page.waitForTimeout(1500);
|
||||
await dump("after-close");
|
||||
await context.close();
|
||||
await browser.close();
|
||||
56
tools/web/complete/probe-save-reopen.mjs
Normal file
56
tools/web/complete/probe-save-reopen.mjs
Normal file
@@ -0,0 +1,56 @@
|
||||
#!/usr/bin/env node
|
||||
/**
|
||||
* Focused case: add Circle -> save to OPFS -> close project -> reopen from
|
||||
* recent projects; verify the object survives.
|
||||
*
|
||||
* node tools/web/complete/probe-save-reopen.mjs --base-url http://127.0.0.1:5176
|
||||
*/
|
||||
import { ASSETS, parseArgs, launchBrowser, newPage, 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, { baseUrl: BASE });
|
||||
page.setDefaultTimeout(90_000);
|
||||
const log = (...parts) => console.log(new Date().toISOString().slice(11, 19), ...parts);
|
||||
const state = async () => page.evaluate(() => ({
|
||||
stats: document.querySelector('[data-testid="scene-stats"]')?.textContent ?? "",
|
||||
status: document.querySelector('[data-testid="engine-status"]')?.textContent ?? "",
|
||||
alerts: Array.from(document.querySelectorAll('[role="alert"]')).map((node) => node.textContent).slice(0, 3),
|
||||
project: document.querySelector('main.blender-app')?.getAttribute('data-project-id') ?? "",
|
||||
recent: Array.from(document.querySelectorAll('select[data-testid="recent-projects"] option')).map((option) => ({ value: option.value, text: option.textContent })),
|
||||
outliner: document.querySelector('.outliner-tree, [aria-label="Outliner"]')?.textContent?.slice(0, 300) ?? "",
|
||||
}));
|
||||
const count = async () => Number((await state()).stats.match(/Objects\s+(\d+)/)?.[1] ?? -1);
|
||||
try {
|
||||
await openFile(page, ASSETS.studio);
|
||||
await waitScene(page, { objects: 6, timeout: 240_000 });
|
||||
await page.getByRole("button", { name: "添加", exact: true }).click();
|
||||
await page.getByRole("menuitem", { name: "网格", exact: true }).click();
|
||||
await page.getByRole("menuitem", { name: "圆环", exact: true }).click();
|
||||
const addDeadline = Date.now() + 90_000;
|
||||
while (Date.now() < addDeadline && await count() !== 7) await page.waitForTimeout(250);
|
||||
log("added", JSON.stringify(await state()));
|
||||
await page.getByRole("button", { name: "保存项目", exact: true }).click();
|
||||
await page.waitForTimeout(4000);
|
||||
log("saved", JSON.stringify(await state()));
|
||||
await page.getByRole("button", { name: "关闭项目", exact: true }).click();
|
||||
await page.waitForTimeout(2000);
|
||||
log("closed", JSON.stringify(await state()));
|
||||
const select = page.locator('select[data-testid="recent-projects"]');
|
||||
await select.waitFor({ timeout: 30_000 });
|
||||
const options = await page.evaluate(() => Array.from(document.querySelectorAll('select[data-testid="recent-projects"] option')).filter((option) => option.value).map((option) => ({ value: option.value, text: option.textContent })));
|
||||
log("recent", JSON.stringify(options));
|
||||
if (!options.length) throw new Error("no recent project after save");
|
||||
await select.selectOption(options[0].value);
|
||||
await waitScene(page, { timeout: 240_000 });
|
||||
for (let index = 0; index < 24 && await count() < 0; index++) await page.waitForTimeout(500);
|
||||
log("reopened", JSON.stringify(await state()));
|
||||
} catch (error) {
|
||||
log("probe error", error instanceof Error ? error.message : String(error));
|
||||
log("state", JSON.stringify(await state().catch(() => null)));
|
||||
} finally {
|
||||
log("consoleErrors", JSON.stringify(consoleErrors.slice(-12)));
|
||||
await context.close();
|
||||
await browser.close();
|
||||
}
|
||||
53
tools/web/complete/probe-scene-new.mjs
Normal file
53
tools/web/complete/probe-scene-new.mjs
Normal file
@@ -0,0 +1,53 @@
|
||||
#!/usr/bin/env node
|
||||
/**
|
||||
* Focused case: 场景 -> 新建场景 in the ?ui=web entry (desktop operator route).
|
||||
*
|
||||
* node tools/web/complete/probe-scene-new.mjs --base-url http://127.0.0.1:5176
|
||||
*/
|
||||
import { ASSETS, parseArgs, launchBrowser, newPage, 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, { baseUrl: BASE });
|
||||
page.setDefaultTimeout(60_000);
|
||||
const log = (...parts) => console.log(new Date().toISOString().slice(11, 19), ...parts);
|
||||
const state = async () => page.evaluate(() => ({
|
||||
stats: document.querySelector('[data-testid="scene-stats"]')?.textContent ?? "",
|
||||
status: document.querySelector('[data-testid="engine-status"]')?.textContent ?? "",
|
||||
alerts: Array.from(document.querySelectorAll('[role="alert"]')).map((node) => node.textContent).slice(0, 3),
|
||||
topbar: Array.from(document.querySelectorAll('.topbar-context')).map((node) => node.textContent),
|
||||
sceneSelect: document.querySelector('select[aria-label="当前场景"]')?.value ?? null,
|
||||
}));
|
||||
try {
|
||||
await openFile(page, ASSETS.studio);
|
||||
await waitScene(page, { objects: 6, timeout: 240_000 });
|
||||
log("start", JSON.stringify(await state()));
|
||||
await page.getByRole("button", { name: "场景", exact: true }).click();
|
||||
await page.getByRole("menuitem", { name: "新建场景", exact: true }).click();
|
||||
for (let index = 0; index < 20; index++) {
|
||||
await page.waitForTimeout(500);
|
||||
const current = await state();
|
||||
if (/已执行|失败|错误|NOT_|FAILED|UNAVAILABLE/.test(current.status) || current.alerts.length) {
|
||||
log("result", JSON.stringify(current)); break;
|
||||
}
|
||||
if (index === 19) log("final", JSON.stringify(current));
|
||||
}
|
||||
await page.getByRole("button", { name: "场景", exact: true }).click();
|
||||
await page.getByRole("menuitem", { name: "删除场景", exact: true }).click();
|
||||
for (let index = 0; index < 20; index++) {
|
||||
await page.waitForTimeout(500);
|
||||
const current = await state();
|
||||
if (/已执行|失败|错误|NOT_|FAILED|UNAVAILABLE/.test(current.status) || current.alerts.length) {
|
||||
log("delete", JSON.stringify(current)); break;
|
||||
}
|
||||
if (index === 19) log("delete final", JSON.stringify(current));
|
||||
}
|
||||
} catch (error) {
|
||||
log("probe error", error instanceof Error ? error.message : String(error));
|
||||
log("state", JSON.stringify(await state().catch(() => null)));
|
||||
} finally {
|
||||
log("consoleErrors", JSON.stringify(consoleErrors.slice(-10)));
|
||||
await context.close();
|
||||
await browser.close();
|
||||
}
|
||||
138
tools/web/complete/probe-usd-wasm.mjs
Normal file
138
tools/web/complete/probe-usd-wasm.mjs
Normal file
@@ -0,0 +1,138 @@
|
||||
#!/usr/bin/env node
|
||||
/**
|
||||
* Focused probe: is /usd present in the WebEngine WASM FS, and where does
|
||||
* wm.usd_export abort? Drives the product worker directly through a Worker
|
||||
* wrapper installed before the app boots. Evidence only; no assertions.
|
||||
*
|
||||
* node tools/web/complete/probe-usd-wasm.mjs --base-url http://127.0.0.1:5176
|
||||
*/
|
||||
import path from "node:path";
|
||||
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 TIMEOUT = Number(args.timeout || 240_000);
|
||||
|
||||
const browser = await launchBrowser(args.gpu);
|
||||
const { context, page, consoleErrors } = await newPage(browser, {});
|
||||
const consoleAll = [];
|
||||
page.on("console", (message) => consoleAll.push(`${message.type()}: ${message.text()}`));
|
||||
page.setDefaultTimeout(60_000);
|
||||
await page.addInitScript(() => {
|
||||
const NativeWorker = window.Worker;
|
||||
window.__probeWorkers = [];
|
||||
window.__probeMessages = [];
|
||||
window.Worker = class extends NativeWorker {
|
||||
constructor(...params) {
|
||||
super(...params);
|
||||
this.__probeLabel = `${String(params[0])} :: ${new Error().stack.split("\n")[2]?.trim() ?? ""}`;
|
||||
window.__probeWorkers.push(this);
|
||||
this.addEventListener("message", (event) => window.__probeMessages.push({ worker: this.__probeLabel, data: event.data }));
|
||||
}
|
||||
};
|
||||
});
|
||||
const log = (...parts) => console.log(new Date().toISOString().slice(11, 19), ...parts);
|
||||
|
||||
try {
|
||||
await openApp(page, BASE);
|
||||
log("app open");
|
||||
await openFile(page, ASSETS.studio);
|
||||
await waitScene(page, { objects: 6, timeout: 240_000 });
|
||||
log("scene open");
|
||||
|
||||
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 targets = window.__probeWorkers;
|
||||
const started = Date.now();
|
||||
const read = () => {
|
||||
const hit = window.__probeMessages.find((entry) => entry.data && entry.data.requestId === requestId && entry.data.kind === "result");
|
||||
if (hit) { clearInterval(timer); resolve({ elapsedMs: Date.now() - started, workers: targets.map((w) => w.__probeLabel), response: hit.data, via: hit.worker }); return; }
|
||||
if (Date.now() - started > 240000) {
|
||||
clearInterval(timer);
|
||||
resolve({ elapsedMs: Date.now() - started, timeout: true, workers: targets.map((w) => w.__probeLabel), messages: window.__probeMessages.slice(-10) });
|
||||
}
|
||||
};
|
||||
const timer = setInterval(read, 250);
|
||||
for (const worker of targets) worker.postMessage({ requestId, command: { type: "jsonCommand", cmd: "pythonExec", params: { source, filename: "ProbeUSD.py", console: false } } });
|
||||
}), { requestId, source }, { timeout: TIMEOUT });
|
||||
};
|
||||
|
||||
log("--- stage 1: WASM FS + pxr import ---");
|
||||
log(JSON.stringify(await python(`
|
||||
import json, os
|
||||
report = {
|
||||
'usd_dir': os.path.isdir('/usd'),
|
||||
'plugInfo': os.path.exists('/usd/plugInfo.json'),
|
||||
'usd_entries': sorted(os.listdir('/usd'))[:40] if os.path.isdir('/usd') else [],
|
||||
'pxr_zip': os.path.exists('/python/lib/webengine-pxr.zip'),
|
||||
'browser_dir': os.path.isdir('/browser'),
|
||||
}
|
||||
try:
|
||||
from pxr import Plug
|
||||
report['pxr_plugins'] = len(Plug.Registry().GetAllPlugins())
|
||||
report['file_formats'] = sorted(Plug.Registry().GetPluginWithName(n) is not None for n in ('usdc', 'usda'))
|
||||
except BaseException as error:
|
||||
report['pxr_error'] = repr(error)
|
||||
print('PROBE_STAGE1 ' + json.dumps(report, sort_keys=True))
|
||||
`)));
|
||||
|
||||
log("--- stage 1b: sys.path / zipimporter / operator schema ---");
|
||||
log(JSON.stringify(await python(`
|
||||
import json, sys
|
||||
report = {'path': list(sys.path)}
|
||||
try:
|
||||
import zipimport
|
||||
report['zip_importer'] = zipimport.zipimporter('/python/lib/webengine-pxr.zip').find_spec('pxr') is not None
|
||||
except BaseException as error:
|
||||
report['zip_error'] = repr(error)
|
||||
try:
|
||||
import bpy
|
||||
rna = bpy.ops.wm.usd_export.get_rna_type()
|
||||
report['usd_props'] = sorted(p.identifier for p in rna.properties if p.identifier in ('filepath', 'export_textures_mode', 'relative_paths', 'selected_objects_only', 'as_background_job'))
|
||||
except BaseException as error:
|
||||
report['schema_error'] = repr(error)
|
||||
print('PROBE_STAGE1B ' + json.dumps(report, sort_keys=True))
|
||||
`)));
|
||||
|
||||
log("--- stage 2: wm.usd_export ---");
|
||||
log(JSON.stringify(await python(`
|
||||
import json, os, web_blender
|
||||
os.makedirs('/browser/probe-usd', exist_ok=True)
|
||||
payload = {
|
||||
'operator': 'wm.usd_export',
|
||||
'properties': {'filepath': '/browser/probe-usd/scene.usdc', 'export_textures_mode': 'NEW', 'relative_paths': True},
|
||||
'baseRevision': web_blender.snapshot().get('revision'),
|
||||
'areaType': 'VIEW_3D',
|
||||
'mode': 'OBJECT',
|
||||
'native': True,
|
||||
'selectedObjects': [], 'activeObject': None,
|
||||
}
|
||||
web_blender.desktop_operator(payload)
|
||||
print('PROBE_STAGE2 DONE ' + json.dumps({'files': sorted(os.listdir('/browser/probe-usd')), 'bytes': os.path.getsize('/browser/probe-usd/scene.usdc') if os.path.exists('/browser/probe-usd/scene.usdc') else -1}))
|
||||
`)));
|
||||
|
||||
log("--- stage 3: wm.alembic_export ---");
|
||||
log(JSON.stringify(await python(`
|
||||
import json, os, web_blender
|
||||
os.makedirs('/browser/probe-abc', exist_ok=True)
|
||||
payload = {
|
||||
'operator': 'wm.alembic_export',
|
||||
'properties': {'filepath': '/browser/probe-abc/scene.abc'},
|
||||
'baseRevision': web_blender.snapshot().get('revision'),
|
||||
'areaType': 'VIEW_3D',
|
||||
'mode': 'OBJECT',
|
||||
'native': True,
|
||||
'selectedObjects': [], 'activeObject': None,
|
||||
}
|
||||
web_blender.desktop_operator(payload)
|
||||
print('PROBE_STAGE3 DONE ' + json.dumps({'files': sorted(os.listdir('/browser/probe-abc')), 'bytes': os.path.getsize('/browser/probe-abc/scene.abc') if os.path.exists('/browser/probe-abc/scene.abc') else -1}))
|
||||
`)));
|
||||
} catch (error) {
|
||||
log("probe error", error instanceof Error ? error.message : String(error));
|
||||
} finally {
|
||||
log("consoleErrors", JSON.stringify(consoleErrors.slice(-30)));
|
||||
log("consoleAll", JSON.stringify(consoleAll.slice(-40)));
|
||||
await context.close();
|
||||
await browser.close();
|
||||
}
|
||||
98
tools/web/complete/probe-uv-unwrap.mjs
Normal file
98
tools/web/complete/probe-uv-unwrap.mjs
Normal file
@@ -0,0 +1,98 @@
|
||||
#!/usr/bin/env node
|
||||
/**
|
||||
* Focused case: edit mode -> select all -> UV -> 展开(角度) on a mesh.
|
||||
*
|
||||
* node tools/web/complete/probe-uv-unwrap.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: "ProbeUV.py", console: false } } });
|
||||
}), { requestId, source }, { timeout: 300_000 });
|
||||
};
|
||||
const uvState = async () => {
|
||||
const result = await python(`
|
||||
import bpy, json
|
||||
obj = bpy.context.view_layer.objects.active
|
||||
mesh = obj.data if obj and obj.type == 'MESH' else None
|
||||
data = {'object': obj.name if obj else None, 'mode': bpy.context.mode}
|
||||
if mesh is not None:
|
||||
data['uv_layers'] = [layer.name for layer in mesh.uv_layers]
|
||||
data['loops'] = len(mesh.loops)
|
||||
if mesh.uv_layers:
|
||||
active = mesh.uv_layers.active
|
||||
data['uv_layer_active'] = active.name if active else None
|
||||
data['uv_data'] = len(active.data) if active else 0
|
||||
if active and len(active.data):
|
||||
data['uv0'] = [round(value, 4) for value in active.data[0].uv]
|
||||
try:
|
||||
import bmesh
|
||||
bm = bmesh.from_edit_mesh(mesh)
|
||||
data['bm_uv_layers'] = [layer.name for layer in bm.loops.layers.uv]
|
||||
data['bm_faces'] = len(bm.faces)
|
||||
data['bm_selected_faces'] = sum(1 for face in bm.faces if face.select)
|
||||
uv = bm.loops.layers.uv.active
|
||||
if uv:
|
||||
data['bm_uvs'] = [[round(value, 4) for value in loop[uv].uv] for face in bm.faces for loop in face.loops][:4]
|
||||
except Exception as error:
|
||||
data['bm_error'] = repr(error)
|
||||
print('UV ' + 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 });
|
||||
await page.getByRole("button", { name: "操作搜索", exact: true }).click();
|
||||
await page.getByRole("textbox", { name: "搜索 Blender 操作" }).fill("Enter Edit Mode");
|
||||
await page.waitForTimeout(400);
|
||||
await page.getByRole("textbox", { name: "搜索 Blender 操作" }).press("Enter");
|
||||
await page.waitForTimeout(1500);
|
||||
await menu("选择", "全部");
|
||||
await page.waitForTimeout(800);
|
||||
log("before", JSON.stringify(await uvState()));
|
||||
await menu("UV", "展开(角度)");
|
||||
await page.waitForTimeout(2000);
|
||||
log("after", JSON.stringify(await uvState()));
|
||||
} catch (error) {
|
||||
log("probe error", error instanceof Error ? error.message : String(error));
|
||||
log("state", JSON.stringify(await uvState().catch(() => null)));
|
||||
} finally {
|
||||
log("consoleErrors", JSON.stringify(consoleErrors.slice(-10)));
|
||||
await context.close();
|
||||
await browser.close();
|
||||
}
|
||||
56
tools/web/complete/probe-worker-recovery.mjs
Normal file
56
tools/web/complete/probe-worker-recovery.mjs
Normal file
@@ -0,0 +1,56 @@
|
||||
#!/usr/bin/env node
|
||||
/**
|
||||
* Focused case: add Circle, inject a worker crash (?worker-fault=1), verify the
|
||||
* project is restored with the native Main intact.
|
||||
*
|
||||
* node tools/web/complete/probe-worker-recovery.mjs --base-url 'http://127.0.0.1:5176/?ui=web&worker-fault=1'
|
||||
*/
|
||||
import { ASSETS, parseArgs, launchBrowser, newPage, openFile, waitScene } from "../course/lib/lesson-recorder.mjs";
|
||||
|
||||
const args = parseArgs();
|
||||
const BASE = args.baseUrl || "http://127.0.0.1:5176/?ui=web&worker-fault=1";
|
||||
const browser = await launchBrowser(args.gpu);
|
||||
const { context, page, consoleErrors } = await newPage(browser, { baseUrl: BASE });
|
||||
page.setDefaultTimeout(90_000);
|
||||
const log = (...parts) => console.log(new Date().toISOString().slice(11, 19), ...parts);
|
||||
const state = async () => page.evaluate(() => ({
|
||||
stats: document.querySelector('[data-testid="scene-stats"]')?.textContent ?? "",
|
||||
status: document.querySelector('[data-testid="engine-status"]')?.textContent ?? "",
|
||||
recovery: document.querySelector('main.blender-app')?.getAttribute('data-worker-recovery-status') ?? "",
|
||||
alerts: Array.from(document.querySelectorAll('[role="alert"]')).map((node) => node.textContent).slice(0, 3),
|
||||
outliner: document.querySelector('.outliner-tree, [aria-label="Outliner"]')?.textContent?.slice(0, 240) ?? "",
|
||||
}));
|
||||
try {
|
||||
await openFile(page, ASSETS.studio);
|
||||
await waitScene(page, { objects: 6, timeout: 240_000 });
|
||||
await page.getByRole("button", { name: "添加", exact: true }).click();
|
||||
await page.getByRole("menuitem", { name: "网格", exact: true }).click();
|
||||
await page.getByRole("menuitem", { name: "圆环", exact: true }).click();
|
||||
const deadline = Date.now() + 90_000;
|
||||
while (Date.now() < deadline && !/Circle/.test((await state()).stats)) await page.waitForTimeout(250);
|
||||
log("before crash", JSON.stringify(await state()));
|
||||
await page.getByTestId("inject-worker-crash").click();
|
||||
for (let index = 0; index < 120; index++) {
|
||||
await page.waitForTimeout(500);
|
||||
const current = await state();
|
||||
if (current.recovery === "SUCCEEDED" || /Recovery:/i.test(current.status) || current.alerts.length) { log("after crash", JSON.stringify(current)); break; }
|
||||
if (index === 119) log("timeout", JSON.stringify(current));
|
||||
}
|
||||
const restart = page.getByRole("button", { name: "重启并恢复", exact: true });
|
||||
if (await restart.count()) {
|
||||
await restart.first().click();
|
||||
for (let index = 0; index < 180; index++) {
|
||||
await page.waitForTimeout(500);
|
||||
const current = await state();
|
||||
if (current.recovery === "SUCCEEDED" || /restored|recovered|已恢复/i.test(current.status)) { log("recovered", JSON.stringify(current)); break; }
|
||||
if (index === 179) log("recovery timeout", JSON.stringify(current));
|
||||
}
|
||||
} else log("no restart button");
|
||||
} catch (error) {
|
||||
log("probe error", error instanceof Error ? error.message : String(error));
|
||||
log("state", JSON.stringify(await state().catch(() => null)));
|
||||
} finally {
|
||||
log("consoleErrors", JSON.stringify(consoleErrors.slice(-12)));
|
||||
await context.close();
|
||||
await browser.close();
|
||||
}
|
||||
77
tools/web/complete/write-manifest.mjs
Normal file
77
tools/web/complete/write-manifest.mjs
Normal file
@@ -0,0 +1,77 @@
|
||||
#!/usr/bin/env node
|
||||
/** Bind the complete-course evidence with SHA-256 and write the task manifest. */
|
||||
import crypto from "node:crypto";
|
||||
import fs from "node:fs";
|
||||
import path from "node:path";
|
||||
import { execFileSync } from "node:child_process";
|
||||
import { fileURLToPath } from "node:url";
|
||||
|
||||
const REPO = path.resolve(path.dirname(fileURLToPath(import.meta.url)), "../../..");
|
||||
const OUT = path.join(REPO, "tests/golden/COMPLETE-TUTORIAL-001");
|
||||
const VIDEO_DIR = path.join(REPO, "web/app/public/tutorial/complete/video");
|
||||
const html = path.join(REPO, "web/app/public/tutorial/complete/index.html");
|
||||
const sha256 = (file) => crypto.createHash("sha256").update(fs.readFileSync(file)).digest("hex");
|
||||
const artifact = (file) => fs.existsSync(file) ? { path: file, bytes: fs.statSync(file).size, sha256: sha256(file) } : null;
|
||||
const readJson = (file) => fs.existsSync(file) ? JSON.parse(fs.readFileSync(file, "utf8")) : null;
|
||||
const probe = (file) => {
|
||||
if (!fs.existsSync(file)) return null;
|
||||
try {
|
||||
return JSON.parse(execFileSync("/usr/bin/ffprobe", ["-v", "error", "-show_entries", "format=duration,size:stream=codec_type,codec_name,width,height", "-of", "json", file], { encoding: "utf8" }));
|
||||
} catch { return null; }
|
||||
};
|
||||
|
||||
const walkthrough = readJson(path.join(OUT, "capture-report.json"));
|
||||
const backend = readJson(path.join(OUT, "backend/backend-report.json"));
|
||||
const videoReport = readJson(path.join(OUT, "video/video-report.json"));
|
||||
const mp4 = path.join(VIDEO_DIR, "complete-course-720p.mp4");
|
||||
const vtt = path.join(VIDEO_DIR, "complete-course.zh-Hans.vtt");
|
||||
const poster = path.join(VIDEO_DIR, "poster.jpg");
|
||||
const narration = path.join(OUT, "video/narration.wav");
|
||||
const mediaProbe = probe(mp4);
|
||||
|
||||
const manifest = {
|
||||
schemaVersion: 1,
|
||||
task: "COMPLETE-TUTORIAL-001",
|
||||
status: "IMPLEMENTED_NOT_USER_ACCEPTED",
|
||||
generatedAt: new Date().toISOString(),
|
||||
assets: {
|
||||
pbrSourceCatalog: { path: "/home/mes123456/workinf_Blender_Wasm/re/5000PBR精简版/5000+ PBR catalog.blend", sha256: "54942f057f913c9923752ba0d4ddcfa6d1f77e98c5e812b83409fb128968c125" },
|
||||
monkeyGlb: { path: "/home/mes123456/workinf_Blender_Wasm/re/猴头.glb", sha256: "60267d607b63ceb5bfc972342a9ff17310d6978ff632f240ecb963c4d5a7e003" },
|
||||
},
|
||||
lanes: {
|
||||
local: "http://127.0.0.1:5184/?ui=web (Vite dev, Chromium hardware)",
|
||||
backend: "http://127.0.0.1:5176/?ui=web (web/dist + deployment server + native Blender 5.2.0 LTS)",
|
||||
},
|
||||
walkthrough: {
|
||||
status: walkthrough?.status ?? null,
|
||||
modules: walkthrough?.modules?.length ?? 0,
|
||||
steps: walkthrough?.modules?.reduce((total, module) => total + module.steps.length, 0) ?? 0,
|
||||
gaps: walkthrough?.gaps?.length ?? null,
|
||||
report: artifact(path.join(OUT, "capture-report.json")),
|
||||
screenshots: fs.existsSync(path.join(OUT, "walkthrough")) ? fs.readdirSync(path.join(OUT, "walkthrough")).length : 0,
|
||||
},
|
||||
backend: {
|
||||
status: backend?.status ?? null,
|
||||
checks: backend?.checks?.length ?? 0,
|
||||
report: artifact(path.join(OUT, "backend/backend-report.json")),
|
||||
},
|
||||
manual: {
|
||||
html: artifact(html),
|
||||
source: artifact(path.join(REPO, "tools/web/course/complete-course.json")),
|
||||
chapters: 24,
|
||||
steps: 90,
|
||||
},
|
||||
video: {
|
||||
status: videoReport?.status ?? null,
|
||||
mp4: artifact(mp4),
|
||||
vtt: artifact(vtt),
|
||||
poster: artifact(poster),
|
||||
narration: artifact(narration),
|
||||
probe: mediaProbe,
|
||||
report: artifact(path.join(OUT, "video/video-report.json")),
|
||||
timeline: artifact(path.join(OUT, "video/timeline.json")),
|
||||
},
|
||||
};
|
||||
|
||||
fs.writeFileSync(path.join(OUT, "manifest.json"), `${JSON.stringify(manifest, null, 2)}\n`);
|
||||
console.log(JSON.stringify({ status: manifest.status, walkthrough: manifest.walkthrough.status, backend: manifest.backend.status, video: manifest.video.status, manifest: path.join(OUT, "manifest.json") }, null, 2));
|
||||
Reference in New Issue
Block a user