5

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
    });
...
}

https://github.com/googlevr/vrview/blob/4e8e57eaddd8e69c8e032a6b5844d4e96af02156/src/embed/main.js#L357

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'));
};

https://github.com/googlevr/vrview/blob/2dd890d147f702b9c561694bda5c86575c2a3d44/src/embed/world-renderer.js#L235

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

Wojciech Jasiński
  • 1,480
  • 2
  • 20
  • 42

0 Answers0