fix(web): sync viewport element picks into the engine BMesh selection
element clicks, box selects and select-all only updated React state, so native operators and readbacks kept the previous edit-mode selection. the pick handlers now write the resulting element set into the active BMesh through the existing embedded-Python route that already carries select_mode and the selection readback, and keep a ref mirror so a click toggles against the latest set. verified headed in ?ui=web: entering edit mode then clicking a vertex changes the native BMesh selection from 8 vertices / 12 edges / 6 faces to 2 / 3 / 1. the INDIVIDUAL_ORIGINS island path already exists in the transform modal and commit; its gizmo display and edit-mode native coverage remain open and are tracked in the inventory. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
This commit is contained in:
@@ -15,7 +15,7 @@
|
||||
| 1 | ~~大工程打开后视口输入未就绪~~(已修复) | `glowing-petting-map.md`(`WBV2-COLLADA-001` 残余 1) | 根因:open 期间/之前的同步命令超时使客户端判定 Main 不确定,帧被拒绝且画布终止;测试的 `exposeWebTools()` 切到 Web 视图进一步造成“需额外输入”的假象。已修:只读命令超时不判定不确定、Main 恢复等待重试、owner 变更帧计入就绪、按 revision 发布场景与几何(响应从 1888 个 transfer 降到小负载)。有头回归用例在原生视图内无输入恢复就绪并通过(约 2.4 分钟) | 已关闭;保留用例防止回归,验收仍 `NOT_CLAIMED` |
|
||||
| 2 | 渲染课程成片缺失:`rendering-lesson-720p.mp4` 已撤回,未重录 | `binary-dreaming-ladybug.md`;`RENDER_PATHS_20261116` 残余 4 | 旧片 1477.8 s 与 `timeline.json` 13 章只覆盖到 1125 s 不符而撤回;`check-render-tutorial.mjs` 现输出 `AWAITING_RERECORD` | 按现有章节重录并重新混音,跑 `check-render-tutorial.mjs` 到非 `AWAITING_RERECORD`;保持 `NOT_CLAIMED` |
|
||||
| 3 | 满尺寸场景 undo/redo 超出单例窗口:YT2 `setObjectOrigin` 后 undo/redo 在 185 s 内未完成 | `glowing-petting-map.md`(残余 4) | 两次尝试均被上限终止;小场景同一路径 PASS(`attempt-OFrAEc`) | 评估 13 MB Main + 236 网格的历史重建耗时;先量化再决定预算或增量恢复;单独开批次 |
|
||||
| 4 | 编辑模式 `INDIVIDUAL_ORIGINS` 回退为中位点枢轴;视口元素点选只更新 React 选择、不同步引擎 BMesh 选择 | `mossy-giggling-moonbeam.md`;`VIEWPORT-NAV_20261125` 残余 | `docs/status/VIEWPORT-NAV-20261125.md` 明列;批次二/三已接入,残余保留 | 分别开小批次:枢轴语义按桌面源码补;元素选择同步 BMesh 需原生选择接口证伪后再定范围 |
|
||||
| 4 | 视口语义残余:`INDIVIDUAL_ORIGINS` 中位点回退;元素点选不同步 BMesh | `mossy-giggling-moonbeam.md`;`VIEWPORT-NAV_20261125` 残余 | **元素点选已修**:点选/框选/全选现在经 `executeEmbeddedPython` 写入编辑模式 BMesh(与 `select_mode`、读回同一路径)。有头验证:进入编辑模式后点击顶点,原生选择 8 顶点→2 顶点。`INDIVIDUAL_ORIGINS` 的多岛变换路径已在 `useViewportTransformModal`/提交路径实现(islands>1 时逐岛矩阵);gizmo 手柄仍显示中位点,且编辑模式原生用例仍未覆盖,保留待验证 | 下一步:按需把选择写入改为专用原生命令以降低每次点击开销;补编辑模式 INDIVIDUAL_ORIGINS 的 gizmo 显示/有头用例;P1 |
|
||||
| 5 | `REVISION_CONFLICT` 的 Worker 采纳未做 | `serialized-cooking-map.md`(Workstream 2) | 计划明示“本批不改 `web-engine.worker.ts`”,采纳需先改 AOV/lightgroup 构造器并协调 `editShaderNode` 契约与既有 e2e | 单独立项;先补构造器契约,再切换 Worker 断言,最后跑既有 e2e |
|
||||
| 6 | 手册 E2E 与截图内容人工审阅未做 | `serialized-waddling-sutherland.md`;`RENDER_PATHS_20261116` 残余 5 | `generate-manual.mjs` PASS、31 章无缺图;`web/app/public/manuals` 已生成 HTML + 4 个 PDF | 跑手册 E2E/链接检查,人工过一遍截图;不达项回写文档 |
|
||||
| 7 | 完成度评估器与 IO 门禁基线不一致:`evaluate-wbv2-completion.mjs` 被 `coverage-baseline.mjs:47` 阻断;`check-io-format-ui-gate.mjs` 报 registry 未在能力矩阵声明 | `glowing-petting-map.md`(残余 2、5) | 均与用例执行无关,属仓库既有基线不一致;`git diff` 为空 | 修 `coverage-baseline` 的 historical references 结构;对齐 IO registry 与 `M12-05B` 能力矩阵;再重跑评估 |
|
||||
|
||||
@@ -6081,6 +6081,10 @@ export function App({localOnly=false,course,teach}:{localOnly?:boolean;course?:A
|
||||
const uvAutoEditAttemptRef = useRef('');
|
||||
const [selectedObjectIds, setSelectedObjectIds] = useState<Set<string>>(() => new Set());
|
||||
const [meshSelection, setMeshSelection] = useState<MeshEditSelection>({ meshId: null, mode: "FACE", indices: new Set() });
|
||||
/* Pointer handlers read this mirror (React state lags one render) and write the
|
||||
* resulting element set into the engine's edit-mode BMesh selection. */
|
||||
const meshSelectionSyncRef = useRef(meshSelection);
|
||||
meshSelectionSyncRef.current = meshSelection;
|
||||
const [objectCameraId, setObjectCameraId] = useState<string | null>(null);
|
||||
const [greasePencilSelection, setGreasePencilSelection] = useState<GreasePencilSelectionStateIR | null>(null);
|
||||
const [geometryBuffers, setGeometryBuffers] = useState<MeshGeometryBuffer[]>([]);
|
||||
@@ -6506,12 +6510,14 @@ export function App({localOnly=false,course,teach}:{localOnly?:boolean;course?:A
|
||||
setSelectedObjectIds((current) => additive ? new Set([...current, owner.id]) : new Set([owner.id]));
|
||||
setSnapshot((current) => current ? { ...current, activeObjectId: owner.id } : current);
|
||||
}
|
||||
setMeshSelection((current) => {
|
||||
const preserve = additive && current.meshId === meshId && current.mode === mode;
|
||||
const next = preserve ? new Set(current.indices) : new Set<number>();
|
||||
for (const index of indices) next.add(index);
|
||||
return { meshId, mode, indices: next, nonMeshSelections: undefined, greasePencilPoints: undefined };
|
||||
});
|
||||
const current = meshSelectionSyncRef.current;
|
||||
const preserve = additive && current.meshId === meshId && current.mode === mode;
|
||||
const next = preserve ? new Set(current.indices) : new Set<number>();
|
||||
for (const index of indices) next.add(index);
|
||||
const state = { meshId, mode, indices: next, nonMeshSelections: undefined, greasePencilPoints: undefined };
|
||||
meshSelectionSyncRef.current = state;
|
||||
setMeshSelection(state);
|
||||
syncNativeMeshElementSelection(meshId, mode, next);
|
||||
};
|
||||
const selectObjectsInBox = (ids: string[], additive: boolean): void => {
|
||||
setSelectedObjectIds((current) => {
|
||||
@@ -6614,12 +6620,16 @@ export function App({localOnly=false,course,teach}:{localOnly?:boolean;course?:A
|
||||
setSelectedObjectIds((current) => additive ? new Set([...current, owner.id]) : new Set([owner.id]));
|
||||
setSnapshot((current) => current ? { ...current, activeObjectId: owner.id } : current);
|
||||
}
|
||||
setMeshSelection((current) => {
|
||||
const preserve = additive && current.meshId === meshId && current.mode === mode;
|
||||
const next = preserve ? new Set(current.indices) : new Set<number>();
|
||||
if (next.has(index)) next.delete(index);
|
||||
else next.add(index);
|
||||
if (!nonMeshKind) return { meshId, mode, indices: next, nonMeshKind, nonMeshSelections: undefined, greasePencilPoints: undefined };
|
||||
const current = meshSelectionSyncRef.current;
|
||||
const preserve = additive && current.meshId === meshId && current.mode === mode;
|
||||
const next = preserve ? new Set(current.indices) : new Set<number>();
|
||||
if (next.has(index)) next.delete(index);
|
||||
else next.add(index);
|
||||
let state: MeshEditSelection;
|
||||
if (!nonMeshKind) {
|
||||
state = { meshId, mode, indices: next, nonMeshKind, nonMeshSelections: undefined, greasePencilPoints: undefined };
|
||||
}
|
||||
else {
|
||||
const selections = new Map<NonMeshElementKind, Set<number>>(preserve ? [...(current.nonMeshSelections ?? [])].map(([kind, values]) => [kind, new Set(values)]) : []);
|
||||
const kindIndices = selections.get(nonMeshKind) ?? new Set<number>();
|
||||
if (kindIndices.has(index)) kindIndices.delete(index);
|
||||
@@ -6628,8 +6638,11 @@ export function App({localOnly=false,course,teach}:{localOnly?:boolean;course?:A
|
||||
else selections.set(nonMeshKind, kindIndices);
|
||||
const combined = new Set<number>();
|
||||
for (const values of selections.values()) for (const value of values) combined.add(value);
|
||||
return { meshId, mode, indices: combined, nonMeshKind, nonMeshSelections: selections, greasePencilPoints: undefined };
|
||||
});
|
||||
state = { meshId, mode, indices: combined, nonMeshKind, nonMeshSelections: selections, greasePencilPoints: undefined };
|
||||
}
|
||||
meshSelectionSyncRef.current = state;
|
||||
setMeshSelection(state);
|
||||
if (!nonMeshKind) syncNativeMeshElementSelection(meshId, mode, next);
|
||||
};
|
||||
/* A successful .blend open arms this counter; the effect below fires
|
||||
* OUTLINER_REFRESH once the open lock is released, because the open reply can
|
||||
@@ -8378,7 +8391,11 @@ export function App({localOnly=false,course,teach}:{localOnly?:boolean;course?:A
|
||||
const mesh = snapshot?.meshes.find((candidate) => candidate.id === activeNode?.dataId);
|
||||
if (!mesh) return;
|
||||
const count = meshSelection.mode === "VERT" ? mesh.vertexCount : meshSelection.mode === "EDGE" ? mesh.edgeCount : mesh.faceCount;
|
||||
setMeshSelection({ meshId: mesh.id, mode: meshSelection.mode, indices: new Set(Array.from({ length: count }, (_, index) => index)), nonMeshSelections: undefined });
|
||||
const indices = new Set(Array.from({ length: count }, (_, index) => index));
|
||||
const state = { meshId: mesh.id, mode: meshSelection.mode, indices, nonMeshSelections: undefined };
|
||||
meshSelectionSyncRef.current = state;
|
||||
setMeshSelection(state);
|
||||
syncNativeMeshElementSelection(mesh.id, meshSelection.mode, indices);
|
||||
};
|
||||
const runMeshEdit = (operation: MeshEditOperation): void => {
|
||||
if (meshSelection.meshId && meshSelection.indices.size > 0) {
|
||||
@@ -10471,6 +10488,24 @@ export function App({localOnly=false,course,teach}:{localOnly?:boolean;course?:A
|
||||
/* Read the live edit-mesh selection after a native operator so repeated mesh
|
||||
* tools operate on what Main actually kept selected. Best effort: a failed
|
||||
* readback never masks the operator result or mutates Main. */
|
||||
/* Viewport element picks must reach the engine's edit-mode BMesh: native
|
||||
* operators and the next snapshot read the select flags, not React state. */
|
||||
const syncNativeMeshElementSelection = (meshId: string, mode: MeshElementMode, indices: Set<number>): void => {
|
||||
const client = webClientRef.current;
|
||||
if (!client || uiState.context.mode !== "Edit") return;
|
||||
const wanted = JSON.stringify([...indices].filter((index) => Number.isSafeInteger(index) && index >= 0));
|
||||
const source = `import bpy, bmesh, json
|
||||
obj = bpy.context.active_object
|
||||
if obj is not None and obj.type == 'MESH' and obj.mode == 'EDIT':
|
||||
bm = bmesh.from_edit_mesh(obj.data)
|
||||
wanted = set(json.loads(${JSON.stringify(wanted)}))
|
||||
elems = bm.verts if ${JSON.stringify(mode)} == 'VERT' else bm.edges if ${JSON.stringify(mode)} == 'EDGE' else bm.faces
|
||||
for e in elems:
|
||||
e.select = e.index in wanted
|
||||
bmesh.update_edit_mesh(obj.data)`;
|
||||
void client.executeEmbeddedPython(source, 'MeshElementSelection.py', false)
|
||||
.catch((error) => setEngineStatus(`元素选择同步失败:${(error as Error)?.message ?? String(error)}`));
|
||||
};
|
||||
const readNativeMeshSelection = async (): Promise<void> => {
|
||||
const client=webClientRef.current;
|
||||
const meshId=activeHeaderNode?.dataId;
|
||||
|
||||
Reference in New Issue
Block a user