更新时间:2023-10-25 09:07:34
新系统可与动画剪辑配合使用(如果正确,则自r74起). 这是我的Blender导出的JSON模型的示例.
New System works with animation clips (since r74 if im right). Heres a sample of my Blender exported JSON models.
var mixer;
var actions = {};
var loader = new THREE.JSONLoader();
loader.load( "webgl/models/model.json", function ( geometry, materials ) {
model = new THREE.SkinnedMesh( geometry, materials, false );
for(var x=0;x<materials.length();x++) materials[x].skinning = true;
mixer = new THREE.AnimationMixer(model );
//idle
actions.idle = mixer.clipAction(geometry.animations[0]);
actions.idle.setLoop(THREE.LoopRepeat);
actions.idle.clampWhenFinished = true;
actions.idle.play();
//walk
actions.walk = mixer.clipAction(geometry.animations[1]);
actions.walk.setLoop(THREE.LoopRepeat);
actions.walk.clampWhenFinished = true;
scene.add( model );
}
每个导出的动画都存储在array.animations数组中.
在我的示例中,我明确地知道哪个索引是哪个动画,但是通过名称(geometry.animations[x].name
)手动对其进行映射也非常容易.
Every exported Animation gets stored in the array geometry.animations.
In my example i explicitly know which index is which animation but its also very easy to map it manually by name: (geometry.animations[x].name
).
然后在动画循环中,您必须定期更新混音器if(typeof mixer != "undefined") mixer.update(delta);
In the animation loop you then have to update the mixer regularlyif(typeof mixer != "undefined") mixer.update(delta);
从 http://yomotsu.net获得了我的信息/blog/2015/10/31/three-r73-anim.html
以下是动画动作的相关源代码: https://github.com/mrdoob/three.js/blob/ab93512c7a44bd98e669592b3db441c04a2057f4/src/animation/AnimationAction.js
Also heres the regarding sourcecode for an animation action: https://github.com/mrdoob/three.js/blob/ab93512c7a44bd98e669592b3db441c04a2057f4/src/animation/AnimationAction.js
从Blender导出有很多可能的陷阱,尤其是当 使用骨骼网格动画(!=变形).
The Export from Blender has A LOT of possible snares especially when using Skeletal mesh animations (!= morphs).
我的导出设置:
my export settings:
希望对未来的探险家有帮助:)
Hope that helps future explorers :)