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.

  • "JB Colebrook" started this thread

Posts: 87

Location: All over

Occupation: this

  • Send private message

1

Tuesday, April 13th 2010, 10:04am

Button to select the last panorama that was viewed

Hi All

I know there is actions to automate next and previous scenes - and thats great.... but what about "go back to the last panorama that I viewed please, not the scene numbered lower but the last one I viewed"

Ideas - cheers

John

2

Wednesday, April 14th 2010, 8:46am

RE: Button to select the last panorama that was viewed

what about "go back to the last panorama that I viewed please, not the scene numbered lower but the last one I viewed"
John

I had written this in javascript a while back when I was trying to make the browser back button work with krpano, so it was a simple matter to recode this into xml actions. These actions will support a complete history of panos viewed in a given session and allow you to go back or forward through the panos visited in a manner similar to your browser's back and foward buttons.

There are three actions which are used to support back and forward buttons: hist_new(), hist_back(), and hist_forward(). To make this work, whenever a pano is loaded, you need to run hist_new(). I put this function in the events.onxmlcomplete action. Then create two plugins for buttons named back_button and forward_button. Set the onclick for these plugins to hist_back() and hist_forward() respectively. Note that this example uses the buttons.jpg that is found in the skin directory for the krpano release as well as the hotspot_ani_white.swf animated hotspot (but neither are required to integrate into your tour).

This code was not written to work with scenes. It relies on the xml.url changing. I suspect that it would be easy to modify for scenes, but I really don't have any experience with them, so I'll leave that to someone else.

Here's a (hopefully) working example. You'll need to copy and paste the following three code sections into three separate files named history1.xml, history2.xml, and history3.xml. In your html use the swf.addVariable('xml', 'history1.xml'); to load the history1.xml and then use the hotspots to navigate around. You'll note that a back button will appear in the upper left hand.corner. If you navigate back then the forward button appears.

First file named history1.xml (this contains the history actions and the plugins for the back and forward buttons):

Source code

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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
<krpano version="1.0.8" >
	<events onxmlcomplete="hist_new()" />

	<history />
	<action name="delete_array">
		if (%1.count !== null,
			if (%1.count GT 0,
				set(%1[0].name,null);
				delete_array(%1);
			);
		);
	</action>
	<action name="hist_new">
		if (%1 == null,
			if (history.back.count === null,
				hist_new(0,-1);
			<!--else-->,
				sub(action[%0].tmp,get(history.back.count),1);
				hist_new(get(history.back.count),get(action[%0].tmp));
			);
		<!--else-->,
			if (history.back[%2].name !== xml.url,
				set(history.back[%1].name,get(xml.url));
				delete_array(history.forward);
				if (history.back.count GE 2,
					set(plugin[back_button].visible,true);
					tween(plugin[back_button].alpha,1,0.5);
				);
				tween(plugin[forward_button].alpha,0,0.5,linear,set(plugin[forward_button].visible,false););
			);
		);
	</action>
	<action name="hist_back">
		if (%1 == null,
			sub(action[%0].tmp,get(history.back.count),1);
			sub(action[%0].tmp2,get(history.back.count),2);
			if (action[%0].tmp2 GE 0,
				hist_back(get(action[%0].tmp),get(action[%0].tmp2));
			);
		<!--else-->,
			set(history.forward[-1].name,get(history.back[%1].name));
			set(history.back[%1].name,null);
			if (history.back[%2].name !== null,
				loadpano(get(history.back[%2].name),null,KEEPBASE,BLEND(2),;);
			);
			if (history.back.count LE 1,
				tween(plugin[back_button].alpha,0,0.5,linear,set(plugin[back_button].visible,false););
			);
			set(plugin[forward_button].visible,true);
			tween(plugin[forward_button].alpha,1,0.5);
		);
		
	</action>
	<action name="hist_forward">
		if (%1 == null,
			if (history.forward.count != null,
				sub(action[%0].tmp,get(history.forward.count),1);
				if (action[%0].tmp GE 0,
					hist_forward(get(action[%0].tmp));
				);
			);
		<!--else-->,
			set(action[%0].tmp,get(history.forward[%1].name));
			set(history.back[-1].name,get(history.forward[%1].name));
			set(history.forward[%1].name,null);
			loadpano(get(action[%0].tmp),null,KEEPBASE,BLEND(2),;);
			if (history.forward.count LE 0,
				tween(plugin[forward_button].alpha,0,0.5,linear,set(plugin[forward_button].visible,false););
			);
			set(plugin[back_button].visible,true);
			tween(plugin[back_button].alpha,1,0.5);
		);
		
	</action>

	<plugin name="back_button"
		url="%SWFPATH%/skin/buttons.jpg"
		keep="true"
		visible="false"
		alpha="0"
		align="topleft"
		edge="center"
		y="20"
		x="20"
		crop="0|0|40|40" onovercrop="0|40|40|40" ondowncrop="0|80|40|40"
		blendmode="screen"
		onover="set(blendmode,add);"
		onout="set(blendmode,screen);"
		onhover="showtext(click to move back);"
		onclick="hist_back()" />
	<plugin name="forward_button"
		url="%SWFPATH%/skin/buttons.jpg"
		keep="true"
		visible="false"
		alpha="0"
		align="topleft"
		edge="center"
		y="20"
		x="60"
		blendmode="screen"
		crop="40|0|40|40" onovercrop="40|40|40|40" ondowncrop="40|80|40|40"
		onover="set(blendmode,add);"
		onout="set(blendmode,screen);"
		onhover="showtext(click to move forward);"
		onclick="hist_forward();" />

	<!--EXAMPLE HOTSPOTS-->
	<hotspot name="hs2"
	         url="%SWFPATH%/plugins/hotspot_ani_white.swf"
	         ath="0"
	         atv="-5.14"
	         keep="false"
	         visible="true" enabled="true" handcursor="true" capture="true" children="false"
	         onhover="showtext(Click here to goto history2)"
	         onclick="set(view.fovmin,5);looktohotspot(hs2,10);loadpano(history2.xml,null,KEEPBASE,BLEND(2),lookat(38.45,24.01,50.34);wait(blend);lookto(0,0,65,smooth(100,100,100));)"
		>
	</hotspot>
	<hotspot name="hs3"
	         url="%SWFPATH%/plugins/hotspot_ani_white.swf"
	         ath="0"
	         atv="5.14"
	         keep="false"
	         visible="true" enabled="true" handcursor="true" capture="true" children="false"
	         onhover="showtext(Click here to goto history3)"
	         onclick="set(view.fovmin,5);looktohotspot(hs3,10);loadpano(history3.xml,null,KEEPBASE,BLEND(2),lookat(38.45,24.01,50.34);wait(blend);lookto(0,0,65,smooth(100,100,100));)"
		>
	</hotspot>

	<preview type="grid(cube,16,16,512,0xCCCCCC,0x333333,0x999999);" details="16" />
