Aframe中如何分离鼠标点击事件和courser点击事件
how separate the mouse click event and the courser click event in Aframe
我正在使用 AFRAME 创建 VR 编辑器...
我需要在用户通过鼠标单击某个元素时创建一个事件,并在通过 Aframe 相机光标单击时执行不同的操作。
我找到了 <a-scene cursor="rayOrigin: mouse">
但这会在鼠标和光标单击时执行相同的单击事件。
这在 AFRAME 中可能吗?
根据游标元素区分:
AFRAME.registerComponent('on-click', {
init: function () {
var self = this;
this.el.addEventListener('click', function (evt) {
if (self.el.sceneEl === evt.detail.cursorEl) {
console.log("MOUSE");
} else {
console.log("CURSOR");
}
});
}
});
我正在使用 AFRAME 创建 VR 编辑器... 我需要在用户通过鼠标单击某个元素时创建一个事件,并在通过 Aframe 相机光标单击时执行不同的操作。
我找到了 <a-scene cursor="rayOrigin: mouse">
但这会在鼠标和光标单击时执行相同的单击事件。
这在 AFRAME 中可能吗?
根据游标元素区分:
AFRAME.registerComponent('on-click', {
init: function () {
var self = this;
this.el.addEventListener('click', function (evt) {
if (self.el.sceneEl === evt.detail.cursorEl) {
console.log("MOUSE");
} else {
console.log("CURSOR");
}
});
}
});