Add gaze buttons to scene using A-frame

久未见 提交于 2019-12-08 07:34:15

问题


Is there a way to add gaze buttons in aframe? Note also for a better experience there must be an little progress bar to know how long the user must look to it.

I've looked inside the inspector tools but nothing found that works.

In this YouTube tutorial, I've found how to add click controls. Is it the same way I could make gaze events?


回答1:


You can select an item by gazing at it using the fuse property of the cursor component. Check the A-Frame docs here: https://aframe.io/docs/0.5.0/components/cursor.html#fuse-based-cursor

This will trigger a click event on the item, so you also need to have a listener set up on the item for the click event.




回答2:


By searching, I've found a solution that works. Here is my code:

document.getElementsByTagName('a-sphere')[0].addEventListener('click', function(){
    alert('click');
});
<script src="https://aframe.io/releases/0.5.0/aframe.min.js"></script>
<a-scene>
    <!-- this is my object that must execute a click event when looked -->
    <a-sphere position="0 0 -7" color="red">
    </a-sphere>

    <!-- camera -->
    <a-camera look-controls wasd-controls cursor="maxDistance: 30; fuse: true">
        <!-- progress bar -->
        <a-entity position="0 0 -3" geometry="primitive: ring; radiusOuter: 0.07;radiusInner: 0.05;" material="color: cyan; shader: flat"
            cursor="maxDistance: 30; fuse: true">
            <!--<a-cursor color="red"></a-cursor>-->
            <a-animation begin="click" easing="ease-in" attribute="scale" fill="backwards" from="0.1 0.1 0.1" to="1 1 1" dur="150"></a-animation>
            <a-animation begin="fusing" easing="ease-in" attribute="scale" fill="forwards" from="1 1 1" to="0.1 0.1 0.1" dur="1500"></a-animation>
        </a-entity>
    </a-camera>
</a-scene>

Thanks to @thoragio for his/her answer.



来源:https://stackoverflow.com/questions/43046362/add-gaze-buttons-to-scene-using-a-frame

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