You are not logged in.

Dear visitor, welcome to krpano.com Forum. If this is your first visit here, please read the Help. It explains in detail how this page works. To use all features of this page, you should consider registering. Please use the registration form, to register here or read more information about the registration process. If you are already registered, please login here.

1

Wednesday, April 8th 2020, 11:07am

Sync Plugin - Lag When Switching Panes

Hi,

I am using the sync JavaScript sync plugin/example (https://krpano.com/releases/1.20.5/examples/#js-sync-viewers), but enabling sync on the click of a button (to allow manual alignment of images before syncing).

This seems to work fine when starting on the left pane, but when switching panes, it doesn't seem to catch up immediately and can take a few seconds before it suddenly catches up. I can't seem to reproduce this with the example, so I was just wondering if anyone could see any issues with my usage?

This is the sync button handler logic:


var panoLeft = document.getElementById('left');
var panoRight = document.getElementById('right');

panoLeft.set("sync", true);
panoRight.set("sync", true);

panoLeft.set("syncviewer", "panoRight");
panoRight.set("syncviewer", "panoLeft");



In my xml I have this:

<include url="/plugins/sync.xml" />



<events
onmousedown="events.onviewchange();"
onmousewheel="events.onmousedown();"
onviewchange="update_compass();"
onloaderror="js(return false;)"
/>

and I also have a couple of other plugins included such as radar, compass and showtext but leaving them out for brevity.

Finally, the sync.xml which is really the same but with the added check for the sync being enabled


<events name="sync" keep="true"
onmousedown="sync_to_other_viewer(get(timertick));"
onmousewheel="sync_to_other_viewer(get(timertick));"
oncontextmenu="sync_to_other_viewer(get(timertick));"
onviewchange="sync_to_other_viewer();"
/>


<action name="sync_to_other_viewer" type="Javascript"><![CDATA[

var sync = krpano.get("sync");

var otherviewer = document.getElementById(krpano.get("syncviewer"));

if (otherviewer && otherviewer.get && sync) {
var lastuserinteraction = args[1] | 0;

if (lastuserinteraction) {
krpano.sync_lastuserinteraction = lastuserinteraction;
} else {
lastuserinteraction = krpano.sync_lastuserinteraction | 0;
}

var otherkrpano = otherviewer.get("global");

otherkrpano_lastuserinteraction = otherkrpano.sync_lastuserinteraction | 0;

if (lastuserinteraction > otherkrpano_lastuserinteraction) {
// An internal API call to remove the focus from the other viewer.
// That will stop any movement frictions, release pressed keyboard-keys and close an open contextmenu.
otherkrpano.control.panoControl.focusLoss();

var view1 = otherkrpano.view;
var view2 = krpano.view;

// copy view2 properties to view1

2

Wednesday, April 8th 2020, 1:08pm

Digging deeper in to it, I'm a bit confused about how the sync plugin works internally.

I've tried debugging by printing to the console but a few things have came up, such as the kr pano ids are numerical only, when I have named them 'spherical-left-5' and 'spherical-right-4', but logging both krpano objects, both have an id of 5.

The syncviewer property seems to be correct for each, so I am checking that and printing out the opposite side and I get both sides appearing when I assumed it'd be only the side I'm currently interacting with (screenshot attached), but I think this is meant to happen since the internal api will be making changes to the left and then subsequently the right, which makes sense, but I am just confused on how I can reliably determine which side has been interacted with most recently, or why the existing logic that's already there doesn't quite work sometimes when switching panes.

Cheers,
Martin
martincarlin87 has attached the following image:
  • Screenshot 2020-04-08 at 12.03.24.png

This post has been edited 1 times, last edit by "martincarlin87" (Apr 8th 2020, 1:43pm)