用途:three.js 的核心动画(Animation)模块,负责时间求值与关键帧轨道。适合处理 AnimationMixer.update、AnimationAction 播放/暂停/停止、crossfade 与剪辑同步;从 glTF 或 AnimationClipCreator 生成 AnimationClip;position/rotation/scale/color 等关键帧轨道及适用的布尔/字符串轨道;addons 中的 IK(CCDIKSolver / CCDIKHelper)。注意区分:animation 负责时间与轨道,对象侧的 SkinnedMesh/Skeleton 绑定与 bind pose 属于 threejs-objects。触发词包括 AnimationMixer、AnimationAction、AnimationClip、crossFade、KeyframeTrack,以及中文“动画混合”“骨骼动画”“剪辑”“淡入淡出”。
主要用法:从 gltf.animations 收集剪辑或用工具/AnimationClipCreator 创建;将 mixer 绑定到根对象(通常是 scene 或 rig root);通过 mixer.clipAction(clip) 为每个剪辑创建 action,并配置循环模式(LoopOnce、LoopRepeat、LoopPingPong);每帧计算 delta 秒(使用 Clock),调用 mixer.update(delta);混合时调整 weight、crossFadeTo、enabled,注意叠加与完全替换语义;PropertyBinding 使用路径字符串定位骨骼/morph,错误常源于对象名不正确;使用 CCD IK 时在基础动画之后附加求解器。参见 examples/workflow-mixer-action.md。
官方文档:Animation 索引 https://threejs.org/docs/#Animation ,AnimationAction https://threejs.org/docs/AnimationAction.html ,AnimationMixer https://threejs.org/docs/AnimationMixer.html ,AnimationClip https://threejs.org/docs/AnimationClip.html ,KeyframeTrack https://threejs.org/docs/KeyframeTrack.html ,PropertyBinding https://threejs.org/docs/PropertyBinding.html 。
范围:包括核心 Animation 模块、关键帧管线及所列的剪辑创建与 IK addons;不包括 DCC 导出最佳实践、物理布娃娃、音频同步(仅概念关联)。
常见陷阱:忘记 mixer.update 会使动画冻结,每帧调用两次会加速;不兼容层级混合剪辑会造成剧烈跳变,需校验 bind pose;未烘焙的 root motion 需在游戏逻辑中处理;轨道数量过大消耗 CPU,预处理时尽量剔除未用轨道。
版本:AnimationMixer、轨道与 glTF 动画导入行为可能随 three.js 主版本变化,应以文档索引的 Animation 部分对应用户安装版本为准;升级时查阅 three.js 仓库发布说明与迁移说明中的重命名属性或 loader 输出变化。