aframe
2016-08-16 67 views 0 likes 
0

我有一個應用程序,用戶必須通過單擊collada模型上的正確區域來回答問題 - 有2個選項,用戶知道當光標變爲藍色(鼠標進入圓柱體,其可見= false)。A-frame mouseleave不會改變光標的顏色

鼠標變成藍色,但鼠標離開圓柱體時,光標顏色應該返回黑色,但是它保持藍色。

在此先感謝您的幫助。

<a-cursor id="myCursor" color="black"></a-cursor> 

<a-entity id='questionA' geometry="primitive: cylinder; height: .01; radius: 2.5" material="color:green; opacity: 1" correctAnswer > </a-entity> 

var cursorVar = document.getElementById('myCursor'); 
var questionVar = document.getElementById('questionA'); 

questionVar.addEventListener('mouseenter', function() { 
       cursorVar.setAttribute('color', 'blue'); 
      }); 
questionVar.addEventListener('mouseleave', function() { 
       cursorVar.setAttribute('color', 'black'); 
      }); 

回答

1

遊標方也發出事件。試着聽聽來自光標事件作爲一種解決方法:

cursorEl.addEventListener('mouseleave'); 

0.3.0應釋放明天或在兩天內對光標,raycaster,以及對COLLADA模型光線投射的改進。這包括限制在上述解決方法中對哪些射線測試人員進行測試的理想能力。

可能是你的bug中的幾個因素,我認爲一旦0.3.0出來,我可以更清楚地說出發生了什麼。

+0

工作得很好 - 謝謝 –

0

this CodePen您預期的性能?

我看不到問題看你的代碼(也許這是與光標原語有關)。嘗試與在上面的CodePen鏈路中使用的手動定義一個替換光標原始:

<!-- Camera with gaze cursor --> 
    <a-entity position="0 1.8 5"> 
     <a-entity camera look-controls wasd-controls> 
      <a-entity cursor 
        geometry="primitive: ring; radiusOuter: 0.025; 
          radiusInner: 0.015; segmentsTheta: 32" 
        material="color: #283644; shader: flat" 
        raycaster="far: 30" 
        position="0 0 -0.75" 
        id='cursor'> 
      </a-entity> 
     </a-entity> 
    </a-entity> 

這就是說,光線投射似乎有點不準確的(與0.2.0至少)。

相關問題