SVG 角色動畫
當需要為由 SVG 部件組成的角色骨架添加動畫時,請使用此技能。
運行時規則
- 應對變換屬性(
x、y、scale、rotation)進行動畫,而非版面配置。 - 對於多部分的表演節拍,請使用時間線。
- 對於 SVG 元素,應使用穩定的樞軸點(
svgOrigin或正確設定的轉換原點)。 - 在 Remotion 中,不要讓 GSAP 透過
requestAnimationFrame推進,而是從當前幀驅動一個暫停的時間線。
瀏覽器模式
gsap.set("#arm_right", { svgOrigin: "390 310" });
const tl = gsap.timeline({ defaults: { ease: "power2.inOut" } });
tl.to("#head", { rotation: -8, duration: 0.2 })
.to("#arm_right", { rotation: 35, duration: 0.4 }, "<");
Remotion 模式
const frame = useCurrentFrame();
const progress = frame / durationInFrames;
timeline.progress(progress);
HyperFrames 模式
使用具備確定性時間線的 HTML/SVG/GSAP 元件,並在最終渲染前透過 HyperFrames CLI 進行驗證。
品質檢查清單
- 部件在運動過程中應始終在樞軸點保持連接。
- 眨眼、視線和嘴巴形狀應足夠分明以便閱讀。
- 姿勢停留時間應足夠長以傳達情感。
- 影格取樣應顯示有意義的變化,而非靜止的動畫。
來源
- GSAP 核心變換屬性與 SVG 處理: https://gsap.com/docs/v3/GSAP/CorePlugins/CSS/
- GSAP 時間線與序列化: https://gsap.com/docs/v3/GSAP/Timeline/
- Remotion
useCurrentFrame: https://www.remotion.dev/docs/use-current-frame