【问题标题】:ThreeJS r75 - TypeError: THREE.Animation is not a constructorThreeJS r75 - TypeError: THREE.Animation 不是构造函数
【发布时间】:2016-04-02 00:00:17
【问题描述】:

我正在使用 ThreeJS 的最新版本(截至发布日期)。我正在尝试导入带有操纵动画的 ThreeJS Blender 模型。我在网上遇到的所有教程都提到了THREE.AnimationHandlerTHREE.Animation。但是我收到错误说不存在这样的构造函数。

在线查看文档时,我可以看到它们:

Animation

AnimationHandler

两者都没有声明它们被贬低。查看 src 文件时,我也看不到它们。 我在这里遗漏了什么吗?

【问题讨论】:

    标签: javascript animation three.js


    【解决方案1】:

    几天前我遇到了同样的问题。我发现在最近的版本中已经实现了新的动画系统。这篇文章帮助了我 - New skinned mesh animation system in three.js。文档好像还没有更新。

    所以在我的情况下,我需要在json 中导入模型并启动动画,代码如下所示:

     var loader = new THREE.ObjectLoader(),
         clock = new THREE.Clock(),
         mixer;
    
     loader.load('models.json', function (object) {
        // Get object animation
        var sceneAnimationClip = object.animations[0];
    
        // Create animation mixer and pass object to it
        mixer = new THREE.AnimationMixer(object);
    
        // Create animation action and start it
        var sceneAnimation = mixer.clipAction(sceneAnimationClip);
        sceneAnimation.play();
    
        scene.add(object);
    
        render()
    });
    
    function render() {
        requestAnimationFrame(render);
    
        // Update animation   
        var delta = clock.getDelta();
        if( mixer ) {
            mixer.update( delta );
        }
    
        renderer.render(scene, camera);
    }
    

    【讨论】:

    • 您需要发布一些与主题相关的代码sn-ps吗?因为资源的链接可能会在一段时间后过时......谢谢。
    • 我尝试使用您的示例代码来运行我的动画,但是现在我反复收到“无法绑定到骨骼,因为节点没有骨架”的错误。猜猜是时候用头撞桌子并再次点击threejs导出器中的每个选项
    • 无法绑定到骨骼,因为节点没有骨架
    • 遇到Can not bind to bones as node does not have a skeleton 问题的人可以使用SkinnedMesh 解决它
    猜你喜欢
    • 2019-08-14
    • 2021-06-29
    • 2018-06-27
    • 2016-04-16
    • 2021-11-26
    • 2019-10-27
    • 2018-07-18
    相关资源
    最近更新 更多