Communitygithub.com

blender-camera-animations

在 Blender 中為產品模型生成攝影機動畫 — 包含旋轉台、完美循環、慢速推近、推軌旋轉、起重機運鏡以及動態全循環,並渲染輸出為影片。

blender-camera-animations 是什麼?

Blender Camera Animations 是一款專為 AI 代理(如 Claude Code、Cursor 及 Codex)設計的技能,能以程式化方式在 Blender 場景中為 3D 模型生成六種電影級攝影機運鏡。此技能可透過 Blender 連接器的 `execute_blender_code` 工具執行所有 Blender 操作,並透過視口截圖驗證結果。支援的運鏡包括:旋轉台(Turntable)、完美循環(Perfect Loop)、慢速推近(Slow Zoom)、推軌旋轉(Dolly-Rotate)、起重機運鏡(Crane Shot)及動態全循環(Dynamic Full Loop),並針對不同展示需求(如網站嵌入、社交媒體英雄影片、細節特寫等)提供最佳預設參數。每個運鏡均包含完整的 Python 程式碼片段,可自動建立約束系統、關鍵幀動畫及鏡頭參數,並內建光照模板(暖色「金色」產品打光)與渲染設定(1920x1080、24fps、透明背景、Cycles 引擎)。此技能會自動偵測場景中主要網格的包圍盒中心與尺寸,確保攝影機目標準確定位,並可透過互動方式詢問使用者產品正面方向,以達成最佳展示角度。輸出的影片會存放於 `~/Desktop/Blender Videos/` 資料夾。

相容平台~Claude Code~Codex CLI~Cursor
npx skills add https://github.com/varad2343/claude-skills/tree/HEAD/plugins/blender-camera-animations/skills/blender-camera-animations

在你喜歡的 AI 中提問

開啟一個已預先載入此 Agent Skill 的新對話。

說明文件

Blender Camera Animations

Six cinematic camera moves for showcasing a 3D model already in the Blender scene. All Blender work goes through the Blender connector's execute-code tool (e.g. execute_blender_code); check results with a viewport screenshot.

Pick the shot

User saysShotDefault length
turntable, orbit, rotate around, all angles (default)Turntable5 s
loop, seamless, GIF, website embedPerfect loop5 s
zoom in, push in, close-up on logo, hero detailSlow zoom5 s
dolly, sweeping, move and rotateDolly-rotate5 s
crane, rise up, low to high, reveal / unveilCrane shot5 s
speed ramp, show every side incl. top/bottom, social heroDynamic full loop10 s

Defaults: 1920x1080, 24 fps, transparent background, output folder ~/Desktop/Blender Videos/ (create it). Ask only if the shot or focus detail is unclear.

Step 0 — Inspect the scene

Get the object list and the main mesh's world bounding-box center and size. Scale all distances below by the object's largest dimension (values assume a ~1 m object). Put the camera target empty at the bbox center, not (0,0,0), when the model isn't centered.

import bpy
from mathutils import Vector
meshes = [o for o in bpy.context.scene.objects if o.type == 'MESH']
pts = [o.matrix_world @ Vector(c) for o in meshes for c in o.bound_box]
mn = Vector((min(p.x for p in pts), min(p.y for p in pts), min(p.z for p in pts)))
mx = Vector((max(p.x for p in pts), max(p.y for p in pts), max(p.z for p in pts)))
print('center', (mn + mx) / 2, 'size', mx - mn)

For turntable/loops, find the product's front: render 4 low-res stills from -Y, +X, +Y, -X, show them, and ask which is the front. Default front = -Y.

Shared helpers (run first in every shot)

import bpy, math

def make_rig(name, target_loc, cam_loc, lens, parent=False):
    bpy.ops.object.empty_add(type='PLAIN_AXES', location=target_loc)
    tgt = bpy.context.active_object; tgt.name = name + 'Target'
    bpy.ops.object.camera_add(location=cam_loc)
    cam = bpy.context.active_object; cam.name = name + 'Cam'
    cam.data.lens = lens
    trk = cam.constraints.new(type='TRACK_TO')
    trk.target = tgt; trk.track_axis = 'TRACK_NEGATIVE_Z'; trk.up_axis = 'UP_Y'
    if parent:  # camera orbits when the target rotates
        cam.parent = tgt
        cam.matrix_parent_inverse = tgt.matrix_world.inverted()
    bpy.context.scene.camera = cam
    return tgt, cam

def iter_fcurves(obj):
    act = obj.animation_data.action
    if hasattr(act, 'layers') and len(act.layers):   # Blender 4.4+/5.x layered actions
        for layer in act.layers:
            for strip in layer.strips:
                for cb in strip.channelbags:
                    yield from cb.fcurves
    else:                                             # older Blender
        yield from act.fcurves

def set_interp(obj, mode):
    for fc in iter_fcurves(obj):
        for kp in fc.keyframe_points:
            kp.interpolation = mode

def set_range(frames, fps=24):
    s = bpy.context.scene
    s.frame_start, s.frame_end, s.render.fps = 1, frames, fps

The shots

C = target center. FRAMES = duration x fps.

