SVG 角色动画
在需要基于 SVG 部件的角色骨骼制作动画时使用此技能。
运行时规则
- 动画应使用变换(
x、y、scale、rotation),而非布局属性。 - 对于多部件表演节拍,使用时间线。
- 对于 SVG 元素,使用稳定的 pivot 点(
svgOrigin或正确设置的 transform-origin)。 - 在 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 进行验证。
质量检查清单
- 运动过程中部件在 pivot 点处保持连接。
- 眨眼、视线方向和口型变化之间区分明显,易于识别。
- 姿态停顿足够长以传达情感。
- 帧采样显示有意义的差异变化,而非静止动画。
来源
- 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