I want in an aframe game continuous moving to the viewport of the camera. I used the code from here:
In my desktop browser (not vr mode) it works pretty well, but when I am switching to the vr-mode the moving doesn't work...
Here is an exampe of what i have:
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>360° Image Browser</title>
<script src="https://aframe.io/releases/0.7.1/aframe.min.js"></script>
<script src="https://unpkg.com/[email protected]/dist/aframe-extras.ocean.min.js"></script>
</head>
<body>
<a-scene>
<!-- sky + ocean -->
<a-sky radius="100" src="http://2.bp.blogspot.com/-ELqPrSgPbGU/Vcnw54n7Q1I/AAAAAAAAGdk/rcfkvjlMNqI/s1600/PANO_360Test09.jpg"
position="0 -6 0 "></a-sky>
<a-ocean width="200" depth="200" density="200" position="0 0 0"></a-ocean>
<!-- camera + cursor. -->
<a-camera id="camera" position="0 20 80" fly wasd-controls-enabled="false" look>
<a-cursor id="cursor" color="black"></a-cursor>
</a-camera>
</a-scene>
<script>
// document.querySelector("a-scene").enterVR();
AFRAME.registerComponent("fly", {
schema: {
stepFactor: { type: "number", default: 0.1 },
isFlying: { type: "boolean", default: true }
},
tick: function () {
if (this.data.isFlying) {
this.el.components.camera.camera.parent.position.add(
this.el.components.camera.camera
.getWorldDirection()
.multiplyScalar(this.data.stepFactor)
);
}
}
});
</script>
</body>
</html>
you can turn on the vr mode in the script by removing the commit
Anyone an idea?