141 lines
11 KiB
TypeScript
141 lines
11 KiB
TypeScript
import type { FCurveInterpolation } from "./web-engine";
|
|
import type { WebEngineEditCommand } from "./web-engine";
|
|
|
|
type AnimationCommand<T extends WebEngineEditCommand["type"]> = Extract<WebEngineEditCommand, { type: T }>;
|
|
|
|
/** Typed constructors for animation, constraint and render property edits. */
|
|
export const animationRenderCommands = Object.freeze({
|
|
insertKeyframe(objectId: string, frame: number, property: AnimationCommand<"insertObjectKeyframe">["property"], interpolation: FCurveInterpolation = "BEZIER"): AnimationCommand<"insertObjectKeyframe"> {
|
|
return { type: "insertObjectKeyframe", objectId, frame, property, interpolation };
|
|
},
|
|
deleteKeyframe(objectId: string, frame: number, property?: AnimationCommand<"deleteObjectKeyframe">["property"]): AnimationCommand<"deleteObjectKeyframe"> {
|
|
return { type: "deleteObjectKeyframe", objectId, frame, ...(property ? { property } : {}) };
|
|
},
|
|
createAction(name: string, objectId?: string): AnimationCommand<"createAction"> {
|
|
return { type: "createAction", name, ...(objectId ? { objectId } : {}) };
|
|
},
|
|
removeAction(actionId: string): AnimationCommand<"removeAction"> {
|
|
return { type: "removeAction", actionId };
|
|
},
|
|
setKeyframe(animationId: string, path: string, frame: number, options: Omit<AnimationCommand<"setKeyframe">, "type" | "animationId" | "path" | "frame"> = {}): AnimationCommand<"setKeyframe"> {
|
|
return { type: "setKeyframe", animationId, path, frame, ...options };
|
|
},
|
|
setFCurveKeyframes(animationId: string, path: string, points: AnimationCommand<"setFCurveKeyframes">["points"]): AnimationCommand<"setFCurveKeyframes"> {
|
|
return { type: "setFCurveKeyframes", animationId, path, points: points.map((point) => ({ ...point, handleLeft: point.handleLeft ? [...point.handleLeft] as [number, number] : undefined, handleRight: point.handleRight ? [...point.handleRight] as [number, number] : undefined })) };
|
|
},
|
|
setDriverExpression(animationId: string, path: string, expression: string): AnimationCommand<"setDriverExpression"> {
|
|
return { type: "setDriverExpression", animationId, path, expression };
|
|
},
|
|
setActionGroups(animationId: string, groups: AnimationCommand<"setActionGroups">["groups"]): AnimationCommand<"setActionGroups"> {
|
|
return { type: "setActionGroups", animationId, groups: groups.map((group) => ({ name: group.name, paths: [...group.paths] })) };
|
|
},
|
|
setKeyingSet(sceneId: string, name: string, paths: AnimationCommand<"setKeyingSet">["paths"], active = true): AnimationCommand<"setKeyingSet"> {
|
|
return { type: "setKeyingSet", sceneId, name, paths: paths.map((path) => ({ ...path })), active };
|
|
},
|
|
bakeAnimation(objectId: string, frameStart: number, frameEnd: number, step = 1): AnimationCommand<"bakeAnimation"> {
|
|
return { type: "bakeAnimation", objectId, frameStart, frameEnd, step };
|
|
},
|
|
setTimelineMarkers(dataId: string, markers: AnimationCommand<"setTimelineMarkers">["markers"]): AnimationCommand<"setTimelineMarkers"> {
|
|
return { type: "setTimelineMarkers", dataId, markers: markers.map((marker) => ({ ...marker })) };
|
|
},
|
|
setConstraint(objectId: string, constraintName: string, enabled: boolean, influence: number): AnimationCommand<"setConstraint"> {
|
|
return { type: "setConstraint", objectId, constraintName, enabled, influence };
|
|
},
|
|
setActiveAction(objectId: string, actionId: string | null): AnimationCommand<"setActiveAction"> {
|
|
return { type: "setActiveAction", objectId, actionId };
|
|
},
|
|
setNLAStack(objectId: string, tracks: AnimationCommand<"setNLAStack">["tracks"], baseRevision?: number): AnimationCommand<"setNLAStack"> {
|
|
return { type: "setNLAStack", objectId, tracks, ...(baseRevision === undefined ? {} : { baseRevision }) };
|
|
},
|
|
moveNLAStrip(objectId: string, trackId: string, stripId: string, frameStart: number, baseRevision: number): AnimationCommand<"moveNLAStrip"> {
|
|
return { type: "moveNLAStrip", objectId, trackId, stripId, frameStart, baseRevision };
|
|
},
|
|
setLightProperties(dataId: string, properties: AnimationCommand<"setLightProperties">["properties"]): AnimationCommand<"setLightProperties"> {
|
|
return { type: "setLightProperties", dataId, properties };
|
|
},
|
|
setCameraProperties(dataId: string, properties: AnimationCommand<"setCameraProperties">["properties"]): AnimationCommand<"setCameraProperties"> {
|
|
return { type: "setCameraProperties", dataId, properties };
|
|
},
|
|
setWorldProperties(dataId: string, properties: AnimationCommand<"setWorldProperties">["properties"]): AnimationCommand<"setWorldProperties"> {
|
|
return { type: "setWorldProperties", dataId, properties };
|
|
},
|
|
setSceneProperties(dataId: string, properties: AnimationCommand<"setSceneProperties">["properties"]): AnimationCommand<"setSceneProperties"> {
|
|
return { type: "setSceneProperties", dataId, properties: { ...properties } };
|
|
},
|
|
setSceneRenderSettings(dataId: string, properties: AnimationCommand<"setSceneRenderSettings">["properties"]): AnimationCommand<"setSceneRenderSettings"> {
|
|
return { type: "setSceneRenderSettings", dataId, properties: { ...properties } };
|
|
},
|
|
setSceneAudioSettings(dataId: string, properties: AnimationCommand<"setSceneAudioSettings">["properties"]): AnimationCommand<"setSceneAudioSettings"> {
|
|
return { type: "setSceneAudioSettings", dataId, properties: { ...properties } };
|
|
},
|
|
setSceneUnitSettings(dataId: string, properties: AnimationCommand<"setSceneUnitSettings">["properties"]): AnimationCommand<"setSceneUnitSettings"> {
|
|
return { type: "setSceneUnitSettings", dataId, properties: { ...properties } };
|
|
},
|
|
setSceneTimelineSettings(dataId: string, properties: AnimationCommand<"setSceneTimelineSettings">["properties"]): AnimationCommand<"setSceneTimelineSettings"> {
|
|
return { type: "setSceneTimelineSettings", dataId, properties: { ...properties } };
|
|
},
|
|
setScenePipelineSettings(dataId: string, properties: AnimationCommand<"setScenePipelineSettings">["properties"]): AnimationCommand<"setScenePipelineSettings"> {
|
|
return { type: "setScenePipelineSettings", dataId, properties: { ...properties } };
|
|
},
|
|
setSceneBindings(dataId: string, properties: AnimationCommand<"setSceneBindings">["properties"]): AnimationCommand<"setSceneBindings"> {
|
|
return { type: "setSceneBindings", dataId, properties: { ...properties } };
|
|
},
|
|
setSceneViewLayerSettings(dataId: string, layerName: string, properties: AnimationCommand<"setSceneViewLayerSettings">["properties"]): AnimationCommand<"setSceneViewLayerSettings"> {
|
|
return { type: "setSceneViewLayerSettings", dataId, layerName, properties: { ...properties } };
|
|
},
|
|
setSceneCollectionSettings(dataId: string, layerName: string, collectionId: string, properties: AnimationCommand<"setSceneCollectionSettings">["properties"]): AnimationCommand<"setSceneCollectionSettings"> {
|
|
return { type: "setSceneCollectionSettings", dataId, layerName, collectionId, properties: { ...properties } };
|
|
},
|
|
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 } };
|
|
},
|
|
setSceneColorManagement(dataId: string, properties: AnimationCommand<"setSceneColorManagement">["properties"]): AnimationCommand<"setSceneColorManagement"> {
|
|
return { type: "setSceneColorManagement", dataId, properties: { ...properties } };
|
|
},
|
|
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 } };
|
|
},
|
|
setSceneHairSettings(dataId: string, properties: AnimationCommand<"setSceneHairSettings">["properties"]): AnimationCommand<"setSceneHairSettings"> {
|
|
return { type: "setSceneHairSettings", dataId, properties: { ...properties } };
|
|
},
|
|
setSceneCompositorSettings(dataId: string, properties: AnimationCommand<"setSceneCompositorSettings">["properties"]): AnimationCommand<"setSceneCompositorSettings"> {
|
|
return { type: "setSceneCompositorSettings", dataId, properties: { ...properties } };
|
|
},
|
|
setScenePerformanceSettings(dataId: string, properties: AnimationCommand<"setScenePerformanceSettings">["properties"]): AnimationCommand<"setScenePerformanceSettings"> {
|
|
return { type: "setScenePerformanceSettings", dataId, properties: { ...properties } };
|
|
},
|
|
setSceneSamplingSettings(dataId: string, properties: AnimationCommand<"setSceneSamplingSettings">["properties"]): AnimationCommand<"setSceneSamplingSettings"> {
|
|
return { type: "setSceneSamplingSettings", dataId, properties: { ...properties } };
|
|
},
|
|
setSceneMultiviewSettings(dataId: string, properties: AnimationCommand<"setSceneMultiviewSettings">["properties"]): AnimationCommand<"setSceneMultiviewSettings"> {
|
|
return { type: "setSceneMultiviewSettings", dataId, properties: { ...properties } };
|
|
},
|
|
setSceneStampSettings(dataId: string, properties: AnimationCommand<"setSceneStampSettings">["properties"]): AnimationCommand<"setSceneStampSettings"> {
|
|
return { type: "setSceneStampSettings", dataId, properties: { ...properties } };
|
|
},
|
|
setSceneLineSettings(dataId: string, properties: AnimationCommand<"setSceneLineSettings">["properties"]): AnimationCommand<"setSceneLineSettings"> {
|
|
return { type: "setSceneLineSettings", dataId, properties: { ...properties } };
|
|
},
|
|
setSceneViewLayerPassSettings(dataId: string, layerName: string, properties: AnimationCommand<"setSceneViewLayerPassSettings">["properties"]): AnimationCommand<"setSceneViewLayerPassSettings"> {
|
|
return { type: "setSceneViewLayerPassSettings", dataId, layerName, properties: { ...properties } };
|
|
},
|
|
setSceneViewLayerAOVs(dataId: string, layerName: string, aovs: AnimationCommand<"setSceneViewLayerAOVs">["aovs"]): AnimationCommand<"setSceneViewLayerAOVs"> {
|
|
return { type: "setSceneViewLayerAOVs", dataId, layerName, aovs: aovs.map((aov) => ({ ...aov })) };
|
|
},
|
|
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 };
|
|
},
|
|
setWorldLightgroup(dataId: string, lightgroup: string | null): AnimationCommand<"setWorldLightgroup"> {
|
|
return { type: "setWorldLightgroup", dataId, lightgroup };
|
|
},
|
|
} satisfies Record<string, (...args: never[]) => WebEngineEditCommand>);
|