如何使用 onmouseover 事件在框架中控制 .gtlf2 网格动画?

How can I control a .gtlf2 mesh animation in aframe with onmouseover event?

我正在尝试控制 (start/stop) 鼠标悬停时的 gtlf 动画。我找到了一个很好的例子,但它依赖于 .json 格式的模型:

示例:https://rexraptor08.github.io/animation-controls/

来源:https://github.com/rexraptor08/animation-controls

问题是我无法再从搅拌机导出 .json 格式,因为插件已被删除:https://github.com/mrdoob/three.js/tree/dev/utils/exporters/blender

有人知道如何实现吗?

您可以使用 animation-mixer 组件使用 glTF 动画。

首先,您需要使用 Kupoman's exporter 导出您的模型。我用过 Khronos group one,但它在导出具有多个动画的模型时遇到了问题。

导出模型后,只需包含 aframe-extras,这样您就可以使用动画加载器了。

那么你可以这样使用它:

<a-entity gltf-model="url(model.gltf)"
   animation-mixer="clip: DoStuff;"></a-entity>

如果您想用任何事件启动动画,只需创建一个 component,它将设置 animation-mixer:

this.el.addEventListener("click", (e)=> {
  this.el.setAttribute("animation-mixer", "clip", "DoStuff") 
})

另外一定要查看 Don McCurdys guide