Search code examples
objectentitymouseaframeraycasting

Aframe disable raycaster of the mouse


Hey Community/(Piotr Adam),

My raycaster just should interact with elements with the class "clickable". This works fine but my mouse still activates every element how can i let my mouse know that it should just interact with "clickable" elements?

Here a bit code but i guess its not necessary:

<a-scene cursor="rayOrigin: mouse">

<a-entity rotation="0 90 0">
  <a-camera user-height="0" look-controls>
    <a-cursor fuse="true" fusetimeout="2000"
      position="0 0 -0.1"
      raycaster="objects: .clickable"
      geometry="primitive: ring;
      radiusInner: 0.002;
      radiusOuter: 0.003"
      material="color: red; shader: flat">
      <a-animation attribute="scale"
                      to="3 3 3"
                      dur="2000"
                      begin="cursor-fusing"
                      fill="backwards"
                      easing="linear">
      </a-animation>
   </a-cursor>
    <a-entity id="redcircle" position="0 0 -0.1" 
            geometry="primitive: ring;
            radiusInner: 0.007;
            radiusOuter: 0.0077"
            material="color: red; opacity: 0.25; shader: flat"></a-entity>
 </a-camera>  
</a-entity>  

Solution

  • Just throw the whitelist piece to the scene, where you have your mouse cursor:

    <a-scene cursor="rayOrigin: mouse" raycaster="objects: .clickable">
    

    fiddle here.

    But ideally it would be if you had some piece of code setting up either one cursor or another depending on your needs.