Play sound component with animation using A-Frame

穿精又带淫゛_ 提交于 2019-12-12 04:23:20

问题


I'm trying to build an A-Frame scene where a car drives by the user, and I need the sound of the car to start playing as the car starts moving. For example:

<a-collada-model id="car" src="#car-dae" position="-0.7 0 -100" rotation="0 90 0">
  <a-animation attribute="position"
         dur="7000"
         begin="model-loaded"
         fill="forwards"
         to="-0.7 0 20"
         repeat="0"
  ></a-animation>
</a-collada-model>

Can I put a sound component on the animation? If not, how should I go about having the sound play at the same time as the animation? I tried putting the sound component on the collada model and gave it a on:model-loaded (same event as the animation), but this never played the sound. In fact, the only way I seem to be able to get the sound to play is using autoplay. Any ideas?

If it helps, all of my code is in this git repo under carChase.html

https://github.com/zeekw/aFrameTests


回答1:


Did you try putting the sound component on the model, or as a child of it?

<a-collada-model src="#car-dae" sound="on: model-loaded; src: #car-sound">


来源:https://stackoverflow.com/questions/41353368/play-sound-component-with-animation-using-a-frame

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!