From 8f08c1bda908ae6765ad4ec56dd199b97a576005 Mon Sep 17 00:00:00 2001 From: mes123456 Date: Sun, 29 Nov 2026 18:33:01 +0800 Subject: [PATCH] feat(web): armature properties split edit, pose and object modes with Ctrl+Tab MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Properties gates the rest-edit forms (add bone, per-bone rest form, bone operations) to Edit mode and the pose readback form to Pose mode; Object mode shows a read-only summary with 进入编辑模式 / 进入姿态模式 buttons. The workbench root carries data-armature-mode for assertions. - Ctrl+Tab on an armature object toggles Pose/Object; Tab still enters Edit. - armature-ui-readback-web waits for the native object.mode_set to report 模式:Pose/模式:Object before pressing shortcuts, matching the app's pending guard that ignores keys during a mode change. - armature-editor-coverage-ui-production enters Edit mode before the rest-edit operations. The coverage spec still cannot run as written: the app worker already holds the web-blender:native-files lock, so the spec's own WebEngineClient fails with WASM_INIT_FAILED. Pre-existing on this branch (also fails with the previous App.tsx); tracked separately from this change. Co-Authored-By: Claude Fable 5.2 --- docs/web/ARMATURE-ROBOT-HEADED-TESTS.md | 10 ++++-- web/app/src/app/App.tsx | 36 +++++++++++-------- ...ture-editor-coverage-ui-production.spec.ts | 4 +++ .../armature-engine-headed-production.spec.ts | 29 +++++++++++++++ 4 files changed, 63 insertions(+), 16 deletions(-) diff --git a/docs/web/ARMATURE-ROBOT-HEADED-TESTS.md b/docs/web/ARMATURE-ROBOT-HEADED-TESTS.md index 80b469b53..fdef56297 100644 --- a/docs/web/ARMATURE-ROBOT-HEADED-TESTS.md +++ b/docs/web/ARMATURE-ROBOT-HEADED-TESTS.md @@ -32,7 +32,7 @@ node tools/web/check-armature-robot-headed.mjs --dir /abs/tests/golden/ARMATURE- | `armature-pose-web` | `setPoseBoneTransform` | poseMatrix/子物体 world 变化、重复写入幂等、归零复原 | | `armature-viewport-web` | 属性面板姿态表单 → Apply Pose | 画布 `data-armature-bone-count`、截图前后不同 | | `armature-decimal-input-web` | 用户逐键输入 `0.5` | `缩放 X` 与姿态 `Scale X` 保留小数;姿态提交后 poseScale 读回 0.5 | -| `armature-ui-readback-web` | 姿态表单回填 | UI 显示角度/缩放 = 引擎 pose 通道(弧度×180/π),`data-testid="armature-pose-readback"` | +| `armature-ui-readback-web` | 物体模式 → 进入姿态模式;姿态表单回填;Ctrl+Tab 往返 | 物体模式只读(无 rest 操作/姿态表单);UI 显示角度/缩放 = 引擎 pose 通道(弧度×180/π),`data-testid="armature-pose-readback"`;Ctrl+Tab 回到物体模式并再进姿态 | | `armature-reopen-web` | 文件 → 保存到浏览器 OPFS → 最近打开 | worker `openBlend` 成功回复为前置;重开后骨骼、骨骼父级、姿态与世界矩阵与保存前一致 | ## 门禁(checker 硬校验) @@ -74,4 +74,10 @@ node tools/web/check-armature-robot-headed.mjs --dir /abs/tests/golden/ARMATURE- - `armature-reopen-web` 已落地:保存走「文件 → 保存到浏览器 OPFS」,重开走「文件 → 最近打开」。 断言前必须等到 worker 的 `openBlend` 成功回复计数增长(证据 `openBlendReplies` 1→2),否则活着的 Main 会直接回答快照、比较恒真;实测重开前 r4 → 重开后 r1,骨骼 / 父级 / 姿态 / 世界矩阵零偏差。 -- 姿态表单「编辑 / 姿态 / 物体」模式分离与 Ctrl+Tab 进入姿态待实现。 +- 姿态表单已按 `uiState.context.mode` 分离,与桌面骨骼模式一致:编辑模式显示 rest 编辑(添加骨骼、 + 逐骨 rest 变换、`armature-edit-operations` 五项操作);姿态模式显示姿态读回/提交表单 + (`armature-pose-readback`);物体模式只读,显示 `armature-mode-actions` 与「进入编辑模式 / 进入姿态模式」 + 按钮。工作台根节点带 `data-armature-mode`,便于断言当前模式。 +- 快捷键:骨骼对象上 Ctrl+Tab 在姿态 / 物体间切换,Tab 仍进入编辑模式。原生 `object.mode_set` + 进行中(状态栏显示「正在切换到 … 模式…」)时 App 会忽略快捷键,属刻意的 pending 守卫;物体模式按钮 + 始终可用,切换完成后再按快捷键生效。 diff --git a/web/app/src/app/App.tsx b/web/app/src/app/App.tsx index 54f6c7047..b0cdbcd2d 100644 --- a/web/app/src/app/App.tsx +++ b/web/app/src/app/App.tsx @@ -3374,11 +3374,13 @@ function NumberDraftInput({ value, step, label, disabled, onCommit }: { value: n onKeyDown={(event) => { if (event.key === "Enter") { event.preventDefault(); setDraft(null); } }} />; } -function Properties({ selectedEdgeIndices, nonMeshGeometryBuffers, client, snapshot, editorWorkflow, selectedFaceIndices, selectedVertexIndices, greasePencilSelection, onGreasePencilCanvasPointSelect, onCommand, onExecutePython, objectCameraId, onObjectCameraChange, onPointCacheOperation, onSoftBodyCacheOperation, onFluidCacheOperation, onSimulatePhysics, physicsSimulationRange, onImportSequencerMedia, onRestoreSequencerMedia, pointCacheBusy, onImportImage, onImportVFont, onRequestAsset, onAppendLibraryObject, onAssetLibraryCommand, onQueryRenderCapability, onApplyDecimate, onPreviewDecimate, onApplyDecimateSelected, onGenerateLOD, onSetModifierEnabled, onApplyModifier, onModifierOperator, onCollectionInstance, previewActive, onCancelPreview, simplifyReport, cacheLevels, activeMaterialSlot, onActiveMaterialSlotChange }: { +function Properties({ selectedEdgeIndices, nonMeshGeometryBuffers, client, snapshot, uiMode, onSetMode, editorWorkflow, selectedFaceIndices, selectedVertexIndices, greasePencilSelection, onGreasePencilCanvasPointSelect, onCommand, onExecutePython, objectCameraId, onObjectCameraChange, onPointCacheOperation, onSoftBodyCacheOperation, onFluidCacheOperation, onSimulatePhysics, physicsSimulationRange, onImportSequencerMedia, onRestoreSequencerMedia, pointCacheBusy, onImportImage, onImportVFont, onRequestAsset, onAppendLibraryObject, onAssetLibraryCommand, onQueryRenderCapability, onApplyDecimate, onPreviewDecimate, onApplyDecimateSelected, onGenerateLOD, onSetModifierEnabled, onApplyModifier, onModifierOperator, onCollectionInstance, previewActive, onCancelPreview, simplifyReport, cacheLevels, activeMaterialSlot, onActiveMaterialSlotChange }: { selectedEdgeIndices: number[]; nonMeshGeometryBuffers: NonMeshGeometryChunk[]; client: WebEngineClient | null; snapshot: SceneSnapshotIR | null; + uiMode: string; + onSetMode: (mode: 'Object' | 'Edit' | 'Pose') => void; editorWorkflow: EditorWorkflowIR | null; selectedFaceIndices: number[]; selectedVertexIndices: number[]; @@ -4417,6 +4419,10 @@ function Properties({ selectedEdgeIndices, nonMeshGeometryBuffers, client, snaps if (!armature) return null; const activeArmatureBone = armature.bones.find((bone) => bone.name === activeArmatureBoneName) ?? armature.bones[0]; const constraintTarget = snapshot?.nodes.some((node) => node.id === poseConstraintTargetId && node.id !== activeNode.id) ? poseConstraintTargetId : ""; + /* Desktop splits armature editing by mode: rest bones in Edit mode, pose + * channels in Pose mode, and a read-only summary in Object mode. */ + const isEditMode = uiMode === "Edit"; + const isPoseMode = uiMode === "Pose"; const commandBones = armature.bones.map((bone) => ({ name: bone.name, parentName: armature.bones.find((candidate) => candidate.id === bone.parentId)?.name ?? null, @@ -4425,12 +4431,13 @@ function Properties({ selectedEdgeIndices, nonMeshGeometryBuffers, client, snaps roll: bone.roll ?? 0, connected: bone.connected ?? false, })); - return
+ return

