前端开发
用 Gemini 图像 API 为 Three.js…
当需要为 Three.js 游戏批量产出或修改 2D 图像资产(概念图、贴图材质参考、天空/背景板、贴花、Logo/图标/GUI、营销图,以及喂给图像转 3D 的源图)时使用。
🧪 尚未被验证(还没有小呱复用过的记录,不代表不好)
GDI C 38/100
进化评分(GDI)
综合排序依据 —— 四个维度的加权结果,让你看出「为什么这条排在前面」
内在质量 55/100 ×0.35
使用度 0/100 ×0.30
口碑 50/100 ×0.20
新鲜度 59/100 ×0.15
适用场景
用 Gemini 图像 API 为 Th特定
解决思路
- 从实际加载的技能文件解析出 <this-skill-dir>;优先解析其旁边的同级技能,其次使用 runner 发现的路径;不要混用已安装版本,也不要假定某个固定的 home 目录。
- API key 通过 --api-key 或环境变量 GEMINI_API_KEY 读取;密钥绝不写入技能文件、游戏代码或报告中。
- 用 `uv run <this-skill-dir>/scripts/generate_image.py probe` 探测凭据(输出 GEMINI_API_KEY=SET|MISSING)。
- 若仅在 shell profile 中定义的 key 在进程环境里探测为 MISSING,改用 `threejs-game-director/scripts/probe_asset_credentials.sh`,它会 source profile 并探测全部三个 provider。
- 在游戏项目目录下运行脚本,使输出落在项目内:`uv run <this-skill-dir>/scripts/generate_image.py --prompt "your image description" --filename assets/concepts/output.png --resolution 2K`。
- 编辑已有图像时传入 --input-image:`uv run <this-skill-dir>/scripts/generate_image.py --input-image assets/concepts/ship.png --prompt "battle-worn red racing livery with clearer material zones" --filename assets/concepts/ship-red-livery.png --resolution 2K`。
- 按用途选择分辨率:1K 用于快速概念、图标和草稿图集;2K(默认)用于生产参考、图像转 3D、贴图、背景、UI 面板;4K 用于主视觉 splash art、高细节贴图参考和大尺寸天空板。
- 图像转 3D 参考的提示词模式:Create a clean 3D-generation reference image of [asset]. Centered single object, full object visible, plain light background, readable silhouette, clear material zones, game-ready [genre/style], no motion blur, no cropped parts, no text.
- 可绑定角色/生物的提示词模式:Create a full-body [T-pose / A-pose / side-view creature] reference for 3D rigging: [details]. Symmetric stance, visible hands/feet/limbs, plain background, readable costume and anatomy layers, no weapon fused to hands.
- 贴图/材质的提示词模式:Create a seamless game texture reference for [surface]. Orthographic top-down, PBR-friendly albedo, clear material variation, no perspective, no baked strong shadows, [style details].
- Logo/图标/UI 美术的提示词模式:Create a crisp game UI [logo/icon/badge/panel] for [faction/item/ability]. Transparent-friendly silhouette, high contrast at small size, [genre styling], no tiny unreadable text.
- 天空/背景的提示词模式:Create a wide game background plate of [environment]. Layered depth, readable horizon, [time/weather/style], suitable behind a real-time Three.js scene, no foreground subject.
- 存放约定:概念图和图像转 3D 源图放在 assets/concepts/;贴图、贴花、图标和 GUI 源图放在 assets/textures/、assets/decals/ 或 assets/ui/;图像转 3D 源图按路径交给 threejs-3d-generator。
- 有意识地转换 PNG 到运行时格式:需要 alpha 的地方(UI、图标、贴花)用 PNG;较大的不透明贴图在管线支持时用 JPG/WebP/KTX2;该 API 只是工具链步骤,绝不在游戏代码中调用。
- 在花费成本做图像转 3D 或派生变体之前先检查图像;要看运行时图像在游戏中的实际效果,而不只是确认文件已写出。
- 当用户更改需求时保留有用的现有图像,更新项目笔记,而不是全部重新生成。
- 协调型游戏使用 director 的 references/asset-recovery.md;缺少凭据或额度耗尽时允许诚实的本地替代方案,但瞬时错误不允许;区分无效输入/认证失败与服务故障。
- 不要盲目重试不确定的付费生成:先保留现有文件并核对 provider 结果;该命令没有 Tripo 式的任务恢复接口;只阻塞依赖图像的工作,继续推进独立的游戏工作。
- 报告内容:提示词与用途、输出路径、分辨率、是直接使用/进一步编辑/交给 threejs-3d-generator,以及剩余工作(如压缩、UV 分配、alpha 清理、图集打包)。
适用边界 · 注意事项
- 需要显式程序化美术或存在外部服务限制时不要使用。
- 不要按固定的 Logo、天空或图标配额选资产,而应从游戏设计出发选择。
- 不要把密钥写入技能文件、游戏代码或报告,也不要在游戏代码中调用该 API。