Sie sind nicht angemeldet.

1

Sonntag, 11. Dezember 2022, 21:15

Synchronise viewers - how to synchronise more than two viewers

Hey krpanians,
using the: https://krpano.com/releases/1.20.5/examples/#js-sync-viewers, could someone kindly help me with how to synchronize more than two viewers *confused* I would need to synchronize 2 (done using example), 3 and 4 viewers in one html. Any help is highly appreciated (I am strong in photography but not so strong in javascript). Thx
V.

Tuur

Erleuchteter

Beiträge: 3 839

Wohnort: Netherlands

Beruf: Krpano custom coding / Virtual Tours / Photography / Musician / Recording engineer

  • Nachricht senden

2

Montag, 12. Dezember 2022, 12:36

Hi,

a good, and relative simple, option is to use the layer type krpano for such.
https://krpano.com/docu/xml/#layer.type

I have done this and it works just great.

Tuur *thumbsup*

3

Montag, 12. Dezember 2022, 16:56

Hi,

a good, and relative simple, option is to use the layer type krpano for such.
https://krpano.com/docu/xml/#layer.type

I have done this and it works just great.

Tuur *thumbsup*
Hi Tuur!
it seems reasonable to use layers in this case, but how do you then synchronise all the views (in individual layers) in a way that all (in my case 4) views are synchronised and the view can be controlled from any one of them. That's what I have been struggling with, I have been trying to modify sync.xml from https://krpano.com/releases/1.20.5/examples/#js-sync-viewer, but I haven't really sucseeded *pinch* . Thanks

Venca

kme

Fortgeschrittener

Beiträge: 310

Wohnort: Belgium

Beruf: Long time coder, product manager and 3D enthousiast

  • Nachricht senden

4

Montag, 12. Dezember 2022, 18:51

I managed to do it using a modified version of the syncscreen example.
Basically, I modified the sync.xml to take an array of syncviewers and loop through the array to update the other views:

Quellcode

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
	<action name="sync_to_other_viewer" type="Javascript"><![CDATA[

		viewers = krpano.get("syncviewer").split(",");
		
		viewers.forEach(function(viewer) {

			var otherviewer = document.getElementById( viewer );
			if (otherviewer && otherviewer.get)
			{
			
				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();
					
					krpano.call("trace(" + krpano.get("syncviewer").split(",") + ")");
				
					var view1 = otherkrpano.view;
					var view2 = krpano.view;
					
					view1.hlookat = view2.hlookat;
					view1.vlookat = view2.vlookat;
					view1.camroll = view2.camroll;
					view1.fovtype = view2.fovtype;
					view1.fov = view2.fov;
					view1.fisheye = view2.fisheye;
					view1.architectural = view2.architectural;
					view1.pannini = view2.pannini;
					view1.tx = view2.tx;
					view1.ty = view2.ty;
					view1.tz = view2.tz;
					view1.ox = view2.ox;
					view1.oy = view2.oy;
					view1.oz = view2.oz;
					view1.rx = view2.rx;
					view1.ry = view2.ry;
				}
			}
		});

		
	]]></action>


and for the html:

Quellcode

1
2
3
4
5
6
7
8
9
10
11
12
13
	<div id="viewersDiv" style="position:absolute; left:0; top:0; width:100%; height:100%;">
		<div id="div1"  style="position:absolute; left:0%;  top:0; width:25%; height:100%;"></div>
		<div id="div2" style="position:absolute; left:25%; top:0; width:25%; height:100%;"></div>
		<div id="div3" style="position:absolute; left:50%; top:0; width:25%; height:100%;"></div>
		<div id="div4" style="position:absolute; left:75%; top:0; width:25%; height:100%;"></div>
	</div>
	
	<script>
		embedpano({html5:"only", consolelog:true, basepath:"../../../", id:"pano1viewer",  target:"div1",  xml:"pano1.xml", vars:{syncside:"pano1",syncviewer:"pano2viewer,pano3viewer,pano4viewer"}, passQueryParameters:true});
		embedpano({html5:"only", consolelog:true,basepath:"../../../", id:"pano2viewer", target:"div2", xml:"pano2.xml", vars:{syncside:"pano2",syncviewer:"pano1viewer,pano3viewer,pano4viewer"}, passQueryParameters:true});
		embedpano({html5:"only", consolelog:true,basepath:"../../../", id:"pano3viewer", target:"div3", xml:"pano3.xml", vars:{syncside:"pano3",syncviewer:"pano1viewer,pano2viewer,pano4viewer"}, passQueryParameters:true});
		embedpano({html5:"only", consolelog:true,basepath:"../../../", id:"pano4viewer", target:"div4", xml:"pano4.xml", vars:{syncside:"pano4",syncviewer:"pano1viewer,pano2viewer,pano3viewer"}, passQueryParameters:true});
	</script>

5

Montag, 12. Dezember 2022, 19:31

I managed to do it using a modified version of the syncscreen example.
Basically, I modified the sync.xml to take an array of syncviewers and loop through the array to update the other views:

Quellcode

1
	


and for the html:

Quellcode

1
2
3
4
5
		embedpano({html5:"only", consolelog:true, basepath:"../../../", id:"pano1viewer",  target:"div1",  xml:"pano1.xml", vars:{syncside:"pano1",syncviewer:"pano2viewer,pano3viewer,pano4viewer"}, passQueryParameters:true});
		embedpano({html5:"only", consolelog:true,basepath:"../../../", id:"pano2viewer", target:"div2", xml:"pano2.xml", vars:{syncside:"pano2",syncviewer:"pano1viewer,pano3viewer,pano4viewer"}, passQueryParameters:true});
		embedpano({html5:"only", consolelog:true,basepath:"../../../", id:"pano3viewer", target:"div3", xml:"pano3.xml", vars:{syncside:"pano3",syncviewer:"pano1viewer,pano2viewer,pano4viewer"}, passQueryParameters:true});
		embedpano({html5:"only", consolelog:true,basepath:"../../../", id:"pano4viewer", target:"div4", xml:"pano4.xml", vars:{syncside:"pano4",syncviewer:"pano1viewer,pano2viewer,pano3viewer"}, passQueryParameters:true});
	
Awesome, working fine here, thanks kme, highly appreciated *w00t*

Eric Chen

Schüler

Beiträge: 68

Wohnort: China

Beruf: Krpano custom coding

  • Nachricht senden

6

Dienstag, 13. Dezember 2022, 05:50

One way to do this is through webgl shaders.
Better performance for multiple identical views.
https://shader-split.vercel.app/

Another option is to use multiple layers of type "krpano". The plug-in will be released soon, but it currently only supports two views.
https://contrast-plugin.vercel.app/pano.html

If you have a customization requirement, we can talk about it. ;-)
*thumbup*

Preload Plugin (Free, source code)
Constrast Plugin
KR HLS Plugin
Slider Controller Plugin
KR+Next+MapBox+TS Demo (source code)


微信:Eric_Chen1990