我正在使用A-Frame AR开发AR应用程序。我现在想做的是,我想在AR场景中添加一个按钮并将click事件绑定到它。但这是行不通的。我正在使用https://github.com/rdub80/aframe-gui这个库来添加按钮。
这是我的代码。
<a-scene stats embedded arjs='trackingMethod: best;'>
<a-marker preset="hiro">
<a-gui-button
width="3" height="1"
onclick="buttonActionFunction"
value="Just a button"
margin="0 0 0.05 0"
rotation="200 0 0"
>
</a-gui-button>
</a-marker>
<a-entity camera></a-entity>
</a-scene>
我将此脚本添加到头部
<script src="https://aframe.io/releases/0.6.1/aframe.min.js"></script>
<script src="https://rawgit.com/donmccurdy/aframe-extras/master/dist/aframe-extras.loaders.min.js"></script>
<script src="https://cdn.rawgit.com/jeromeetienne/AR.js/1.5.0/aframe/build/aframe-ar.js"> </script>
<script src="https://rawgit.com/rdub80/aframe-gui/master/dist/aframe-gui.min.js"></script>
<script>
window.buttonActionFunction = function () {
alert('I am here');
}
</script>
当相机检测到标记时,我可以看到场景中的按钮。但是,当我单击按钮时,它不会触发功能/事件。它也没有显示错误。我的代码有什么问题,我该如何解决?