使用 A-Frame 播放带有动画的声音组件
Play sound component with animation using A-Frame
我正在尝试构建用户驾驶汽车的 A 帧场景,我需要在汽车开始移动时开始播放汽车的声音。例如:
<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>
我可以在动画中添加声音组件吗?如果没有,我应该如何让声音与动画同时播放?我尝试将声音组件放在 collada 模型上并给它一个 on:model-loaded
(与动画相同的事件),但这从未播放过声音。事实上,我似乎能够播放声音的唯一方法是使用自动播放。有什么想法吗?
如果有帮助,我的所有代码都在 carChase.html
下的 git 存储库中
您是否尝试将声音组件放在模型上,或者作为模型的子组件?
<a-collada-model src="#car-dae" sound="on: model-loaded; src: #car-sound">
我正在尝试构建用户驾驶汽车的 A 帧场景,我需要在汽车开始移动时开始播放汽车的声音。例如:
<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>
我可以在动画中添加声音组件吗?如果没有,我应该如何让声音与动画同时播放?我尝试将声音组件放在 collada 模型上并给它一个 on:model-loaded
(与动画相同的事件),但这从未播放过声音。事实上,我似乎能够播放声音的唯一方法是使用自动播放。有什么想法吗?
如果有帮助,我的所有代码都在 carChase.html
下的 git 存储库中您是否尝试将声音组件放在模型上,或者作为模型的子组件?
<a-collada-model src="#car-dae" sound="on: model-loaded; src: #car-sound">