Files
workinf_Blender_Wasm/web/protocol/nonmesh-geometry-commands.ts
mes123456 81113159dc
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
feat(web): continue source-backed implementation waves
2026-08-29 05:46:53 +08:00

35 lines
2.6 KiB
TypeScript

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. */
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 };
},
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 }) };
},
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 } };
},
setVolumeProperties(dataId: string, sourcePath: string, displayDensity: number, interpolation: "NEAREST" | "LINEAR", stepSize: number): NonMeshCommand<"setVolumeProperties"> {
return { type: "setVolumeProperties", dataId, sourcePath, displayDensity, interpolation, stepSize };
},
setMetaballElements(dataId: string, elements: NonMeshCommand<"setMetaballElements">["elements"]): NonMeshCommand<"setMetaballElements"> {
return { type: "setMetaballElements", dataId, elements: elements.map((element) => ({ ...element, position: [...element.position] as [number, number, number], scale: [...element.scale] as [number, number, number] })) };
},
createGreasePencilLayer(dataId: string, name: string): NonMeshCommand<"createGreasePencilLayer"> {
return { type: "createGreasePencilLayer", dataId, name };
},
removeGreasePencilLayer(dataId: string, layerId: string): NonMeshCommand<"removeGreasePencilLayer"> {
return { type: "removeGreasePencilLayer", dataId, layerId };
},
clearGreasePencilFrame(dataId: string, layerId: string, frame: number, baseRevision?: number): NonMeshCommand<"setGreasePencilStrokes"> {
return { type: "setGreasePencilStrokes", dataId, layerId, frame, ...(baseRevision === undefined ? {} : { baseRevision }), strokes: [] };
},
} satisfies Record<string, (...args: never[]) => WebEngineEditCommand>);