自动绑定和动画 API
自动绑定和动画 API 允许您通过编程方式对 3D 模型进行骨骼绑定,并为其应用动画,利用 Meshy 的后端能力。本节提供了集成这些功能所需的详细信息。
请注意,目前编程绑定与动画仅适用于标准人形(双足)资产,且需具备清晰的四肢和身体结构。
自动绑定 API
用于提交和获取角色绑定任务的接口。绑定过程包括创建内部骨架(骨架结构)并将模型的网格(皮肤)绑定到骨架上,使其可以进行动画处理。
创建绑定任务
该接口允许您为指定的 3D 模型创建新的绑定任务。任务完成后,将返回标准格式的已绑定角色,并可选提供基础的行走/奔跑动画。
当前,自动绑定不适用于以下模型:
- 无贴图网格
- 非人形资产
- 人形但四肢和身体结构不清晰的资产
使用 input_task_id 时,面数超过 300,000 的模型不支持绑定。请先使用 Remesh API 降低面数后再进行绑定。
参数
只需提供 input_task_id 或 model_url 其中之一(必选)。如果两者都提供,input_task_id 优先。
- Name
- input_task_id
- Type
- string
- 必选
- Description
需要进行绑定的输入任务 ID。目前仅支持带贴图的人形模型。
- Name
- model_url
- Type
- string
- 必选
- Description
请通过公开可访问的 URL 或 Data URI 提供需要绑定的 3D 模型。目前仅支持带贴图的人形 GLB 文件(.glb 格式)。
- Name
- height_meters
- Type
- number
- 默认值 1.7
- Description
角色模型的大致身高(单位:米)。有助于缩放和绑定精度。必须为正数。
- Name
- texture_image_url
- Type
- string
- Description
模型的 UV 展开基础色贴图。需为公开可访问的 URL 或 Data URI。目前仅支持
.png格式。
返回值
响应的 result 字段包含新建绑定任务的任务 id。
失败模式
- Name
400 - Bad Request- Description
请求不合法。常见原因:
- 缺少参数:必须提供
model_url或input_task_id其中之一。 - 模型格式无效:
model_url指向的文件扩展名不受支持(仅支持 .glb 格式)。 - URL 不可访问:
model_url无法下载。 - 输入任务无效:
input_task_id未指向有效的 API 任务。 - 面数超限:输入模型面数超过 300,000。请先使用 Remesh API 降低面数后再进行绑定。
- 缺少参数:必须提供
- Name
401 - Unauthorized- Description
认证失败。请检查您的 API 密钥。
- Name
402 - Payment Required- Description
积分不足,无法执行此任务。
- Name
422 - Unprocessable Entity- Description
姿态估计失败。提供的模型可能不是有效的人形角色。
- Name
429 - Too Many Requests- Description
您已超出请求频率限制。
请求
# 从 URL 绑定模型
curl https://api.meshy.ai/openapi/v1/rigging \
-X POST \
-H "Authorization: Bearer ${YOUR_API_KEY}" \
-H 'Content-Type: application/json' \
-d '{
"model_url": "YOUR_MODEL_URL_OR_DATA_URI",
"height_meters": 1.8
}'
响应
{
"result": "018b314a-a1b5-716d-c222-2f1776f7f579"
}
获取绑定任务
此端点允许您通过有效的任务 id 获取绑定任务。请参阅绑定任务对象了解包含的属性。
参数
- Name
- id
- Type
- path
- Description
要获取的绑定任务的唯一标识符。
返回
响应包含绑定任务对象。详情请查看绑定任务对象部分。
请求
curl https://api.meshy.ai/openapi/v1/rigging/018b314a-a1b5-716d-c222-2f1776f7f579
-H "Authorization: Bearer ${YOUR_API_KEY}"
响应
{
"id": "018b314a-a1b5-716d-c222-2f1776f7f579",
"type": "rig",
"status": "SUCCEEDED",
"created_at": 1747032400453,
"progress": 100,
"started_at": 1747032401314,
"finished_at": 1747032418417,
"expires_at": 1747291618417,
"task_error": {
"message": ""
},
"result": {
"rigged_character_fbx_url": "https://assets.meshy.ai/0630d47c-84b8-4d37-bc02-69e45d9272c1/tasks/018b314a-a1b5-716d-c222-2f1776f7f579/output/Character_output.fbx?Expires=...",
"rigged_character_glb_url": "https://assets.meshy.ai/0630d47c-84b8-4d37-bc02-69e45d9272c1/tasks/018b314a-a1b5-716d-c222-2f1776f7f579/output/Character_output.glb?Expires=...",
"basic_animations": {
"walking_glb_url": "https://assets.meshy.ai/0630d47c-84b8-4d37-bc02-69e45d9272c1/tasks/018b314a-a1b5-716d-c222-2f1776f7f579/output/Animation_Walking_withSkin.glb?Expires=...",
"walking_fbx_url": "https://assets.meshy.ai/0630d47c-84b8-4d37-bc02-69e45d9272c1/tasks/018b314a-a1b5-716d-c222-2f1776f7f579/output/Animation_Walking_withSkin.fbx?Expires=...",
"walking_armature_glb_url": "https://assets.meshy.ai/0630d47c-84b8-4d37-bc02-69e45d9272c1/tasks/018b314a-a1b5-716d-c222-2f1776f7f579/output/Animation_Walking_withSkin_armature.glb?Expires=...",
"running_glb_url": "https://assets.meshy.ai/0630d47c-84b8-4d37-bc02-69e45d9272c1/tasks/018b314a-a1b5-716d-c222-2f1776f7f579/output/Animation_Running_withSkin.glb?Expires=...",
"running_fbx_url": "https://assets.meshy.ai/0630d47c-84b8-4d37-bc02-69e45d9272c1/tasks/018b314a-a1b5-716d-c222-2f1776f7f579/output/Animation_Running_withSkin.fbx?Expires=...",
"running_armature_glb_url": "https://assets.meshy.ai/0630d47c-84b8-4d37-bc02-69e45d9272c1/tasks/018b314a-a1b5-716d-c222-2f1776f7f579/output/Animation_Running_withSkin_armature.glb?Expires=..."
}
},
"preceding_tasks": 0
}
删除绑定任务
此端点可永久删除一个绑定任务,包括所有相关的模型和数据。此操作不可逆。
路径参数
- Name
- id
- Type
- path
- Description
要删除的绑定任务的ID。
返回值
成功则返回 200 OK。
请求
curl --request DELETE \
--url https://api.meshy.ai/openapi/v1/rigging/018b314a-a1b5-716d-c222-2f1776f7f579 \
-H "Authorization: Bearer ${YOUR_API_KEY}"
响应
// 成功则返回 200 Ok。
流式获取绑定任务
此端点使用服务器发送事件(SSE)流式传输绑定任务的实时更新。
参数
- Name
- id
- Type
- path
- Description
要流式传输的绑定任务的唯一标识符。
返回
以服务器发送事件的形式返回绑定任务对象的流。
对于PENDING或IN_PROGRESS状态的任务,响应流将只包含必要的progress和status字段。
请求
curl -N https://api.meshy.ai/openapi/v1/rigging/018b314a-a1b5-716d-c222-2f1776f7f579/stream
-H "Authorization: Bearer ${YOUR_API_KEY}"
响应流
// 错误事件示例
event: error
data: {
"status_code": 404,
"message": "Task not found"
}
// 消息事件示例说明了任务进度
// 对于PENDING或IN_PROGRESS状态的任务,响应流不会包含所有字段
event: message
data: {
"id": "018b314a-a1b5-716d-c222-2f1776f7f579",
"progress": 0,
"status": "PENDING"
}
event: message
data: {
"id": "018b314a-a1b5-716d-c222-2f1776f7f579",
"progress": 50,
"status": "IN_PROGRESS"
}
event: message
data: { // Example of a SUCCEEDED task stream item, mirroring The Rigging Task Object structure
"id": "018b314a-a1b5-716d-c222-2f1776f7f579",
"type": "rig",
"status": "SUCCEEDED",
"created_at": 1747032400453,
"progress": 100,
"started_at": 1747032401314,
"finished_at": 1747032418417,
"expires_at": 1747291618417,
"task_error": {
"message": ""
},
"result": {
"rigged_character_fbx_url": "https://assets.meshy.ai/.../Character_output.fbx?...",
"rigged_character_glb_url": "https://assets.meshy.ai/.../Character_output.glb?...",
"basic_animations": {
"walking_glb_url": "https://assets.meshy.ai/.../Animation_Walking_withSkin.glb?...",
"walking_fbx_url": "https://assets.meshy.ai/.../Animation_Walking_withSkin.fbx?...",
"walking_armature_glb_url": "https://assets.meshy.ai/.../Animation_Walking_withSkin_armature.glb?...",
"running_glb_url": "https://assets.meshy.ai/.../Animation_Running_withSkin.glb?...",
"running_fbx_url": "https://assets.meshy.ai/.../Animation_Running_withSkin.fbx?...",
"running_armature_glb_url": "https://assets.meshy.ai/.../Animation_Running_withSkin_armature.glb?..."
}
},
"preceding_tasks": 0
}
绑定任务对象
绑定任务对象表示角色绑定的工作单元。
属性
- Name
- id
- Type
- string
- Description
任务的唯一标识符。
- Name
- type
- Type
- string
- Description
绑定任务的类型。值为
rig。
- Name
- status
- Type
- string
- Description
任务状态。可能的值:
PENDING(等待中)、IN_PROGRESS(进行中)、SUCCEEDED(成功)、FAILED(失败)、CANCELED(已取消)。
- Name
- progress
- Type
- integer
- Description
任务进度(0-100)。未开始时为
0,成功时为100。
- Name
- created_at
- Type
- timestamp
- Description
任务创建时的时间戳(自1970年1月1日UTC以来的毫秒数)。
时间戳表示自1970年1月1日UTC以来经过的毫秒数,遵循 RFC 3339
标准。 例如,2023年9月1日星期五12:00:00 PM GMT表示为1693569600000。这适用于 Meshy API中的所有时间戳。
- Name
- started_at
- Type
- timestamp
- Description
任务开始处理时的时间戳。未开始时为
0。
- Name
- finished_at
- Type
- timestamp
- Description
任务完成时的时间戳。未完成时为
0。
- Name
- expires_at
- Type
- timestamp
- Description
任务结果资源过期并可被删除时的时间戳。
- Name
- task_error
- Type
- object
- Description
任务失败时的错误对象,否则为包含空消息字符串的对象。详情请参阅 Errors。
- Name
message- Type
- string
- Description
- 详细错误信息。任务成功时为空。
- Name
- result
- Type
- object
- Description
任务
SUCCEEDED时包含输出资源URL,否则为null。- Name
rigged_character_fbx_url- Type
- string
- Description
已绑定角色的FBX格式可下载URL。
- Name
rigged_character_glb_url- Type
- string
- Description
已绑定角色的GLB格式可下载URL。
- Name
basic_animations- Type
- object (optional)
- Description
包含默认动画的URL。(例如,如果
generate_basic_animations默认为true或默认启用)。- Name
walking_glb_url- Type
- string
- Description
- 行走动画的GLB格式可下载URL(带蒙皮)。
- Name
walking_fbx_url- Type
- string
- Description
- 行走动画的FBX格式可下载URL(带蒙皮)。
- Name
walking_armature_glb_url- Type
- string
- Description
- 行走动画骨架的GLB格式可下载URL。
- Name
running_glb_url- Type
- string
- Description
- 跑步动画的GLB格式可下载URL(带蒙皮)。
- Name
running_fbx_url- Type
- string
- Description
- 跑步动画的FBX格式可下载URL(带蒙皮)。
- Name
running_armature_glb_url- Type
- string
- Description
- 跑步动画骨架的GLB格式可下载URL。
- Name
- preceding_tasks
- Type
- integer
- Description
队列中前置任务的数量。仅在状态为
PENDING时有意义。
绑定任务对象示例
{
"id": "018b314a-a1b5-716d-c222-2f1776f7f579",
"type": "rig",
"status": "SUCCEEDED",
"created_at": 1747032400453,
"progress": 100,
"started_at": 1747032401314,
"finished_at": 1747032418417,
"expires_at": 1747291618417,
"task_error": {
"message": ""
},
"result": {
"rigged_character_fbx_url": "https://assets.meshy.ai/0630d47c-84b8-4d37-bc02-69e45d9272c1/tasks/018b314a-a1b5-716d-c222-2f1776f7f579/output/Character_output.fbx?Expires=...",
"rigged_character_glb_url": "https://assets.meshy.ai/0630d47c-84b8-4d37-bc02-69e45d9272c1/tasks/018b314a-a1b5-716d-c222-2f1776f7f579/output/Character_output.glb?Expires=...",
"basic_animations": {
"walking_glb_url": "https://assets.meshy.ai/0630d47c-84b8-4d37-bc02-69e45d9272c1/tasks/018b314a-a1b5-716d-c222-2f1776f7f579/output/Animation_Walking_withSkin.glb?Expires=...",
"walking_fbx_url": "https://assets.meshy.ai/0630d47c-84b8-4d37-bc02-69e45d9272c1/tasks/018b314a-a1b5-716d-c222-2f1776f7f579/output/Animation_Walking_withSkin.fbx?Expires=...",
"walking_armature_glb_url": "https://assets.meshy.ai/0630d47c-84b8-4d37-bc02-69e45d9272c1/tasks/018b314a-a1b5-716d-c222-2f1776f7f579/output/Animation_Walking_withSkin_armature.glb?Expires=...",
"running_glb_url": "https://assets.meshy.ai/0630d47c-84b8-4d37-bc02-69e45d9272c1/tasks/018b314a-a1b5-716d-c222-2f1776f7f579/output/Animation_Running_withSkin.glb?Expires=...",
"running_fbx_url": "https://assets.meshy.ai/0630d47c-84b8-4d37-bc02-69e45d9272c1/tasks/018b314a-a1b5-716d-c222-2f1776f7f579/output/Animation_Running_withSkin.fbx?Expires=...",
"running_armature_glb_url": "https://assets.meshy.ai/0630d47c-84b8-4d37-bc02-69e45d9272c1/tasks/018b314a-a1b5-716d-c222-2f1776f7f579/output/Animation_Running_withSkin_armature.glb?Expires=..."
}
},
"preceding_tasks": 0
}