Global heading

478 views
Skip to first unread message

Rodolfo Jbegood

unread,
May 27, 2018, 2:21:48 PM5/27/18
to marzipano
Is it possibile when navigating from a scene to another to keep same heading? 
(don't reset heading when changing scene)

IE: Nine images (3x3) with four hotspots (NESW): 
The fist scene (center) heads W.
Rotating and clicking the N hotspot next scene heads N, 
After rotating and clicking the S hotspot, first scene heads S

Tiago Quelhas

unread,
May 29, 2018, 5:28:28 PM5/29/18
to jbego...@gmail.com, marzipano
It can be done with Javascript by listening for the `sceneChange` Viewer event, and copying the view yaw parameter from the old scene to the new one.


--
You received this message because you are subscribed to the Google Groups "marzipano" group.
To unsubscribe from this group and stop receiving emails from it, send an email to marzipano+...@googlegroups.com.
To post to this group, send email to marz...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/marzipano/9e01b452-ca6c-4522-8d40-be95d5916e4f%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Rodolfo Jbegood

unread,
May 31, 2018, 7:47:51 AM5/31/18
to marzipano


Il giorno martedì 29 maggio 2018 23:28:28 UTC+2, Tiago Quelhas ha scritto:
It can be done with Javascript by listening for the `sceneChange`

Thank you, I'll try it.
 

Rodolfo Jbegood

unread,
Jun 28, 2018, 8:19:30 PM6/28/18
to marzipano
Tried this in index.js, but doesn't work. What I did wrong?

  function switchScene(scene) {
       
var myyaw = scene.view._yaw; // read current yaw
     scene
.view.setParameters(scene.data.initialViewParameters);
        scene
.view._yaw = myyaw; // keep current yaw
    scene
.scene.switchTo();
    startAutorotate
();
    updateSceneName
(scene);
    updateSceneList
(scene);
 
}


 

Tiago Quelhas

unread,
Jul 3, 2018, 9:52:47 AM7/3/18
to Rodolfo Jbegood, marzipano
Inside the switchScene function, the `scene` variable points to the scene being switched to. You need to get the yaw from the previous scene (the one being switched from).

You should also call scene.view.yaw() instead of referencing scene.view._yaw directly (which is an implementation detail that may change in the future).

--
You received this message because you are subscribed to the Google Groups "marzipano" group.
To unsubscribe from this group and stop receiving emails from it, send an email to marzipano+...@googlegroups.com.
To post to this group, send email to marz...@googlegroups.com.

Rodolfo Jbegood

unread,
Jul 5, 2018, 5:43:39 PM7/5/18
to marzipano
Now it works. Dirty, but it works.

I can't read scene.view.yaw()  inside click event (null object), 
I can't set scene.view.yaw()  

So I set a global variable

    vat myjaw = 0;


I read yaw inside click event handler

wrapper.addEventListener('click', function () {
    myjaw
= hotspot.yaw;


Then I write yaw in switchScene()

    scene.view.setParameters(scene.data.initialViewParameters);
    scene
.view._yaw = myjaw;

Is there a better way? Thanks

Doug La Farge

unread,
Dec 4, 2018, 10:05:08 AM12/4/18
to marzipano
I'm trying to figure out how to make this modification but am stuck.  This is what i have (including the original unedited function and then in comments the way I'm attempting to edit):

  function switchScene(scene) {
    stopAutorotate();
    scene.view.setParameters(scene.data.initialViewParameters);
    scene.view.yaw = 0;
    scene.scene.switchTo();
    startAutorotate();
    updateSceneName(scene);
    updateSceneList(scene);
  }
/*
function switchScene(scene) {
    ### added
    
    vat myjaw = 0;
    wrapper.addEventListener('click', function () {
    myjaw = hotspot.yaw;
    }
    
    stopAutorotate();
    scene.view.setParameters(scene.data.initialViewParameters);
    
    ###added
    scene.view._yaw = myjaw;
    
    
    scene.scene.switchTo();
    startAutorotate();
    updateSceneName(scene);
    updateSceneList(scene);
  }

*/

Doug La Farge

unread,
Dec 4, 2018, 10:06:42 AM12/4/18
to marzipano
My yaw doesn't change between scenes.  Can you point out what I'm missing? 
Any help is appreciated. 

Rodolfo Jbegood

unread,
Aug 7, 2020, 5:54:38 AM8/7/20
to marzipano
You coded fine, but the variable 'myjaw' is in the wrong place. My Yaw must be added in three different places: global variables, switchScene and in click event handler.



'use strict';
(function () {
  // Add jaw here for global value
  var myyaw = 0;    // added

  var Marzipano = window.Marzipano;

...
...

 
  function switchScene(scene) {
    stopAutorotate();
    scene.view.setParameters(scene.data.initialViewParameters);

    scene.view._yaw = myyaw;    // added

    scene.scene.switchTo();
    startAutorotate();
    updateSceneName(scene);
    updateSceneList(scene);
  }

...
...

    // Add click event handler.
   wrapper.addEventListener('click', function () {

      myyaw = hotspot.yaw;      // added

      switchScene(findSceneById(hotspot.target));
    });

    

 

lol 257

unread,
Aug 30, 2024, 5:07:01 PM8/30/24
to marzipano
I had the problem and created a little tool to help me: [marzipano-hotspot-view (github)](https://github.com/gamebeaker/marzipano-hotspot-view)
It is a little bit different because you have to set the view manual per hotspot and not automatically.
Reply all
Reply to author
Forward
0 new messages