fal-regenerate-3d
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
Chinesefal-regenerate-3d Skill
fal-regenerate-3d 技能
Runtime: Asset generation steps run via the genmedia CLI (FLUX.2 / GPT-Image-2 / Meshy v6 / Seedance / etc.). The final deliverable is a static HTML page with Three.js, generated assets are bundled into it. See theskill for command syntax; rungenmediaonce if not yet installed.genmedia init
End-to-end recipe to ship a polished, multi-character 3D web experience using fal.ai models.
This is the recipe that powers fal-roster.vercel.app: a cyberpunk character selector with 10 unique operatives, each with a matching companion creature, environment-themed floor texture, animated background and color palette.
运行时说明:资源生成步骤通过genmedia CLI执行(FLUX.2 / GPT-Image-2 / Meshy v6 / Seedance 等)。最终交付物是一个集成Three.js的静态HTML页面,生成的资源会打包到其中。有关命令语法,请查看技能;若未安装,请先运行genmedia。genmedia init
这是一套使用fal.ai模型打造精美多角色3D网页体验的端到端方案。
该方案为**fal-roster.vercel.app**提供技术支持:这是一个包含10名独特特工的赛博朋克风格角色选择器,每个特工都配有匹配的伴生生物、环境主题地面纹理、动画背景和调色板。
What it builds
构建产出
For each character you get:
- A stylized 3D character GLB (rigged + animated, baked into the file)
- A companion creature GLB (small static, themed to match the character)
- A per-character PBR floor (basecolor / normal / roughness / metalness, all generated)
- A looped video background keyed to the biome
- A 3-color palette that drives the whole UI (CSS custom properties)
- A portrait crop for the roster card
All packaged into a single static HTML page with a Three.js scene. ~25–35 MB of GLBs total after compression.
针对每个角色,你将获得:
- 风格化3D角色GLB文件(带骨骼绑定+动画,已烘焙到文件中)
- 伴生生物GLB文件(小型静态模型,风格与角色匹配)
- 角色专属PBR地面(基础色/法线/粗糙度/金属度,全部生成)
- 循环视频背景(与生物群落主题匹配)
- 三色调色板(驱动整个UI的CSS自定义属性)
- ** roster卡片头像裁剪图**
所有内容都打包到一个集成Three.js场景的静态HTML页面中。压缩后GLB文件总大小约为25–35 MB。
Pipeline
流程管线
1. GPT-Image-2 → 1024x1536 character full-body T-pose (per character)
2. Meshy v6 → image-to-3d, enable_rigging=true, animation_action_id={chosen}
→ animated GLB (idle, dance, alert, etc.)
3. GPT-Image-2/edit → companion creature image, color-locked to character palette
4. Meshy v6 → image-to-3d, enable_rigging=false → static creature GLB
5. PATINA → fal-ai/patina/material/extract on the character image,
returns basecolor + normal + roughness + metalness for the floor
6. Seedance 2.0 → fal-ai/bytedance/seedance-2.0/fast/image-to-video, 8s loop
7. gltf-transform CLI → resize 1024 → webp q80 → draco
(typically 95–96% size reduction, ~400–800 KB final)
8. Three.js scene → MeshStandardMaterial floor with alphaMap circular cutout,
mirrored reflection (refl.y = root.y, scale.y = -1),
breathing animation on companions,
per-character palette via CSS custom properties (--c1/--c2/--c3),
per-character floor texture swap on character click,
transition lines + radial flash on swap1. GPT-Image-2 → 生成1024x1536分辨率的角色全身T姿图像(每个角色一张)
2. Meshy v6 → 图像转3D,启用enable_rigging=true,设置animation_action_id={所选动作}
→ 生成带动画的GLB文件( idle、dance、alert等动作)
3. GPT-Image-2/edit → 生成伴生生物图像,颜色与角色调色板锁定匹配
4. Meshy v6 → 图像转3D,启用enable_rigging=false → 生成静态生物GLB文件
5. PATINA → 对角色图像执行fal-ai/patina/material/extract操作,
返回地面所需的基础色+法线+粗糙度+金属度贴图
6. Seedance 2.0 → 执行fal-ai/bytedance/seedance-2.0/fast/image-to-video,生成8秒循环视频
7. gltf-transform CLI → 调整分辨率至1024 → 转webp格式(质量q80)→ 应用draco压缩
(通常可减少95–96%的大小,最终约400–800 KB)
8. Three.js场景 → 使用MeshStandardMaterial创建带alphaMap圆形镂空的地面,
添加镜像反射(refl.y = root.y,scale.y = -1),
为伴生生物添加呼吸动画,
通过CSS自定义属性(--c1/--c2/--c3)实现角色专属调色板,
点击角色时切换对应地面纹理,
切换时显示过渡线条+径向闪光效果CREATE-YOUR-OWN flow
自定义创建流程
Visitors with a FAL key can generate their own character + companion live, in-browser:
flux-2 klein 9b (text-to-image)
└─ character full-body image
├─ Meshy v6 (rigged + animated) → character GLB
└─ flux-2 klein 9b/edit → companion image
└─ Meshy v6 (no rig) → companion GLBCost: ~$2–3 per generation (4 fal calls). Runs in background, modal closes on Generate so the user can keep using the experience while the gen runs. The tile transforms into a loading state, then becomes the new character card with a button.
CREATE YOUR OWN↻ re-create拥有FAL密钥的访客可在浏览器中实时生成自己的角色+伴生生物:
flux-2 klein 9b(文本转图像)
└─ 生成角色全身图像
├─ Meshy v6(带绑定+动画)→ 角色GLB文件
└─ flux-2 klein 9b/edit → 伴生生物图像
└─ Meshy v6(无绑定)→ 伴生生物GLB文件成本:每次生成约2–3美元(4次fal调用)。生成在后台运行,点击「生成」后模态框关闭,用户可在生成过程中继续使用体验。「自定义创建」卡片会切换为加载状态,生成完成后变为新角色卡片,并带有「↻ 重新创建」按钮。
Key fal endpoints used
使用的核心fal端点
| Step | Endpoint |
|---|---|
| Character image (curated) | |
| Character image (live) | |
| Companion image | |
| 3D character/companion | |
| Per-character floor PBR | |
| Background video | |
| Logo / icon cleanup | |
| 步骤 | 端点 |
|---|---|
| 角色图像(精选) | |
| 角色图像(实时) | |
| 伴生生物图像 | |
| 3D角色/伴生生物 | |
| 角色专属地面PBR | |
| 背景视频 | |
| Logo/图标清理 | |
Meshy animation IDs
Meshy动画ID
Curated dance / idle action IDs (full list at https://docs.meshy.ai/en/api/animation-library):
| ID | Animation |
|---|---|
| 0 | Idle (default) |
| 2 | Alert |
| 36 | Confused (scratch) |
| 48 | Mirror viewing |
| 64 | All_Night_Dance |
| 405 | Joyful_Dance_with_Hand_Sway |
| 591 | Hip_Hop_Dance |
| 64–83 | Various Pop_Dance variants |
精选的舞蹈/ idle动作ID(完整列表见https://docs.meshy.ai/en/api/animation-library):
| ID | 动画动作 |
|---|---|
| 0 | Idle(默认) |
| 2 | Alert(警觉) |
| 36 | Confused(挠头疑惑) |
| 48 | Mirror viewing(照镜子) |
| 64 | All_Night_Dance(通宵舞蹈) |
| 405 | Joyful_Dance_with_Hand_Sway(摆手欢乐舞) |
| 591 | Hip_Hop_Dance(嘻哈舞蹈) |
| 64–83 | 各种Pop_Dance(流行舞)变体 |
Three.js scene notes
Three.js场景说明
- Floor: cut into a disc via radial-gradient
PlaneGeometry(7, 7, 220, 220). High tessellation enables realalphaMap(uses basecolor as height).displacementMap - Reflection: clone of the root with ,
scale.y = -1,BackSide,depthWrite = false. For characters whose origin is at the feet,renderOrder = -1produces a visible mirror; the floor'srefl.position.y = root.position.ylets it bleed through.transparent = true; opacity ≈ 0.5 - Breathing: per-frame + a small Y bob on companions. The reflection mirrors the bob so the mirror stays consistent.
scale.setScalar(base * (1 + sin(t*1.3)*0.025)) - Palette swap: etc. Every UI element (sparklines, pulses, bars, model pills, edge map dots) derives its color from
:root.style.setProperty('--c1', hex)/var(--c1).var(--c2) - Floor swap: 4 PBR maps from
texLoader.load(), dispose old textures, setassets/floor/{charId}/back to white (since the basecolor is already char-themed).floorMat.color - Transition: 9 diagonal lines sweep across the viewport () on character click + a radial flash; bg video crossfades between two
@keyframes tfx-sweepelements; character GLB slides out and the new one slides in.<video>
- 地面:使用,通过径向渐变
PlaneGeometry(7, 7, 220, 220)裁剪为圆盘形状。高细分度支持真实的alphaMap(使用基础色作为高度)。displacementMap - 反射:克隆根节点并设置、
scale.y = -1、BackSide、depthWrite = false。对于原点在脚部的角色,设置renderOrder = -1可生成可见镜像;地面设置refl.position.y = root.position.y让镜像效果自然渗透。transparent = true; opacity ≈ 0.5 - 呼吸动画:每帧执行,并为伴生生物添加微小的Y轴摆动。反射会同步摆动,保持镜像一致性。
scale.setScalar(base * (1 + sin(t*1.3)*0.025)) - 调色板切换:通过等方式实现。所有UI元素(火花线条、脉冲效果、进度条、模型标签、边缘映射点)的颜色均取自
:root.style.setProperty('--c1', hex)/var(--c1)。var(--c2) - 地面切换:使用加载
texLoader.load()下的4张PBR贴图,销毁旧纹理,将assets/floor/{charId}/重置为白色(因为基础色已与角色主题匹配)。floorMat.color - 过渡效果:点击角色时,9条对角线扫过视口()并伴随径向闪光;背景视频在两个
@keyframes tfx-sweep元素间交叉淡入淡出;旧角色GLB滑出,新角色GLB滑入。<video>
Reference implementation
参考实现
- Live: https://fal-roster.vercel.app
- Source: https://github.com/lovisdotio/fal-roster
- Skill repo: https://github.com/lovisdotio/skills-fal-ai
Cost reference (curated build)
成本参考(精选构建)
For one full character:
| Step | Approx. cost |
|---|---|
| 1 GPT-Image-2 (character) | $0.04 |
| 1 Meshy v6 rigged + animated | $0.80 |
| 1 GPT-Image-2/edit (companion) | $0.04 |
| 1 Meshy v6 static (companion) | $0.20 |
| 1 PATINA floor (4 maps) | $0.04 |
| 1 Seedance fast (bg video) | $0.08 |
| Total per character | ~$1.20 |
| 10 characters | ~$12 |
Runtime parallelizes well, the original 10-character set was generated in ~10 minutes wall-clock with 9 concurrent jobs per stage.
单个完整角色的成本:
| 步骤 | 近似成本 |
|---|---|
| 1次GPT-Image-2(角色) | $0.04 |
| 1次Meshy v6(带绑定+动画) | $0.80 |
| 1次GPT-Image-2/edit(伴生生物) | $0.04 |
| 1次Meshy v6(静态) | $0.20 |
| 1次PATINA地面(4张贴图) | $0.04 |
| 1次Seedance fast(背景视频) | $0.08 |
| 单个角色总成本 | ~$1.20 |
| 10个角色总成本 | ~$12 |
运行时支持良好的并行处理,最初的10角色集在每个阶段使用9个并发任务的情况下,约10分钟即可生成完成。