feat(web): complete user-facing workflow command coverage
This commit is contained in:
@@ -2,20 +2,88 @@ import type { WebEngineEditCommand } from "./web-engine";
|
||||
|
||||
type NonMeshCommand<T extends WebEngineEditCommand["type"]> = Extract<WebEngineEditCommand, { type: T }>;
|
||||
|
||||
/** Typed constructors for curve, font, volume and Grease Pencil editing. */
|
||||
/** Typed constructors for non-mesh data, curve/surface topology, font, volume and Grease Pencil editing. */
|
||||
export const nonMeshGeometryCommands = Object.freeze({
|
||||
createCurve(name: string, controlPoints: readonly number[], cyclic = false, resolution = 12): NonMeshCommand<"createCurve"> {
|
||||
return { type: "createCurve", curveType: "CURVE", name, controlPoints: [...controlPoints], cyclic, resolution };
|
||||
},
|
||||
deleteNonMeshData(dataId: string): NonMeshCommand<"deleteNonMeshData"> {
|
||||
return { type: "deleteNonMeshData", dataId };
|
||||
},
|
||||
setCurveControlPoints(dataId: string, controlPoints: readonly number[], splineOffsets?: readonly number[], resolution?: number): NonMeshCommand<"setCurveControlPoints"> {
|
||||
return { type: "setCurveControlPoints", dataId, controlPoints: [...controlPoints], ...(splineOffsets ? { splineOffsets: [...splineOffsets] } : {}), ...(resolution === undefined ? {} : { resolution }) };
|
||||
},
|
||||
setCurveHandle(dataId: string, pointIndex: number, side: "LEFT" | "RIGHT", position: readonly [number, number, number]): NonMeshCommand<"setCurveHandle"> {
|
||||
return { type: "setCurveHandle", dataId, pointIndex, side, position: [...position] as [number, number, number] };
|
||||
},
|
||||
setCurveSplines(
|
||||
dataId: string,
|
||||
splineTypes: ReadonlyArray<NonMeshCommand<"setCurveSplines">["splineTypes"][number]>,
|
||||
splineOffsets: readonly number[],
|
||||
ordersU: readonly number[],
|
||||
controlPoints: readonly number[],
|
||||
pointWeights: readonly number[],
|
||||
cyclicU: readonly boolean[],
|
||||
handleTypes: readonly number[],
|
||||
handlePoints: readonly number[],
|
||||
): NonMeshCommand<"setCurveSplines"> {
|
||||
return {
|
||||
type: "setCurveSplines",
|
||||
dataId,
|
||||
splineTypes: [...splineTypes],
|
||||
splineOffsets: [...splineOffsets],
|
||||
ordersU: [...ordersU],
|
||||
controlPoints: [...controlPoints],
|
||||
pointWeights: [...pointWeights],
|
||||
cyclicU: [...cyclicU],
|
||||
handleTypes: [...handleTypes],
|
||||
handlePoints: [...handlePoints],
|
||||
};
|
||||
},
|
||||
setSurfaceTopology(
|
||||
dataId: string,
|
||||
splineDimensions: ReadonlyArray<NonMeshCommand<"setSurfaceTopology">["splineDimensions"][number]>,
|
||||
controlPoints: readonly number[],
|
||||
pointWeights: readonly number[],
|
||||
cyclicU: readonly boolean[],
|
||||
cyclicV: readonly boolean[],
|
||||
): NonMeshCommand<"setSurfaceTopology"> {
|
||||
return {
|
||||
type: "setSurfaceTopology",
|
||||
dataId,
|
||||
splineDimensions: splineDimensions.map((dimension) => ({ ...dimension })),
|
||||
controlPoints: [...controlPoints],
|
||||
pointWeights: [...pointWeights],
|
||||
cyclicU: [...cyclicU],
|
||||
cyclicV: [...cyclicV],
|
||||
};
|
||||
},
|
||||
setFontBody(dataId: string, body: string): NonMeshCommand<"setFontBody"> {
|
||||
return { type: "setFontBody", dataId, body };
|
||||
},
|
||||
setFontProperties(dataId: string, properties: NonMeshCommand<"setFontProperties">["properties"]): NonMeshCommand<"setFontProperties"> {
|
||||
return { type: "setFontProperties", dataId, properties: { ...properties } };
|
||||
},
|
||||
setFontAdvanced(
|
||||
dataId: string,
|
||||
characters: ReadonlyArray<NonMeshCommand<"setFontAdvanced">["characters"][number]>,
|
||||
textBoxes: ReadonlyArray<NonMeshCommand<"setFontAdvanced">["textBoxes"][number]>,
|
||||
activeTextBox: number,
|
||||
): NonMeshCommand<"setFontAdvanced"> {
|
||||
return {
|
||||
type: "setFontAdvanced",
|
||||
dataId,
|
||||
characters: characters.map((character) => ({ ...character })),
|
||||
textBoxes: textBoxes.map((textBox) => ({ ...textBox })),
|
||||
activeTextBox,
|
||||
};
|
||||
},
|
||||
importVFont(payload: Omit<NonMeshCommand<"importVFont">, "type">): NonMeshCommand<"importVFont"> {
|
||||
return { type: "importVFont", ...payload };
|
||||
},
|
||||
setFontLinks(dataId: string, links: NonMeshCommand<"setFontLinks">["links"]): NonMeshCommand<"setFontLinks"> {
|
||||
return { type: "setFontLinks", dataId, links: { ...links } };
|
||||
},
|
||||
setVolumeProperties(dataId: string, sourcePath: string, displayDensity: number, interpolation: "NEAREST" | "LINEAR", stepSize: number): NonMeshCommand<"setVolumeProperties"> {
|
||||
return { type: "setVolumeProperties", dataId, sourcePath, displayDensity, interpolation, stepSize };
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user