googlearchive / vrview

Library for embedding immersive media into traditional websites.
http://developers.google.com/cardboard/vrview
Apache License 2.0
1.71k stars 1.09k forks source link

Read position form onGetPosition and set its value for next init #296

Open WojciechJasinski opened 6 years ago

WojciechJasinski commented 6 years ago

Hi, I'm wondering if it is possible (I hope it is) to set init camera rotation read from onGetPosition?

My onGetPosition function look like this:

function onGetPosition() {
    console.log({
        Yaw: worldRenderer.camera.rotation.y * 180 / Math.PI,
        Pitch: worldRenderer.camera.rotation.x * 180 / Math.PI,
        x: worldRenderer.camera.rotation.x,
        y: worldRenderer.camera.rotation.y,
        z: worldRenderer.camera.rotation.z
    });
...
}

I use this image as a texture: crafter

Initial view, with default_yaw set to 0 degrees looks like this: init In this position onGetPosition returns: {Yaw: 0, Pitch: -0, x: -0, y: 0, z: -0}

Then I rotate the scene to see this position (about 90 deg to the left): xxx onGetPosition returns: {Yaw: 75.66036892219512, Pitch: -42.97581864568984, x: -0.7500695341072581, y: 1.3205225509658982, z: 0.7343037709331535}

I thought that if I set camera rotation inside setDefaultYaw_ function I would see last view so I did this:

WorldRenderer.prototype.setDefaultYaw_ = function(angleRad) {
    ...
    this.camera.setRotationFromEuler(new THREE.Euler(-0.7500695341072581, 1.3205225509658982, 0.7343037709331535, 'XYZ'));
};

Unfortunately nothing happened I still see the view from second image on init. How can I solve it?