我对Java脚本和html非常陌生,对此我感到非常满意。
以下是我写的内容,并希望在检测到标记后开始进行基本操作。
但是,当我在浏览器上访问html时,声音就会立即开始。
<a-marker type="pattern" url="pat/ban.patt">
<a-entity>
<a-image id="obj0" rotation="-90 0 0" src="#banto" width="5" height="5"></a-image>
<a-entity position="-0.75 1 1" rotation="-90 0 0" text-geometry="value: Head of the cleark; bevelEnabled: false; bevelSize: 0.008; bevelThickness: 0.08; size: 0.25;" material="color: cyan;"></a-entity>
<a-sound src="#bantoSound" autoplay="true"></a-sound>
</a-entity>
</a-marker>
尽管仅在检测到标记时才显示...。
与???不能相同
最佳答案
恐怕只要实体在DOM中加载,autoplay:true
就会发出声音。
我建议您禁用自动播放,或在场景加载时停止所有声音,并在标记可见时激活它:
if(document.querySelector("a-marker").object3D.visible == true){
// play the sound
}
关于image - 当检测到标记时,<a-sound>无法启动,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45582946/