Skip to content

Commit d02d0e5

Browse files
seed93liangd
andauthored
[add] tripo3.0 (#10663)
* [add] tripo3.0 * [tripo] change paramter order * change order --------- Co-authored-by: liangd <liangding@vastai3d.com>
1 parent 70541d4 commit d02d0e5

2 files changed

Lines changed: 122 additions & 10 deletions

File tree

comfy_api_nodes/apis/tripo_api.py

Lines changed: 38 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,17 @@
55
from pydantic import BaseModel, Field, RootModel
66

77
class TripoModelVersion(str, Enum):
8+
v3_0_20250812 = 'v3.0-20250812'
89
v2_5_20250123 = 'v2.5-20250123'
910
v2_0_20240919 = 'v2.0-20240919'
1011
v1_4_20240625 = 'v1.4-20240625'
1112

1213

14+
class TripoGeometryQuality(str, Enum):
15+
standard = 'standard'
16+
detailed = 'detailed'
17+
18+
1319
class TripoTextureQuality(str, Enum):
1420
standard = 'standard'
1521
detailed = 'detailed'
@@ -61,14 +67,20 @@ class TripoSpec(str, Enum):
6167
class TripoAnimation(str, Enum):
6268
IDLE = "preset:idle"
6369
WALK = "preset:walk"
70+
RUN = "preset:run"
71+
DIVE = "preset:dive"
6472
CLIMB = "preset:climb"
6573
JUMP = "preset:jump"
66-
RUN = "preset:run"
6774
SLASH = "preset:slash"
6875
SHOOT = "preset:shoot"
6976
HURT = "preset:hurt"
7077
FALL = "preset:fall"
7178
TURN = "preset:turn"
79+
QUADRUPED_WALK = "preset:quadruped:walk"
80+
HEXAPOD_WALK = "preset:hexapod:walk"
81+
OCTOPOD_WALK = "preset:octopod:walk"
82+
SERPENTINE_MARCH = "preset:serpentine:march"
83+
AQUATIC_MARCH = "preset:aquatic:march"
7284

7385
class TripoStylizeStyle(str, Enum):
7486
LEGO = "lego"
@@ -105,6 +117,11 @@ class TripoTaskStatus(str, Enum):
105117
BANNED = "banned"
106118
EXPIRED = "expired"
107119

120+
class TripoFbxPreset(str, Enum):
121+
BLENDER = "blender"
122+
MIXAMO = "mixamo"
123+
_3DSMAX = "3dsmax"
124+
108125
class TripoFileTokenReference(BaseModel):
109126
type: Optional[str] = Field(None, description='The type of the reference')
110127
file_token: str
@@ -142,6 +159,7 @@ class TripoTextToModelRequest(BaseModel):
142159
model_seed: Optional[int] = Field(None, description='The seed for the model')
143160
texture_seed: Optional[int] = Field(None, description='The seed for the texture')
144161
texture_quality: Optional[TripoTextureQuality] = TripoTextureQuality.standard
162+
geometry_quality: Optional[TripoGeometryQuality] = TripoGeometryQuality.standard
145163
style: Optional[TripoStyle] = None
146164
auto_size: Optional[bool] = Field(False, description='Whether to auto-size the model')
147165
quad: Optional[bool] = Field(False, description='Whether to apply quad to the generated model')
@@ -156,6 +174,7 @@ class TripoImageToModelRequest(BaseModel):
156174
model_seed: Optional[int] = Field(None, description='The seed for the model')
157175
texture_seed: Optional[int] = Field(None, description='The seed for the texture')
158176
texture_quality: Optional[TripoTextureQuality] = TripoTextureQuality.standard
177+
geometry_quality: Optional[TripoGeometryQuality] = TripoGeometryQuality.standard
159178
texture_alignment: Optional[TripoTextureAlignment] = Field(TripoTextureAlignment.ORIGINAL_IMAGE, description='The texture alignment method')
160179
style: Optional[TripoStyle] = Field(None, description='The style to apply to the generated model')
161180
auto_size: Optional[bool] = Field(False, description='Whether to auto-size the model')
@@ -173,6 +192,7 @@ class TripoMultiviewToModelRequest(BaseModel):
173192
model_seed: Optional[int] = Field(None, description='The seed for the model')
174193
texture_seed: Optional[int] = Field(None, description='The seed for the texture')
175194
texture_quality: Optional[TripoTextureQuality] = TripoTextureQuality.standard
195+
geometry_quality: Optional[TripoGeometryQuality] = TripoGeometryQuality.standard
176196
texture_alignment: Optional[TripoTextureAlignment] = TripoTextureAlignment.ORIGINAL_IMAGE
177197
auto_size: Optional[bool] = Field(False, description='Whether to auto-size the model')
178198
orientation: Optional[TripoOrientation] = Field(TripoOrientation.DEFAULT, description='The orientation for the model')
@@ -219,14 +239,24 @@ class TripoConvertModelRequest(BaseModel):
219239
type: TripoTaskType = Field(TripoTaskType.CONVERT_MODEL, description='Type of task')
220240
format: TripoConvertFormat = Field(..., description='The format to convert to')
221241
original_model_task_id: str = Field(..., description='The task ID of the original model')
222-
quad: Optional[bool] = Field(False, description='Whether to apply quad to the model')
223-
force_symmetry: Optional[bool] = Field(False, description='Whether to force symmetry')
224-
face_limit: Optional[int] = Field(10000, description='The number of faces to limit the conversion to')
225-
flatten_bottom: Optional[bool] = Field(False, description='Whether to flatten the bottom of the model')
226-
flatten_bottom_threshold: Optional[float] = Field(0.01, description='The threshold for flattening the bottom')
227-
texture_size: Optional[int] = Field(4096, description='The size of the texture')
242+
quad: Optional[bool] = Field(None, description='Whether to apply quad to the model')
243+
force_symmetry: Optional[bool] = Field(None, description='Whether to force symmetry')
244+
face_limit: Optional[int] = Field(None, description='The number of faces to limit the conversion to')
245+
flatten_bottom: Optional[bool] = Field(None, description='Whether to flatten the bottom of the model')
246+
flatten_bottom_threshold: Optional[float] = Field(None, description='The threshold for flattening the bottom')
247+
texture_size: Optional[int] = Field(None, description='The size of the texture')
228248
texture_format: Optional[TripoTextureFormat] = Field(TripoTextureFormat.JPEG, description='The format of the texture')
229-
pivot_to_center_bottom: Optional[bool] = Field(False, description='Whether to pivot to the center bottom')
249+
pivot_to_center_bottom: Optional[bool] = Field(None, description='Whether to pivot to the center bottom')
250+
scale_factor: Optional[float] = Field(None, description='The scale factor for the model')
251+
with_animation: Optional[bool] = Field(None, description='Whether to include animations')
252+
pack_uv: Optional[bool] = Field(None, description='Whether to pack the UVs')
253+
bake: Optional[bool] = Field(None, description='Whether to bake the model')
254+
part_names: Optional[List[str]] = Field(None, description='The names of the parts to include')
255+
fbx_preset: Optional[TripoFbxPreset] = Field(None, description='The preset for the FBX export')
256+
export_vertex_colors: Optional[bool] = Field(None, description='Whether to export the vertex colors')
257+
export_orientation: Optional[TripoOrientation] = Field(None, description='The orientation for the export')
258+
animate_in_place: Optional[bool] = Field(None, description='Whether to animate in place')
259+
230260

231261
class TripoTaskRequest(RootModel):
232262
root: Union[

comfy_api_nodes/nodes_tripo.py

Lines changed: 84 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -102,8 +102,9 @@ def define_schema(cls):
102102
IO.Int.Input("model_seed", default=42, optional=True),
103103
IO.Int.Input("texture_seed", default=42, optional=True),
104104
IO.Combo.Input("texture_quality", default="standard", options=["standard", "detailed"], optional=True),
105-
IO.Int.Input("face_limit", default=-1, min=-1, max=500000, optional=True),
105+
IO.Int.Input("face_limit", default=-1, min=-1, max=2000000, optional=True),
106106
IO.Boolean.Input("quad", default=False, optional=True),
107+
IO.Combo.Input("geometry_quality", default="standard", options=["standard", "detailed"], optional=True),
107108
],
108109
outputs=[
109110
IO.String.Output(display_name="model_file"),
@@ -131,6 +132,7 @@ async def execute(
131132
model_seed: Optional[int] = None,
132133
texture_seed: Optional[int] = None,
133134
texture_quality: Optional[str] = None,
135+
geometry_quality: Optional[str] = None,
134136
face_limit: Optional[int] = None,
135137
quad: Optional[bool] = None,
136138
) -> IO.NodeOutput:
@@ -154,6 +156,7 @@ async def execute(
154156
texture_seed=texture_seed,
155157
texture_quality=texture_quality,
156158
face_limit=face_limit,
159+
geometry_quality=geometry_quality,
157160
auto_size=True,
158161
quad=quad,
159162
),
@@ -194,6 +197,7 @@ def define_schema(cls):
194197
),
195198
IO.Int.Input("face_limit", default=-1, min=-1, max=500000, optional=True),
196199
IO.Boolean.Input("quad", default=False, optional=True),
200+
IO.Combo.Input("geometry_quality", default="standard", options=["standard", "detailed"], optional=True),
197201
],
198202
outputs=[
199203
IO.String.Output(display_name="model_file"),
@@ -220,6 +224,7 @@ async def execute(
220224
orientation=None,
221225
texture_seed: Optional[int] = None,
222226
texture_quality: Optional[str] = None,
227+
geometry_quality: Optional[str] = None,
223228
texture_alignment: Optional[str] = None,
224229
face_limit: Optional[int] = None,
225230
quad: Optional[bool] = None,
@@ -246,6 +251,7 @@ async def execute(
246251
pbr=pbr,
247252
model_seed=model_seed,
248253
orientation=orientation,
254+
geometry_quality=geometry_quality,
249255
texture_alignment=texture_alignment,
250256
texture_seed=texture_seed,
251257
texture_quality=texture_quality,
@@ -295,6 +301,7 @@ def define_schema(cls):
295301
),
296302
IO.Int.Input("face_limit", default=-1, min=-1, max=500000, optional=True),
297303
IO.Boolean.Input("quad", default=False, optional=True),
304+
IO.Combo.Input("geometry_quality", default="standard", options=["standard", "detailed"], optional=True),
298305
],
299306
outputs=[
300307
IO.String.Output(display_name="model_file"),
@@ -323,6 +330,7 @@ async def execute(
323330
model_seed: Optional[int] = None,
324331
texture_seed: Optional[int] = None,
325332
texture_quality: Optional[str] = None,
333+
geometry_quality: Optional[str] = None,
326334
texture_alignment: Optional[str] = None,
327335
face_limit: Optional[int] = None,
328336
quad: Optional[bool] = None,
@@ -359,6 +367,7 @@ async def execute(
359367
model_seed=model_seed,
360368
texture_seed=texture_seed,
361369
texture_quality=texture_quality,
370+
geometry_quality=geometry_quality,
362371
texture_alignment=texture_alignment,
363372
face_limit=face_limit,
364373
quad=quad,
@@ -508,13 +517,20 @@ def define_schema(cls):
508517
options=[
509518
"preset:idle",
510519
"preset:walk",
520+
"preset:run",
521+
"preset:dive",
511522
"preset:climb",
512523
"preset:jump",
513524
"preset:slash",
514525
"preset:shoot",
515526
"preset:hurt",
516527
"preset:fall",
517528
"preset:turn",
529+
"preset:quadruped:walk",
530+
"preset:hexapod:walk",
531+
"preset:octopod:walk",
532+
"preset:serpentine:march",
533+
"preset:aquatic:march"
518534
],
519535
),
520536
],
@@ -563,7 +579,7 @@ def define_schema(cls):
563579
"face_limit",
564580
default=-1,
565581
min=-1,
566-
max=500000,
582+
max=2000000,
567583
optional=True,
568584
),
569585
IO.Int.Input(
@@ -579,6 +595,40 @@ def define_schema(cls):
579595
default="JPEG",
580596
optional=True,
581597
),
598+
IO.Boolean.Input("force_symmetry", default=False, optional=True),
599+
IO.Boolean.Input("flatten_bottom", default=False, optional=True),
600+
IO.Float.Input(
601+
"flatten_bottom_threshold",
602+
default=0.0,
603+
min=0.0,
604+
max=1.0,
605+
optional=True,
606+
),
607+
IO.Boolean.Input("pivot_to_center_bottom", default=False, optional=True),
608+
IO.Float.Input(
609+
"scale_factor",
610+
default=1.0,
611+
min=0.0,
612+
optional=True,
613+
),
614+
IO.Boolean.Input("with_animation", default=False, optional=True),
615+
IO.Boolean.Input("pack_uv", default=False, optional=True),
616+
IO.Boolean.Input("bake", default=False, optional=True),
617+
IO.String.Input("part_names", default="", optional=True), # comma-separated list
618+
IO.Combo.Input(
619+
"fbx_preset",
620+
options=["blender", "mixamo", "3dsmax"],
621+
default="blender",
622+
optional=True,
623+
),
624+
IO.Boolean.Input("export_vertex_colors", default=False, optional=True),
625+
IO.Combo.Input(
626+
"export_orientation",
627+
options=["align_image", "default"],
628+
default="default",
629+
optional=True,
630+
),
631+
IO.Boolean.Input("animate_in_place", default=False, optional=True),
582632
],
583633
outputs=[],
584634
hidden=[
@@ -604,12 +654,31 @@ async def execute(
604654
original_model_task_id,
605655
format: str,
606656
quad: bool,
657+
force_symmetry: bool,
607658
face_limit: int,
659+
flatten_bottom: bool,
660+
flatten_bottom_threshold: float,
608661
texture_size: int,
609662
texture_format: str,
663+
pivot_to_center_bottom: bool,
664+
scale_factor: float,
665+
with_animation: bool,
666+
pack_uv: bool,
667+
bake: bool,
668+
part_names: str,
669+
fbx_preset: str,
670+
export_vertex_colors: bool,
671+
export_orientation: str,
672+
animate_in_place: bool,
610673
) -> IO.NodeOutput:
611674
if not original_model_task_id:
612675
raise RuntimeError("original_model_task_id is required")
676+
677+
# Parse part_names from comma-separated string to list
678+
part_names_list = None
679+
if part_names and part_names.strip():
680+
part_names_list = [name.strip() for name in part_names.split(',') if name.strip()]
681+
613682
response = await sync_op(
614683
cls,
615684
endpoint=ApiEndpoint(path="/proxy/tripo/v2/openapi/task", method="POST"),
@@ -618,9 +687,22 @@ async def execute(
618687
original_model_task_id=original_model_task_id,
619688
format=format,
620689
quad=quad if quad else None,
690+
force_symmetry=force_symmetry if force_symmetry else None,
621691
face_limit=face_limit if face_limit != -1 else None,
692+
flatten_bottom=flatten_bottom if flatten_bottom else None,
693+
flatten_bottom_threshold=flatten_bottom_threshold if flatten_bottom_threshold != 0.0 else None,
622694
texture_size=texture_size if texture_size != 4096 else None,
623695
texture_format=texture_format if texture_format != "JPEG" else None,
696+
pivot_to_center_bottom=pivot_to_center_bottom if pivot_to_center_bottom else None,
697+
scale_factor=scale_factor if scale_factor != 1.0 else None,
698+
with_animation=with_animation if with_animation else None,
699+
pack_uv=pack_uv if pack_uv else None,
700+
bake=bake if bake else None,
701+
part_names=part_names_list,
702+
fbx_preset=fbx_preset if fbx_preset != "blender" else None,
703+
export_vertex_colors=export_vertex_colors if export_vertex_colors else None,
704+
export_orientation=export_orientation if export_orientation != "default" else None,
705+
animate_in_place=animate_in_place if animate_in_place else None,
624706
),
625707
)
626708
return await poll_until_finished(cls, response, average_duration=30)

0 commit comments

Comments
 (0)