@doufunao123/asset-gateway 0.12.1 → 0.13.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +43 -11
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -627,7 +627,7 @@ import { existsSync as existsSync3, mkdirSync as mkdirSync2, readFileSync as rea
|
|
|
627
627
|
import { dirname as dirname2, extname, join as join2 } from "path";
|
|
628
628
|
import { Command as Command3 } from "commander";
|
|
629
629
|
function inferExtension(assetType) {
|
|
630
|
-
const map = { image: "png", audio: "mp3", music: "mp3", tts: "mp3", video: "mp4", model3d: "glb", text: "txt", sprite: "png" };
|
|
630
|
+
const map = { image: "png", audio: "mp3", music: "mp3", tts: "mp3", video: "mp4", model3d: "glb", text: "txt", sprite: "png", world: "spz" };
|
|
631
631
|
return map[assetType] ?? "bin";
|
|
632
632
|
}
|
|
633
633
|
function stripDataUri(data) {
|
|
@@ -914,19 +914,19 @@ function createGenerateCommand() {
|
|
|
914
914
|
})
|
|
915
915
|
);
|
|
916
916
|
command.addCommand(
|
|
917
|
-
new Command3("sprite").description("
|
|
917
|
+
new Command3("sprite").description("Generate sprite animation using SpriteForge AI").requiredOption("--prompt <text>", "Character description").option("--input <path>", "Reference image (local path or URL)").option("--animation-type <type>", "Animation type (idle, walk, run, attack, death, jump, cast, dance, or any custom)", "idle").option("--direction <dir>", "Facing direction: right, left, front, back", "right").option("--grid-size <size>", "Grid size: 2x2, 3x3, 4x4", "3x3").option("--style <style>", "Visual style (e.g. pixel art, hand-drawn, chibi)").option("--output-format <fmt>", "Output format: spritesheet or gif", "spritesheet").option("--fps <n>", "GIF frame rate", "8").option("--output-dir <dir>", "Directory to save output", ".").action(async function(options) {
|
|
918
918
|
try {
|
|
919
919
|
const ctx = createContext(this);
|
|
920
920
|
const params = {
|
|
921
|
-
|
|
922
|
-
|
|
921
|
+
animation_type: options.animationType,
|
|
922
|
+
direction: options.direction,
|
|
923
|
+
grid_size: options.gridSize,
|
|
924
|
+
output_format: options.outputFormat,
|
|
925
|
+
fps: Number(options.fps)
|
|
923
926
|
};
|
|
924
|
-
if (options.
|
|
925
|
-
if (options.negativePrompt) params.negative_prompt = options.negativePrompt;
|
|
926
|
-
if (options.seed) params.seed = Number(options.seed);
|
|
927
|
-
if (options.matteColor) params.matte_color = options.matteColor;
|
|
927
|
+
if (options.style) params.style = options.style;
|
|
928
928
|
let inputFile = options.input;
|
|
929
|
-
if (existsSync3(inputFile)) {
|
|
929
|
+
if (inputFile && existsSync3(inputFile)) {
|
|
930
930
|
const ext = extname(inputFile).toLowerCase();
|
|
931
931
|
const mime = ext === ".jpg" || ext === ".jpeg" ? "image/jpeg" : "image/png";
|
|
932
932
|
const b64 = readFileSync2(inputFile).toString("base64");
|
|
@@ -935,10 +935,9 @@ function createGenerateCommand() {
|
|
|
935
935
|
const body = {
|
|
936
936
|
asset_type: "sprite",
|
|
937
937
|
prompt: options.prompt,
|
|
938
|
-
model: options.model,
|
|
939
|
-
input_file: inputFile,
|
|
940
938
|
params
|
|
941
939
|
};
|
|
940
|
+
if (inputFile) body.input_file = inputFile;
|
|
942
941
|
const data = await ctx.client.post("/api/generate", body);
|
|
943
942
|
const localPath = await saveOutput(data, "sprite", options.outputDir);
|
|
944
943
|
if (localPath) data.local_path = localPath;
|
|
@@ -948,6 +947,39 @@ function createGenerateCommand() {
|
|
|
948
947
|
}
|
|
949
948
|
})
|
|
950
949
|
);
|
|
950
|
+
command.addCommand(
|
|
951
|
+
new Command3("world").description("Generate a 3D world/environment using WorldLabs Marble").requiredOption("--prompt <text>", "Text prompt describing the environment").option("--input <path>", "Input image (local path or URL) for image-to-world").option("--model <model>", "Model: marble-1.0-draft, marble-1.0, marble-1.1, marble-1.1-plus", "marble-1.1").option("--display-name <name>", "Display name for the generated world").option("--output-dir <dir>", "Directory to save output", ".").action(async function(options) {
|
|
952
|
+
try {
|
|
953
|
+
const ctx = createContext(this);
|
|
954
|
+
const params = {};
|
|
955
|
+
if (options.displayName) params.display_name = options.displayName;
|
|
956
|
+
let inputFile;
|
|
957
|
+
if (options.input) {
|
|
958
|
+
if (existsSync3(options.input)) {
|
|
959
|
+
const ext = extname(options.input).toLowerCase();
|
|
960
|
+
const mime = ext === ".jpg" || ext === ".jpeg" ? "image/jpeg" : "image/png";
|
|
961
|
+
const b64 = readFileSync2(options.input).toString("base64");
|
|
962
|
+
inputFile = `data:${mime};base64,${b64}`;
|
|
963
|
+
} else {
|
|
964
|
+
inputFile = options.input;
|
|
965
|
+
}
|
|
966
|
+
}
|
|
967
|
+
const body = {
|
|
968
|
+
asset_type: "world",
|
|
969
|
+
prompt: options.prompt,
|
|
970
|
+
model: options.model,
|
|
971
|
+
params
|
|
972
|
+
};
|
|
973
|
+
if (inputFile) body.input_file = inputFile;
|
|
974
|
+
const data = await ctx.client.post("/api/generate", body);
|
|
975
|
+
const localPath = await saveOutput(data, "world", options.outputDir);
|
|
976
|
+
if (localPath) data.local_path = localPath;
|
|
977
|
+
printSuccess("generate.world", data, ctx);
|
|
978
|
+
} catch (error2) {
|
|
979
|
+
printError("generate.world", error2);
|
|
980
|
+
}
|
|
981
|
+
})
|
|
982
|
+
);
|
|
951
983
|
return command;
|
|
952
984
|
}
|
|
953
985
|
|