Ya existe alguna herramienta que me permita usar los datos del Giroscopio

Comments

3 comments

  • Avatar
    Goyo Gomez

    Hola.

     

    No, lo siento, aunque dependiendo del dispositivo y usando javascript o html5 puede hacerse funcionar en las web screen:

    http://support.mobincube.com/hc/es/articles/200325767-Web

     

    Por ejemplo, este código mostrará  el giroscopio, si buscas en google hay miles de ejemplos:

     

     
    <DOCTYPE html>
    <html>
      <head>
        <style>
          #compass{
            width:100%;
            transform-origin: 50% 50%;
            -webkit-transform-origin: 50% 50%;
            -moz-transform-origin: 50% 50%;
          }
        </style>
        <script>
          function init() {
            var compass = document.getElementById('compass');
            if(window.DeviceOrientationEvent) {
     
              window.addEventListener('deviceorientation', function(event) {
                    var alpha;
                    //Check for iOS property
                    if(event.webkitCompassHeading) {
                      alpha = event.webkitCompassHeading;
                      //Rotation is reversed for iOS
                      compass.style.WebkitTransform = 'rotate(-' + alpha + 'deg)';
                    }
                    //non iOS
                    else {
                      alpha = event.alpha;
                      webkitAlpha = alpha;
                      if(!window.chrome) {
                        //Assume Android stock (this is crude, but good enough for our example) and apply offset
                        webkitAlpha = alpha-270;
                      }
                    }
     
                    compass.style.Transform = 'rotate(' + alpha + 'deg)';
                    compass.style.WebkitTransform = 'rotate('+ webkitAlpha + 'deg)';
                    //Rotation is reversed for FF
                    compass.style.MozTransform = 'rotate(-' + alpha + 'deg)';
                  }, false);
            }
          }
        </script>
      </head>
      <body onload="init()">
        <div id="compassContainer">
          <img src="compass.jpg" id="compass"/>
        </div>
      </body>
    </html>

    0
    Comment actions Permalink
  • Avatar
    Diego Vega

    Gracias X el aporte, ya deberían tener un modulo nativo para Android....me podría decir que detiene a su plataforma implementarla. A ver si contribuimos con un grano de arena.

    0
    Comment actions Permalink
  • Avatar
    Goyo Gomez

    Hola.

    Que los programadores no dan a basto con tantas nuevas características.

    0
    Comment actions Permalink

Please sign in to leave a comment.

Powered by Zendesk