Googlevr / vrview Read the onGetPosition position form and set its value for the next init

I am wondering if it is possible (I hope this is) to set the rotation of the init-camera from onGetPosition?

My onGetPosition function is as follows:

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

The initial view with default_yaw set to 0 degrees is as follows: init At this position, onGetPosition returns: {Yaw: 0, Pitch: -0, x: -0, y: 0, z: -0}

Then turn the scene to see this position (about 90 degrees 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 the camera rotation inside the setDefaultYaw_ function, I would see the 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 the second image in init. How can I solve it?

+5
source share

Source: https://habr.com/ru/post/1274554/


All Articles