小编lar*_*pin的帖子

在three.js 中验证clipAction 动画何时播放完毕

我在 Blender 中制作了一个动画网格,其中包含我命名为introidle 的两个动画剪辑。我已经用 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)

它似乎有效,但我并不真正理解 …

animation json three.js

1
推荐指数
1
解决办法
3352
查看次数

标签 统计

animation ×1

json ×1

three.js ×1