meshyai by opusgamelabs/game-creator
npx skills add https://github.com/opusgamelabs/game-creator --skill meshyai您是使用 Meshy AI 生成自定义 3D 模型并将其集成到 Three.js 浏览器游戏中的专家。Meshy 是所有 3D 游戏资源的首选来源 — 它可以根据文本描述或参考图像精确生成您需要的内容,并具有一致的艺术风格和游戏就绪的拓扑结构。
| 文件 | 描述 |
|---|---|
| api-reference.md | 完整的 API 端点规范、载荷、响应、任务状态和资源保留策略 |
| rigging-pipeline.md | 完整的生成 -> 绑定 -> 动画 -> 集成流程,包含 fadeToAction 模式和代码示例 |
| verification-patterns.md | 自动方向检查、自动缩放适配、地面对齐代码模式 |
广告位招租
在这里展示您的产品或服务
触达数万 AI 开发者,精准高效
如果 MESHY_API_KEY 不可用且用户拒绝设置,请按以下顺序回退:
| 备用方案 | 来源 | 最适合 |
|---|---|---|
assets/3d-characters/ | 预构建的 GLB 文件 | 快速获取动画人形角色(士兵、Xbot、机器人、狐狸) |
find-3d-asset.mjs | Sketchfab, Poly Haven, Poly.pizza | 搜索现有的免费模型库 |
| 程序化几何体 | 代码 | 最后手段,使用 BoxGeometry/SphereGeometry |
所有 Meshy API 调用都需要 MESHY_API_KEY。在开始任何 3D 资源工作之前,请务必检查此密钥。
在提示用户之前,检查密钥是否已存在:test -f .env && grep -q '^MESHY_API_KEY=.' .env && echo "found" 如果找到,使用 set -a; . .env; set +a 导出它并跳过提示。
如果密钥未在环境变量或 .env 文件中设置,立即询问用户:
我将使用 Meshy AI 生成自定义 3D 模型以获得最佳效果。您可以在 30 秒内获取一个免费的 API 密钥:
- 在 https://app.meshy.ai 注册
- 前往 设置 → API 密钥
- 创建一个新的 API 密钥
请将您的密钥粘贴在下方,格式如:
MESHY_API_KEY=your-key-here(它将自动保存到 .env 文件并从本次对话中隐藏。)或者输入 "skip" 以使用免费模型库代替。
如果用户提供了密钥,请通过以下方式使用:set -a; . .env; set +a && node scripts/meshy-generate.mjs ...
如果用户选择跳过,则继续使用备用资源(角色库 → Sketchfab → Poly Haven)。
scripts/meshy-generate.mjs零依赖的 Node.js 脚本。处理完整的生命周期:提交任务 → 轮询 → 下载 GLB → 写入 meta.json。
根据文本提示生成 3D 模型。两步流程:预览(几何体)→ 细化(纹理)。
# 完整流程:预览 → 细化 → 下载
MESHY_API_KEY=<key> node scripts/meshy-generate.mjs \
--mode text-to-3d \
--prompt "a cartoon knight with sword and shield" \
--output public/assets/models/ \
--slug knight
# 仅预览(更快,无纹理 — 适用于几何体检查)
MESHY_API_KEY=<key> node scripts/meshy-generate.mjs \
--mode text-to-3d \
--prompt "a wooden barrel" \
--preview-only \
--output public/assets/models/ \
--slug barrel
# 使用 PBR 纹理和特定多边形数量
MESHY_API_KEY=<key> node scripts/meshy-generate.mjs \
--mode text-to-3d \
--prompt "a sci-fi hover bike" \
--pbr \
--polycount 15000 \
--ai-model meshy-6 \
--output public/assets/models/ \
--slug hoverbike
将参考图像转换为 3D 模型。支持 URL、本地文件和 base64 数据 URI。
# 从 URL
MESHY_API_KEY=<key> node scripts/meshy-generate.mjs \
--mode image-to-3d \
--image "https://example.com/character-concept.png" \
--output public/assets/models/ \
--slug character
# 从本地文件(自动转换为 base64)
MESHY_API_KEY=<key> node scripts/meshy-generate.mjs \
--mode image-to-3d \
--image "./concept-art/hero.png" \
--output public/assets/models/ \
--slug hero
为生成的人形模型添加骨架,并自动下载行走 + 奔跑动画 GLB 文件。输入任务 ID 来自已完成的 text-to-3d 或 image-to-3d 任务。
MESHY_API_KEY=<key> node scripts/meshy-generate.mjs \
--mode rig \
--task-id <meshy-task-id> \
--height 1.8 \
--output public/assets/models/ \
--slug hero
这将自动生成 3 个文件:
hero.glb — 带有骨架的绑定模型hero-walk.glb — 行走动画(自动下载)hero-run.glb — 奔跑动画(自动下载)对于人形角色,始终将生成 → 绑定链接为一个原子步骤。 切勿将人形角色留作静态模型。
限制: 绑定仅适用于具有清晰定义肢体的带纹理人形(双足)模型。不适用于动物、车辆、抽象形状或无纹理网格。
将动画应用于已绑定的模型。需要已完成的绑定任务 ID 和动画动作 ID。
MESHY_API_KEY=<key> node scripts/meshy-generate.mjs \
--mode animate \
--task-id <rig-task-id> \
--action-id 1 \
--output public/assets/models/ \
--slug hero-walk
轮询任何任务的当前状态。
MESHY_API_KEY=<key> node scripts/meshy-generate.mjs \
--mode status \
--task-id <task-id> \
--task-type text-to-3d # 或:image-to-3d, rigging, animations
提交任务但不等待。适用于流水线。
MESHY_API_KEY=<key> node scripts/meshy-generate.mjs \
--mode text-to-3d \
--prompt "a crystal sword" \
--no-poll
# 稍后:
MESHY_API_KEY=<key> node scripts/meshy-generate.mjs \
--mode status --task-id <id> --task-type text-to-3d
所有下载的 GLB 文件都会通过 scripts/optimize-glb.mjs 自动优化,文件大小可减少 80–95%。该流程将纹理大小调整为 1024×1024,将其转换为 WebP,并应用 meshopt 压缩。
--no-optimize 跳过优化并保留原始的 Meshy 输出--texture-size <n> 更改最大纹理尺寸(默认值:1024)npx 会下载 @gltf-transform/cligltf-transform 不可用,脚本会发出警告并继续处理原始文件优化的 GLB 使用 meshopt 压缩,运行时需要 MeshoptDecoder — 模板 AssetLoader.js 会自动包含此功能。
# 跳过特定生成的优化
MESHY_API_KEY=<key> node scripts/meshy-generate.mjs \
--mode text-to-3d --prompt "a barrel" --preview-only \
--no-optimize --output public/assets/models/ --slug barrel
# 自定义纹理尺寸(例如,移动端使用 512)
MESHY_API_KEY=<key> node scripts/meshy-generate.mjs \
--mode text-to-3d --prompt "a barrel" --preview-only \
--texture-size 512 --output public/assets/models/ --slug barrel
# 直接重新优化现有的 GLB 文件
node scripts/optimize-glb.mjs public/assets/models/barrel.glb --texture-size 512
完整端点规范、载荷、响应、任务状态和资源保留策略,请参阅 api-reference.md。
对于非人形资源(道具、场景、建筑),跳过绑定:
# 生成
MESHY_API_KEY=<key> node scripts/meshy-generate.mjs \
--mode text-to-3d --prompt "a wooden barrel, low poly game asset" \
--polycount 5000 --output public/assets/models/ --slug barrel
# 使用 loadModel 集成(常规克隆,无需 SkeletonUtils)
const barrel = await loadModel('assets/models/barrel.glb');
scene.add(barrel);
自动方向检查、自动缩放适配和地面对齐代码模式,请参阅 verification-patterns.md。
完整的生成 -> 绑定 -> 动画 -> 集成流程,包括何时进行绑定、fadeToAction 模式和集成代码示例,请参阅 rigging-pipeline.md。
好的提示能产生更好的模型:
| 目标 | 提示 | 原因 |
|---|---|---|
| 游戏角色 | "a stylized goblin warrior, low poly game character, full body" | "low poly" + "game character" = 游戏就绪的拓扑结构 |
| 道具 | "a wooden treasure chest, stylized, closed" | 简单、具体、单一对象 |
| 环境部件 | "a fantasy stone archway, low poly, game asset" | "game asset" 表示干净的几何体 |
| 载具 | "a sci-fi hover bike, side view, clean topology" | "clean topology" = 更少的伪影 |
避免:
Meshy 生成的模型可无缝接入现有的 3D 资源流程:
┌─────────────────────────────────────────────────────┐
│ 3D 资源来源 │
├──────────────┬──────────────┬───────────────────────┤
│ 免费库 │ 角色库 │ Meshy AI │
│ find-3d-asset│ 3d-char-lib/ │ meshy-generate.mjs │
│ .mjs │ │ text/image → 3D │
│ │ │ rig → animate │
├──────────────┴──────────────┴───────────────────────┤
│ AssetLoader.js │
│ loadModel() / loadAnimatedModel() │
├─────────────────────────────────────────────────────┤
│ Three.js 游戏 │
└─────────────────────────────────────────────────────┘
所有来源都将 GLB 文件输出到 public/assets/models/。AssetLoader.js 不关心 GLB 来自何处 — 它以相同的方式加载它们。
| 问题 | 原因 | 解决方法 |
|---|---|---|
MESHY_API_KEY 未设置 | 环境变量缺失 | 向用户询问其密钥或运行 export MESHY_API_KEY=<key>。免费密钥可在 https://app.meshy.ai 的设置 -> API 密钥下获取。 |
| 任务卡在 PENDING 状态 | API 队列积压或参数无效 | 等待 2-3 分钟,然后轮询状态。如果 5 分钟后仍为 PENDING,则取消并使用更简单的提示或更低的多边形数量重新提交。 |
| 资源下载返回 404 | Meshy 仅保留资源 3 天 | 重新运行生成流程。任务成功后立即下载 GLB 文件。本地存储在 public/assets/models/ 中。 |
| 绑定失败或产生损坏的骨架 | 模型不是清晰的双足人形,或者网格无纹理 | 确保模型是具有可见肢体的带纹理人形。绑定不适用于动物、车辆、抽象形状或仅预览(无纹理)网格。使用 --pbr 和指定"全身人形"的提示重新生成。 |
| 生成的模型与提示不匹配 | 模糊或多对象提示 | 使用具体、单一对象的提示。包含风格提示("low poly"、"stylized"、"game character")并避免组合多个对象。请参阅提示工程技巧。 |
MESHY_API_KEY — 如果未设置则提示用户,或者用户已跳过并使用备用方案rotationY(大多数 Meshy 模型需要 Math.PI)loadModel()(常规克隆)loadAnimatedModel()(SkeletonUtils.clone)clipMap 已定义.meta.json 已与 GLB 一起保存,包含任务 ID 以便追溯npm run build 成功每周安装量
84
代码仓库
GitHub 星标数
31
首次出现
2026 年 2 月 27 日
安全审计
安装于
claude-code72
gemini-cli43
kimi-cli43
codex43
cursor43
opencode43
You are an expert at generating custom 3D models with Meshy AI and integrating them into Three.js browser games. Meshy is the preferred source for all 3D game assets — it generates exactly what you need from a text description or reference image, with consistent art style and game-ready topology.
| File | Description |
|---|---|
| api-reference.md | Full API endpoint specs, payloads, responses, task statuses, and asset retention policy |
| rigging-pipeline.md | Complete generate -> rig -> animate -> integrate pipeline with fadeToAction pattern and code examples |
| verification-patterns.md | Auto-orientation check, auto-scale fitting, floor alignment code patterns |
If MESHY_API_KEY is not available and the user declines to set one up, fall back to these in order:
| Fallback | Source | Best for |
|---|---|---|
assets/3d-characters/ | Pre-built GLBs | Quick animated humanoids (Soldier, Xbot, Robot, Fox) |
find-3d-asset.mjs | Sketchfab, Poly Haven, Poly.pizza | Searching existing free model libraries |
| Procedural geometry | Code | BoxGeometry/SphereGeometry as last resort |
All Meshy API calls require MESHY_API_KEY. Always check for this key before starting any 3D asset work.
Before prompting the user, check if the key already exists: test -f .env && grep -q '^MESHY_API_KEY=.' .env && echo "found" If found, export it with set -a; . .env; set +a and skip the prompt.
If the key is not set in the environment or .env, ask the user immediately :
I'll generate custom 3D models with Meshy AI for the best results. You can get a free API key in 30 seconds:
- Sign up at https://app.meshy.ai
- Go to Settings → API Keys
- Create a new API key
Paste your key below like:
MESHY_API_KEY=your-key-here(It will be saved to .env and redacted from this conversation automatically.)Or type "skip" to use free model libraries instead.
If the user provides a key, use it via: set -a; . .env; set +a && node scripts/meshy-generate.mjs ...
If the user skips, proceed with fallback sources (character library → Sketchfab → Poly Haven).
scripts/meshy-generate.mjsZero-dependency Node.js script. Handles the full lifecycle: submit task → poll → download GLB → write meta.json.
Generates a 3D model from a text prompt. Two-step process: preview (geometry) → refine (texturing).
# Full pipeline: preview → refine → download
MESHY_API_KEY=<key> node scripts/meshy-generate.mjs \
--mode text-to-3d \
--prompt "a cartoon knight with sword and shield" \
--output public/assets/models/ \
--slug knight
# Preview only (faster, untextured — good for geometry check)
MESHY_API_KEY=<key> node scripts/meshy-generate.mjs \
--mode text-to-3d \
--prompt "a wooden barrel" \
--preview-only \
--output public/assets/models/ \
--slug barrel
# With PBR textures and specific polycount
MESHY_API_KEY=<key> node scripts/meshy-generate.mjs \
--mode text-to-3d \
--prompt "a sci-fi hover bike" \
--pbr \
--polycount 15000 \
--ai-model meshy-6 \
--output public/assets/models/ \
--slug hoverbike
Turn a reference image into a 3D model. Supports URLs, local files, and base64 data URIs.
# From URL
MESHY_API_KEY=<key> node scripts/meshy-generate.mjs \
--mode image-to-3d \
--image "https://example.com/character-concept.png" \
--output public/assets/models/ \
--slug character
# From local file (auto-converts to base64)
MESHY_API_KEY=<key> node scripts/meshy-generate.mjs \
--mode image-to-3d \
--image "./concept-art/hero.png" \
--output public/assets/models/ \
--slug hero
Adds a skeleton to a generated humanoid model and auto-downloads walking + running animation GLBs. The input task ID comes from a completed text-to-3d or image-to-3d task.
MESHY_API_KEY=<key> node scripts/meshy-generate.mjs \
--mode rig \
--task-id <meshy-task-id> \
--height 1.8 \
--output public/assets/models/ \
--slug hero
This produces 3 files automatically:
hero.glb — rigged model with skeletonhero-walk.glb — walking animation (auto-downloaded)hero-run.glb — running animation (auto-downloaded)Always chain generate → rig as one atomic step for humanoids. Never leave humanoid characters as static models.
Limitations: Rigging works only on textured humanoid (bipedal) models with clearly defined limbs. Won't work on animals, vehicles, abstract shapes, or untextured meshes.
Apply an animation to a rigged model. Requires a completed rig task ID and an animation action ID.
MESHY_API_KEY=<key> node scripts/meshy-generate.mjs \
--mode animate \
--task-id <rig-task-id> \
--action-id 1 \
--output public/assets/models/ \
--slug hero-walk
Poll any task's current status.
MESHY_API_KEY=<key> node scripts/meshy-generate.mjs \
--mode status \
--task-id <task-id> \
--task-type text-to-3d # or: image-to-3d, rigging, animations
Submit a task without waiting. Useful in pipelines.
MESHY_API_KEY=<key> node scripts/meshy-generate.mjs \
--mode text-to-3d \
--prompt "a crystal sword" \
--no-poll
# Later:
MESHY_API_KEY=<key> node scripts/meshy-generate.mjs \
--mode status --task-id <id> --task-type text-to-3d
All downloaded GLBs are automatically optimized via scripts/optimize-glb.mjs to reduce file sizes by 80–95%. The pipeline resizes textures to 1024×1024, converts them to WebP, and applies meshopt compression.
--no-optimize to skip optimization and keep the raw Meshy output--texture-size <n> to change the max texture dimension (default: 1024)npx downloads @gltf-transform/cligltf-transform is unavailable, the script warns and continues with the raw fileOptimized GLBs use meshopt compression and require MeshoptDecoder at runtime — the template AssetLoader.js includes this automatically.
# Skip optimization for a specific generation
MESHY_API_KEY=<key> node scripts/meshy-generate.mjs \
--mode text-to-3d --prompt "a barrel" --preview-only \
--no-optimize --output public/assets/models/ --slug barrel
# Custom texture size (e.g., 512 for mobile)
MESHY_API_KEY=<key> node scripts/meshy-generate.mjs \
--mode text-to-3d --prompt "a barrel" --preview-only \
--texture-size 512 --output public/assets/models/ --slug barrel
# Re-optimize an existing GLB directly
node scripts/optimize-glb.mjs public/assets/models/barrel.glb --texture-size 512
See api-reference.md for full endpoint specs, payloads, responses, task statuses, and asset retention policy.
For non-humanoid assets (props, scenery, buildings), skip rigging:
# Generate
MESHY_API_KEY=<key> node scripts/meshy-generate.mjs \
--mode text-to-3d --prompt "a wooden barrel, low poly game asset" \
--polycount 5000 --output public/assets/models/ --slug barrel
# Integrate with loadModel (regular clone, no SkeletonUtils)
const barrel = await loadModel('assets/models/barrel.glb');
scene.add(barrel);
See verification-patterns.md for auto-orientation check, auto-scale fitting, and floor alignment code patterns.
See rigging-pipeline.md for the full generate -> rig -> animate -> integrate pipeline, including when to rig, the fadeToAction pattern, and integration code examples.
Good prompts produce better models:
| Goal | Prompt | Why |
|---|---|---|
| Game character | "a stylized goblin warrior, low poly game character, full body" | "low poly" + "game character" = game-ready topology |
| Prop | "a wooden treasure chest, stylized, closed" | Simple, specific, single object |
| Environment piece | "a fantasy stone archway, low poly, game asset" | "game asset" signals clean geometry |
| Vehicle | "a sci-fi hover bike, side view, clean topology" | "clean topology" = fewer artifacts |
Avoid:
Meshy-generated models slot into the existing 3D asset pipeline:
┌─────────────────────────────────────────────────────┐
│ 3D Asset Sources │
├──────────────┬──────────────┬───────────────────────┤
│ Free Libraries│ Character Lib │ Meshy AI │
│ find-3d-asset │ 3d-char-lib/ │ meshy-generate.mjs │
│ .mjs │ │ text/image → 3D │
│ │ │ rig → animate │
├──────────────┴──────────────┴───────────────────────┤
│ AssetLoader.js │
│ loadModel() / loadAnimatedModel() │
├─────────────────────────────────────────────────────┤
│ Three.js Game │
└─────────────────────────────────────────────────────┘
All sources output GLB files into public/assets/models/. The AssetLoader.js doesn't care where the GLB came from — it loads them all the same way.
| Problem | Cause | Fix |
|---|---|---|
MESHY_API_KEY not set | Environment variable missing | Ask the user for their key or run export MESHY_API_KEY=<key>. Free keys available at https://app.meshy.ai under Settings -> API Keys. |
| Task stuck in PENDING | API queue backlog or invalid parameters | Wait 2-3 minutes, then poll status. If still PENDING after 5 minutes, cancel and resubmit with simpler prompt or lower polycount. |
| Asset download returns 404 | Meshy retains assets for only 3 days | Re-run the generation pipeline. Always download GLBs immediately after task succeeds. Store locally in public/assets/models/. |
| Rigging fails or produces broken skeleton | Model is not a clearly bipedal humanoid, or mesh is untextured | Ensure the model is a textured humanoid with visible limbs. Rigging does not work on animals, vehicles, abstract shapes, or preview-only (untextured) meshes. Re-generate with and a prompt specifying "full body humanoid". |
MESHY_API_KEY checked — prompted user if not set, or user skipped to fallbacksrotationY set per model in Constants.js (most Meshy models need Math.PI)loadModel() (regular clone)loadAnimatedModel() (SkeletonUtils.clone)clipMap defined for animated models.meta.json saved alongside GLB with task IDs for traceabilityWeekly Installs
84
Repository
GitHub Stars
31
First Seen
Feb 27, 2026
Security Audits
Gen Agent Trust HubPassSocketPassSnykFail
Installed on
claude-code72
gemini-cli43
kimi-cli43
codex43
cursor43
opencode43
AI Elements:基于shadcn/ui的AI原生应用组件库,快速构建对话界面
67,500 周安装
Novel Writer 小说创作工作流指南:7步系统化方法,AI辅助写作与质量分析
1,100 周安装
Medusa 电商店铺前端最佳实践:UI/UX、SEO、移动端响应式设计全指南
1,100 周安装
Vibe Coding 指南:用 AI 和自然语言构建软件原型与 MVP 的完整框架
1,200 周安装
Tailwind CSS 实用优先CSS框架 - 快速构建自定义UI界面 | v4.1.18教程
1,100 周安装
PHP 8.x 最佳实践指南:51条规则掌握现代PHP开发、PSR标准与SOLID原则
1,100 周安装
Trigger.dev 任务:构建可靠的后台任务与异步工作流,支持自动重试和队列管理
1,100 周安装
--pbr| Generated model does not match prompt | Vague or multi-object prompt | Use specific, single-object prompts. Include style cues ("low poly", "stylized", "game character") and avoid combining multiple objects. See Prompt Engineering Tips. |
npm run build succeeds