动画 Three.js 文件未呈现

Animated Three.js file not rendering

我在 Blender 中制作了动画并将其导出为 Three.js 文件,以便可以在我的 Three.js 代码中显示它。

这里是 Javascript 代码:

var loader = new THREE.JSONLoader();
loader.load( "obj/dog5.js", function( geometry ) {
    mesh = new THREE.Mesh( geometry, new THREE.MeshNormalMaterial() );
    mesh.scale.set( 10, 10, 10 );
    mesh.position.y = 20;
    mesh.position.x = 0;

    var materials = mesh.material.materials;

    for (var k in materials) {
        materials[k].skinning = true;
    }

    animation = new THREE.Animation(mesh, "ArmatureAction", THREE.AnimationHandler.CATMULLROM);
    animation.play();

    lesson6.scene.add(mesh);

这是我得到的错误:

Uncaught TypeError: Cannot read property 'length' of undefined

这是我的代码中发生的地方:

animation = new THREE.Animation(mesh, "ArmatureAction", THREE.AnimationHandler.CATMULLROM);

这是它在 Three.js 库文件中发生的地方 three.min.js:

init:function(a){if(!0===a.initialized)return a;for(var b=0;b<a.hierarchy.length;b++)

我知道我的 JSON 文件有层次结构,所以我不知道为什么它未定义。我想我只是缺少一些代码,我不确定。

如果我拿走常规对象呈现但不动画的动画内容。

我完全被难住了。任何意见,将不胜感激!谢谢!

编辑:

所以它现在用这段代码渲染:

          for ( var k in materials ) {

        materials[k].skinning = true;

      }

      skinnedMesh = new THREE.SkinnedMesh(geometry, new THREE.MeshFaceMaterial(materials));
      skinnedMesh.scale.set( 11, 11, 11 );
      lesson6.scene.add( skinnedMesh );
      animation = new THREE.Animation( skinnedMesh, skinnedMesh.geometry.animations[ 0 ], THREE.AnimationHandler.CATMULLROM);
      animation.play();

但它仍然没有动画。 animation.play 需要开始时间吗?难不成是我的json?

谢谢!

我想通了我的问题。我的动画和渲染不正确。

来自threejs.org/examples/webgl_skinning_simple.html的解决方案:

function animate() {

  requestAnimationFrame( animate );

  THREE.AnimationHandler.update( clock.getDelta() );

  controls.update();

  render();
  stats.update();

}

function render() {

  renderer.render( scene, camera );

}