feat(web): add object lightgroup membership
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

This commit is contained in:
mes123456
2026-08-30 07:21:38 +08:00
parent 49b42a0f99
commit cc8f805e76
46 changed files with 1900 additions and 35 deletions

Binary file not shown.

View File

@@ -954,6 +954,7 @@ function Properties({ snapshot, selectedFaceIndices, selectedVertexIndices, grea
{activeScene?.timelineSettings ? <div className="property-section" data-testid="scene-timeline-settings-workbench"><h3>Timeline Settings</h3><output>{activeScene.timelineSettings.fps} / {activeScene.timelineSettings.fpsBase.toFixed(3)} fps · Step {activeScene.timelineSettings.frameStep}</output><output>{activeScene.timelineSettings.usePreviewRange ? `Preview ${activeScene.timelineSettings.previewStart} - ${activeScene.timelineSettings.previewEnd}` : "Full frame range"}</output><div className="property-actions"><button type="button" onClick={() => onCommand(animationRenderCommands.setSceneTimelineSettings(activeScene.id, { fps: Math.min(1000, activeScene.timelineSettings!.fps + 1) }))}>增加帧率</button><button type="button" onClick={() => onCommand(animationRenderCommands.setSceneTimelineSettings(activeScene.id, { frameStep: Math.min(1000, activeScene.timelineSettings!.frameStep + 1) }))}>增加步进</button><button type="button" onClick={() => onCommand(animationRenderCommands.setSceneTimelineSettings(activeScene.id, { usePreviewRange: !activeScene.timelineSettings!.usePreviewRange }))}>{activeScene.timelineSettings.usePreviewRange ? "关闭预览范围" : "启用预览范围"}</button></div></div> : null}
{activeScene?.pipelineSettings ? <div className="property-section" data-testid="scene-pipeline-settings-workbench"><h3>Render Pipeline</h3><output>{activeScene.pipelineSettings.useCompositor ? "Compositor" : "Direct"} · {activeScene.pipelineSettings.useSequencer ? "Sequencer" : "No Sequencer"}</output><output>{activeScene.pipelineSettings.saveOutput ? "Save output" : "Preview only"} · {activeScene.pipelineSettings.noOverwrite ? "No overwrite" : "Overwrite allowed"}</output><div className="property-actions"><button type="button" onClick={() => onCommand(animationRenderCommands.setScenePipelineSettings(activeScene.id, { useCompositor: !activeScene.pipelineSettings!.useCompositor }))}>切换 Compositor</button><button type="button" onClick={() => onCommand(animationRenderCommands.setScenePipelineSettings(activeScene.id, { useSequencer: !activeScene.pipelineSettings!.useSequencer }))}>切换 Sequencer</button><button type="button" onClick={() => onCommand(animationRenderCommands.setScenePipelineSettings(activeScene.id, { saveOutput: !activeScene.pipelineSettings!.saveOutput }))}>切换输出保存</button></div></div> : null}
{activeScene ? <div className="property-section" data-testid="scene-bindings-workbench"><h3>Scene Bindings</h3><output>Camera {activeScene.cameraObjectId ?? "None"} · World {activeScene.worldId ?? "None"}</output><div className="property-actions"><button type="button" disabled={!snapshot?.nodes.some((node) => node.id === activeScene.cameraObjectId && node.type === "CAMERA")} onClick={() => onCommand(animationRenderCommands.setSceneBindings(activeScene.id, { cameraObjectId: activeScene.cameraObjectId }))}>确认相机绑定</button><button type="button" disabled={!activeWorld} onClick={() => onCommand(animationRenderCommands.setSceneBindings(activeScene.id, { worldId: activeWorld?.id ?? null }))}>绑定当前世界</button></div></div> : null}
{activeNode ? <div className="property-section" data-testid="object-lightgroup-workbench"><h3>Object Lightgroup</h3><output>{activeNode.lightgroup ?? "No lightgroup"}</output><div className="property-actions"><button type="button" onClick={() => onCommand(animationRenderCommands.setObjectLightgroup(activeNode.id, activeNode.lightgroup ? null : "Lightgroup_1"))}>{activeNode.lightgroup ? "清除分组" : "绑定分组"}</button></div></div> : null}
{activeScene?.viewLayers?.length ? <div className="property-section" data-testid="scene-view-layer-settings-workbench"><h3>View Layers</h3>{activeScene.viewLayers.map((layer) => <div key={layer.name}><output>{layer.name} · {layer.useRender ? "Render" : "Disabled"} · {layer.useFreestyle ? "Freestyle" : "No Freestyle"} · {layer.samples} samples</output><button type="button" onClick={() => onCommand(animationRenderCommands.setSceneViewLayerSettings(activeScene.id, layer.name, { useRender: !layer.useRender }))}>切换渲染</button><button type="button" onClick={() => onCommand(animationRenderCommands.setSceneViewLayerSettings(activeScene.id, layer.name, { samples: Math.min(1000000, layer.samples + 1) }))}>增加采样</button></div>)}</div> : null}
{activeScene?.viewLayers?.filter((layer) => layer.aovs?.length).map((layer) => <div className="property-section" data-testid="scene-view-layer-aov-workbench" key={`aovs-${layer.name}`}><h3>{layer.name} AOVs</h3>{layer.aovs?.map((aov) => <output key={aov.name}>{aov.name} · {aov.type === 1 ? "Color" : "Value"}</output>)}<button type="button" onClick={() => onCommand(animationRenderCommands.setSceneViewLayerAOVs(activeScene.id, layer.name, [...(layer.aovs ?? []).map((aov) => ({ name: aov.name, type: (aov.type === 1 ? 1 : 0) as 0 | 1 })), { name: `AOV_${(layer.aovs?.length ?? 0) + 1}`, type: 1 }]))}>Add Color AOV</button></div>) ?? null}
{activeScene?.viewLayers?.filter((layer) => layer.lightgroups?.length).map((layer) => <div className="property-section" data-testid="scene-view-layer-lightgroup-workbench" key={`lightgroups-${layer.name}`}><h3>{layer.name} Lightgroups</h3>{layer.lightgroups?.map((group) => <output key={group}>{group}</output>)}<button type="button" onClick={() => onCommand(animationRenderCommands.setSceneViewLayerLightgroups(activeScene.id, layer.name, [...(layer.lightgroups ?? []), `Lightgroup_${(layer.lightgroups?.length ?? 0) + 1}`]))}>Add Lightgroup</button></div>) ?? null}

Binary file not shown.

View File

@@ -828,6 +828,12 @@ function assertFutureCapability(payload: Extract<WebEngineRequest["command"], {
for (const name of payload.lightgroups) { if (typeof name !== "string" || name.length === 0 || new TextEncoder().encode(name).byteLength > 63 || names.has(name)) throw report("RENDER_PROPERTY_INVALID", "Scene lightgroup names must be unique and bounded"); names.add(name); }
return;
}
case "setObjectLightgroup": {
const object = currentSnapshot?.nodes.find((candidate) => candidate.id === payload.objectId);
if (!object || typeof payload.lightgroup !== "string" && payload.lightgroup !== null) throw report("RENDER_PROPERTY_INVALID", "Object lightgroup target is invalid");
if (payload.lightgroup !== null && (payload.lightgroup.length === 0 || new TextEncoder().encode(payload.lightgroup).byteLength > 63)) throw report("RENDER_PROPERTY_INVALID", "Object lightgroup name is not bounded");
return;
}
case "setGeometryNodeGraph": {
const snapshot = currentSnapshot;
const availableResourceIds = new Set([

View File

@@ -101,4 +101,7 @@ export const animationRenderCommands = Object.freeze({
setSceneViewLayerLightgroups(dataId: string, layerName: string, lightgroups: string[]): AnimationCommand<"setSceneViewLayerLightgroups"> {
return { type: "setSceneViewLayerLightgroups", dataId, layerName, lightgroups: [...lightgroups] };
},
setObjectLightgroup(objectId: string, lightgroup: string | null): AnimationCommand<"setObjectLightgroup"> {
return { type: "setObjectLightgroup", objectId, lightgroup };
},
} satisfies Record<string, (...args: never[]) => WebEngineEditCommand>);

View File

@@ -48,6 +48,7 @@ export interface SceneNodeIR {
transform: SceneTransformIR;
assetData?: AssetMetadataIR;
constraints?: ConstraintIR[];
lightgroup?: string | null;
}
export interface AssetMetadataIR {

View File

@@ -103,6 +103,7 @@ export const WEB_ENGINE_COMMAND_CAPABILITIES = {
setSceneViewLayerPassSettings: { family: "RENDER", route: "MAIN_AUTHORITATIVE", implementation: "SOURCE_BACKED" },
setSceneViewLayerAOVs: { family: "RENDER", route: "MAIN_AUTHORITATIVE", implementation: "SOURCE_BACKED" },
setSceneViewLayerLightgroups: { family: "RENDER", route: "MAIN_AUTHORITATIVE", implementation: "SOURCE_BACKED" },
setObjectLightgroup: { family: "RENDER", route: "MAIN_AUTHORITATIVE", implementation: "SOURCE_BACKED" },
setMetaballElements: { family: "GEOMETRY", route: "MAIN_AUTHORITATIVE", implementation: "SOURCE_BACKED" },
sculptStroke: { family: "SCULPT", route: "MAIN_AUTHORITATIVE", implementation: "SOURCE_BACKED" },
setSculptMeshAttributes: { family: "SCULPT", route: "MAIN_AUTHORITATIVE", implementation: "SOURCE_BACKED" },

View File

@@ -167,6 +167,7 @@ export type WebEngineEditCommand =
| { type: "setSceneViewLayerPassSettings"; dataId: string; layerName: string; properties: { passMask?: number; cryptomatteMask?: number; cryptomatteLevels?: number; alphaThreshold?: number } }
| { type: "setSceneViewLayerAOVs"; dataId: string; layerName: string; aovs: Array<{ name: string; type: 0 | 1 }> }
| { type: "setSceneViewLayerLightgroups"; dataId: string; layerName: string; lightgroups: string[] }
| { type: "setObjectLightgroup"; objectId: string; lightgroup: string | null }
| { type: "setMetaballElements"; dataId: string; elements: Array<{ type: number; position: [number, number, number]; radius: number; scale: [number, number, number] }> }
| { type: "sculptStroke"; stroke: SculptStrokeIR }
| { type: "setSculptMeshAttributes"; attributes: SculptMeshAttributesIR }

View File

@@ -4,7 +4,7 @@ export const WORKBENCH_COMMAND_GROUPS = Object.freeze({
OBJECT: ["createPrimitive", "duplicateObject", "deleteObject", "setObjectTransform", "setParent", "createCollection", "moveObjectToCollection", "renameId", "applyObjectTransform", "setObjectOrigin"],
MESH: ["meshEdit", "translateMeshVertices", "createUVMap", "setActiveUVMap", "unwrapUV", "setVertexColors", "setVertexWeights"],
ANIMATION: ["setFrame", "insertObjectKeyframe", "deleteObjectKeyframe", "setFCurveInterpolation", "setConstraint", "setNLAStack"],
RENDER: ["setCameraProperties", "setLightProperties", "setWorldProperties", "setSceneProperties", "setSceneRenderSettings", "setSceneAudioSettings", "setSceneUnitSettings", "setSceneTimelineSettings", "setScenePipelineSettings", "setSceneBindings", "setSceneViewLayerSettings", "setSceneCollectionSettings", "setSceneBorderSettings", "setSceneSimplifySettings", "setSceneColorManagement", "setSceneImageFormat", "setSceneMotionBlur", "setSceneHairSettings", "setSceneCompositorSettings", "setScenePerformanceSettings", "setSceneSamplingSettings", "setSceneMultiviewSettings", "setSceneStampSettings", "setSceneLineSettings", "setSceneViewLayerPassSettings", "setSceneViewLayerAOVs", "setSceneViewLayerLightgroups"],
RENDER: ["setCameraProperties", "setLightProperties", "setWorldProperties", "setSceneProperties", "setSceneRenderSettings", "setSceneAudioSettings", "setSceneUnitSettings", "setSceneTimelineSettings", "setScenePipelineSettings", "setSceneBindings", "setSceneViewLayerSettings", "setSceneCollectionSettings", "setSceneBorderSettings", "setSceneSimplifySettings", "setSceneColorManagement", "setSceneImageFormat", "setSceneMotionBlur", "setSceneHairSettings", "setSceneCompositorSettings", "setScenePerformanceSettings", "setSceneSamplingSettings", "setSceneMultiviewSettings", "setSceneStampSettings", "setSceneLineSettings", "setSceneViewLayerPassSettings", "setSceneViewLayerAOVs", "setSceneViewLayerLightgroups", "setObjectLightgroup"],
IO: ["importImage", "importVFont", "setMaterialImageNode"],
} as const satisfies Record<string, readonly WebEngineCommandType[]>);