在移动设备上无法使用VR模式

时间:2018-06-10 02:54:20

标签: javascript aframe

  • A-Frame版本:8.2
  • 平台/设备:I-Phone
  • 可重复使用的代码段或网址:JSFiddle

我创造了一个VR世界,你环顾四周,然后点击前进。但是,当您在移动设备上进入VR模式时,由于某种原因您无法继续前进。我认为这是一个框架中的错误。请帮我解决这个问题,我一直试图解决它几个小时。



<script src="https://aframe.io/releases/0.8.2/aframe.min.js"></script>
<script>
  AFRAME.registerComponent("foo", {
    init: function() {
      this.mouseDown = false
      this.el.addEventListener("mousedown", (e) => {
        this.mouseDown = true
      })
      this.el.addEventListener("mouseup", (e) => {
        this.mouseDown = false
      })
    },
    tick: function() {
      if (this.mouseDown) {
        let pos = this.el.getAttribute("position")
        let mesh = this.el.object3D
        var matrix = new THREE.Matrix4();
        var direction = new THREE.Vector3(0, 0, -0.1);

        matrix.extractRotation(mesh.matrix);
        direction.applyMatrix4(matrix)
        direction.add(new THREE.Vector3(pos.x, pos.y, pos.z))
        this.el.setAttribute("position", direction)
      }
    }
  })

</script>
<a-scene>
  <a-torus-knot color="red" arc="90" p="3" q="8" radius="3" radius-tubular="0.2" position="0 0 -10"></a-torus-knot>

  <a-camera id="theCamera" position="0 1 5" wasd-controls="acceleration: 100" foo>
    <a-cursor color="red" />
  </a-camera>

</a-scene>
&#13;
&#13;
&#13;

0 个答案:

没有答案