diff --git a/blender-5.2.0/source/blender/web_engine/web_engine_main_state.cpp b/blender-5.2.0/source/blender/web_engine/web_engine_main_state.cpp index 600b8a417..657a6a322 100644 --- a/blender-5.2.0/source/blender/web_engine/web_engine_main_state.cpp +++ b/blender-5.2.0/source/blender/web_engine/web_engine_main_state.cpp @@ -10838,6 +10838,7 @@ bool web_engine_blend_main_merge_editor_snapshot(WebBlendMainState *state, web_outliner_rows(space, [&](auto &te, const std::string &key, int depth) { TreeStoreElem *store = TREESTORE(&te); json object_id = nullptr; + json collection_id = nullptr; if (store->type == TSE_SOME_ID && te.idcode == ID_OB && store->id) { object_id = "object:" + id_name(*store->id); } @@ -10888,6 +10889,9 @@ bool web_engine_blend_main_merge_editor_snapshot(WebBlendMainState *state, } kind = "collection"; restriction_editable = !collection || bool(ID_IS_EDITABLE(&collection->id)); + if (collection != nullptr && collection->id.lib == nullptr) { + collection_id = source_data_id("collection:", collection->id); + } } } rows.push_back({{"id", key}, {"label", te.name ? te.name : ""}, {"depth", depth}, @@ -10897,6 +10901,7 @@ bool web_engine_blend_main_merge_editor_snapshot(WebBlendMainState *state, {"hasChildren", !te.subtree.is_empty() || bool(te.flag & blender::ed::outliner::TE_PRETEND_HAS_CHILDREN)}, {"objectId", object_id}, + {"collectionId", collection_id}, {"kind", kind}, {"restrict", std::move(restrict)}, {"restrictionEditable", restriction_editable}, diff --git a/tools/web/check-outliner-headed.mjs b/tools/web/check-outliner-headed.mjs index e72c24312..09421bbf3 100644 --- a/tools/web/check-outliner-headed.mjs +++ b/tools/web/check-outliner-headed.mjs @@ -19,7 +19,7 @@ import path from "node:path"; import { fileURLToPath } from "node:url"; const REPO_ROOT = path.resolve(path.dirname(fileURLToPath(import.meta.url)), "../.."); -const EXPECTED_CASES = ["outliner-tree-baseline-web", "outliner-tools-baseline-web", "outliner-mirror-baseline-web", "outliner-metrics-web", "outliner-display-mode-web", "outliner-filter-web", "outliner-restrict-web", "outliner-select-keys-web", "outliner-delete-web", "outliner-box-select-web", "outliner-id-operation-web", "outliner-id-clipboard-web"]; +const EXPECTED_CASES = ["outliner-tree-baseline-web", "outliner-tools-baseline-web", "outliner-mirror-baseline-web", "outliner-metrics-web", "outliner-display-mode-web", "outliner-filter-web", "outliner-restrict-web", "outliner-select-keys-web", "outliner-delete-web", "outliner-box-select-web", "outliner-id-operation-web", "outliner-id-clipboard-web", "outliner-collection-delete-web"]; /* Desktop Layout geometry the metrics case must reproduce (batch 2: UI sizes). */ const GEOMETRY_GOLDEN = path.join(REPO_ROOT, "tests/golden/OUTLINER-DESKTOP-METRICS/outliner-metrics.json"); const errors = []; diff --git a/tools/web/run-outliner-headed.mjs b/tools/web/run-outliner-headed.mjs index 90815cae4..07cfcf97d 100644 --- a/tools/web/run-outliner-headed.mjs +++ b/tools/web/run-outliner-headed.mjs @@ -43,6 +43,7 @@ const KNOWN_CASES = [ { id: "outliner-box-select-web", title: /\[outliner-box-select-web\]/ }, { id: "outliner-id-operation-web", title: /\[outliner-id-operation-web\]/ }, { id: "outliner-id-clipboard-web", title: /\[outliner-id-clipboard-web\]/ }, + { id: "outliner-collection-delete-web", title: /\[outliner-collection-delete-web\]/ }, ]; function usage() { diff --git a/web/app/public/vendor/blender/web_engine.wasm b/web/app/public/vendor/blender/web_engine.wasm index a12ae7f5c..f1a7b5097 100644 Binary files a/web/app/public/vendor/blender/web_engine.wasm and b/web/app/public/vendor/blender/web_engine.wasm differ diff --git a/web/app/public/wasm-module-manifest.json b/web/app/public/wasm-module-manifest.json index a1e55fa51..b89a0d93e 100644 --- a/web/app/public/wasm-module-manifest.json +++ b/web/app/public/wasm-module-manifest.json @@ -10,7 +10,7 @@ "single": { "fileName": "web_engine.wasm", "url": "/vendor/blender/web_engine.wasm", - "sha256": "182743ee1f9bf37a9427a894f56b88c899d4dd1159aaf0182c119b677d857609" + "sha256": "506883d3cfe9a1f92b901a0ac1f82f5dcac367538d9f272a41685d9ebee81340" }, "pthread": { "fileName": "web_engine.wasm", @@ -27,7 +27,7 @@ "single": { "fileName": "web_engine.wasm", "url": "/vendor/blender/web_engine.wasm", - "sha256": "182743ee1f9bf37a9427a894f56b88c899d4dd1159aaf0182c119b677d857609" + "sha256": "506883d3cfe9a1f92b901a0ac1f82f5dcac367538d9f272a41685d9ebee81340" }, "pthread": { "fileName": "web_engine.wasm", @@ -44,7 +44,7 @@ "single": { "fileName": "web_engine.wasm", "url": "/vendor/blender/web_engine.wasm", - "sha256": "182743ee1f9bf37a9427a894f56b88c899d4dd1159aaf0182c119b677d857609" + "sha256": "506883d3cfe9a1f92b901a0ac1f82f5dcac367538d9f272a41685d9ebee81340" }, "pthread": { "fileName": "web_engine.wasm", @@ -61,7 +61,7 @@ "single": { "fileName": "web_engine.wasm", "url": "/vendor/blender/web_engine.wasm", - "sha256": "182743ee1f9bf37a9427a894f56b88c899d4dd1159aaf0182c119b677d857609" + "sha256": "506883d3cfe9a1f92b901a0ac1f82f5dcac367538d9f272a41685d9ebee81340" }, "pthread": { "fileName": "web_engine.wasm", diff --git a/web/app/src/app/App.tsx b/web/app/src/app/App.tsx index 907997171..8e9e80f9c 100644 --- a/web/app/src/app/App.tsx +++ b/web/app/src/app/App.tsx @@ -2521,13 +2521,14 @@ const OUTLINER_RESTRICT_POPOVER_LABELS: Record void; onToggleVisibility: (id: string, visible: boolean) => void; onRefresh?: () => void; onSelectAll?: (operation: 'SELECT' | 'DESELECT' | 'INVERT' | 'TOGGLE') => void; onDeleteObject?: (objectId: string) => void; + onDeleteCollection?: (collectionId: string, hierarchy: boolean) => void; areaId?: string; onToggleExpand?: (rowId: string, toggleAll: boolean, areaId: string) => void; onTreeSelect?: (rowId: string, extend: boolean, range: boolean, areaId: string, activateData: boolean, activateProperties?: boolean, recursive?: boolean) => void; @@ -2748,7 +2749,7 @@ function Outliner({ snapshot, areaId, onSelect, onToggleVisibility, onRefresh, o window.addEventListener('dragstart', onDragStart, true); }; const renameTarget = (row: NonNullable['rows'][number]) => { - const object = nodeById.get(row.objectId ?? ''); const collection = collectionRows.find(item => item.id === row.remapId); + const object = nodeById.get(row.objectId ?? ''); const collection = collectionRows.find(item => item.id === (row.collectionId ?? row.remapId)); const data = tree?.remapIds?.some(id => id.id === row.remapId && id.editable && !id.library) ? [...(snapshot?.meshes ?? []), ...(snapshot?.materials ?? []), ...(snapshot?.images ?? []), ...(snapshot?.nonMeshData ?? [])].find(item => !('sourceLibrary' in item && item.sourceLibrary) && !('libraryLinked' in item && item.libraryLinked) && !('libraryPath' in item && item.libraryPath) && Object.entries({mesh: 'ME', material: 'MA', image: 'IM', curve: 'CU', metaball: 'MB'}).some(([prefix, code]) => item.id.startsWith(prefix + ':') && row.remapId === JSON.stringify([code + item.name, '']))) : undefined; return object ? (!object.sourceLibrary ? object : undefined) : collection && !collection.sourceLibrary && !collection.isMaster ? collection : data; }; @@ -2761,6 +2762,8 @@ function Outliner({ snapshot, areaId, onSelect, onToggleVisibility, onRefresh, o finally { remapPending.current = false; setTreeRenameBusy(false); } }; const menuTarget = tree?.rows.find(row => menuRow ? row.id === menuRow : row.active); + const menuCollection = menuTarget ? collectionRows.find(item => item.id === (menuTarget.collectionId ?? menuTarget.remapId)) : undefined; + const canDeleteCollection = Boolean(menuCollection && !menuCollection.isMaster && !menuCollection.sourceLibrary && workspace?.writable && onDeleteCollection); const sourceIDs = remap ? tree?.remapIds?.filter(id => id.id === remap.oldId) ?? [] : []; const sourceID = sourceIDs.length === 1 ? sourceIDs[0] : undefined; const choices = sourceID ? tree?.remapIds?.filter(id => id.idType === sourceID.idType && id.id !== sourceID.id) ?? [] : []; @@ -2799,7 +2802,7 @@ function Outliner({ snapshot, areaId, onSelect, onToggleVisibility, onRefresh, o {/* Desktop SpaceOutliner display_mode selector (View Layer, Blender File, …). */} {onSetDisplayMode && tree?.displayModes?.length ? : null} { setMenuRow(null); setDataMenu(!dataMenu); }} - onClose={() => setDataMenu(false)} items={[{label: '复制', disabled: treeRenameBusy || remapBusy || !onIdOperation || !nativeArea || !menuTarget || !workspace?.writable, reason: '把所选数据块复制到内部剪贴板(桌面 OUTLINER_OT_id_copy)', action: () => { if (menuTarget && nativeArea) onIdOperation?.(menuTarget.id, 'COPY', nativeArea.id); }}, {label: '粘贴', disabled: treeRenameBusy || remapBusy || !onIdOperation || !nativeArea || !menuTarget || !workspace?.writable, reason: '从内部剪贴板粘贴数据块(桌面 OUTLINER_OT_id_paste)', action: () => { if (menuTarget && nativeArea) onIdOperation?.(menuTarget.id, 'PASTE', nativeArea.id); }}, {label: '重命名 (F2)', disabled: treeRenameBusy || remapBusy || !onRemap || !workspace?.writable || !menuTarget || !renameTarget(menuTarget), reason: '重命名受支持的本地数据块', action: () => { if (menuTarget) beginTreeRename(menuTarget); }}, {label: '删除 (X)', disabled: treeRenameBusy || remapBusy || !onDeleteObject || !menuTarget?.objectId, reason: '删除所选对象(桌面 OUTLINER_OT_delete)', action: () => { if (menuTarget?.objectId) onDeleteObject?.(menuTarget.objectId); }}, {label: '取消链接', disabled: treeRenameBusy || remapBusy || !onIdOperation || !nativeArea || !menuTarget || !(menuTarget.objectId || menuTarget.remapId), reason: '把所选数据块从其父级取消链接(桌面 OUTLINER_OT_id_operation UNLINK)', action: () => { if (menuTarget) if (nativeArea) onIdOperation?.(menuTarget.id, 'UNLINK', nativeArea.id); }}, {label: '设为单用户 (Make Single User)', disabled: treeRenameBusy || remapBusy || !onIdOperation || !nativeArea || !menuTarget || !(menuTarget.objectId || menuTarget.remapId), reason: '把多用户的 ID 数据块设为单用户(桌面 OUTLINER_OT_id_operation SINGLE)', action: () => { if (menuTarget) if (nativeArea) onIdOperation?.(menuTarget.id, 'SINGLE', nativeArea.id); }}, {label: 'Remap Users', + onClose={() => setDataMenu(false)} items={[{label: '复制', disabled: treeRenameBusy || remapBusy || !onIdOperation || !nativeArea || !menuTarget || !workspace?.writable, reason: '把所选数据块复制到内部剪贴板(桌面 OUTLINER_OT_id_copy)', action: () => { if (menuTarget && nativeArea) onIdOperation?.(menuTarget.id, 'COPY', nativeArea.id); }}, {label: '粘贴', disabled: treeRenameBusy || remapBusy || !onIdOperation || !nativeArea || !menuTarget || !workspace?.writable, reason: '从内部剪贴板粘贴数据块(桌面 OUTLINER_OT_id_paste)', action: () => { if (menuTarget && nativeArea) onIdOperation?.(menuTarget.id, 'PASTE', nativeArea.id); }}, {label: '重命名 (F2)', disabled: treeRenameBusy || remapBusy || !onRemap || !workspace?.writable || !menuTarget || !renameTarget(menuTarget), reason: '重命名受支持的本地数据块', action: () => { if (menuTarget) beginTreeRename(menuTarget); }}, {label: '删除 (X)', disabled: treeRenameBusy || remapBusy || !onDeleteObject || !menuTarget?.objectId, reason: '删除所选对象(桌面 OUTLINER_OT_delete)', action: () => { if (menuTarget?.objectId) onDeleteObject?.(menuTarget.objectId); }}, {label: '删除集合', disabled: treeRenameBusy || remapBusy || !canDeleteCollection, reason: '删除所选集合,内容保留并移到主集合(桌面 outliner.delete)', action: () => { if (menuCollection) onDeleteCollection?.(menuCollection.id, false); }}, {label: '删除层级', disabled: treeRenameBusy || remapBusy || !canDeleteCollection, reason: '删除所选集合及其全部内容(桌面 outliner.delete hierarchy)', action: () => { if (menuCollection) onDeleteCollection?.(menuCollection.id, true); }},{label: '取消链接', disabled: treeRenameBusy || remapBusy || !onIdOperation || !nativeArea || !menuTarget || !(menuTarget.objectId || menuTarget.remapId), reason: '把所选数据块从其父级取消链接(桌面 OUTLINER_OT_id_operation UNLINK)', action: () => { if (menuTarget) if (nativeArea) onIdOperation?.(menuTarget.id, 'UNLINK', nativeArea.id); }}, {label: '设为单用户 (Make Single User)', disabled: treeRenameBusy || remapBusy || !onIdOperation || !nativeArea || !menuTarget || !(menuTarget.objectId || menuTarget.remapId), reason: '把多用户的 ID 数据块设为单用户(桌面 OUTLINER_OT_id_operation SINGLE)', action: () => { if (menuTarget) if (nativeArea) onIdOperation?.(menuTarget.id, 'SINGLE', nativeArea.id); }}, {label: 'Remap Users', disabled: remapBusy || treeRenameBusy || !onRemap || !workspace?.writable || !menuTarget?.remapId || tree?.remapIds?.filter(id => id.id === menuTarget.remapId).length !== 1, reason: 'Remap all local usages of this data-block to another one of the same type', action: openRemap}]} /> @@ -10403,7 +10406,7 @@ else: onSelect={(id,additive,range)=>selectObject(id,additive,range,area.id)} onRefresh={()=>refreshOutliner(area.id)} onSelectAll={operation=>selectAllOutliner(operation,area.id)} onToggleVisibility={(id,visible)=>void applyEditCommand({type:'setObjectVisibility',objectId:id,visible})} - onDeleteObject={(id)=>void applyEditCommand({type:'deleteObject',objectId:id})} + onDeleteObject={(id)=>void applyEditCommand({type:'deleteObject',objectId:id})} onDeleteCollection={(collectionId, hierarchy) => void applyEditCommand({ type: "deleteCollection", collectionId, hierarchy })} onSelectBox={(firstRowId,lastRowId,mode,id)=>setOutlinerSelectBox(firstRowId,lastRowId,mode,id)} onIdOperation={(firstRowId,operation,id)=>setOutlinerIdOperation(firstRowId,operation,id)}/>; if(area.editor==='VIEW_3D')return { const client=webClientRef.current;if(!client||!nativeWorkspace)return false; @@ -10581,7 +10584,7 @@ else: case "3D Viewport": return 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 })} />; 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 })} onDeleteObject={(id) => void applyEditCommand({ type: "deleteObject", objectId: id })} onSelectBox={(firstRowId,lastRowId,mode,id)=>setOutlinerSelectBox(firstRowId,lastRowId,mode,id)} onIdOperation={(firstRowId,operation,id)=>setOutlinerIdOperation(firstRowId,operation,id)} />; + 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 })} onDeleteObject={(id) => void applyEditCommand({ type: "deleteObject", objectId: id })} onDeleteCollection={(collectionId, hierarchy) => void applyEditCommand({ type: "deleteCollection", collectionId, hierarchy })} onSelectBox={(firstRowId,lastRowId,mode,id)=>setOutlinerSelectBox(firstRowId,lastRowId,mode,id)} onIdOperation={(firstRowId,operation,id)=>setOutlinerIdOperation(firstRowId,operation,id)} />; 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} 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; @@ -10748,9 +10751,9 @@ else: {localOnly ? fileInputRef.current?.click()} onSearch={() => dispatchUI({ type: "toggleOperatorSearch", open: true })} /> : workspace === "Geometry Nodes" ? : null} {scriptingMounted.current ? !projectActionMutexRef.current.owner} onDraftChanged={dirty=>{if(dirty)textDraftAreas.current.add('web-tools-text');else textDraftAreas.current.delete('web-tools-text');textDraftDirty.current=textDraftAreas.current.size>0;}} onNativeRun={localOnly?undefined:(name,source)=>void runNativeWorkflow({kind:'PYTHON',context:nativeContext(),python:{source,textName:name,console:false}})} onPythonRun={pythonSession?(name,source)=>pythonSession.run(source,name,false):undefined} pythonBusy={pythonState?.status==='running'||pythonState?.status==='stopping'}/> - {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 })} onDeleteObject={(id) => void applyEditCommand({ type: "deleteObject", objectId: id })} onSelectBox={(firstRowId,lastRowId,mode,id)=>setOutlinerSelectBox(firstRowId,lastRowId,mode,id)} onIdOperation={(firstRowId,operation,id)=>setOutlinerIdOperation(firstRowId,operation,id)} /> : null} + {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 })} onDeleteObject={(id) => void applyEditCommand({ type: "deleteObject", objectId: id })} onDeleteCollection={(collectionId, hierarchy) => void applyEditCommand({ type: "deleteCollection", collectionId, hierarchy })} onSelectBox={(firstRowId,lastRowId,mode,id)=>setOutlinerSelectBox(firstRowId,lastRowId,mode,id)} onIdOperation={(firstRowId,operation,id)=>setOutlinerIdOperation(firstRowId,operation,id)} /> : 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 })} onDeleteObject={(id) => void applyEditCommand({ type: "deleteObject", objectId: id })} onSelectBox={(firstRowId,lastRowId,mode,id)=>setOutlinerSelectBox(firstRowId,lastRowId,mode,id)} onIdOperation={(firstRowId,operation,id)=>setOutlinerIdOperation(firstRowId,operation,id)} /> + 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 })} onDeleteObject={(id) => void applyEditCommand({ type: "deleteObject", objectId: id })} onDeleteCollection={(collectionId, hierarchy) => void applyEditCommand({ type: "deleteCollection", collectionId, hierarchy })} onSelectBox={(firstRowId,lastRowId,mode,id)=>setOutlinerSelectBox(firstRowId,lastRowId,mode,id)} onIdOperation={(firstRowId,operation,id)=>setOutlinerIdOperation(firstRowId,operation,id)} /> 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; }); diff --git a/web/app/src/vendor/blender/web_engine.wasm b/web/app/src/vendor/blender/web_engine.wasm index a12ae7f5c..f1a7b5097 100644 Binary files a/web/app/src/vendor/blender/web_engine.wasm and b/web/app/src/vendor/blender/web_engine.wasm differ diff --git a/web/protocol/editor-workflow.ts b/web/protocol/editor-workflow.ts index 24de4b35f..8b52dfef8 100644 --- a/web/protocol/editor-workflow.ts +++ b/web/protocol/editor-workflow.ts @@ -355,7 +355,7 @@ export interface NativeAreaLayout { headerMenusVisible?: boolean; } export interface NativeOutlinerRestrict { enable?: boolean; select?: boolean; hide?: boolean; viewport?: boolean; render?: boolean; holdout?: boolean; indirectOnly?: boolean } -export interface NativeOutlinerRow { id: string; label: string; depth: number; selected: boolean; active: boolean; expanded: boolean; hasChildren: boolean; objectId: string | null; kind?: string; restrict?: NativeOutlinerRestrict; restrictionEditable?: boolean; remapId?: string | null } +export interface NativeOutlinerRow { id: string; label: string; depth: number; selected: boolean; active: boolean; expanded: boolean; hasChildren: boolean; objectId: string | null; kind?: string; restrict?: NativeOutlinerRestrict; restrictionEditable?: boolean; remapId?: string | null; collectionId?: string | null } export interface NativeOutlinerRemapID { id: string; name: string; idType: number; library: string; editable: boolean } export interface NativeOutlinerFilter { searchString: string; caseSensitive: boolean; complete: boolean; sortAlpha: boolean; invert: boolean; state: 'ALL' | 'VISIBLE' | 'SELECTED' | 'ACTIVE' | 'SELECTABLE'; showObjects: boolean; showObjectContents: boolean; showChildren: boolean; showCollections: boolean; showViewLayers: boolean } export interface NativeOutlinerTree { rows: NativeOutlinerRow[]; truncated: boolean; syncSelection: boolean; displayMode?: string; displayModes?: Array<{ id: string; label: string }>; filter?: NativeOutlinerFilter; restrictColumns?: NativeOutlinerRestrict; remapIds?: NativeOutlinerRemapID[] } @@ -779,7 +779,8 @@ export function parseEditorWorkflow(value: unknown): EditorWorkflowIR { active: row.active as boolean, expanded: row.expanded as boolean, hasChildren: row.hasChildren as boolean, objectId: row.objectId === null ? null : text(row.objectId, 'outliner.row.objectId'), kind, restrict, restrictionEditable: row.restrictionEditable as boolean | undefined, - remapId: row.remapId == null ? null : text(row.remapId, 'outliner.row.remapId', 65536) }; + remapId: row.remapId == null ? null : text(row.remapId, 'outliner.row.remapId', 65536), + collectionId: row.collectionId == null ? null : text(row.collectionId, 'outliner.row.collectionId', 65536) }; }); let remapIds: NativeOutlinerRemapID[] | undefined; if (tree.remapIds !== undefined) { diff --git a/web/tests/e2e/outliner-headed-production.spec.ts b/web/tests/e2e/outliner-headed-production.spec.ts index e39a8420a..ebd838526 100644 --- a/web/tests/e2e/outliner-headed-production.spec.ts +++ b/web/tests/e2e/outliner-headed-production.spec.ts @@ -401,6 +401,24 @@ test.describe("Outliner headed baseline", () => { await expect(page.locator(`.outliner-tree [role="treeitem"][aria-label="${label}"]`)).toHaveCount(0); }); + test("[outliner-collection-delete-web] Delete Hierarchy removes the collection and its contents", async ({ page }) => { + test.setTimeout(150_000); + await openWorkbench(page); + const objectRows = page.locator('.outliner-tree .tree-row[data-node-id]:not([data-node-id=""])'); + const collectionRow = page.locator('.outliner-tree [role="treeitem"][aria-label="Collection"]'); + await expect(collectionRow).toHaveCount(1, { timeout: 20_000 }); + const before = await objectRows.count(); + expect(before).toBeGreaterThan(0); + /* The fixture nests BasicArea/BasicCamera/BasicCube inside "Collection"; the + * desktop collection menu's Delete Hierarchy removes the collection with + * everything under it. */ + await collectionRow.locator(".tree-node-name").first().click({ button: "right" }); + await expect(page.getByRole("menuitem", { name: "删除层级", exact: true })).toBeEnabled({ timeout: 15_000 }); + await page.getByRole("menuitem", { name: "删除层级", exact: true }).click(); + await expect.poll(() => objectRows.count(), { timeout: 20_000 }).toBe(0); + await expect(collectionRow).toHaveCount(0); + }); + test("[outliner-id-clipboard-web] Copy and Paste run OUTLINER_OT_id_copy and id_paste", async ({ page }) => { test.setTimeout(150_000); await openWorkbench(page);