【问题标题】:Aframe disable raycaster of the mouseAframe禁用鼠标的raycaster
【发布时间】:2018-11-20 14:16:05
【问题描述】:

嘿社区/(Piotr Adam),

我的 raycaster 应该与“可点击”类的元素交互。这工作正常,但我的鼠标仍然激活每个元素我怎样才能让我的鼠标知道它应该只与“可点击”元素交互?

这里有一点代码,但我想没有必要:

<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>  

【问题讨论】:

    标签: object entity mouse aframe raycasting


    【解决方案1】:

    只需将白名单片段扔到您有鼠标光标的场景中:

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

    小提琴here.

    但理想情况下,如果您有一段代码根据您的需要设置一个或另一个光标。

    【讨论】:

    • 嘿,我也可以在 div´s = 上应用这个吗?我的光标仍然触发 div 没有可点击的类。
    • @Delidragon 光线投射器在 a 帧渲染场景上工作。如果你想禁用点击尝试使用css属性pointer-events:none
    • 工作完美 thx :D 你知道我是如何在 javascript 中编码的,当我按下我的元素指针事件:none 可以添加吗?比如 document.getElementById("videoicon").classList.add('clickable');
    • document.getElementById("videoicon").style.pointer-events = "none";不工作:)
    • 哦,很简单:document.getElementById("videoicon").style.pointerEvents = "none";
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2023-03-08
    • 1970-01-01
    • 1970-01-01
    • 2019-08-18
    • 2018-10-04
    相关资源
    最近更新 更多