对此问题的部分成功回答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}>
我尝试将示例侦听器组件添加到球体实体
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)
})
},
})
我只是想知道点击它的点。
答案 0 :(得分:0)
A-Frame附带一只鼠标cursor。您将其添加为单独的实体:
var array1 = ['a','b','c'];
var array2 = ['d','e','f'];
var name = 'e';
array1.concat(array2).forEach(function(item) {
if(item === name) {
//do your stuff here
}
};
事件包括const result = array1.concat(array2).filter(item => item === name);
if(result.length > 0)
//do your stuff
else
// return an error
,<a-entity cursor="rayOrigin: mouse"></a-entity>
,mouseenter
,mouseleave
,click
。不是mousedown
。