我在 Blender 中制作了一个动画网格,其中包含我命名为intro和idle 的两个动画剪辑。我已经用 JSON 格式的 Blender 导出器导出了它。一切都很好。我可以切换我想播放的动画。我的问题是我想完全播放第一个动画,然后切换到我将设置为循环的第二个动画。
这是我用于 JSON 和动画部分的代码部分:
var jsonLoader = new THREE.JSONLoader();
jsonLoader.load('models/feuille(19fevrier).json',
function (geometry, materials) {
mesh = new THREE.SkinnedMesh(geometry,
new THREE.MeshLambertMaterial({
skinning: true
}));
mixer = new THREE.AnimationMixer(mesh);
action.intro = mixer.clipAction(geometry.animations[ 0 ]);
action.idle = mixer.clipAction(geometry.animations[ 1 ]);
action.intro.setEffectiveWeight(1);
action.idle.setEffectiveWeight(1);
action.intro.enabled = true;
action.idle.enabled = true;
action.intro.setLoop(THREE.LoopOnce, 0);
scene.add(mesh);
scene.traverse(function(children){
objects.push(children);
});
action.intro.play();
});
Run Code Online (Sandbox Code Playgroud)
我正在寻找的是一个函数,它告诉我动作已完成,就像 clipAction 完成播放时的 onComplete 事件。我在three.js GitHub上找到了这个回复:
mesh.mixer.addEventListener('finished',function(e){
// some code
});
Run Code Online (Sandbox Code Playgroud)
它似乎有效,但我并不真正理解 …