GLTF 3D 模型在应该动画时不会进行动画处理



因此,目标很简单,我想动画一个3D模型,导入为.gltf文件(它只有1个动画(。

我一直在遵循文档步骤:

https://threejs.org/docs/#manual/en/introduction/animation-system

和来自实习的其他一些示例,所有这些示例看起来几乎相同,只有很少的东西修改了,但每个想法都是相同的。

我的代码(所评论的是失败的尝试(:

                let loader = new THREE.GLTFLoader();
                loader.load('scene.gltf', function ( gltf ) {
                        GLTF = gltf;
                        let xMesh = gltf.scene.children[0];
                        scene.add(xMesh);//arWorldRoot.add(xMesh);
                        animation = new THREE.AnimationMixer(xMesh);
               animation.clipAction(gltf.animations[0]).setDuration(8).play();
                        //scene.add( gltf.scene );
                        //animation = new THREE.AnimationMixer(gltf.scene);
                        //animation.clipAction(gltf.animations[0]).play();
                        //gltf.animations.forEach(( clip ) => {
                        //animation.clipAction(clip).play();
                        //});
                        //render();
                }, undefined, function ( error ) {
                        console.error( error );
                } );
....
....
....
 function render() {
            requestAnimationFrame(render);
            var delta = new THREE.Clock().getDelta();
            if (animation != null) {
                animation.update(delta);
            };
            renderer.render(scene, camera);
 }

我从所有这些尝试中获得的输出是显示3D模型,但没有动画。在DevTools无错误/警告中。

在《官方文档》之后,这很奇怪,而行不通,但我敢肯定我缺少一些东西...

我尝试了相同的代码,并且遇到了相同的问题。凭我的,GetDelta((正在返回0,因此动画并没有向前推进。要检查动画正在工作,我刚刚手动输入一个值。update((,即动画。

最新更新