Cloud Pass:骑摩托穿过云间山道
摩托车沿草坡向山顶拱门行进,滚动控制镜头,前后景以不同速度运动,鱼眼视角拉开山路和远景的距离。作者把做法拆成三个可复用的 Agent 技能开源发布。
提示词 Prompt
# endless-riding-parallax # 来源: https://raw.githubusercontent.com/MengTo/Skills/main/agent-skills/3d/endless-riding-parallax/SKILL.md --- name: endless-riding-parallax description: Use for motorcycle rides and endless runners that need nearby ground to pass quickly while a distant castle or mountain range moves slowly. --- # Build an endless riding landscape 1. Keep cumulative travel as a JavaScript number. For constant speed use `distance = elapsedSeconds * speed`; for variable speed integrate velocity over elapsed time. Use this same station for the road, wheel contact, roadside plants and odometer. 2. Reuse a finite set of road and verge instances ahead of the camera. Return each instance to the far end only when it has cleared the visible region. Feed the GPU the remainder for each repeating period. Keep the integer cycle in CPU code when placement needs a stable seed. 3. Parent the castle, its foundations, the plains and the nearer mountain faces to one landscape transform. Apply that displacement to shadows, lighting probes and culling queries in the same frame. The depth of each feature determines its screen speed. 4. For a finite vista, use a small closed camera-relative move. Cloud Pass uses `x = 1.2*(1-cos(a))`, `z = 12*sin(a)` with `a = 2π*(t % 140)/140`. Position and velocity match across the join. Keep forward motion on the road running across this boundary. 5. Check a side view as well as a chase view. The relative motion is easiest to see where a nearby tree overlaps a distant roof. Check wheels against the ground separately when the landscape is displaced. ## Check the result At the same focal length, a sideways displacement should move a marker at 10 units about ten times as far across the image as a marker at 100 units. At 139.99 and 140.01 seconds, the scenery should pass smoothly through its origin. Run `node examples/check.mjs` from this skill folder for the numeric check. # scroll-fisheye-dolly-zoom # 来源: https://raw.githubusercontent.com/MengTo/Skills/main/agent-skills/3d/scroll-fisheye-dolly-zoom/SKILL.md --- name: scroll-fisheye-dolly-zoom description: Use for a scroll or pinch camera that widens from a normal lens into a mild fisheye while the rider, vehicle or portrait stays framed. --- # Scroll a rider-locked fisheye lens 1. Save the normal camera pose, the subject’s projected position and the vertical field of view before applying the lens. Rebuild from that pose each frame so small wheel events cannot accumulate camera error. 2. Convert wheel lines and pages to pixels. Let a positive wheel delta widen the lens. Clamp a width control to 0–1, ease toward it using elapsed time, and give pinch and keyboard input the same control. Leave modified wheel gestures to the browser. 3. For width `w`, use `spread = 1 + 0.72*w`. Divide the subject-to-camera vector by `spread`, then multiply `tan(fov/2)` by `spread`. Their product sets the visible height at the subject. Clamp the camera above terrain before reprojecting the subject. 4. Use `curve = 0.30*w*w`. Multiply the widened FOV tangent by `1+curve` for overscan. Keep the saved subject position by adjusting the projection offsets, then refresh the inverse projection matrix. Center the distortion at that screen position. 5. In the final scene pass, sample at `center + delta * (1 + curve*r2)/(1 + curve)`. Compute `r2` from the aspect-corrected squared distance to the anchor, normalized by the furthest corner. Put rain and clouds through the same pass. Draw HTML controls afterward. At zero width the original lens can render directly. ## Check the result Measure the chest-to-seat distance in pixels at normal and wide settings. A few percent of change gives a convincing dolly zoom. The ground beside the bike should expand, straight features at the edges should bend, and scrolling back should recover the first frame. Run `node examples/check.mjs` from this skill folder for the numeric check. # ride-particles-and-clouds # 来源: https://raw.githubusercontent.com/MengTo/Skills/main/agent-skills/3d/ride-particles-and-clouds/SKILL.md --- name: ride-particles-and-clouds description: Use for forward motion through pollen, seeds or rain below moving 3D cloud layers. Tie the atmosphere to the terrain and the light. --- # Light windborne particles under a 3D sky 1. Seed a fixed pool of instanced quads once. Give each a field station, altitude, wind phase and size. Start with mostly tiny grains and a few recognizable seeds. Cloud Pass uses 920 instances on desktop and 425 on smaller devices. 2. Advance the near population through a bounded depth volume using the road station. For a 34-unit corridor, `z = mod(seedZ + travel + flutter, 34) - 24`. Use positive modulo. Sample the terrain at the particle’s displaced position and add its altitude so the particles follow the slope. 3. Fade both ends of the wrap. Cloud Pass fades the far edge in field coordinates, then fades very near and very distant particles in camera depth. Change the sideways seed offset at the hidden boundary. Project the previous and current positions through their respective camera matrices for motion streaks. Reset that history after a seek or camera cut. 4. Sample 3D cloud density in world or weather coordinates. Move the noise with wind independently of the road. March each camera ray through the cloud layer up to the opaque geometry depth. At each step accumulate scattered light, then reduce transmittance by `exp(-density*stepLength)`. A lower-resolution cloud pass can be upsampled with scene depth to resolve rooflines. 5. Share the sun direction and weather state between the cloud scattering and particle highlights. Render transparent particles with depth testing and without depth writes. Let sunset and storm change the light on the seeds as well as the sky. ## Check the result Pause travel and orbit. A seed should pass in front of or behind the rider according to depth, and a roof should occlude a cloud bank behind it. Inspect the nearest and furthest positions of one seed, then switch from daylight to low light and check the highlights. Run `node examples/check.mjs` from this skill folder for the numeric check.
复刻指南
怎么复刻
- 克隆技能仓库:
git clone https://github.com/MengTo/Skills,进入agent-skills/3d/,读三个技能的SKILL.md:endless-riding-parallax—— 多层视差的无尽骑行地形scroll-fisheye-dolly-zoom—— 滚动驱动的鱼眼推拉镜头ride-particles-and-clouds—— 云层与粒子氛围
- 把技能喂给编码 Agent:这些目录本身就是为 Claude Code / Codex / Cursor 设计的 Agent Skills,直接让 Agent 按 SKILL.md 的约束实现,比手写提示词更稳。
- 关键手法(摘自 SKILL.md):累计里程用 JavaScript 数值保存(
distance = elapsedSeconds * speed);路面实例循环复用而不是无限生成;远景统一挂到一个 landscape transform 上,深度决定屏幕移动速度。 - 验收:从侧视图检查远近层的相对运动是否自然,再回追车视角看轮地接触点。