add-3d-assets
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseAdd 3D Assets
添加3D资源
Replace basic geometric shapes (BoxGeometry, SphereGeometry) with real 3D models. The player gets an animated character with idle/walk/run animations. World objects get GLB models from free libraries.
将基础几何形状(BoxGeometry、SphereGeometry)替换为真实3D模型。玩家将拥有一个包含 idle/walk/run 动画的角色。世界对象将使用来自免费库的GLB模型。
Instructions
操作步骤
Analyze the game at (or the current directory if no path given).
$ARGUMENTSFirst, load the game-3d-assets skill for the full model pipeline, AssetLoader pattern, and integration patterns.
分析路径下的游戏(如果未指定路径则分析当前目录)。
$ARGUMENTS首先,加载game-3d-assets技能以获取完整的模型流水线、AssetLoader模式和集成模式。
Step 1: Audit
步骤1:审计
- Read to confirm this is a Three.js game (not Phaser — use
package.jsonfor 2D games)/add-assets - Read for entity types, sizes, colors
src/core/Constants.js - Read entity files (,
src/gameplay/*.js) — findsrc/entities/*.js,BoxGeometry, etc.SphereGeometry - Read for environment primitives
src/level/LevelBuilder.js - List every entity using geometric shapes
- Identify which entity is the player character (needs animated model)
- 读取确认这是一个Three.js游戏(如果是Phaser游戏,请使用
package.json处理2D游戏)/add-assets - 读取获取实体类型、尺寸、颜色信息
src/core/Constants.js - 读取实体文件(、
src/gameplay/*.js)——查找src/entities/*.js、BoxGeometry等基础形状的使用SphereGeometry - 读取查看环境基础形状
src/level/LevelBuilder.js - 列出所有使用几何形状的实体
- 确定哪个实体是玩家角色(需要动画模型)
Step 2: Plan
步骤2:规划
Split entities into two categories:
Animated characters (player, enemies with AI) — use pre-built GLBs from :
3d-character-library/| Entity | Character | Reason |
|---|---|---|
| Player | Soldier | Military/action theme |
| Enemy | RobotExpressive | Sci-fi theme, 13 animations |
Available characters in :
3d-character-library/manifest.json- Soldier — realistic military (Idle, Walk, Run) — best default
- Xbot — stylized mannequin (idle, walk, run + additive poses)
- RobotExpressive — cartoon robot (Idle, Walking, Running, Dance, Jump + 8 more)
- Fox — low-poly animal (Survey, Walk, Run) — scale 0.02
World objects (buildings, props, scenery, collectibles) — search free libraries:
| Entity | Search Query | Source | Notes |
|---|---|---|---|
| Tree | "low poly tree" | Sketchfab | Environment |
| House | "medieval house" | Poly Haven | Background |
| Barrel | "barrel" | Poly Haven | Obstacle |
| Coin | "gold coin" | Sketchfab | Collectible |
将实体分为两类:
动画角色(玩家、带AI的敌人)——使用中的预构建GLB模型:
3d-character-library/| 实体 | 角色 | 原因 |
|---|---|---|
| 玩家 | Soldier | 军事/动作主题 |
| 敌人 | RobotExpressive | 科幻主题,包含13种动画 |
3d-character-library/manifest.json- Soldier — 写实风格军事角色(Idle、Walk、Run)——最佳默认选择
- Xbot — 风格化人体模型(idle、walk、run + 附加姿态)
- RobotExpressive — 卡通风格机器人(Idle、Walking、Running、Dance、Jump + 另外8种动画)
- Fox — 低多边形动物(Survey、Walk、Run)——缩放比例0.02
世界对象(建筑、道具、场景、可收集物品)——在免费库中搜索:
| 实体 | 搜索关键词 | 来源 | 说明 |
|---|---|---|---|
| 树木 | "low poly tree" | Sketchfab | 环境元素 |
| 房屋 | "medieval house" | Poly Haven | 背景元素 |
| 木桶 | "barrel" | Poly Haven | 障碍物 |
| 金币 | "gold coin" | Sketchfab | 可收集物品 |
Step 3: Download
步骤3:下载
Characters — copy from library (no auth, instant):
bash
undefined角色模型——从库中复制(无需授权,即时获取):
bash
undefinedFind the plugin root (where 3d-character-library/ lives)
找到插件根目录(3d-character-library/所在位置)
cp <plugin-root>/3d-character-library/models/Soldier.glb public/assets/models/
**World objects** — search and download:
```bashcp <plugin-root>/3d-character-library/models/Soldier.glb public/assets/models/
**世界对象模型**——搜索并下载:
```bashUse --list-only first to review results
先使用--list-only参数查看结果
node <plugin-root>/scripts/find-3d-asset.mjs --query "barrel" --source polyhaven --list-only
node <plugin-root>/scripts/find-3d-asset.mjs --query "barrel" --source polyhaven --list-only
Download the best match
下载最匹配的模型
node <plugin-root>/scripts/find-3d-asset.mjs --query "barrel" --source polyhaven
--output public/assets/models/ --slug barrel
--output public/assets/models/ --slug barrel
node <plugin-root>/scripts/find-3d-asset.mjs --query "barrel" --source polyhaven
--output public/assets/models/ --slug barrel
--output public/assets/models/ --slug barrel
Poly Haven = no auth, CC0 (best for props)
Poly Haven = 无需授权,CC0协议(最适合道具)
Sketchfab = search free, download needs SKETCHFAB_TOKEN
Sketchfab = 免费搜索,下载需要SKETCHFAB_TOKEN
undefinedundefinedStep 4: Integrate
步骤4:集成
- Create — use
src/level/AssetLoader.jsfor animated models (import fromSkeletonUtils.clone()). Regularthree/addons/utils/SkeletonUtils.jsbreaks skeleton → T-pose..clone() - Add to Constants.js with
CHARACTER,path,scale,facingOffsetclipMap - Add and
ASSET_PATHSfor static modelsMODEL_CONFIG - Update :
Player.js- as position anchor
THREE.Group - +
loadAnimatedModel()AnimationMixer - for idle/walk/run crossfade
fadeToAction() - Camera-relative WASD via
applyAxisAngle(_up, cameraAzimuth) - Model facing:
atan2(v.x, v.z) + CHARACTER.facingOffset model.quaternion.rotateTowards(targetQuat, turnSpeed * delta)
- Update :
Game.js- Add — third-person camera orbiting player
OrbitControls - Camera follows: move +
orbitControls.targetby player deltacamera.position - Pass to Player for camera-relative movement
orbitControls.getAzimuthalAngle()
- Add
- Replace environment primitives with calls +
loadModel()fallback.catch() - Add for visible movement reference
THREE.GridHelper - Preload all models on startup with for instant loading
preloadAll()
- 创建——对于动画模型,请使用
src/level/AssetLoader.js(从SkeletonUtils.clone()导入)。常规的three/addons/utils/SkeletonUtils.js会破坏骨骼结构,导致角色呈T字姿势。.clone() - 在Constants.js中添加配置,包含
CHARACTER、path、scale、facingOffsetclipMap - 为静态模型添加和
ASSET_PATHS配置MODEL_CONFIG - 更新:
Player.js- 使用作为位置锚点
THREE.Group - 实现+
loadAnimatedModel()AnimationMixer - 使用实现idle/walk/run动画的平滑过渡
fadeToAction() - 通过实现基于相机视角的WASD移动
applyAxisAngle(_up, cameraAzimuth) - 模型朝向:
atan2(v.x, v.z) + CHARACTER.facingOffset model.quaternion.rotateTowards(targetQuat, turnSpeed * delta)
- 使用
- 更新:
Game.js- 添加——围绕玩家的第三人称相机
OrbitControls - 相机跟随:根据玩家的位移量更新+
orbitControls.targetcamera.position - 将传递给Player,实现基于相机视角的移动
orbitControls.getAzimuthalAngle()
- 添加
- 使用调用替换环境基础形状,并添加
loadModel()作为回退方案.catch() - 添加作为可见的移动参考
THREE.GridHelper - 在启动时使用预加载所有模型,实现即时加载
preloadAll()
Step 5: Tune & Verify
步骤5:调整与验证
- Run — walk around with WASD, orbit camera with mouse
npm run dev - Confirm character animates (Idle when stopped, Walk when moving, Run with Shift)
- Adjust values (scale, rotationY, offsetY) per model
MODEL_CONFIG - Run to confirm no errors
npm run build - Generate from
ATTRIBUTION.mdfiles.meta.json
- 运行——使用WASD移动,鼠标拖动旋转相机
npm run dev - 确认角色动画正常(静止时为Idle,移动时为Walk,按住Shift时为Run)
- 根据每个模型调整中的值(scale、rotationY、offsetY)
MODEL_CONFIG - 运行确认无错误
npm run build - 从.meta.json文件生成
ATTRIBUTION.md
Next Step
下一步
Tell the user:
Your 3D game now has animated characters and real models! The player walks, runs, and idles with smooth animation crossfading. World objects are loaded from GLB files.Files created:
— model loader with SkeletonUtilssrc/level/AssetLoader.js — character and world GLB modelspublic/assets/models/- OrbitControls third-person camera
Controls: WASD to move, Shift to run, mouse drag to orbit camera, scroll to zoom. Run the game to see everything in action. Adjustin Constants.js to fine-tune scale and orientation.MODEL_CONFIG
告知用户:
你的3D游戏现在拥有动画角色和真实模型了!玩家可以通过平滑的动画过渡实现行走、奔跑和 idle 状态。世界对象均从GLB文件加载。创建的文件:
— 集成SkeletonUtils的模型加载器src/level/AssetLoader.js — 角色和世界对象的GLB模型public/assets/models/- 第三人称相机OrbitControls
操作方式: WASD移动,Shift奔跑,鼠标拖动旋转相机,滚轮缩放。 运行游戏查看效果。可在Constants.js中调整来优化模型的缩放和朝向。MODEL_CONFIG