我创造了一个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;