"""动作预设目录。 数据来自 studio 前端的静态表(页面加载的 chunk 里的 ``biped:[{action_type,category,name}...]``), 因为服务端**没有**提供预设清单接口(实测:``/motion/list_assets`` 返回的是用户自己的动画资产, ``/operation/get_user_operation_context`` 只返回「最近用过」的几个)。 动作标识格式:``preset::``,例如 ``preset:biped:afraid``。 每个动作的预览图:``https://tripo-public.tripo3d.ai/studio_riging_data//.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"