在部分成功地回答了这个问题之后,AFRAME position far away from camera
我正试着在相机周围使用一个球体,以从相机获得100左右的位置。
我添加了这个球体
<Entity
id='mouse-listener'
geometry='primitive: sphere;
radius: 100;
segmentsWidth: 64;
segmentsHeight: 64;'
position='0 0 0'
scale="-1 1 1"
material={{color: 'blue' }}
className='clickable'
events={{click: (e) => console.log(e)}}
/>我的相机就是这样
<Entity primitive='a-camera' id='camera' look-controls={`enabled:${isLookControlsEnabled}`} mouse-cursor mouse-zoom wasd-controls={wasdControls}>我已经尝试将示例侦听器组件添加到sphere实体
import AFRAME from 'aframe'
AFRAME.registerComponent('cursor-listener', {
init: function () {
this.el.addEventListener('click', function (evt) {
console.log('I was clicked at: ', evt.detail.intersection.point)
})
},
})我只想知道它被点击的点。
发布于 2018-01-30 02:40:20
A-Frame自带鼠标cursor。您可以将其添加为单独的实体:
<a-entity cursor="rayOrigin: mouse"></a-entity>这些事件是mouseenter、mouseleave、click、mousedown、mouseup。不是onmouseup。
https://stackoverflow.com/questions/48498065
复制相似问题