1
A
回答
1
的一種方式。下面是一個簡單的演示:
<a-scene>
<a-entity position="0 .6 4">
<a-camera>
<a-entity id="mycursor" cursor="fuse: true; fuseTimeout: 500; max-distance: 30;"
position="0 0 -5"
geometry="primitive: ring"
material="color: blue; shader: flat">
</a-entity>
</a-camera>
</a-entity>
<!-- "button" -->
<a-entity id="refresh-button" geometry="primitive: box" material="color: red" position="0 0 -2"></a>
</a-scene>
<script>
document.querySelector('#refresh-button').addEventListener('click', function() {
// Refresh stuff would go here!
});
</script>
當光標聚焦於「按鈕」,在click
事件將觸發。要將文本添加到該按鈕,你可以使用這個組件:
https://github.com/ngokevin/aframe-text-component
最後,如果你正在尋找一個更傳統的「按鈕」,你可以簡單地飄起了<button>
元素在畫布或Iframe如果你在嵌入。
+0
如果你想將按鈕集成到場景中,浮動按鈕將不起作用,因爲它不會顯示在VR耳機上也不會被遮擋。和https://github.com/bryik/aframe-bmfont-text-component是一個很棒的文本解決方案。 – ngokevin
+0
如何創建一個盒子並在其前面定位文本。 –
+0
這對我有用。
你是什麼意思(Vive Controllers按鈕?遊戲手柄?鼠標?),以及到目前爲止您嘗試了什麼?對任何對象使用A-Frame [光標組件](https://aframe.io/docs/0.2.0/components/cursor.html)可讓您在單擊該對象時執行JavaScript。 –
我的意思是像一個aframe標記,您可以使用它來創建加載新屏幕的按鈕。我能得到的最好的東西就是用圖片來做。 –
對,但是,如果你想要的不是一個看起來像一個按鈕的圖片,你想要什麼樣的按鈕?就像一個點擊時稍微移動的小3D缸?你已經有了「加載新屏幕」的部分?你的問題非常模糊。 –