覆盖文生 3D、图生 3D、多视图、批量生成,以及重拓扑、绑定、动画、智能分割、 纹理、PBR、智能 UV、部件补全、格式导出与下载。 代码组织:一个功能一个模块(tripo/features/),入口薄壳 tripocli.py。
45 lines
1.3 KiB
Python
45 lines
1.3 KiB
Python
"""动作预设目录。
|
|
|
|
数据来自 studio 前端的静态表(页面加载的 chunk 里的 ``biped:[{action_type,category,name}...]``),
|
|
因为服务端**没有**提供预设清单接口(实测:``/motion/list_assets`` 返回的是用户自己的动画资产,
|
|
``/operation/get_user_operation_context`` 只返回「最近用过」的几个)。
|
|
|
|
动作标识格式:``preset:<rig_type>:<name>``,例如 ``preset:biped:afraid``。
|
|
每个动作的预览图:``https://tripo-public.tripo3d.ai/studio_riging_data/<rig_type>/<name>.avif``
|
|
"""
|
|
|
|
import json
|
|
from pathlib import Path
|
|
|
|
DATA_PATH = Path(__file__).parent / "data" / "motions.json"
|
|
PREVIEW_BASE = "https://tripo-public.tripo3d.ai/studio_riging_data"
|
|
|
|
_cache = None
|
|
|
|
|
|
def catalog():
|
|
"""``{rig_type: [{action_type, category, name}, ...]}``"""
|
|
global _cache
|
|
if _cache is None:
|
|
try:
|
|
_cache = json.loads(DATA_PATH.read_text(encoding="utf-8"))
|
|
except (OSError, json.JSONDecodeError):
|
|
_cache = {}
|
|
return _cache
|
|
|
|
|
|
def rig_types():
|
|
return sorted(catalog())
|
|
|
|
|
|
def names(rig_type="biped"):
|
|
return [item["name"] for item in catalog().get(rig_type, [])]
|
|
|
|
|
|
def identifier(rig_type, name):
|
|
return f"preset:{rig_type}:{name}"
|
|
|
|
|
|
def preview_url(rig_type, name):
|
|
return f"{PREVIEW_BASE}/{rig_type}/{name}.avif"
|