Files
workinf_Blender_Wasm/web/protocol/io-media-commands.ts
mes123456 e9bfef0c5a
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): complete Blender route runtime execution
2026-09-07 00:12:32 +08:00

50 lines
2.5 KiB
TypeScript

import type { WebEngineEditCommand } from "./web-engine";
type IOCommand<T extends WebEngineEditCommand["type"]> = Extract<WebEngineEditCommand, { type: T }>;
export type IOSceneFormat = "GLTF" | "GLB" | "OBJ" | "STL" | "PLY" | "USD" | "ALEMBIC";
export interface IOSceneImportCommand {
type: "importScene";
format: IOSceneFormat;
fileName: string;
mimeType: string;
base64: string;
}
export interface IOSceneExportCommand {
type: "exportScene";
format: IOSceneFormat;
fileName: string;
}
export type IOSceneCommand = IOSceneImportCommand | IOSceneExportCommand;
/** Typed constructors for media import and persistence-facing edit commands. */
export const ioMediaCommands = Object.freeze({
importScene(format: IOSceneFormat, fileName: string, mimeType: string, base64: string): IOSceneImportCommand {
return { type: "importScene", format, fileName, mimeType, base64 };
},
exportScene(format: IOSceneFormat, fileName: string): IOSceneExportCommand {
return { type: "exportScene", format, fileName };
},
importImage(name: string, mimeType: IOCommand<"importImage">["mimeType"], width: number, height: number, base64: string): IOCommand<"importImage"> {
return { type: "importImage", name, mimeType, width, height, base64 };
},
setMaterialImageNode(materialId: string, imageId: string, usage: IOCommand<"setMaterialImageNode">["usage"], uvMap?: string): IOCommand<"setMaterialImageNode"> {
return { type: "setMaterialImageNode", materialId, imageId, usage, ...(uvMap ? { uvMap } : {}) };
},
setSoundProperties(dataId: string, properties: IOCommand<"setSoundProperties">["properties"]): IOCommand<"setSoundProperties"> {
return { type: "setSoundProperties", dataId, properties: { ...properties } };
},
setSpeakerProperties(dataId: string, properties: IOCommand<"setSpeakerProperties">["properties"]): IOCommand<"setSpeakerProperties"> {
return { type: "setSpeakerProperties", dataId, properties: { ...properties } };
},
setParticleSettings(dataId: string, properties: IOCommand<"setParticleSettings">["properties"]): IOCommand<"setParticleSettings"> {
return { type: "setParticleSettings", dataId, properties: { ...properties } };
},
setTextureProperties(dataId: string, properties: IOCommand<"setTextureProperties">["properties"]): IOCommand<"setTextureProperties"> {
return { type: "setTextureProperties", dataId, properties: { ...properties } };
},
} satisfies Record<string, (...args: never[]) => WebEngineEditCommand | IOSceneCommand>);