Files
tripocli/tripo/motions.py
T
Mrpzx 977f97995a tripocli v2.0.0:Tripo AI 3D 生成与加工 CLI(面向 Agent 与开发者,纯 Python 标准库、零第三方依赖)
覆盖文生 3D、图生 3D、多视图、批量生成,以及重拓扑、绑定、动画、智能分割、
纹理、PBR、智能 UV、部件补全、格式导出与下载。

代码组织:一个功能一个模块(tripo/features/),入口薄壳 tripocli.py。
2026-10-13 19:22:54 +08:00

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"