【问题标题】:How to determine if glTF has animation data如何判断glTF是否有动画数据
【发布时间】:2020-06-01 18:53:18
【问题描述】:

从显示静态网格(工作正常)到动画网格(混合结果)时,我遇到了一些错误。我怀疑我一直导出到 glTF 的 fbx 是错误的,但我想问一下:

首先,您如何确定 glTF 文件是否有动画数据/剪辑?而且,如果显示的模型没有任何动画,调用AnimationMixer会导致任何问题吗?

这就是我所拥有的:

    // Mix and animate!
    mixer = new THREE.AnimationMixer( model );
    var clips = model.animations;

    // if there's no first animation; there's no animation
    if (mixer.clipAction( gltf.animations[ 0 ] ) == undefined)
    // if (clips == undefined) // doesn't seem to work
    {
        // console.log("-> clips " + clips);
        console.log("-> no anim for " + model.name);
    }
    else
    {
        mixer.clipAction( gltf.animations[ 0 ] ).play();
    }

只是偶尔在静态网格上我会收到错误TypeError: Cannot read property 'uuid' of undefined 这让我有点困惑。

【问题讨论】:

    标签: animation three.js gltf


    【解决方案1】:

    gltfloader 调用带有结构的完成函数。在该结构中是一个 .animations[] 数组。如果为空,则找不到动画。只要你自己做混音器,不要尝试添加未定义的动画,它本身应该没问题,你可以在以后找到动画时添加。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2014-12-06
      • 1970-01-01
      • 1970-01-01
      • 2011-04-22
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多