2017-07-24 64 views
0

将边框添加到 边框如何在选择时向曲面图像添加边框? Aframe.io:在鼠标悬停时使用

以下代码将更改图像的材质颜色,但我更愿意添加边框或发光。

AFRAME.registerComponent('selectable', { 

    init: function() { 
     var el = this.el; 
     this.el.addEventListener('mouseenter', function (evt) { 
      this.setAttribute('material', 'color', 'blue'); 

     }); 
     this.el.addEventListener('mouseleave', function (evt) { 
      this.setAttribute('material', 'color', ''); 
     }); 

    } 
}); 

这里是一个JSBIN表示用于说明上述

回答

2

创建一个稍微大一点的<a-curvedimage>你落后了,但不给它的图像纹理src,只是提供了坚实的颜色,也许切换不透明/可视性。

AFRAME.registerComponent('selectable', { 

    init: function() { 
     var el = this.el; 
     var backgroundEl = el.sceneEl.querySelector('#backgroundEl'); 
     this.el.addEventListener('mouseenter', function (evt) { 
      backgroundEl.setAttribute('visible', true); 

     }); 
     this.el.addEventListener('mouseleave', function (evt) { 
      backgroundEl.setAttribute('visible', false) 
     }); 

    } 
});