Обнаружение устройства Aframe - PullRequest
0 голосов
/ 23 мая 2018

я пытаюсь отключить курсор в браузере, есть идеи?На афрамезите (https://aframe.io/docs/master/core/utils.html#function-utils) я нашел AFRAME.utils.device.isMobile (), но я не знаю, что мне с ним делать, я попробовал что-то вроде этого:

<script>AFRAME.utils.device.isMobile ()
  if (isMobile = true){
    console.log('hallo mobile');
  } else {
    console.log('hallo browser');
  }
</script>

, чтобы я мог видетьесли я хотя бы могу это обнаружить, но думаю, у меня проблема с синтаксисом, пожалуйста, помогите :) здесь мой компонент курсора, если необходимо.

<!--camera-->
<a-entity rotation="0 90 0">
  <a-camera user-height="0" look-controls>
    <a-cursor cursor="fuse: true; fuseTimeout: 2000"
        position="0 0 -0.1"
        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 position="0 0 -0.1" 
        geometry="primitive: ring;
        radiusInner: 0.009;
        radiusOuter: 0.0095"
        material="color: red; opacity: 0.25; shader: flat"></a-entity>
  </a-camera>  
</a-entity>  

1 Ответ

0 голосов
/ 23 мая 2018

как насчет простого компонента, который переключит видимость курсора:

AFRAME.registerComponent("foo", {
  init: function() {
   var cursor = document.querySelector("a-cursor")
   if (AFRAME.utils.device.isMobile() === false) {
      cursor.setAttribute("visible", false);
      //or just cursor.parentNode.removeChild(cursor)
      this.el.sceneEl.setAttribute("cursor","rayOrigin","mouse")
   }
 }
})

с такой настройкой:

<!--camera-->
<a-entity foo rotation="0 90 0">
  <a-camera user-height="0" look-controls>
    <a-cursor fuse="true" fuseTimeout="2000"
      position="0 0 -0.1"
      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-camera>  
</a-entity>  
...