覆盖文生 3D、图生 3D、多视图、批量生成,以及重拓扑、绑定、动画、智能分割、 纹理、PBR、智能 UV、部件补全、格式导出与下载。 代码组织:一个功能一个模块(tripo/features/),入口薄壳 tripocli.py。
48 lines
1.4 KiB
Python
48 lines
1.4 KiB
Python
"""Global settings (API base, device id).
|
|
|
|
Credentials live in ``tripo/accounts.py``; this module only holds the non-secret
|
|
settings, in ``~/.tripo/config.json``.
|
|
"""
|
|
|
|
import json
|
|
import os
|
|
from pathlib import Path
|
|
|
|
DEFAULT_CONFIG_PATH = Path.home() / ".tripo" / "config.json"
|
|
DEFAULT_API_BASE = "https://api.tripo3d.ai"
|
|
DEFAULT_DEVICE_ID = "2c3443d027e6d5d268e9e9af3bdbf3ec"
|
|
|
|
|
|
class Config:
|
|
def __init__(self, path=None):
|
|
self.path = Path(path) if path else DEFAULT_CONFIG_PATH
|
|
self.data = {}
|
|
self.load()
|
|
|
|
def load(self):
|
|
if self.path.exists():
|
|
try:
|
|
self.data = json.loads(self.path.read_text(encoding="utf-8"))
|
|
except Exception:
|
|
self.data = {}
|
|
else:
|
|
self.data = {}
|
|
|
|
def save(self):
|
|
self.path.parent.mkdir(parents=True, exist_ok=True)
|
|
self.path.write_text(json.dumps(self.data, indent=2, ensure_ascii=False), encoding="utf-8")
|
|
|
|
@property
|
|
def api_base(self):
|
|
return os.environ.get("TRIPO_API_BASE") or self.data.get("api_base") or DEFAULT_API_BASE
|
|
|
|
@property
|
|
def device_id(self):
|
|
return os.environ.get("TRIPO_DEVICE_ID") or self.data.get("device_id") or DEFAULT_DEVICE_ID
|
|
|
|
def set(self, **kwargs):
|
|
for key, value in kwargs.items():
|
|
if value is not None:
|
|
self.data[key] = value
|
|
self.save()
|