@doufunao123/asset-gateway 0.9.0 → 0.10.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
|
@@ -490,7 +490,7 @@ import { mkdirSync as mkdirSync2, writeFileSync as writeFileSync2 } from "fs";
|
|
|
490
490
|
import { join as join2 } from "path";
|
|
491
491
|
import { Command as Command3 } from "commander";
|
|
492
492
|
function inferExtension(assetType) {
|
|
493
|
-
const map = { image: "png", audio: "mp3", tts: "mp3", video: "mp4", model3d: "glb", text: "txt" };
|
|
493
|
+
const map = { image: "png", audio: "mp3", music: "mp3", tts: "mp3", video: "mp4", model3d: "glb", text: "txt" };
|
|
494
494
|
return map[assetType] ?? "bin";
|
|
495
495
|
}
|
|
496
496
|
function stripDataUri(data) {
|
|
@@ -577,8 +577,10 @@ function createGenerateCommand() {
|
|
|
577
577
|
asset_type: "audio",
|
|
578
578
|
prompt: options.prompt
|
|
579
579
|
};
|
|
580
|
-
|
|
581
|
-
if (options.
|
|
580
|
+
const params = {};
|
|
581
|
+
if (options.type) params.audio_type = options.type;
|
|
582
|
+
if (options.duration) params.duration_seconds = Number(options.duration);
|
|
583
|
+
if (Object.keys(params).length > 0) body.params = params;
|
|
582
584
|
const data = await ctx.client.post("/api/generate", body);
|
|
583
585
|
const localPath = await saveOutput(data, "audio", options.outputDir);
|
|
584
586
|
if (localPath) data.local_path = localPath;
|
|
@@ -588,6 +590,26 @@ function createGenerateCommand() {
|
|
|
588
590
|
}
|
|
589
591
|
})
|
|
590
592
|
);
|
|
593
|
+
command.addCommand(
|
|
594
|
+
new Command3("music").description("Generate music from a text prompt").requiredOption("--prompt <text>", "Music description prompt").option("--duration <seconds>", "Duration in seconds").option("--output-dir <dir>", "Directory to save output", ".").action(async function(options) {
|
|
595
|
+
try {
|
|
596
|
+
const ctx = createContext(this);
|
|
597
|
+
const body = {
|
|
598
|
+
asset_type: "music",
|
|
599
|
+
prompt: options.prompt
|
|
600
|
+
};
|
|
601
|
+
if (options.duration) {
|
|
602
|
+
body.params = { duration_seconds: Number(options.duration) };
|
|
603
|
+
}
|
|
604
|
+
const data = await ctx.client.post("/api/generate", body);
|
|
605
|
+
const localPath = await saveOutput(data, "music", options.outputDir);
|
|
606
|
+
if (localPath) data.local_path = localPath;
|
|
607
|
+
printSuccess("generate.music", data, ctx);
|
|
608
|
+
} catch (error2) {
|
|
609
|
+
printError("generate.music", error2);
|
|
610
|
+
}
|
|
611
|
+
})
|
|
612
|
+
);
|
|
591
613
|
command.addCommand(
|
|
592
614
|
new Command3("tts").description("Text-to-speech synthesis via Qwen3-TTS").requiredOption("--prompt <text>", "Text to synthesize").option("--voice <name>", "Voice name or custom voice ID", "Cherry").option("--language <lang>", "Language hint: Auto, Chinese, English, Japanese, etc.", "Auto").option("--model <model>", "Qwen3-TTS model", "qwen3-tts-flash").option("--instructions <text>", "Natural language speaking instructions (for instruct models)").option("--provider <id>", "Provider to use").option("--output-dir <dir>", "Directory to save output", ".").action(async function(options) {
|
|
593
615
|
try {
|
|
@@ -839,7 +861,7 @@ async function saveProcess3dOutput(data, operation, outputDir, format) {
|
|
|
839
861
|
function createProcess3dCommand() {
|
|
840
862
|
const command = new Command6("process3d").description("3D model post-processing via Tripo pipeline");
|
|
841
863
|
command.addCommand(
|
|
842
|
-
new Command6("convert").description("Convert 3D model format (FBX/USDZ/OBJ/STL/GLTF/3MF)").requiredOption("--task-id <id>", "Tripo task ID from generate model").requiredOption("--format <fmt>", "Target format: FBX, USDZ, OBJ, STL, GLTF, 3MF").option("--quad", "Enable quad remeshing").option("--face-limit <n>", "Max face count").option("--output-dir <dir>", "Directory to save output", ".").action(async function(options) {
|
|
864
|
+
new Command6("convert").description("Convert 3D model format (FBX/USDZ/OBJ/STL/GLTF/3MF)").requiredOption("--task-id <id>", "Tripo task ID from generate model").requiredOption("--format <fmt>", "Target format: FBX, USDZ, OBJ, STL, GLTF, 3MF").option("--quad", "Enable quad remeshing").option("--face-limit <n>", "Max face count").option("--pack-uv", "Pack UVs during export").option("--bake", "Bake textures during export").option("--texture-format <fmt>", "Texture export format override").option("--force-symmetry", "Force symmetry during conversion").option("--output-dir <dir>", "Directory to save output", ".").action(async function(options) {
|
|
843
865
|
try {
|
|
844
866
|
const ctx = createContext(this);
|
|
845
867
|
const params = {
|
|
@@ -847,6 +869,10 @@ function createProcess3dCommand() {
|
|
|
847
869
|
};
|
|
848
870
|
if (options.quad) params.quad = true;
|
|
849
871
|
if (options.faceLimit) params.face_limit = Number(options.faceLimit);
|
|
872
|
+
if (options.packUv) params.pack_uv = true;
|
|
873
|
+
if (options.bake) params.bake = true;
|
|
874
|
+
if (options.textureFormat) params.texture_format = options.textureFormat;
|
|
875
|
+
if (options.forceSymmetry) params.force_symmetry = true;
|
|
850
876
|
const data = await ctx.client.post("/api/process3d", {
|
|
851
877
|
task_id: options.taskId,
|
|
852
878
|
operation: "convert",
|
|
@@ -861,13 +887,17 @@ function createProcess3dCommand() {
|
|
|
861
887
|
})
|
|
862
888
|
);
|
|
863
889
|
command.addCommand(
|
|
864
|
-
new Command6("texture").description("Re-texture a 3D model with new materials").requiredOption("--task-id <id>", "Tripo task ID").option("--prompt <text>", "Texture description prompt").option("--pbr", "Enable PBR materials").option("--quality <q>", "Texture quality: standard or detailed").option("--output-dir <dir>", "Directory to save output", ".").action(async function(options) {
|
|
890
|
+
new Command6("texture").description("Re-texture a 3D model with new materials").requiredOption("--task-id <id>", "Tripo task ID").option("--prompt <text>", "Texture description prompt").option("--style-image <input>", "Texture style reference image URL or local file path").option("--pbr", "Enable PBR materials").option("--quality <q>", "Texture quality: standard or detailed").option("--texture-alignment <mode>", "Tripo texture alignment mode").option("--bake", "Bake textures during re-texturing").option("--texture-version <version>", "Tripo texture model version override").option("--output-dir <dir>", "Directory to save output", ".").action(async function(options) {
|
|
865
891
|
try {
|
|
866
892
|
const ctx = createContext(this);
|
|
867
893
|
const params = {};
|
|
868
894
|
if (options.prompt) params.prompt = options.prompt;
|
|
895
|
+
if (options.styleImage) params.style_image = options.styleImage;
|
|
869
896
|
if (options.pbr) params.pbr = true;
|
|
870
|
-
if (options.quality) params.
|
|
897
|
+
if (options.quality) params.texture_quality = options.quality;
|
|
898
|
+
if (options.textureAlignment) params.texture_alignment = options.textureAlignment;
|
|
899
|
+
if (options.bake) params.bake = true;
|
|
900
|
+
if (options.textureVersion) params.model_version = options.textureVersion;
|
|
871
901
|
const data = await ctx.client.post("/api/process3d", {
|
|
872
902
|
task_id: options.taskId,
|
|
873
903
|
operation: "texture",
|
|
@@ -882,16 +912,18 @@ function createProcess3dCommand() {
|
|
|
882
912
|
})
|
|
883
913
|
);
|
|
884
914
|
command.addCommand(
|
|
885
|
-
new Command6("rig").description("Auto-rig a 3D model (add skeleton for animation)").requiredOption("--task-id <id>", "Tripo task ID").option("--format <fmt>", "Output format: glb or fbx", "glb").option("--spec <spec>", "Rig spec: mixamo or tripo", "mixamo").option("--output-dir <dir>", "Directory to save output", ".").action(async function(options) {
|
|
915
|
+
new Command6("rig").description("Auto-rig a 3D model (add skeleton for animation)").requiredOption("--task-id <id>", "Tripo task ID").option("--format <fmt>", "Output format: glb or fbx", "glb").option("--spec <spec>", "Rig spec: mixamo or tripo", "mixamo").option("--rig-type <type>", "Rig type override passed through to Tripo").option("--output-dir <dir>", "Directory to save output", ".").action(async function(options) {
|
|
886
916
|
try {
|
|
887
917
|
const ctx = createContext(this);
|
|
918
|
+
const params = {
|
|
919
|
+
out_format: options.format,
|
|
920
|
+
spec: options.spec
|
|
921
|
+
};
|
|
922
|
+
if (options.rigType) params.rig_type = options.rigType;
|
|
888
923
|
const data = await ctx.client.post("/api/process3d", {
|
|
889
924
|
task_id: options.taskId,
|
|
890
925
|
operation: "rig",
|
|
891
|
-
params
|
|
892
|
-
format: options.format,
|
|
893
|
-
spec: options.spec
|
|
894
|
-
}
|
|
926
|
+
params
|
|
895
927
|
});
|
|
896
928
|
const localPath = await saveProcess3dOutput(data, "rig", options.outputDir, options.format);
|
|
897
929
|
if (localPath) data.local_path = localPath;
|