richtr / threeVR

An orientation-aware Virtual Reality controller for web browsers built on top of three.js
http://richtr.github.io/threeVR/examples/vr_basic.html
439 stars 97 forks source link

Override Camera Reposition on onDocumentTouchEnd #15

Open bwolvin opened 8 years ago

bwolvin commented 8 years ago

I wanted to see if there was a way to override the camera getting set back to the original position when a user manually interacts with the DOM element. Right now, I am trying the following code but it seems like something in the threeVR is overriding this getting set correctly:

function getCameraPosition() {
    var vector = new THREE.Vector3(0, 0, -1);
    vector.applyEuler(camera.rotation, camera.eulerOrder);
    return vector;
}

controls.addEventListener('userinteractionend', function () {
    camera.lookAt(position);
});
jtreat3 commented 5 years ago

The problem is the orientation events are setting the camera's position, not modifying/updating it relative to where it was. I've been struggling with this problem myself.