- 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>
99 lines
4.3 KiB
JavaScript
99 lines
4.3 KiB
JavaScript
#!/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();
|
|
}
|