From 87e3f7207d2ead444f805168b264b04bcf00495c Mon Sep 17 00:00:00 2001 From: mes123456 Date: Sat, 14 Nov 2026 06:40:38 +0800 Subject: [PATCH] feat(web): expose auto-keying preferences The insert-keyframe path already existed but both preferences were marked unsupported and hidden. Enable useAutoKeying and keyframeInterpolation; verified g transform inserts location/rotation/scale F-Curves. Co-Authored-By: Claude Code --- .../WBV2-P1425-001-web-operator-dispatch.md | 4 + .../continuation-20261113-web-export.json | 8 +- tools/web/complete/probe-autokey.mjs | 86 +++++++++++++++++++ web/protocol/web-preferences.ts | 4 +- 4 files changed, 99 insertions(+), 3 deletions(-) create mode 100644 tools/web/complete/probe-autokey.mjs diff --git a/docs/status/WBV2-P1425-001-web-operator-dispatch.md b/docs/status/WBV2-P1425-001-web-operator-dispatch.md index c4952e5f4..81a1f73de 100644 --- a/docs/status/WBV2-P1425-001-web-operator-dispatch.md +++ b/docs/status/WBV2-P1425-001-web-operator-dispatch.md @@ -403,6 +403,10 @@ 形态键 `Basis/Cast`;SUBSURF 被原生拒绝“Only deforming modifiers can be applied to shapes”,与桌面语义一致;证据 `tools/web/complete/probe-modifier-shapekey.mjs`。 +- 自动关键帧:偏好设置的原生实现已存在但 `supported: false` 隐藏。已开放 + “自动关键帧”和“新建关键帧插值”两项。复测:勾选后在视口按 `g`, + location 0→0.1,自动生成 location/rotation_euler/scale 共 9 条 F-Curve + (各 1 键),状态 revision r5;证据 `tools/web/complete/probe-autokey.mjs`。 ## 下一动作 diff --git a/tests/golden/WBV2-P1425-001/continuation-20261113-web-export.json b/tests/golden/WBV2-P1425-001/continuation-20261113-web-export.json index bb4e04952..b6399912c 100644 --- a/tests/golden/WBV2-P1425-001/continuation-20261113-web-export.json +++ b/tests/golden/WBV2-P1425-001/continuation-20261113-web-export.json @@ -1,7 +1,7 @@ { "schemaVersion": 1, "task": "WBV2-P1425-001", - "updatedAt": "2026-11-14T06:38:00+08:00", + "updatedAt": "2026-11-14T06:41:00+08:00", "status": "in_progress", "focus": "COMPLETE-TUTORIAL-001 backend export gap (USD/Alembic)", "breakpoint": "blender-5.2.0/source/blender/web_engine/CMakeLists.txt (USD wiring); WASM 6ee2b261", @@ -153,5 +153,11 @@ "subsurf": "rejected by native operator (only deforming modifiers), correct desktop behavior", "script": "tools/web/complete/probe-modifier-shapekey.mjs", "acceptance": "NOT_CLAIMED" + }, + "autoKeyProbe": { + "fix": "web/protocol/web-preferences.ts: animation.useAutoKeying and animation.keyframeInterpolation supported=true (were hidden)", + "result": "checkbox enabled; g moved Ground location 0→0.1 and inserted 9 F-Curves (location/rotation_euler/scale, 1 key each)", + "script": "tools/web/complete/probe-autokey.mjs", + "acceptance": "NOT_CLAIMED" } } diff --git a/tools/web/complete/probe-autokey.mjs b/tools/web/complete/probe-autokey.mjs new file mode 100644 index 000000000..1b5a91a0f --- /dev/null +++ b/tools/web/complete/probe-autokey.mjs @@ -0,0 +1,86 @@ +#!/usr/bin/env node +/** + * Focused case: edit mode -> select all -> UV -> 展开(角度) on a mesh. + * + * node tools/web/complete/probe-autokey.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: "ProbeAutoKey.py", console: false } } }); + }), { requestId, source }, { timeout: 300_000 }); +}; +const autoKeyState = async () => { + const result = await python(` +import bpy, json +obj = bpy.context.view_layer.objects.active +action = obj.animation_data.action if obj.animation_data else None +curves = [] +if action: + for layer in action.layers: + for strip in layer.strips: + for bag in getattr(strip, 'channelbags', []): + for curve in bag.fcurves: + curves.append({'path': curve.data_path, 'index': curve.array_index, 'keys': len(curve.keyframe_points)}) +print('AUTOKEY ' + json.dumps({'object': obj.name, 'location': [round(value, 4) for value in obj.location], 'fcurves': curves})) +`); + 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 autoKeyState())); + await menu("编辑", "偏好设置"); + await page.getByRole("dialog", { name: "Web Blender 偏好设置" }).waitFor({ timeout: 30_000 }); + await page.getByRole("button", { name: "动画", exact: true }).click(); + const autoKey = page.getByRole("checkbox", { name: "自动关键帧", exact: true }); + await autoKey.waitFor({ timeout: 30_000 }); + log("checkbox", JSON.stringify({ checked: await autoKey.isChecked(), disabled: await autoKey.isDisabled() })); + await autoKey.check(); + await page.getByRole("button", { name: "关闭偏好设置", exact: true }).click(); + await page.waitForTimeout(800); + await page.keyboard.press("g"); + await page.waitForTimeout(2500); + log("after g", JSON.stringify(await autoKeyState())); +} catch (error) { + log("probe error", error instanceof Error ? error.message : String(error)); + log("state", JSON.stringify(await autoKeyState().catch(() => null))); +} finally { + log("consoleErrors", JSON.stringify(consoleErrors.slice(-10))); + await context.close(); + await browser.close(); +} diff --git a/web/protocol/web-preferences.ts b/web/protocol/web-preferences.ts index 1ed2e23fd..39b55d850 100644 --- a/web/protocol/web-preferences.ts +++ b/web/protocol/web-preferences.ts @@ -164,9 +164,9 @@ export const PREFERENCE_DEFINITIONS: PreferenceDefinition[] = [ { path: "viewport.navigationSensitivity", tab: "viewport", label: "导航灵敏度", kind: "number", min: 0.2, max: 4, step: 0.1, supported: false, desktopSource: "preferences.inputs.* 导航速度" }, { path: "viewport.defaultShading", tab: "viewport", label: "默认着色", kind: "select", options: [{ value: "SOLID", label: "Solid" }, { value: "MATERIAL", label: "Material" }, { value: "RENDERED", label: "Rendered" }], supported: false, desktopSource: "SpaceView3D.shading(每视口)" }, - { path: "animation.useAutoKeying", tab: "animation", label: "自动关键帧", kind: "boolean", supported: false, desktopSource: "preferences.edit.use_auto_keying (false)" }, + { path: "animation.useAutoKeying", tab: "animation", label: "自动关键帧", kind: "boolean", supported: true, desktopSource: "preferences.edit.use_auto_keying (false)" }, { path: "animation.autoKeyingMode", tab: "animation", label: "自动关键帧模式", kind: "select", options: [{ value: "ADD_REPLACE_KEYS", label: "Add/Replace" }, { value: "REPLACE_KEYS", label: "Replace" }], supported: false, desktopSource: "preferences.edit.auto_keying_mode" }, - { path: "animation.keyframeInterpolation", tab: "animation", label: "新建关键帧插值", kind: "select", options: [{ value: "BEZIER", label: "Bezier" }, { value: "LINEAR", label: "Linear" }, { value: "CONSTANT", label: "Constant" }], supported: false, desktopSource: "preferences.edit.keyframe_new_interpolation_type (BEZIER)" }, + { path: "animation.keyframeInterpolation", tab: "animation", label: "新建关键帧插值", kind: "select", options: [{ value: "BEZIER", label: "Bezier" }, { value: "LINEAR", label: "Linear" }, { value: "CONSTANT", label: "Constant" }], supported: true, desktopSource: "preferences.edit.keyframe_new_interpolation_type (BEZIER)" }, { path: "animation.keyframeHandle", tab: "animation", label: "新建关键帧手柄", kind: "select", options: [{ value: "AUTO_CLAMPED", label: "Auto Clamped" }, { value: "AUTO", label: "Auto" }, { value: "VECTOR", label: "Vector" }, { value: "ALIGNED", label: "Aligned" }, { value: "FREE", label: "Free" }], supported: false, desktopSource: "preferences.edit.keyframe_new_handle_type (AUTO_CLAMPED)" }, { path: "navigation.orbitSensitivity", tab: "input", label: "轨道旋转灵敏度", kind: "number", min: 0.2, max: 4, step: 0.1, supported: false, desktopSource: "preferences.inputs.ndof/view rotation speed" },