# アニメーションのリターゲティング

> **POST** `/v3/animations/retarget`

プリセット アニメーションをリグ付き 3D モデルに適用します。

## リクエストパラメータ

### リクエストヘッダー

| パラメータ | 種類 | 必須 | デフォルト | 説明 |
| :-: | :-: | :-: | :-: | :-: |
| Content-Type | 文字列 | はい | — | `application/json` |
| Authorization | 文字列 | はい | — | `Bearer {api_key}` |

### リクエストボディ

| パラメータ | 種類 | 必須 | デフォルト | 説明 |
| :-: | :-: | :-: | :-: | :-: |
| input | 文字列 | はい | — | `task_` で始まるリグモデルの task_id |
| animation | 文字列 | 条件付きで必須 | — | 単一のプリセットアニメーション識別子。 `animations` と相互に排他的です。利用可能な値については、以下のプリセット アニメーション リストを参照してください。 |
| animations | 文字列[] | 条件付きで必須 | — | 複数のプリセットアニメーション識別子のリスト。 `animation` と相互排他的 |
| out_format | 文字列 | いいえ | `glb` | 出力形式。可能な値: `glb`、`fbx` |
| bake_animation | ブール値 | いいえ | `true` | アニメーションをモデルにベイク処理します。 `glb`出力のみ有効 |
| export_with_geometry | ブール値 | いいえ | `true` | ジオメトリを含めてエクスポート |
| animate_in_place | ブール値 | いいえ | `false` | アニメーションをディスプレイスメントなしでその場で再生します |

### プリセットアニメーション一覧

使用可能なプリセットは、上流の `POST /v3/animations/rig` ステップで使用される **リグ モデル バージョン**によって異なります。

#### リグ v2.0 / v2.5 — すべてのリグ タイプ

| アニメーション識別子 | 説明 |
| :-: | :-: |
| `preset:idle` | アイドル状態 |
| `preset:walk` | 歩く |
| `preset:run` | 走る |
| `preset:dive` | ダイブ |
| `preset:climb` | 登る |
| `preset:jump` | ジャンプ |
| `preset:slash` | スラッシュ |
| `preset:shoot` | シュート |
| `preset:hurt` | 傷ついた |
| `preset:fall` | 秋 |
| `preset:turn` | ターン |
| `preset:quadruped:walk` | 四足歩行 |
| `preset:hexapod:walk` | ヘキサポッドウォーク |
| `preset:octopod:walk` | タコ足の散歩 |
| `preset:serpentine:march` | 蛇行運動 |
| `preset:aquatic:march` | 水中移動 |

#### リグ v1.0 — Biped のみ (90 以上のプリセット)

上流のリグ タスクで `v1.0-20240301` が使用された場合にのみ使用できます。感情、スポーツ、戦闘、ダンス、日常の行動をカバーします。

<詳細>
<概要><strong>クリックして Biped プリセット リスト全体を展開します</strong></summary>

