import type { WebEngineEditCommand } from "./web-engine"; type IOCommand = Extract; 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 WebEngineEditCommand | IOSceneCommand>);