Angularjs A帧glft单击事件
我试图捕捉场景中glft模型的点击事件。场景代码如下Angularjs A帧glft单击事件,angularjs,aframe,Angularjs,Aframe,我试图捕捉场景中glft模型的点击事件。场景代码如下 <a-scene raycaster-autorefresh> <a-assets> <a-asset-item id="store_homeModel" src="app/home/store_models/store_model.gltf"></a-asset-item> <a-asset-item id="shampoo" src="app/home/p
<a-scene raycaster-autorefresh>
<a-assets>
<a-asset-item id="store_homeModel" src="app/home/store_models/store_model.gltf"></a-asset-item>
<a-asset-item id="shampoo" src="app/home/product_models/Ayush Shampoo.gltf"></a-asset-item>
<a-asset-item id="soap" src="app/home/product_models/Ayush Soap.gltf"></a-asset-item>
<a-asset-item id="facewash" src="app/home/product_models/Citra Pearl face wash.gltf"></a-asset-item>
</a-assets>
<a-gltf-model src="#store_homeModel"></a-gltf-model>
<a-gltf-model src="#shampoo" open-desc"></a-gltf-model>
</a-scene>
请记住,
a-frame
在
上呈现整个视图,因此您不能只使用鼠标单击中的任何元素,您使用的是什么版本的a-frame?0.8.0可能需要一些bug修复。I readyyyy
是否打印?是的,我已准备好打印…并且仅使用0.8.0您必须使用光标
来创建单击事件。看到了,谢谢@DonMcCurdy。请你把它作为答案贴出来,这样我就可以接受了
AFRAME.registerComponent('raycaster-autorefresh', {
init: function () {
// This will be called after the entity has properly attached and loaded.
console.log('I am readyyyyy!');
}
});
AFRAME.registerComponent('open-desc', {
init: function() {
var data = this.data;
var el = this.el;
el.addEventListener('click', function() {
console.log("hiiiiiiiiiiii");
});
},
});
<a-camera>
<a-cursor></a-cursor>
</a-camera>
<a-scene cursor="rayOrigin:mouse">