【问题标题】:Animation of JSON model THREE.jsJSON模型THREE.js的动画
【发布时间】:2015-02-26 10:21:37
【问题描述】:

JSON 模型是在 Blender 中创建的,动画也是在 Blender 中使用骨骼制作的。 但是当我尝试在 three.js 中运行动画时,除了鱼之外,场景的其余部分都被显示出来了。我一直在寻找答案,但没有找到任何可以解决我的问题的方法。我正在关注 Jos Dirksen 的《Learning three.js》一书。我也是three.js的初学者

var loader=new THREE.JSONLoader();
var mesh;
loader.load('fish_anim1.json', function (model, mat){
    mat[0] = new THREE.MeshLambertMaterial({color: 0x9ABF15, skinning: true});
    mesh = new THREE.SkinnedMesh(model, mat[0]);

    animation = new THREE.Animation(model, model.animations);

    mesh.position.set(0,5,0);
    mesh.scale.x = 3;
    mesh.scale.y = 3;
    mesh.scale.z = 4;
    mesh.rotation.y=Math.PI;
    mesh.name='fish'+fish_count;
    scene.add(mesh);

    animation.play();
});

在渲染循环中,我添加了这一行来更新动画

THREE.AnimationHandler.update(delta);

【问题讨论】:

    标签: javascript json three.js blender


    【解决方案1】:

    你很接近,你没有将所有动画作为 THREE.Animation 中的第二个参数传递,你只传递一个动画。

    animation = new THREE.Animation(mesh, model.animations[0]); // EDIT: First parameter is the SKinnedMesh not geometry.
    

    【讨论】:

    • 我编辑了答案,我使用“模型”作为我的网格的 var 名称,通过我说你将它用于几何,我的错。
    猜你喜欢
    • 1970-01-01
    • 2013-05-28
    • 1970-01-01
    • 2017-08-10
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-04-23
    • 1970-01-01
    相关资源
    最近更新 更多