mcpField
P
perfect-loop

perfect-loop

github.com/kevinbadi创意与媒体210149 次安装30 周前更新
代码仓库

关于 perfect-loop

perfect-loop 是用于制作无缝 360 度转台视频的 Blender 技能。通过关键帧位置和线性插值设置,使视频结尾与开头平滑衔接。

主要功能

  1. 01无缝 360 度转台动画
  2. 02在渲染范围外设置关键帧
  3. 03旋转使用线性插值
  4. 04保持相机参数静止
  5. 05渲染并编码图像序列

适用场景

  1. 01制作产品页面循环视频
  2. 02制作社交媒体动画
  3. 03准备 GIF 或 WebM 转台视频

MCP 相关

该技能介绍 Blender 场景动画与渲染,但未说明 MCP 连接方式。

安装

复制下面的命令,在终端中运行。

$npx skills add https://github.com/kevinbadi/blender-skills --skill perfect-loop

安装后在 Claude Code 中输入/perfect-loop确认已加载。

详细介绍

完美循环相机动画

无缝 360 度转台动画,最后一帧与第一帧完美衔接,形成无限循环。适合用作网站背景、社交媒体内容和产品页面嵌入动画。

使用场景

  • 用户想要“循环”或“无缝”动画
  • 用户提到“完美循环”“无限循环”“GIF”“循环转台”
  • 网站产品嵌入、社交媒体循环动画

参数

参数默认值描述
duration5视频时长,单位为秒
fps24每秒帧数
camera_distance4.0与物体的距离
camera_height2.0相机高度
camera_lens50焦距

流程

步骤 1:设置相机支架
import bpy, math

bpy.ops.object.empty_add(type='PLAIN_AXES', location=(0, 0, 0))
tgt = bpy.context.active_object
tgt.name = 'PerfectLoopTarget'

bpy.ops.object.camera_add(location=(0, -CAMERA_DISTANCE, CAMERA_HEIGHT))
cam = bpy.context.active_object
cam.name = 'PerfectLoopCam'
cam.data.lens = CAMERA_LENS

trk = cam.constraints.new(type='TRACK_TO')
trk.target = tgt
trk.track_axis = 'TRACK_NEGATIVE_Z'
trk.up_axis = 'UP_Y'

bpy.ops.object.select_all(action='DESELECT')
cam.select_set(True)
tgt.select_set(True)
bpy.context.view_layer.objects.active = tgt
bpy.ops.object.parent_set(type='OBJECT', keep_transform=True)

bpy.context.scene.camera = cam
步骤 2:制作无缝循环动画

关键:在第 N+1 帧(比最后一帧渲染帧多一帧)设置 360 度关键帧。这样,循环时第 N 帧和第 1 帧会相邻,而不是重复。

TOTAL_FRAMES = DURATION * FPS  # 120

scene = bpy.context.scene
scene.frame_start = 1
scene.frame_end = TOTAL_FRAMES  # render 1-120
scene.render.fps = FPS

tgt.rotation_euler = (0, 0, 0)
tgt.keyframe_insert(data_path='rotation_euler', frame=1)

# 360 at frame 121 — frame 121 is NOT rendered, but ensures
# frame 120 is one step before frame 1, creating seamless loop
tgt.rotation_euler = (0, 0, math.radians(360))
tgt.keyframe_insert(data_path='rotation_euler', frame=TOTAL_FRAMES + 1)

# LINEAR interpolation is CRITICAL for perfect loop
action = tgt.animation_data.action
strip = action.layers[0].strips[0]
for cb in strip.channelbags:
    for fc in cb.fcurves:
        for kp in fc.keyframe_points:
            kp.interpolation = 'LINEAR'
步骤 3:渲染并编码
ffmpeg -y -framerate 24 \
  -i "~/Desktop/Blender Videos/perfect_loop_frames/%04d.png" \
  -c:v prores_ks -profile:v 4444 -pix_fmt yuva444p10le \
  "~/Desktop/Blender Videos/perfect_loop.mov"

关键说明

  • 仅使用 LINEAR 插值 — 使用 BEZIER 会导致循环衔接处卡顿
  • 在 N+1 帧设置关键帧:将 360 度关键帧放在渲染范围之外一帧的位置
  • 相机保持静止:相机距离、高度和镜头必须固定(这些参数不要设置关键帧)
  • 验证循环效果:重复播放视频,确认过渡无缝
  • 适合编码为循环格式:GIF、WebM 或使用 -loop 0 的 MP4

评论

支持 Markdown