Turntable — tgt, cam = make_rig('Turntable', C, (C.x, C.y-4.5, C.z+2.0), 50, parent=True). Keyframe tgt.rotation_euler (0,0,0) at frame 1 and (0,0,radians(360)) at FRAMES+1. set_interp(tgt, 'LINEAR') for constant speed.

Perfect loop — Same as turntable, camera distance 4.0, height 2.0. Critical: the 360° key goes at FRAMES+1 (never rendered) so the last frame flows into frame 1. Interpolation MUST be LINEAR. Don't keyframe camera distance, height or lens. Play the result on repeat to check the seam.

Slow zoom — Ask which detail to push toward (logo, texture) and put the target there. make_rig('SlowZoom', FOCUS, (1.5, -4.0, 3.0), 35). Keyframe camera location + cam.data.lens: frame 1 = (1.5,-4.0,3.0), 35 mm; FRAMES = (0.3,-1.8,1.2), 65 mm. Keep the default BEZIER for ease in/out; the lens change adds a subtle dolly-zoom.

Dolly-rotate — make_rig('Dolly', C, (2.5,-4.0,2.0), 40, parent=True). Frame 1: target rot 0, cam (2.5,-4.0,2.0), 40 mm. FRAMES: target rot Z = 90°, cam (1.5,-2.5,1.5), 50 mm. BEZIER.

Crane shot — make_rig('Crane', C, (1.0,-3.0,-0.2), 45). Frame 1: cam (1.0,-3.0,-0.2) looking up, 45 mm. FRAMES: cam (1.5,-4.0,3.5), 35 mm (rises and pulls back). BEZIER.

Dynamic full loop (240 frames) — make_rig('Dynamic', C, (0,-4.0,1.8), 45, parent=True). Close keys with a small change = slow linger; wide jumps = fast whip.

kf_z = [(1,0),(30,10),(45,90),(75,100),(90,180),(120,190),(135,270),(165,280),(180,330),(210,340),(225,355),(240,360)]
kf_x = [(1,0),(30,0),(75,15),(120,0),(135,-20),(165,-45),(180,-60),(210,-30),(240,0)]
for f, d in kf_z:
    tgt.rotation_euler[2] = math.radians(d); tgt.keyframe_insert('rotation_euler', index=2, frame=f)
for f, d in kf_x:
    tgt.rotation_euler[0] = math.radians(d); tgt.keyframe_insert('rotation_euler', index=0, frame=f)
for fc in iter_fcurves(tgt):
    for kp in fc.keyframe_points:
        kp.interpolation = 'BEZIER'; kp.easing = 'AUTO'

Lighting (if the scene has none)

Warm "golden" product rig: put the colour on the LIGHTS, not on the world or materials. Area lights (location, energy W, size, colour): Key (3,-3,4) 2000, 3, (1,.78,.45); Fill (-3,-2,3) 1000, 5, (1,.75,.4); Overhead (0,0,5) 800, 8, (1,.92,.75); Rim (0,4,2) 800, 3, (1,.65,.3); Side (4,0,0.5) 600, 2, (1,.8,.5). Aim each at the target with a Track To constraint. World background: neutral (0.95,0.95,0.95), strength 0.3.

Render

import bpy, os
s = bpy.context.scene
s.render.resolution_x, s.render.resolution_y = 1920, 1080
s.render.film_transparent = True
s.render.engine = 'CYCLES'; s.cycles.samples = 64; s.cycles.use_denoising = True
try: s.cycles.device = 'GPU'
except Exception: pass
s.render.image_settings.file_format = 'PNG'; s.render.image_settings.color_mode = 'RGBA'
out = os.path.expanduser('~/Desktop/Blender Videos/<shot>_frames/')
os.makedirs(out, exist_ok=True)
s.render.filepath = out

First render one still frame mid-animation and show it before the full sequence. A full animation render blocks Blender and the tool call will time out, so start it with bpy.ops.render.render('INVOKE_DEFAULT', animation=True) (or tell the user to press Ctrl+F12), then check the frames folder until all FRAMES PNGs exist. On a heavy mesh use EEVEE ('BLENDER_EEVEE' in 4.2+/5.x) or 32 samples. If Blender freezes, encode whatever frames finished.

Encode

With ffmpeg on the user's computer (or in the workspace after copying the frames over):

# ProRes 4444 with alpha (editing)
ffmpeg -y -framerate 24 -i "<frames>/%04d.png" -c:v prores_ks -profile:v 4444 -pix_fmt yuva444p10le "<out>/<shot>.mov"
# Web / social (no alpha)
ffmpeg -y -framerate 24 -i "<frames>/%04d.png" -c:v libx264 -pix_fmt yuv420p -crf 18 "<out>/<shot>.mp4"
# Transparent web loop
ffmpeg -y -framerate 24 -i "<frames>/%04d.png" -c:v libvpx-vp9 -pix_fmt yuva420p -b:v 0 -crf 30 "<out>/<shot>.webm"

If there's no ffmpeg, set Blender's output to FFmpeg video (H.264) where the version supports it, or deliver the PNG sequence.

Rules

  • Never delete the user's objects. Name every new object with the shot prefix so it can be removed again.
  • Loops: LINEAR only. Reveals and zooms: BEZIER.
  • Report the final file path and duration.

Individual skills in this repo

This repo contains 2 individual skills — each has its own dedicated page.

相關技能