Armature

- + {isEditMode ? : null} {armature.bones.length} bones -
+ {!isEditMode && !isPoseMode ?
物体模式:骨骼与姿态只读。
: null} + {isEditMode ?
{activeArmatureBone ? <> @@ -4440,8 +4447,8 @@ function Properties({ selectedEdgeIndices, nonMeshGeometryBuffers, client, snaps : null} -
-
{ +
: null} + {isEditMode ? { event.preventDefault(); const data = new FormData(event.currentTarget); const name = String(data.get("newBoneName") ?? "").trim(); @@ -4463,12 +4470,12 @@ function Properties({ selectedEdgeIndices, nonMeshGeometryBuffers, client, snaps
- + : null} {armature.bones.map((bone) => { const currentParent = armature.bones.find((candidate) => candidate.id === bone.parentId)?.name ?? ""; return

{bone.name}

-
{ + {isEditMode ? { event.preventDefault(); const data = new FormData(event.currentTarget); const number = (field: string) => Number(data.get(field)); @@ -4489,8 +4496,8 @@ function Properties({ selectedEdgeIndices, nonMeshGeometryBuffers, client, snaps
-
- {(() => { + : null} + {isPoseMode ? (() => { /* Pose channels read back from the snapshot and rotate in degrees * like the desktop pose panel; the engine stores radians. The key * remounts the uncontrolled fields when the pose changes. */ @@ -4512,7 +4519,7 @@ function Properties({ selectedEdgeIndices, nonMeshGeometryBuffers, client, snaps {(["X", "Y", "Z"] as const).map((axis, index) => )}
; - })()} + })() : null}
; })}
; @@ -9873,7 +9880,8 @@ else: if(event.isComposing||target?.closest('input,textarea,select,[contenteditable=true],[role=dialog],[role=menu]')||headerBusy||headerDialog||robotToolOpen||interactiveDesktop)return; if(event.key==='F1'&&event.shiftKey&&!event.ctrlKey&&!event.metaKey&&!event.altKey&&hasProject){event.preventDefault();event.stopImmediatePropagation();focusProperty('[data-testid="library-append-workbench"]');} else if(event.key==='F12'){event.preventDefault();event.stopImmediatePropagation();renderFromMenu(event.ctrlKey);} - else if(event.key==='Tab'&&target?.matches('canvas.viewport-canvas')&&canEdit){event.preventDefault();event.stopImmediatePropagation();dispatchUI({type:'setMode',mode:uiState.context.mode==='Edit'?'Object':'Edit'});} + else if(event.key==='Tab'&&event.ctrlKey&&target?.matches('canvas.viewport-canvas')&&activeHeaderNode?.type==='ARMATURE'){event.preventDefault();event.stopImmediatePropagation();dispatchUI({type:'setMode',mode:uiState.context.mode==='Pose'?'Object':'Pose'});} + else if(event.key==='Tab'&&!event.ctrlKey&&!event.metaKey&&target?.matches('canvas.viewport-canvas')&&canEdit){event.preventDefault();event.stopImmediatePropagation();dispatchUI({type:'setMode',mode:uiState.context.mode==='Edit'?'Object':'Edit'});} else if(target?.matches('canvas.viewport-canvas')&&event.key.toLowerCase()==='a'&&!event.ctrlKey&&!event.metaKey){event.preventDefault();event.stopImmediatePropagation();selectHeader(event.altKey?'none':'all');} else if(target?.matches('canvas.viewport-canvas')&&(event.ctrlKey||event.metaKey)&&event.key.toLowerCase()==='i'){event.preventDefault();event.stopImmediatePropagation();selectHeader('invert');} }; @@ -10193,7 +10201,7 @@ else: case "Outliner": return applyEditCommand(command, undefined, feedback)} onReparent={(ids, parentId, keepTransform) => void applyEditCommand({ type: 'setParents', objectIds: ids, parentId, keepTransform })} onMoveToCollection={(ids, collectionId, keepExistingLinks) => { for (const id of ids) void applyEditCommand({ type: 'moveObjectToCollection', objectId: id, collectionId, keepExistingLinks }); }} onMoveCollection={(collectionId, parentCollectionId) => void applyEditCommand(coreSceneCommands.moveCollection(collectionId, parentCollectionId))} onSelect={selectObject} onRefresh={refreshOutliner} onSelectAll={selectAllOutliner} onToggleVisibility={(id, visible) => void applyEditCommand({ type: "setObjectVisibility", objectId: id, visible })} />; case "Properties": - return queueLocalDesktopOperator("fluid." + operation, {}, true, objectId, "OBJECT") : undefined} pointCacheBusy={headerBusy || Boolean(localInvokePending) || localInvokeActive || nativeModalActive || projectActionLocked} onPointCacheOperation={localOnly ? operation => queueLocalDesktopOperator(operation === "BAKE_ALL" ? "ptcache.bake_all" : "ptcache.free_bake_all", operation === "BAKE_ALL" ? { bake: true } : {}, true) : undefined} selectedEdgeIndices={meshSelection.mode === "EDGE" ? [...meshSelection.indices] : []} nonMeshGeometryBuffers={nonMeshGeometryBuffers} client={webClientRef.current} snapshot={snapshot} editorWorkflow={editorWorkflow} onExecutePython={executePythonAndApply} objectCameraId={objectCameraId} onObjectCameraChange={setObjectCameraId} onSimulatePhysics={simulatePhysicsRange} physicsSimulationRange={snapshot?.scenes[0]?.renderSettings ? { start: snapshot.scenes[0].renderSettings.frameStart, end: snapshot.scenes[0].renderSettings.frameEnd } : undefined} onImportSequencerMedia={importSequencerMedia} onRestoreSequencerMedia={restoreSequencerMedia} selectedFaceIndices={meshSelection.mode === "FACE" ? [...meshSelection.indices] : []} selectedVertexIndices={meshSelection.mode === "VERT" ? [...meshSelection.indices] : []} greasePencilSelection={greasePencilSelection} onGreasePencilCanvasPointSelect={(point, mode, baseSelectionRevision) => { commitGreasePencilSelection("CANVAS_2D", mode === "ADD" ? "TOGGLE" : mode, [point], baseSelectionRevision, point); }} onCommand={(command) => applyEditCommand(command)} onImportImage={(file) => void importImage(file)} onImportVFont={(file) => void importVFont(file)} onRequestAsset={(assetId) => { const client = webClientRef.current; if (!client) return; void client.requestAsset(assetId).then((asset) => setEngineStatus(`Asset: ${asset.assetId} (${asset.status})`)).catch((error: unknown) => setEngineStatus(recordDiagnostic("ENGINE", "PBR_ASSET_INVALID", error, { assetId }))); }} onAppendLibraryObject={async (source, request) => { + return queueLocalDesktopOperator("fluid." + operation, {}, true, objectId, "OBJECT") : undefined} pointCacheBusy={headerBusy || Boolean(localInvokePending) || localInvokeActive || nativeModalActive || projectActionLocked} onPointCacheOperation={localOnly ? operation => queueLocalDesktopOperator(operation === "BAKE_ALL" ? "ptcache.bake_all" : "ptcache.free_bake_all", operation === "BAKE_ALL" ? { bake: true } : {}, true) : undefined} selectedEdgeIndices={meshSelection.mode === "EDGE" ? [...meshSelection.indices] : []} nonMeshGeometryBuffers={nonMeshGeometryBuffers} client={webClientRef.current} snapshot={snapshot} uiMode={uiState.context.mode} onSetMode={(mode) => dispatchUI({type:'setMode', mode})} editorWorkflow={editorWorkflow} onExecutePython={executePythonAndApply} objectCameraId={objectCameraId} onObjectCameraChange={setObjectCameraId} onSimulatePhysics={simulatePhysicsRange} physicsSimulationRange={snapshot?.scenes[0]?.renderSettings ? { start: snapshot.scenes[0].renderSettings.frameStart, end: snapshot.scenes[0].renderSettings.frameEnd } : undefined} onImportSequencerMedia={importSequencerMedia} onRestoreSequencerMedia={restoreSequencerMedia} selectedFaceIndices={meshSelection.mode === "FACE" ? [...meshSelection.indices] : []} selectedVertexIndices={meshSelection.mode === "VERT" ? [...meshSelection.indices] : []} greasePencilSelection={greasePencilSelection} onGreasePencilCanvasPointSelect={(point, mode, baseSelectionRevision) => { commitGreasePencilSelection("CANVAS_2D", mode === "ADD" ? "TOGGLE" : mode, [point], baseSelectionRevision, point); }} onCommand={(command) => applyEditCommand(command)} onImportImage={(file) => void importImage(file)} onImportVFont={(file) => void importVFont(file)} onRequestAsset={(assetId) => { const client = webClientRef.current; if (!client) return; void client.requestAsset(assetId).then((asset) => setEngineStatus(`Asset: ${asset.assetId} (${asset.status})`)).catch((error: unknown) => setEngineStatus(recordDiagnostic("ENGINE", "PBR_ASSET_INVALID", error, { assetId }))); }} onAppendLibraryObject={async (source, request) => { const client = webClientRef.current; if (!client) return; const appendProjectId = projectIdRef.current; const isCurrent = () => client === webClientRef.current && appendProjectId === projectIdRef.current; try { const result = await client.appendLibraryObject(source, request); if (!isCurrent()) return; const logicalRevision = Math.max(projectRevisionRef.current + 1, result.snapshot.revision); projectRevisionRef.current = logicalRevision; const ownsRevision = () => isCurrent() && projectRevisionRef.current === logicalRevision; setSnapshot(result.snapshot); setSelectedObjectIds(selectionFromSnapshot(result.snapshot)); setGeometryBuffers(result.geometryBuffers); setNonMeshGeometryBuffers(result.nonMeshGeometryBuffers ?? []); setFrame(result.snapshot.frame.current); setPreview(null); setLodLevels(null); setDirtyState(current => { const accepted = acceptMainTransaction(current, logicalRevision); return accepted.ok ? accepted.state : current; }); void invalidateCachedLODs(appendProjectId, result.snapshot.revision); try { await persistRecoveryCheckpoint(client, appendProjectId, logicalRevision); } catch (error) { if (ownsRevision()) setStorageStatus(recordDiagnostic("STORAGE", "OPERATION_LOG_FAILED", error, { command: "appendLibraryObject", recovery: "checkpoint" })); } if (!ownsRevision()) return; @@ -10361,7 +10369,7 @@ else: {pythonSession?:} fileInputRef.current?.click()} onSearch={() => dispatchUI({ type: "toggleOperatorSearch", open: true })} /> applyEditCommand(command, undefined, feedback)} onReparent={(ids, parentId, keepTransform) => void applyEditCommand({ type: 'setParents', objectIds: ids, parentId, keepTransform })} onMoveToCollection={(ids, collectionId, keepExistingLinks) => { for (const id of ids) void applyEditCommand({ type: 'moveObjectToCollection', objectId: id, collectionId, keepExistingLinks }); }} onMoveCollection={(collectionId, parentCollectionId) => void applyEditCommand(coreSceneCommands.moveCollection(collectionId, parentCollectionId))} onSelect={selectObject} onRefresh={refreshOutliner} onSelectAll={selectAllOutliner} onToggleVisibility={(id, visible) => void applyEditCommand({ type: "setObjectVisibility", objectId: id, visible })} /> : null} setCameraLocks(current=>({...current,"viewport-area":locked}))} onSelect={selectObject} onBoxSelect={selectObjectsInBox} onElementBoxSelect={selectMeshElementsInBox} onElementSelect={selectMeshElement} onGreasePencilPointSelect={selectGreasePencilPoint} onGreasePencilMarqueeSelect={selectGreasePencilMarquee} onTransform={transformActive} transformSettings={viewportTransformSettings} elementGizmo={elementGizmoFrame} onGizmoDrag={onGizmoDrag}onSetObjectTransform={(objectId, translation, rotationEuler, scale) => void applyEditCommand({ type: "setObjectTransform", objectId, translation, rotationEuler, scale })} onDiagnostic={recordDiagnostic} mode={uiState.context.mode} onMeshEdit={runMeshEdit} onMeshSelectionMode={setMeshSelectionMode} onSelectAllMeshElements={selectAllMeshElements} onAddPrimitive={(primitive) => void applyEditCommand(coreSceneCommands.createPrimitive(primitive))} onFocusSculptProperties={() => focusProperty('[data-testid="sculpt-editor"]')} onVoxelRemesh={(voxelSize) => void invokeNativeOperator('object.voxel_remesh', { voxel_size: voxelSize })} /> applyEditCommand(command, undefined, feedback)} onReparent={(ids, parentId, keepTransform) => void applyEditCommand({ type: 'setParents', objectIds: ids, parentId, keepTransform })} onMoveToCollection={(ids, collectionId, keepExistingLinks) => { for (const id of ids) void applyEditCommand({ type: 'moveObjectToCollection', objectId: id, collectionId, keepExistingLinks }); }} onMoveCollection={(collectionId, parentCollectionId) => void applyEditCommand(coreSceneCommands.moveCollection(collectionId, parentCollectionId))} onSelect={selectObject} onRefresh={refreshOutliner} onSelectAll={selectAllOutliner} onToggleVisibility={(id, visible) => void applyEditCommand({ type: "setObjectVisibility", objectId: id, visible })} /> - queueLocalDesktopOperator("fluid." + operation, {}, true, objectId, "OBJECT") : undefined} pointCacheBusy={headerBusy || Boolean(localInvokePending) || localInvokeActive || nativeModalActive || projectActionLocked} onPointCacheOperation={localOnly ? operation => queueLocalDesktopOperator(operation === "BAKE_ALL" ? "ptcache.bake_all" : "ptcache.free_bake_all", operation === "BAKE_ALL" ? { bake: true } : {}, true) : undefined} selectedEdgeIndices={meshSelection.mode === "EDGE" ? [...meshSelection.indices] : []} nonMeshGeometryBuffers={nonMeshGeometryBuffers} client={webClientRef.current} snapshot={snapshot} editorWorkflow={editorWorkflow} onExecutePython={executePythonAndApply} objectCameraId={objectCameraId} onObjectCameraChange={setObjectCameraId} onSimulatePhysics={simulatePhysicsRange} physicsSimulationRange={snapshot?.scenes[0]?.renderSettings ? { start: snapshot.scenes[0].renderSettings.frameStart, end: snapshot.scenes[0].renderSettings.frameEnd } : undefined} onImportSequencerMedia={importSequencerMedia} onRestoreSequencerMedia={restoreSequencerMedia} selectedFaceIndices={meshSelection.mode === "FACE" ? [...meshSelection.indices] : []} selectedVertexIndices={meshSelection.mode === "VERT" ? [...meshSelection.indices] : []} greasePencilSelection={greasePencilSelection} onGreasePencilCanvasPointSelect={(point, mode, baseSelectionRevision) => { commitGreasePencilSelection("CANVAS_2D", mode === "ADD" ? "TOGGLE" : mode, [point], baseSelectionRevision, point); }} onCommand={(command) => applyEditCommand(command)} onImportImage={(file) => void importImage(file)} onImportVFont={(file) => void importVFont(file)} onRequestAsset={(assetId) => { const client = webClientRef.current; if (!client) return; void client.requestAsset(assetId).then((asset) => setEngineStatus(`Asset: ${asset.assetId} (${asset.status})`)).catch((error: unknown) => setEngineStatus(recordDiagnostic("ENGINE", "PBR_ASSET_INVALID", error, { assetId }))); }} onAppendLibraryObject={async (source, request) => { + queueLocalDesktopOperator("fluid." + operation, {}, true, objectId, "OBJECT") : undefined} pointCacheBusy={headerBusy || Boolean(localInvokePending) || localInvokeActive || nativeModalActive || projectActionLocked} onPointCacheOperation={localOnly ? operation => queueLocalDesktopOperator(operation === "BAKE_ALL" ? "ptcache.bake_all" : "ptcache.free_bake_all", operation === "BAKE_ALL" ? { bake: true } : {}, true) : undefined} selectedEdgeIndices={meshSelection.mode === "EDGE" ? [...meshSelection.indices] : []} nonMeshGeometryBuffers={nonMeshGeometryBuffers} client={webClientRef.current} snapshot={snapshot} uiMode={uiState.context.mode} onSetMode={(mode) => dispatchUI({type:'setMode', mode})} editorWorkflow={editorWorkflow} onExecutePython={executePythonAndApply} objectCameraId={objectCameraId} onObjectCameraChange={setObjectCameraId} onSimulatePhysics={simulatePhysicsRange} physicsSimulationRange={snapshot?.scenes[0]?.renderSettings ? { start: snapshot.scenes[0].renderSettings.frameStart, end: snapshot.scenes[0].renderSettings.frameEnd } : undefined} onImportSequencerMedia={importSequencerMedia} onRestoreSequencerMedia={restoreSequencerMedia} selectedFaceIndices={meshSelection.mode === "FACE" ? [...meshSelection.indices] : []} selectedVertexIndices={meshSelection.mode === "VERT" ? [...meshSelection.indices] : []} greasePencilSelection={greasePencilSelection} onGreasePencilCanvasPointSelect={(point, mode, baseSelectionRevision) => { commitGreasePencilSelection("CANVAS_2D", mode === "ADD" ? "TOGGLE" : mode, [point], baseSelectionRevision, point); }} onCommand={(command) => applyEditCommand(command)} onImportImage={(file) => void importImage(file)} onImportVFont={(file) => void importVFont(file)} onRequestAsset={(assetId) => { const client = webClientRef.current; if (!client) return; void client.requestAsset(assetId).then((asset) => setEngineStatus(`Asset: ${asset.assetId} (${asset.status})`)).catch((error: unknown) => setEngineStatus(recordDiagnostic("ENGINE", "PBR_ASSET_INVALID", error, { assetId }))); }} onAppendLibraryObject={async (source, request) => { const client = webClientRef.current; if (!client) return; const appendProjectId = projectIdRef.current; const isCurrent = () => client === webClientRef.current && appendProjectId === projectIdRef.current; try { const result = await client.appendLibraryObject(source, request); if (!isCurrent()) return; const logicalRevision = Math.max(projectRevisionRef.current + 1, result.snapshot.revision); projectRevisionRef.current = logicalRevision; const ownsRevision = () => isCurrent() && projectRevisionRef.current === logicalRevision; setSnapshot(result.snapshot); setSelectedObjectIds(selectionFromSnapshot(result.snapshot)); setGeometryBuffers(result.geometryBuffers); setNonMeshGeometryBuffers(result.nonMeshGeometryBuffers ?? []); setFrame(result.snapshot.frame.current); setPreview(null); setLodLevels(null); setDirtyState(current => { const accepted = acceptMainTransaction(current, logicalRevision); return accepted.ok ? accepted.state : current; }); void invalidateCachedLODs(appendProjectId, result.snapshot.revision); try { await persistRecoveryCheckpoint(client, appendProjectId, logicalRevision); } catch (error) { if (ownsRevision()) setStorageStatus(recordDiagnostic("STORAGE", "OPERATION_LOG_FAILED", error, { command: "appendLibraryObject", recovery: "checkpoint" })); } if (!ownsRevision()) return; diff --git a/web/tests/e2e/armature-editor-coverage-ui-production.spec.ts b/web/tests/e2e/armature-editor-coverage-ui-production.spec.ts index 62c0f3a49..59e2436cf 100644 --- a/web/tests/e2e/armature-editor-coverage-ui-production.spec.ts +++ b/web/tests/e2e/armature-editor-coverage-ui-production.spec.ts @@ -29,6 +29,10 @@ test("armature panel operates on the selected bone", async ({ page }, testInfo) await workflow.load(path.join(root, fixturePath), "PoseConstraintArmatureObject"); const panel = page.getByTestId("armature-authoring-workbench"); await workflow.save("before"); + /* The rest-edit operations live in Edit mode, matching desktop armature mode + * separation; object mode keeps the panel read-only. */ + await panel.getByRole("button", { name: "进入编辑模式", exact: true }).click(); + await expect(panel.getByTestId("armature-edit-operations")).toBeVisible({ timeout: 30_000 }); await panel.getByLabel("Active armature bone").selectOption("Auxiliary"); await panel.getByLabel("Pose constraint target").selectOption({ label: "PoseConstraintTarget" }); for (const name of ["Rotate Bone Roll", "Clear Bone Parent", "Enable X Mirror", "Duplicate Bone", "Add Pose Constraint"]) { diff --git a/web/tests/e2e/armature-engine-headed-production.spec.ts b/web/tests/e2e/armature-engine-headed-production.spec.ts index 53459b0e4..0d5f9d674 100644 --- a/web/tests/e2e/armature-engine-headed-production.spec.ts +++ b/web/tests/e2e/armature-engine-headed-production.spec.ts @@ -234,6 +234,11 @@ test('viewport draws the armature and repaints after a pose [armature-viewport-w await expect(panel).toBeVisible({ timeout: 60_000 }); const bone = panel.locator('.property-subsection').filter({ has: page.getByRole('heading', { name: 'Root', exact: true }) }).first(); await expect(bone).toBeVisible({ timeout: 30_000 }); + /* Desktop keeps rest editing in Edit mode and pose channels in Pose mode; the + * object-mode armature panel is read-only, so enter Pose before the form. */ + await expect(panel.getByTestId('armature-pose-readback')).toHaveCount(0); + await panel.getByRole('button', { name: '进入姿态模式', exact: true }).click(); + await expect(bone.getByTestId('armature-pose-readback')).toBeVisible({ timeout: 120_000 }); /* The pose panel shows degrees; the engine keeps radians. */ await bone.getByLabel('Rotation X', { exact: true }).fill(String(Number((POSE[0] * 180 / Math.PI).toFixed(4)))); await bone.getByLabel('Rotation Z', { exact: true }).fill(String(Number((POSE[2] * 180 / Math.PI).toFixed(4)))); @@ -281,6 +286,8 @@ test('decimal input reaches object and pose transforms [armature-decimal-input-w await expect(panel).toBeVisible({ timeout: 120_000 }); const bone = panel.locator('.property-subsection').filter({ has: page.getByRole('heading', { name: 'Root', exact: true }) }).first(); await expect(bone).toBeVisible({ timeout: 30_000 }); + await panel.getByRole('button', { name: '进入姿态模式', exact: true }).click(); + await expect(bone.getByTestId('armature-pose-readback')).toBeVisible({ timeout: 120_000 }); /* Type key by key like a user: a number input briefly reports "" for "0.", * so only the final value proves the decimal survived the round trip. */ @@ -323,7 +330,29 @@ test('pose form reads back the applied channels [armature-ui-readback-web]', asy const panel = page.getByTestId('armature-authoring-workbench'); await expect(panel).toBeVisible({ timeout: 120_000 }); const bone = panel.locator('.property-subsection').filter({ has: page.getByRole('heading', { name: 'Root', exact: true }) }).first(); + /* Object mode is read-only: neither the rest forms nor the pose form exist + * until the armature enters the matching mode, like desktop Blender. */ + await expect(panel).toHaveAttribute('data-armature-mode', 'Object'); + await expect(panel.getByTestId('armature-pose-readback')).toHaveCount(0); + await expect(panel.getByTestId('armature-edit-operations')).toHaveCount(0); + await panel.getByRole('button', { name: '进入姿态模式', exact: true }).click(); const form = bone.getByTestId('armature-pose-readback'); + await expect(form).toBeVisible({ timeout: 120_000 }); + await expect(panel.getByTestId('armature-edit-operations')).toHaveCount(0); + /* The button's native object.mode_set runs after the local mode flips, and + * shortcuts are ignored while a mode change is pending; wait for the status + * line to report the completed switch before exercising Ctrl+Tab. */ + const status = page.getByTestId('engine-status'); + await expect(status).toContainText('模式:Pose', { timeout: 120_000 }); + + /* Ctrl+Tab toggles Pose on an armature object (Tab keeps entering Edit). */ + const canvas = page.locator('canvas.viewport-canvas').first(); + await canvas.focus(); + await page.keyboard.press('Control+Tab'); + await expect(panel).toHaveAttribute('data-armature-mode', 'Object', { timeout: 30_000 }); + await expect(panel.getByTestId('armature-pose-readback')).toHaveCount(0); + await expect(status).toContainText('模式:Object', { timeout: 120_000 }); + await page.keyboard.press('Control+Tab'); await expect(form).toBeVisible({ timeout: 30_000 }); const degrees = Number((POSE[0] * 180 / Math.PI).toFixed(4));