feat(web): add scene simplify authoring
This commit is contained in:
BIN
web/app/public/vendor/blender/web_engine.wasm
vendored
BIN
web/app/public/vendor/blender/web_engine.wasm
vendored
Binary file not shown.
@@ -947,6 +947,7 @@ function Properties({ snapshot, selectedFaceIndices, selectedVertexIndices, grea
|
||||
{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}
|
||||
{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?.simplifySettings ? <div className="property-section" data-testid="scene-simplify-settings-workbench"><h3>Render Simplify</h3><output>Subdivision {activeScene.simplifySettings.subsurfViewport} / {activeScene.simplifySettings.subsurfRender} · Particles {activeScene.simplifySettings.particlesViewport.toFixed(2)} / {activeScene.simplifySettings.particlesRender.toFixed(2)} · Volumes {activeScene.simplifySettings.volumes.toFixed(2)}</output><div className="property-actions"><button type="button" onClick={() => onCommand(animationRenderCommands.setSceneSimplifySettings(activeScene.id, { subsurfViewport: Math.max(0, activeScene.simplifySettings!.subsurfViewport - 1) }))}>降低细分</button><button type="button" onClick={() => onCommand(animationRenderCommands.setSceneSimplifySettings(activeScene.id, { particlesViewport: Math.max(0, activeScene.simplifySettings!.particlesViewport - 0.1), volumes: Math.max(0, activeScene.simplifySettings!.volumes - 0.1) }))}>降低复杂度</button></div></div> : null}
|
||||
{activeFont ? <div className="property-section" data-testid="font-workbench"><h3>Font</h3><label>Text <textarea aria-label="Font body" value={fontBody} maxLength={65536} onChange={(event) => setFontBody(event.target.value)} /></label><div className="property-actions"><button type="button" disabled={fontBody === activeFont.text} onClick={() => onCommand(nonMeshGeometryCommands.setFontBody(activeFont.id, fontBody))}>Apply Text</button>{activeFont.fontProperties ? <button type="button" onClick={() => onCommand(nonMeshGeometryCommands.setFontProperties(activeFont.id, { extrude: Math.min(1000, activeFont.fontProperties!.extrude + 0.01) }))}>Increase Extrude</button> : null}</div><output>{activeFont.text?.length ?? 0} characters</output></div> : null}
|
||||
{activeVolume ? <div className="property-section" data-testid="volume-workbench"><h3>Volume</h3><output>{activeVolume.sourcePath ?? "No source path"}</output><output>{activeVolume.volumeGrids?.length ?? 0} grids</output>{activeVolume.volumeProperties ? <><output>Density {activeVolume.volumeProperties.displayDensity.toFixed(3)} · Step {activeVolume.volumeProperties.stepSize.toFixed(4)}</output><div className="property-actions"><button type="button" onClick={() => onCommand(nonMeshGeometryCommands.setVolumeProperties(activeVolume.id, activeVolume.sourcePath ?? "", Math.min(1e6, activeVolume.volumeProperties!.displayDensity + 0.1), activeVolume.volumeProperties!.interpolation, activeVolume.volumeProperties!.stepSize))}>Increase Density</button><button type="button" onClick={() => onCommand(nonMeshGeometryCommands.setVolumeProperties(activeVolume.id, activeVolume.sourcePath ?? "", activeVolume.volumeProperties!.displayDensity, activeVolume.volumeProperties!.interpolation === "LINEAR" ? "NEAREST" : "LINEAR", activeVolume.volumeProperties!.stepSize))}>Toggle Interpolation</button></div></> : <output>Volume properties unavailable</output>}</div> : null}
|
||||
{activeMetaball ? <div className="property-section" data-testid="metaball-workbench"><h3>Metaball</h3><output>{activeMetaball.elements?.length ?? 0} elements</output>{activeMetaball.elements?.length ? <div className="property-actions"><button type="button" onClick={() => onCommand(nonMeshGeometryCommands.setMetaballElements(activeMetaball.id, activeMetaball.elements!.map((element, index) => index === 0 ? { ...element, radius: Math.min(100000, element.radius + 0.05) } : element)))}>Increase Active Radius</button></div> : <output>No editable elements</output>}</div> : null}
|
||||
|
||||
BIN
web/app/src/vendor/blender/web_engine.wasm
vendored
BIN
web/app/src/vendor/blender/web_engine.wasm
vendored
Binary file not shown.
@@ -705,6 +705,14 @@ function assertFutureCapability(payload: Extract<WebEngineRequest["command"], {
|
||||
if (maxX <= minX || maxY <= minY) throw report("RENDER_PROPERTY_INVALID", "Scene border max values must exceed min values");
|
||||
return;
|
||||
}
|
||||
case "setSceneSimplifySettings": {
|
||||
const scene = currentSnapshot?.scenes.find((candidate) => candidate.id === payload.dataId);
|
||||
const properties = payload.properties;
|
||||
if (!scene || !validPropertyKeys(properties, ["subsurfViewport", "subsurfRender", "particlesViewport", "particlesRender", "volumes"])) throw report("RENDER_PROPERTY_INVALID", "Scene simplify target or properties are invalid");
|
||||
for (const field of ["subsurfViewport", "subsurfRender"] as const) if (properties[field] !== undefined && (!Number.isSafeInteger(properties[field]) || properties[field] < 0 || properties[field] > 64)) throw report("RENDER_PROPERTY_INVALID", `Scene ${field} is outside the subdivision range`);
|
||||
for (const field of ["particlesViewport", "particlesRender", "volumes"] as const) if (properties[field] !== undefined && !boundedNumber(properties[field], 0, 1000)) throw report("RENDER_PROPERTY_INVALID", `Scene ${field} is outside the simplify range`);
|
||||
return;
|
||||
}
|
||||
case "setGeometryNodeGraph": {
|
||||
const snapshot = currentSnapshot;
|
||||
const availableResourceIds = new Set([
|
||||
|
||||
@@ -59,4 +59,7 @@ export const animationRenderCommands = Object.freeze({
|
||||
setSceneBorderSettings(dataId: string, properties: AnimationCommand<"setSceneBorderSettings">["properties"]): AnimationCommand<"setSceneBorderSettings"> {
|
||||
return { type: "setSceneBorderSettings", dataId, properties: { ...properties } };
|
||||
},
|
||||
setSceneSimplifySettings(dataId: string, properties: AnimationCommand<"setSceneSimplifySettings">["properties"]): AnimationCommand<"setSceneSimplifySettings"> {
|
||||
return { type: "setSceneSimplifySettings", dataId, properties: { ...properties } };
|
||||
},
|
||||
} satisfies Record<string, (...args: never[]) => WebEngineEditCommand>);
|
||||
|
||||
@@ -573,6 +573,7 @@ export interface SceneIR {
|
||||
};
|
||||
viewLayers?: Array<{ name: string; useRender: boolean; useFreestyle: boolean; samples: number }>;
|
||||
borderSettings?: { enabled: boolean; minX: number; maxX: number; minY: number; maxY: number };
|
||||
simplifySettings?: { subsurfViewport: number; subsurfRender: number; particlesViewport: number; particlesRender: number; volumes: number };
|
||||
compositorGraph?: CompositorGraphIR;
|
||||
compositorStatus?: "AVAILABLE" | "BLOCKED";
|
||||
sequencerTimeline?: SequencerTimelineIR;
|
||||
@@ -1604,6 +1605,10 @@ export function parseSceneSnapshotIR(value: unknown): SceneSnapshotIR {
|
||||
requireBoolean(scene.borderSettings.enabled, `scenes[${index}].borderSettings.enabled`);
|
||||
for (const field of ["minX", "maxX", "minY", "maxY"] as const) requireNumber(scene.borderSettings[field], `scenes[${index}].borderSettings.${field}`);
|
||||
}
|
||||
if (scene.simplifySettings !== undefined) {
|
||||
if (!isRecord(scene.simplifySettings)) throw new Error(`SceneIR.scenes[${index}].simplifySettings must be an object`);
|
||||
for (const field of ["subsurfViewport", "subsurfRender", "particlesViewport", "particlesRender", "volumes"] as const) requireNumber(scene.simplifySettings[field], `scenes[${index}].simplifySettings.${field}`);
|
||||
}
|
||||
if (scene.compositorStatus !== undefined && !["AVAILABLE", "BLOCKED"].includes(scene.compositorStatus as string)) {
|
||||
throw new Error(`scenes[${index}].compositorStatus is invalid`);
|
||||
}
|
||||
|
||||
@@ -89,6 +89,7 @@ export const WEB_ENGINE_COMMAND_CAPABILITIES = {
|
||||
setSceneViewLayerSettings: { family: "CORE_SCENE_GRAPH", route: "MAIN_AUTHORITATIVE", implementation: "SOURCE_BACKED" },
|
||||
setSceneCollectionSettings: { family: "CORE_SCENE_GRAPH", route: "MAIN_AUTHORITATIVE", implementation: "SOURCE_BACKED" },
|
||||
setSceneBorderSettings: { family: "CORE_SCENE_GRAPH", route: "MAIN_AUTHORITATIVE", implementation: "SOURCE_BACKED" },
|
||||
setSceneSimplifySettings: { 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" },
|
||||
|
||||
@@ -153,6 +153,7 @@ export type WebEngineEditCommand =
|
||||
| { type: "setSceneViewLayerSettings"; dataId: string; layerName: string; properties: { useRender?: boolean; useFreestyle?: boolean; samples?: number } }
|
||||
| { type: "setSceneCollectionSettings"; dataId: string; layerName: string; collectionId: string; properties: { exclude?: boolean; holdout?: boolean; indirectOnly?: boolean; hide?: boolean } }
|
||||
| { type: "setSceneBorderSettings"; dataId: string; properties: { enabled?: boolean; minX?: number; maxX?: number; minY?: number; maxY?: number } }
|
||||
| { type: "setSceneSimplifySettings"; dataId: string; properties: { subsurfViewport?: number; subsurfRender?: number; particlesViewport?: number; particlesRender?: number; volumes?: number } }
|
||||
| { 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 }
|
||||
|
||||
@@ -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"],
|
||||
RENDER: ["setCameraProperties", "setLightProperties", "setWorldProperties", "setSceneProperties", "setSceneRenderSettings", "setSceneAudioSettings", "setSceneUnitSettings", "setSceneTimelineSettings", "setScenePipelineSettings", "setSceneBindings", "setSceneViewLayerSettings", "setSceneCollectionSettings", "setSceneBorderSettings", "setSceneSimplifySettings"],
|
||||
IO: ["importImage", "importVFont", "setMaterialImageNode"],
|
||||
} as const satisfies Record<string, readonly WebEngineCommandType[]>);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user