feat(web): armature properties split edit, pose and object modes with Ctrl+Tab
Some checks failed
M6 deployable RC / quick (push) Has been cancelled
M6 deployable RC / chromium (push) Has been cancelled
M6 deployable RC / release (push) Has been cancelled

- 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 <noreply@anthropic.com>
This commit is contained in:
mes123456
2026-11-29 18:33:01 +08:00
parent 165763d0d4
commit 8f08c1bda9
4 changed files with 63 additions and 16 deletions

View File

@@ -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 守卫;物体模式按钮
始终可用,切换完成后再按快捷键生效。

View File

@@ -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 <div className="property-section" data-testid="armature-authoring-workbench">
return <div className="property-section" data-testid="armature-authoring-workbench" data-armature-mode={uiMode}>
<h3>Armature</h3>
<label>Bone <select aria-label="Active armature bone" value={activeArmatureBone?.name ?? ""} disabled={!activeArmatureBone} onChange={(event) => setActiveArmatureBoneName(event.target.value)}>{armature.bones.map((bone) => <option key={bone.id} value={bone.name}>{bone.name}</option>)}</select></label>
<label>Constraint target <select aria-label="Pose constraint target" value={constraintTarget} onChange={(event) => setPoseConstraintTargetId(event.target.value)}><option value="">None</option>{snapshot?.nodes.filter((node) => node.id !== activeNode.id).map((node) => <option key={node.id} value={node.id}>{node.name}</option>)}</select></label>
{isEditMode ? <label>Constraint target <select aria-label="Pose constraint target" value={constraintTarget} onChange={(event) => setPoseConstraintTargetId(event.target.value)}><option value="">None</option>{snapshot?.nodes.filter((node) => node.id !== activeNode.id).map((node) => <option key={node.id} value={node.id}>{node.name}</option>)}</select></label> : null}
<output>{armature.bones.length} bones</output>
<div className="property-actions" data-testid="armature-edit-operations">
{!isEditMode && !isPoseMode ? <div className="property-actions" data-testid="armature-mode-actions"><output>物体模式:骨骼与姿态只读。</output><button type="button" onClick={() => onSetMode("Edit")}>进入编辑模式</button><button type="button" onClick={() => onSetMode("Pose")}>进入姿态模式</button></div> : null}
{isEditMode ? <div className="property-actions" data-testid="armature-edit-operations">
<button type="button" onClick={() => onCommand({ type: "setBoneSymmetry", objectId: activeNode.id, enabled: true })}>Enable X Mirror</button>
<button type="button" onClick={() => onCommand({ type: "setBoneSymmetry", objectId: activeNode.id, enabled: false })}>Disable X Mirror</button>
{activeArmatureBone ? <>
@@ -4440,8 +4447,8 @@ function Properties({ selectedEdgeIndices, nonMeshGeometryBuffers, client, snaps
<button type="button" onClick={() => onCommand({ type: "setPoseConstraint", objectId: activeNode.id, boneName: activeArmatureBone.name, constraintName: "Web Copy Rotation", constraintType: "COPY_ROTATION", targetObjectId: constraintTarget || null, influence: 1, enabled: true })}>Add Pose Constraint</button>
<button type="button" onClick={() => onCommand({ type: "setPoseConstraint", objectId: activeNode.id, boneName: activeArmatureBone.name, constraintName: "Web Copy Rotation", constraintType: null })}>Remove Pose Constraint</button>
</> : null}
</div>
<form className="property-grid" onSubmit={(event) => {
</div> : null}
{isEditMode ? <form className="property-grid" onSubmit={(event) => {
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
<label>Roll <input name="newRoll" type="number" step="0.01" defaultValue={0} /></label>
<label>Connected <input name="newConnected" type="checkbox" /></label>
<div className="property-actions"><button type="submit">Add Bone</button></div>
</form>
</form> : null}
{armature.bones.map((bone) => {
const currentParent = armature.bones.find((candidate) => candidate.id === bone.parentId)?.name ?? "";
return <div className="property-subsection" key={bone.id} data-resource-id={bone.id}>
<h4>{bone.name}</h4>
<form className="property-grid" onSubmit={(event) => {
{isEditMode ? <form className="property-grid" onSubmit={(event) => {
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
<label>Roll <input name="roll" type="number" step="any" defaultValue={bone.roll ?? 0} /></label>
<label>Connected <input name="connected" type="checkbox" defaultChecked={bone.connected ?? false} /></label>
<div className="property-actions"><button type="submit">Apply Rest Pose</button><button type="button" onClick={() => onCommand({ type: "armatureEditOperations", objectId: activeNode.id, operations: [{ operation: "DELETE", boneName: bone.name }] })}>Remove Bone</button></div>
</form>
{(() => {
</form> : 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) => <label key={`scale-${axis}`}>Scale {axis} <input name={`scale${axis}`} type="number" step="any" defaultValue={Number((poseScale[index] ?? 1).toFixed(4))} /></label>)}
<div className="property-actions"><button type="submit">Apply Pose</button></div>
</form>;
})()}
})() : null}
</div>;
})}
</div>;
@@ -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 <Outliner key={`${projectIdRef.current}:${userActionSequenceRef.current}`} snapshot={snapshot} onToggleExpand={toggleOutlinerExpand} onTreeSelect={selectOutlinerRow} onRemap={(command, feedback) => 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 <Properties key={mainReplacementEpoch} onSoftBodyCacheOperation={localOnly ? queueSoftBodyCache : undefined} onFluidCacheOperation={localOnly ? (objectId, operation) => 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 <Properties key={mainReplacementEpoch} onSoftBodyCacheOperation={localOnly ? queueSoftBodyCache : undefined} onFluidCacheOperation={localOnly ? (objectId, operation) => 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:
</Area><Area className="console-area" editor="Python Console">{pythonSession?<WasmPythonConsole session={pythonSession} enabled={Boolean(snapshot)&&!headerPending}/>:<NativeSessionPanel key={projectIdRef.current} client={webClientRef.current} context={nativeContext()} onApplied={applyNativeScene}/>}</Area><Area className="info-area" editor="Info"><WorkspaceEditorSurface editor="Info" snapshot={snapshot} engineStatus={engineStatus} onOpen={() => fileInputRef.current?.click()} onSearch={() => dispatchUI({ type: "toggleOperatorSearch", open: true })} /></Area><Area className="secondary-outliner-area" editor="Outliner"><Outliner key={`${projectIdRef.current}:${userActionSequenceRef.current}`} snapshot={snapshot} onToggleExpand={toggleOutlinerExpand} onTreeSelect={selectOutlinerRow} onRemap={(command, feedback) => 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 })} /></Area></ScriptingContainer> : null}
<Area className="viewport-area" editor="3D Viewport"><ViewportPlaceholder snapshot={preview?.snapshot ?? snapshot} geometryBuffers={preview?.geometryBuffers ?? geometryBuffers} nonMeshGeometryBuffers={preview?.nonMeshGeometryBuffers ?? nonMeshGeometryBuffers} textureAssets={gpuTextureAssets} volumeProject={volumeProject} lodLevels={preview ? null : lodLevels} selectedObjectIds={selectedObjectIds} editMode={uiState.context.mode === "Edit"} meshSelection={meshSelection} greasePencilSelectionRevision={greasePencilSelection?.revision ?? 0} cameraPose={objectCameraId ? objectCameraPose(snapshot, objectCameraId) : undefined} cameraLocked={Boolean(cameraLocks["viewport-area"])} showViewName={webPreferences.interface.showViewName} viewportPreferences={{ gizmoSize: webPreferences.viewport.gizmoSize, gizmoSizeNavigate: webPreferences.viewport.gizmoSizeNavigate, miniAxis: webPreferences.viewport.miniAxis, defaultShading: webPreferences.viewport.defaultShading, orbitSensitivity: webPreferences.navigation.orbitSensitivity, zoomSensitivity: webPreferences.navigation.zoomSensitivity, invertZoom: webPreferences.navigation.invertZoom }} onCameraWrite={handleCameraWrite} onCameraLockChange={(locked)=>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 })} /></Area>
<Area className="outliner-area" editor="Outliner"><Outliner key={`${projectIdRef.current}:${userActionSequenceRef.current}`} snapshot={snapshot} onToggleExpand={toggleOutlinerExpand} onTreeSelect={selectOutlinerRow} onRemap={(command, feedback) => 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 })} /></Area>
<Area className="properties-area" editor="Properties"><Properties key={mainReplacementEpoch} onSoftBodyCacheOperation={localOnly ? queueSoftBodyCache : undefined} onFluidCacheOperation={localOnly ? (objectId, operation) => 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) => {
<Area className="properties-area" editor="Properties"><Properties key={mainReplacementEpoch} onSoftBodyCacheOperation={localOnly ? queueSoftBodyCache : undefined} onFluidCacheOperation={localOnly ? (objectId, operation) => 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;

View File

@@ -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"]) {

View File

@@ -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));