feat(web): add scene motion blur authoring
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-29 16:50:49 +08:00
parent d1635f5163
commit 05f9bf1433
47 changed files with 1918 additions and 40 deletions

Binary file not shown.

View File

@@ -942,6 +942,7 @@ function Properties({ snapshot, selectedFaceIndices, selectedVertexIndices, grea
{activeScene ? <div className="property-section" data-testid="scene-properties-workbench"><h3>Scene Render</h3><output>{activeScene.name} · {activeScene.renderEngine ?? "UNKNOWN"}</output><output>{activeScene.colorManagement ? `${activeScene.colorManagement.viewTransform} · ${activeScene.colorManagement.look} · Exposure ${activeScene.colorManagement.exposure.toFixed(2)} · Gamma ${activeScene.colorManagement.gamma.toFixed(2)}` : "Color management unavailable"}</output><div className="property-actions"><button type="button" onClick={() => onCommand(animationRenderCommands.setSceneProperties(activeScene.id, { exposure: Math.max(-1000, Math.min(1000, (activeScene.colorManagement?.exposure ?? 0) + 0.5)) }))}>增加曝光</button><button type="button" onClick={() => onCommand(animationRenderCommands.setSceneProperties(activeScene.id, { gamma: Math.max(0, Math.min(1000, (activeScene.colorManagement?.gamma ?? 1) + 0.1)) }))}>增加 Gamma</button><button type="button" onClick={() => onCommand(animationRenderCommands.setSceneProperties(activeScene.id, { viewTransform: activeScene.colorManagement?.viewTransform === "AgX" ? "Standard" : "AgX" }))}>切换 View Transform</button></div></div> : null}
{activeScene?.colorManagement ? <div className="property-section" data-testid="scene-color-management-workbench"><h3>Color Management</h3><output>{activeScene.colorManagement.displayDevice} · {activeScene.colorManagement.temperature?.toFixed(0) ?? "-"} K · Tint {activeScene.colorManagement.tint?.toFixed(2) ?? "-"}</output><div className="property-actions"><button type="button" onClick={() => onCommand(animationRenderCommands.setSceneColorManagement(activeScene.id, { temperature: Math.min(20000, (activeScene.colorManagement!.temperature ?? 6500) + 250) }))}>升高色温</button><button type="button" onClick={() => onCommand(animationRenderCommands.setSceneColorManagement(activeScene.id, { tint: Math.max(-100, Math.min(100, (activeScene.colorManagement!.tint ?? 0) + 1)) }))}>调整 Tint</button></div></div> : null}
{activeScene?.imageFormatSettings ? <div className="property-section" data-testid="scene-image-format-workbench"><h3>Output Format</h3><output>{activeScene.imageFormatSettings.fileType} · {activeScene.imageFormatSettings.colorMode}-channel · {activeScene.imageFormatSettings.depth}-bit · Quality {activeScene.imageFormatSettings.quality}</output><div className="property-actions"><button type="button" onClick={() => onCommand(animationRenderCommands.setSceneImageFormat(activeScene.id, { fileType: activeScene.imageFormatSettings!.fileType === "PNG" ? "OPEN_EXR" : "PNG" }))}>切换格式</button><button type="button" onClick={() => onCommand(animationRenderCommands.setSceneImageFormat(activeScene.id, { colorMode: activeScene.imageFormatSettings!.colorMode === 32 ? 24 : 32 }))}>切换通道</button><button type="button" onClick={() => onCommand(animationRenderCommands.setSceneImageFormat(activeScene.id, { quality: Math.min(100, activeScene.imageFormatSettings!.quality + 5) }))}>提高质量</button></div></div> : null}
{activeScene?.motionBlurSettings ? <div className="property-section" data-testid="scene-motion-blur-workbench"><h3>Motion Blur</h3><output>{activeScene.motionBlurSettings.enabled ? "Enabled" : "Disabled"} · Shutter {activeScene.motionBlurSettings.shutter.toFixed(3)} · Position {activeScene.motionBlurSettings.position}</output><div className="property-actions"><button type="button" onClick={() => onCommand(animationRenderCommands.setSceneMotionBlur(activeScene.id, { enabled: !activeScene.motionBlurSettings!.enabled }))}>{activeScene.motionBlurSettings.enabled ? "关闭运动模糊" : "启用运动模糊"}</button><button type="button" onClick={() => onCommand(animationRenderCommands.setSceneMotionBlur(activeScene.id, { shutter: Math.min(10, activeScene.motionBlurSettings!.shutter + 0.05) }))}>增加快门</button><button type="button" onClick={() => onCommand(animationRenderCommands.setSceneMotionBlur(activeScene.id, { position: ((activeScene.motionBlurSettings!.position + 1) % 3) as 0 | 1 | 2 }))}>切换位置</button></div></div> : null}
{activeScene?.renderSettings ? <div className="property-section" data-testid="scene-render-settings-workbench"><h3>Render Output</h3><output>{activeScene.renderSettings.resolutionX} × {activeScene.renderSettings.resolutionY} @ {activeScene.renderSettings.resolutionPercentage}%</output><output>Frames {activeScene.renderSettings.frameStart} - {activeScene.renderSettings.frameEnd} · {activeScene.renderSettings.outputPath}</output><div className="property-actions"><button type="button" onClick={() => onCommand(animationRenderCommands.setSceneRenderSettings(activeScene.id, { resolutionX: Math.min(65536, activeScene.renderSettings!.resolutionX + 64), resolutionY: Math.min(65536, activeScene.renderSettings!.resolutionY + 64) }))}>增加分辨率</button><button type="button" onClick={() => onCommand(animationRenderCommands.setSceneRenderSettings(activeScene.id, { resolutionPercentage: Math.min(1000, activeScene.renderSettings!.resolutionPercentage + 10) }))}>增加百分比</button><button type="button" onClick={() => onCommand(animationRenderCommands.setSceneRenderSettings(activeScene.id, { frameEnd: Math.min(1000000, activeScene.renderSettings!.frameEnd + 1) }))}>延长帧范围</button></div></div> : null}
{activeScene?.audioSettings ? <div className="property-section" data-testid="scene-audio-settings-workbench"><h3>Scene Audio</h3><output>Volume {activeScene.audioSettings.volume.toFixed(2)} · Speed {activeScene.audioSettings.speedOfSound.toFixed(1)} · Doppler {activeScene.audioSettings.dopplerFactor.toFixed(2)}</output><output>Distance model {activeScene.audioSettings.distanceModel} · {activeScene.audioSettings.muted ? "Muted" : "Audible"} · {activeScene.audioSettings.sync ? "Synced" : "Free"}</output><div className="property-actions"><button type="button" onClick={() => onCommand(animationRenderCommands.setSceneAudioSettings(activeScene.id, { volume: Math.min(10, activeScene.audioSettings!.volume + 0.1) }))}>增加音量</button><button type="button" onClick={() => onCommand(animationRenderCommands.setSceneAudioSettings(activeScene.id, { muted: !activeScene.audioSettings!.muted }))}>{activeScene.audioSettings.muted ? "取消静音" : "静音"}</button><button type="button" onClick={() => onCommand(animationRenderCommands.setSceneAudioSettings(activeScene.id, { sync: !activeScene.audioSettings!.sync }))}>切换同步</button></div></div> : null}
{activeScene?.unitSettings ? <div className="property-section" data-testid="scene-unit-settings-workbench"><h3>Scene Units</h3><output>System {activeScene.unitSettings.system} · Scale {activeScene.unitSettings.scaleLength.toFixed(4)} · Rotation {activeScene.unitSettings.rotationSystem}</output><output>Length {activeScene.unitSettings.lengthUnit} · Mass {activeScene.unitSettings.massUnit} · Time {activeScene.unitSettings.timeUnit}</output><div className="property-actions"><button type="button" onClick={() => onCommand(animationRenderCommands.setSceneUnitSettings(activeScene.id, { system: activeScene.unitSettings!.system === 1 ? 2 : 1 }))}>切换单位系统</button><button type="button" onClick={() => onCommand(animationRenderCommands.setSceneUnitSettings(activeScene.id, { scaleLength: Math.min(1000000, Math.max(0.000001, activeScene.unitSettings!.scaleLength || 1) * 1.1) }))}>调整单位缩放</button><button type="button" onClick={() => onCommand(animationRenderCommands.setSceneUnitSettings(activeScene.id, { rotationSystem: activeScene.unitSettings!.rotationSystem === 2 ? 0 : 2 }))}>切换旋转单位</button></div></div> : null}

Binary file not shown.

View File

@@ -734,6 +734,15 @@ function assertFutureCapability(payload: Extract<WebEngineRequest["command"], {
if (properties.exrCodec !== undefined && (!Number.isSafeInteger(properties.exrCodec) || properties.exrCodec < 0 || properties.exrCodec > 10)) throw report("RENDER_PROPERTY_INVALID", "Scene exrCodec is outside the bounded range");
return;
}
case "setSceneMotionBlur": {
const scene = currentSnapshot?.scenes.find((candidate) => candidate.id === payload.dataId);
const properties = payload.properties;
if (!scene || !validPropertyKeys(properties, ["enabled", "shutter", "position"])) throw report("RENDER_PROPERTY_INVALID", "Scene motion blur target or properties are invalid");
if (properties.enabled !== undefined && typeof properties.enabled !== "boolean") throw report("RENDER_PROPERTY_INVALID", "Scene motion blur enabled must be boolean");
if (properties.shutter !== undefined && !boundedNumber(properties.shutter, 0, 10)) throw report("RENDER_PROPERTY_INVALID", "Scene motion blur shutter is outside the bounded range");
if (properties.position !== undefined && ![0, 1, 2].includes(properties.position)) throw report("RENDER_PROPERTY_INVALID", "Scene motion blur position is unsupported");
return;
}
case "setGeometryNodeGraph": {
const snapshot = currentSnapshot;
const availableResourceIds = new Set([

View File

@@ -68,4 +68,7 @@ export const animationRenderCommands = Object.freeze({
setSceneImageFormat(dataId: string, properties: AnimationCommand<"setSceneImageFormat">["properties"]): AnimationCommand<"setSceneImageFormat"> {
return { type: "setSceneImageFormat", dataId, properties: { ...properties } };
},
setSceneMotionBlur(dataId: string, properties: AnimationCommand<"setSceneMotionBlur">["properties"]): AnimationCommand<"setSceneMotionBlur"> {
return { type: "setSceneMotionBlur", dataId, properties: { ...properties } };
},
} satisfies Record<string, (...args: never[]) => WebEngineEditCommand>);

View File

@@ -575,6 +575,7 @@ export interface SceneIR {
borderSettings?: { enabled: boolean; minX: number; maxX: number; minY: number; maxY: number };
simplifySettings?: { subsurfViewport: number; subsurfRender: number; particlesViewport: number; particlesRender: number; volumes: number };
imageFormatSettings?: { fileType: string; colorMode: number; depth: number; quality: number; compression: number; exrCodec: number };
motionBlurSettings?: { enabled: boolean; shutter: number; position: number };
compositorGraph?: CompositorGraphIR;
compositorStatus?: "AVAILABLE" | "BLOCKED";
sequencerTimeline?: SequencerTimelineIR;
@@ -1615,6 +1616,11 @@ export function parseSceneSnapshotIR(value: unknown): SceneSnapshotIR {
requireString(scene.imageFormatSettings.fileType, `scenes[${index}].imageFormatSettings.fileType`);
for (const field of ["colorMode", "depth", "quality", "compression", "exrCodec"] as const) requireNumber(scene.imageFormatSettings[field], `scenes[${index}].imageFormatSettings.${field}`);
}
if (scene.motionBlurSettings !== undefined) {
if (!isRecord(scene.motionBlurSettings)) throw new Error(`SceneIR.scenes[${index}].motionBlurSettings must be an object`);
requireBoolean(scene.motionBlurSettings.enabled, `scenes[${index}].motionBlurSettings.enabled`);
for (const field of ["shutter", "position"] as const) requireNumber(scene.motionBlurSettings[field], `scenes[${index}].motionBlurSettings.${field}`);
}
if (scene.compositorStatus !== undefined && !["AVAILABLE", "BLOCKED"].includes(scene.compositorStatus as string)) {
throw new Error(`scenes[${index}].compositorStatus is invalid`);
}

View File

@@ -92,6 +92,7 @@ export const WEB_ENGINE_COMMAND_CAPABILITIES = {
setSceneSimplifySettings: { family: "CORE_SCENE_GRAPH", route: "MAIN_AUTHORITATIVE", implementation: "SOURCE_BACKED" },
setSceneColorManagement: { family: "CORE_SCENE_GRAPH", route: "MAIN_AUTHORITATIVE", implementation: "SOURCE_BACKED" },
setSceneImageFormat: { family: "CORE_SCENE_GRAPH", route: "MAIN_AUTHORITATIVE", implementation: "SOURCE_BACKED" },
setSceneMotionBlur: { family: "CORE_SCENE_GRAPH", 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

@@ -156,6 +156,7 @@ export type WebEngineEditCommand =
| { type: "setSceneSimplifySettings"; dataId: string; properties: { subsurfViewport?: number; subsurfRender?: number; particlesViewport?: number; particlesRender?: number; volumes?: number } }
| { type: "setSceneColorManagement"; dataId: string; properties: { displayDevice?: string; temperature?: number; tint?: number } }
| { type: "setSceneImageFormat"; dataId: string; properties: { fileType?: "PNG" | "JPEG" | "OPEN_EXR" | "TIFF" | "WEBP"; colorMode?: number; depth?: number; quality?: number; compression?: number; exrCodec?: number } }
| { type: "setSceneMotionBlur"; dataId: string; properties: { enabled?: boolean; shutter?: number; position?: 0 | 1 | 2 } }
| { 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"],
RENDER: ["setCameraProperties", "setLightProperties", "setWorldProperties", "setSceneProperties", "setSceneRenderSettings", "setSceneAudioSettings", "setSceneUnitSettings", "setSceneTimelineSettings", "setScenePipelineSettings", "setSceneBindings", "setSceneViewLayerSettings", "setSceneCollectionSettings", "setSceneBorderSettings", "setSceneSimplifySettings", "setSceneColorManagement", "setSceneImageFormat", "setSceneMotionBlur"],
IO: ["importImage", "importVFont", "setMaterialImageNode"],
} as const satisfies Record<string, readonly WebEngineCommandType[]>);