</krpano>


Second file named history2.xml:

Source code

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
<krpano version="1.0.8" >

	<events onxmlcomplete="hist_new()" />

	<!--EXAMPLE HOTSPOTS-->
	<hotspot name="hs1"
	         url="%SWFPATH%/plugins/hotspot_ani_white.swf"
	         ath="0"
	         atv="-5.14"
	         keep="false"
	         visible="true" enabled="true" handcursor="true" capture="true" children="false"
	         onhover="showtext(Click here to goto history1)"
	         onclick="set(view.fovmin,5);looktohotspot(hs1,10);loadpano(history1.xml,null,KEEPBASE,BLEND(2),lookat(38.45,24.01,50.34);wait(blend);lookto(0,0,65,smooth(100,100,100));)"
		>
	</hotspot>
	<hotspot name="hs3"
	         url="%SWFPATH%/plugins/hotspot_ani_white.swf"
	         ath="0"
	         atv="5.14"
	         keep="false"
	         visible="true" enabled="true" handcursor="true" capture="true" children="false"
	         onhover="showtext(Click here to goto history3)"
	         onclick="set(view.fovmin,5);looktohotspot(hs3,10);loadpano(history3.xml,null,KEEPBASE,BLEND(2),lookat(38.45,24.01,50.34);wait(blend);lookto(0,0,65,smooth(100,100,100));)"
		>
	</hotspot>
	<preview type="grid(cube,16,16,512,0xCCCCCC,0xFF0000,0x999999);" details="16" />
</krpano>

Third file named history3.xml:

Source code

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
<krpano version="1.0.8" >

	<events onxmlcomplete="hist_new()" />

	<!--EXAMPLE HOTSPOTS-->
	<hotspot name="hs1"
	         url="%SWFPATH%/plugins/hotspot_ani_white.swf"
	         ath="0"
	         atv="-5.14"
	         keep="false"
	         visible="true" enabled="true" handcursor="true" capture="true" children="false"
	         onhover="showtext(Click here to goto history1)"
	         onclick="set(view.fovmin,5);looktohotspot(hs1,10);loadpano(history1.xml,null,KEEPBASE,BLEND(2),lookat(38.45,24.01,50.34);wait(blend);lookto(0,0,65,smooth(100,100,100));)"
		>
	</hotspot>
	<hotspot name="hs2"
	         url="%SWFPATH%/plugins/hotspot_ani_white.swf"
	         ath="0"
	         atv="5.14"
	         keep="false"
	         visible="true" enabled="true" handcursor="true" capture="true" children="false"
	         onhover="showtext(Click here to goto history2)"
	         onclick="set(view.fovmin,5);looktohotspot(hs2,10);loadpano(history2.xml,null,KEEPBASE,BLEND(2),lookat(38.45,24.01,50.34);wait(blend);lookto(0,0,65,smooth(100,100,100));)"
		>
	</hotspot>
	<preview type="grid(cube,16,16,512,0xCCCCCC,0x0000FF,0x999999);" details="16" />
</krpano>

Hope this meets your needs!

steve

VN2009

Professional

Posts: 1,334

Location: Duluth MN

  • Send private message

3

Wednesday, April 14th 2010, 3:28pm

nice work. this will be handy is some situations.

4

Thursday, October 7th 2010, 1:23am

thanks

your script has helped me alot
learning about the krpano syntax.
thanks so much for sharing

5

Thursday, October 7th 2010, 1:27am

RE: thanks

your script has helped me alot
learning about the krpano syntax.
thanks so much for sharing
You're more than welcome.

Actually, I've found that the best way to learn about krpano is to create working solutions to questions posted on the forum. I believe our resident guru Michel has said the same thing.

steve

michel

Professional

Posts: 1,153

Location: ANDORRA

Occupation: TV

  • Send private message

6

Thursday, October 7th 2010, 10:55pm

Quoted

You're more than welcome.
*attention* It's a great guy *thumbsup*



*g* Cheers Guru Steve... *thumbup*

SAlut.

7

Friday, October 8th 2010, 1:32am

you guys are an amazing inspiration and love the sign.
makes me want to plug in again that old amiga up on the attic.