2017-07-24 40 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) 
     }); 

    } 
});