0
votes

Hi I am trying to navigate between scenes. And when i navigate between scenes, i am not able to set/update rotation of the changed scene. i am storing rotation of scenes and then navigate between. Please help struggling from many days

Link to my code on Glitch https://glitch.com/~thin-newsstand

Working explained. 1. Save camera button saves the rotation into select along with the scene and custom data attribute name data-r 2. If you inspect select dropdown options, you will notice. 3. When select option is changed, it will change sky image from select option and also change rotation. 4. I have used aframe-viewable-component.js to restrict top/bottom movement of skybox.

1

1 Answers

0
votes

It sounds like you want to save and restore camera rotation, when a new panorama is loaded. Since you are using the look-controls component on the camera, you will need to do this using that component. It might be best to modify that component, and create your own custom variation. You can download the original here: https://github.com/aframevr/aframe/blob/master/src/components/look-controls.js

The component does have a built in function for saving and restoring position and rotation

saveCameraPose: function () 
restoreCameraPose: function () 

as it is written, the component can only save one entry

 this.savedPose.position.copy(el.object3D.position);
 this.savedPose.rotation.copy(el.object3D.rotation);

Depending on what you want, you may have to save the position/rotation to new variable that are associated with each pano, so that when a new pano is selected, that same entry for camera pos/rot is also loaded and camera restored. It would probably be best to do this with an array. Psuedo code looks something like:

  1. Make an array (containing objects: {camPos, camRot}). named savedCamPR.
  2. When new pano is selected get the index of current pano. named curPanoID
  3. Save the look-controls pos/rot to savedCamPR[curPanoID], ie the array using the index of current pano.
  4. Get the index of the new pao.
  5. if there is a saved entry in the in savedCamPR, use that to restore the camera.

If you have trouble figuring it out, let us know, and I can probably make an online example that saves and restored camera positions for multiple panos.