'How to change camera position/walk in aframe vr with accelerometer?

(I know it will be unstable but I still want to try it)

I want to move around in aframe scene using accelerometer

  AFRAME.registerComponent('acccam',{
  window.addEventListener('devicemotion', function(){
            var acc = event.acceleration;
            this.el.object3D.position.x += acc.x*9.8;
            this.el.object3D.position.y += acc.y*9.8;
            this.el.object3D.position.z += acc.z*9.8;

        }, true);
  })

I expect the camera to move or at least shake/something but nothing is happening could getelement by id, get attribute and set attribute be used to update the position by taking temporary values and then cloning them if yes then how?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source