| アニメーション識別子 | カテゴリ |
| :-: | :-: |
| `preset:biped:idle` | 基本 |
| `preset:biped:walk` | 基本 |
| `preset:biped:run` | 基本 |
| `preset:biped:run_upstairs` | 基本 |
| `preset:biped:turn` | 基本 |
| `preset:biped:jump` | 基本 |
| `preset:biped:jump_down` | 基本 |
| `preset:biped:jump_rope_01` | 基本 |
| `preset:biped:jump_rope_02` | 基本 |
| `preset:biped:fall` | 基本 |
| `preset:biped:climb` | 基本 |
| `preset:biped:dive` | 基本 |
| `preset:biped:swim` | 基本 |
| `preset:biped:surf` | 基本 |
| `preset:biped:flip` | 基本 |
| `preset:biped:sit` | 基本 |
| `preset:biped:standing_relax` | 基本 |
| `preset:biped:look_around` | 基本 |
| `preset:biped:wait` | 基本 |
| `preset:biped:swagger` | 基本 |
| `preset:biped:dance_01` | ダンス |
| `preset:biped:dance_02` | ダンス |
| `preset:biped:dance_03` | ダンス |
| `preset:biped:dance_04` | ダンス |
| `preset:biped:dance_05` | ダンス |
| `preset:biped:dance_06` | ダンス |
| `preset:biped:freaky` | ダンス |
| `preset:biped:sing_01` | パフォーマンス |
| `preset:biped:sing_02` | パフォーマンス |
| `preset:biped:sing_03` | パフォーマンス |
| `preset:biped:sing_04` | パフォーマンス |
| `preset:biped:cheer` | パフォーマンス |
| `preset:biped:clap` | 感情 |
| `preset:biped:bow` | 感情 |
| `preset:biped:greet_01` | 感情 |
| `preset:biped:greet_02` | 感情 |
| `preset:biped:greet_03` | 感情 |
| `preset:biped:greet_04` | 感情 |
| `preset:biped:wave_goodbye_01` | 感情 |
| `preset:biped:wave_goodbye_02` | 感情 |
| `preset:biped:agree` | 感情 |
| `preset:biped:heart_pose` | 感情 |
| `preset:biped:hug` | 感情 |
| `preset:biped:fold_arms` | 感情 |
| `preset:biped:laugh_01` | 感情 |
| `preset:biped:laugh_02` | 感情 |
| `preset:biped:cry` | 感情 |
| `preset:biped:sob` | 感情 |
| `preset:biped:afraid` | 感情 |
| `preset:biped:frightened` | 感情 |
| `preset:biped:scared_01` | 感情 |
| `preset:biped:scared_02` | 感情 |
| `preset:biped:angry_01` | 感情 |
| `preset:biped:angry_02` | 感情 |
| `preset:biped:angry_03` | 感情 |
| `preset:biped:depressed` | 感情 |
| `preset:biped:frustrated_01` | 感情 |
| `preset:biped:frustrated_02` | 感情 |
| `preset:biped:complain_01` | 感情 |
| `preset:biped:complain_02` | 感情 |
| `preset:biped:victory_celebration` | 感情 |
| `preset:biped:defeat_02` | 感情 |
| `preset:biped:defeat_03` | 感情 |
| `preset:biped:scratch` | 毎日 |
| `preset:biped:make_a_call_01` | 毎日 |
| `preset:biped:make_a_call_02` | 毎日 |
| `preset:biped:play_mobile_game` | 毎日 |
| `preset:biped:play_video_game` | 毎日 |
| `preset:biped:dig` | 毎日 |
| `preset:biped:chop` | 毎日 |
| `preset:biped:shovel` | 毎日 |
| `preset:biped:lift_heavy` | 毎日 |
| `preset:biped:warm_up` | スポーツ |
| `preset:biped:press-up` | スポーツ |
| `preset:biped:cross_body_crunch` | スポーツ |
| `preset:biped:basketball_shot` | スポーツ |
| `preset:biped:crossover_dribble` | スポーツ |
| `preset:biped:dribble` | スポーツ |
| `preset:biped:pitch_baseball` | スポーツ |
| `preset:biped:golf` | スポーツ |
| `preset:biped:volleyball` | スポーツ |
| `preset:biped:football_catch` | スポーツ |
| `preset:biped:football_save` | スポーツ |
| `preset:biped:football_pass` | スポーツ |
| `preset:biped:box_01` | 戦闘 |
| `preset:biped:box_02` | 戦闘 |
| `preset:biped:box_03` | 戦闘 |
| `preset:biped:front_kick_01` | 戦闘 |
| `preset:biped:front_kick_02` | 戦闘 |
| `preset:biped:slash` | 戦闘 |
| `preset:biped:shoot` | 戦闘 |
| `preset:biped:fire` | 戦闘 |
| `preset:biped:cast_a_spell` | 戦闘 |
| `preset:biped:hurt` | 戦闘 |
| `preset:biped:hit_to_body_01` | 戦闘 |
| `preset:biped:hit_to_body_02` | 戦闘 |
| `preset:biped:hit_to_head` | 戦闘 |
| `preset:biped:hit_to_side` | 戦闘 |
| `preset:biped:hit_to_stomach` | 戦闘 |
| `preset:biped:flee_01` | 戦闘 |
| `preset:biped:flee_02` | 戦闘 |

</details>

## リクエスト例

### curl

```bash
curl -X POST https://openapi.tripo3d.ai/v3/animations/retarget \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer {api_key}" \
  -d '{
    "input": "task_abc123",
    "animation": "preset:walk",
    "out_format": "glb",
    "bake_animation": true,
    "animate_in_place": false
  }'
```

### Python

```python
import requests

url = "https://openapi.tripo3d.ai/v3/animations/retarget"
headers = {
    "Content-Type": "application/json",
    "Authorization": "Bearer {api_key}"
}
payload = {
    "input": "task_abc123",
    "animation": "preset:walk",
    "out_format": "glb",
    "bake_animation": True,
    "animate_in_place": False
}

response = requests.post(url, headers=headers, json=payload)
print(response.json())
```

### JavaScript

```javascript
const url = "https://openapi.tripo3d.ai/v3/animations/retarget";

const response = await fetch(url, {
  method: "POST",
  headers: {
    "Content-Type": "application/json",
    "Authorization": "Bearer {api_key}"
  },
  body: JSON.stringify({
    input: "task_abc123",
    animation: "preset:walk",
    out_format: "glb",
    bake_animation: true,
    animate_in_place: false
  })
});

const data = await response.json();
console.log(data);
```

## 応答

### 成功した応答

```json
{
  "code": 0,
  "data": {
    "task_id": "task_def456"
  }
}
```

### 応答フィールド

| パラメータ | 種類 | 説明 |
| :-: | :-: | :-: |
| code | 整数 | ステータスコード。 `0` は成功を示します |
| data.task_id | 文字列 | アニメーションのリターゲットの進行状況と結果をポーリングするために使用される一意のタスク識別子 |

## エラーコード

| HTTP ステータスコード | エラーコード | 説明 | おすすめ |
| :-: | :-: | :-: | :-: |
| 429 | 2000 | 世代制限を超えました | リクエスト率を下げて後で再試行してください |
| 400 | 2002 | サポートされていないリクエストパラメータです | リクエストボディのパラメータ名と値の範囲を確認してください |
| 400 | 2006 | 入力ソースのタスクタイプが無効です | task_id がリグモデルに対応していることを確認します |
| 400 | 2007 | ソースタスクのステータスが成功ではありません | アニメーションのリターゲットを開始する前に、ソース タスクが完了するまで待ってください。 |
| 403 | 2010 | クレジットが不十分です | クレジットをリチャージして再試行してください |
