我正在将蒙皮网格上的动画从 Blender 中创建的 glTF 导入到 THREE.js 我有两个同步动画会影响骨骼的平移。在 Blender 中,这些翻译是相加的,但在 THREE.js 中,它们是按权重平均的。
例如,动画是 translate(2, 0, 0) 和 translate(4, 0, 0) 如何让 AnimationMixer 产生 (6, 0, 0) 而不是 (3, 0, 0)?
对于我的特定需求,我真的只需要第一帧和最后一帧的值(它们都是 3 帧动画,第二帧是默认值)。所以我从关键帧轨道中提取值,根本不会使用动画系统。//将动画转换为值函数 convertAnim( clips ){
var anims = [];
for ( i = 0; i < clips.length; i ++ ){
anims[i] = {name: "name", bone: []};
anims[i].name = clips[i].name;
for ( j = 0; j < clips[i].tracks.length; j++ ){
var val = clips[i].tracks[j].values
if ( clips[i].tracks[j].name.indexOf( 'position' ) > -1 ) {
anims[i].bone[j] = { name: "name", minTranslate: "min", maxTranslate: "max"};
anims[i].bone[j].name = clips[i].tracks[j].name;
anims[i].bone[j].minTranslate = new THREE.Vector3( val[0], val[1], val[3] );
anims[i].bone[j].maxTranslate = new THREE.Vector3( val[val.length - 3], val[val.length - 2], val[val.length - 1] );
}
else if ( clips[i].tracks[j].name.indexOf( 'scale' ) > -1 ) {
anims[i].bone[j] = { name: "name", minSize: "min", maxSize: "max"};
anims[i].bone[j].name = clips[i].tracks[j].name;
anims[i].bone[j].minSize = new THREE.Vector3( val[0], val[1], val[2] );
anims[i].bone[j].maxSize = new THREE.Vector3( val[val.length - 3], val[val.length - 2], val[val.length - 1] );
}
else if ( clips[i].tracks[j].name.indexOf( 'scale' ) > -1 ) {
anims[i].bone[j] = { name: "name", minRotation: "min", maxRotation: "max"};
anims[i].bone[j].name = clips[i].tracks[j].name;
anims[i].bone[j].minRotation = new THREE.Quaternion( val[0], val[1], val[2], val[3] );
anims[i].bone[j].maxRotation = new THREE.Quaternion( val[val.length -4], val[val.length - 3], val[val.length - 2], val[val.length - 1] );
}
}
}
return anims;
}