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

Thursday, November 28th 2013, 6:52am

Trigger Event at HLOOKAT update from old post

This has been posted before, with a response from Klaus. post

I am hoping there is an updated, or better way of accomplishing this with adjusthlookat or something. I wanted to do a daytime to nighttime to daytime transition when the user reached a certain horizontal point... ie around hlookat 0. It works fine if the user swings the pano left and back to the right, but if the user continues around and around in same direction, hlookat goes beyond 360 degree count and continues indefinitely with user persistence, thereby never reaching near the 0 value again.

I am using cubeface hotspots that turn on/off inside the daytime scene to show/hide the nighttime scene.

Test here... move right, then left, then right... but full rotate not work.
test
xml
Ideas? Suggestions? Help? Advice? Criticism? *cool*

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
<krpano version="1.16" onstart="showlog();  set(counter, 0); startup();">

	<events onviewchange="transition();" />

	<action name="transition">
    if(counter == 0,
    	if(view.hlookat GE 0, 
    		if(view.hlookat LT 1.0, 
    			delayedcall(1.0, changetonight(); );
    		); 
    	);
    );
    if(counter == 1,
    	if(view.hlookat GE 0, 
    		if(view.hlookat LT 1.0, 
    			delayedcall(1.0, changetoday(); );
    		); 
    	);
    );
	</action>

	<action name="changetonight">
		set(counter, 1); if(counter == 1, stopall();); 
		for(set(i, 1), i LE 6, inc(i),
			txtadd(night, 'hot_', get(i));
			set(hotspot[get(night)].visible, true);
			tweenhsalpha(get(night), 1.0);
		);
		trace(Its Night);
	</action>
	<action name="changetoday">
		set(counter, 0); if(counter == 0, stopall(););
		for(set(i, 1), i LE 6, inc(i),
			txtadd(day, 'hot_', get(i));
			set(hotspot[get(day)].visible, true);
			tweenhsalpha(get(day), 0.0);
		);
		trace(Its Day);
	</action>
<action name="tweenhsalpha">
   tween(hotspot[%1].alpha,%2, 1.0);
</action>

	<action name="startup">
		loadscene(scene_day, null, MERGE);
	</action>
	
	<scene name="scene_day" title="day" onstart="" thumburl="panos/day.tiles/thumb.jpg" lat="" lng="" heading="">
		<view hlookat="-1" vlookat="0" fovtype="MFOV" fov="120" maxpixelzoom="2.0" fovmin="70" fovmax="140" limitview="auto" />
		<preview url="panos/day.tiles/preview.jpg" />
		<image>
			<cube url="panos/day.tiles/pano_%s.jpg" />
			<mobile>
				<cube url="panos/day.tiles/mobile_%s.jpg" />
			</mobile>
		</image>

   <style name="cubeface" width="1002" height="1002" distorted="true" enabled="false" pixelhittest="true" preload="true" visible="false" alpha="0.0" />
    <hotspot name="hot_1" style="cubeface" url="panos/night.tiles/pano_l.jpg" ath="-90"  atv="0"   zorder="2" />
    <hotspot name="hot_2" style="cubeface" url="panos/night.tiles/pano_f.jpg" ath="0"    atv="0"   zorder="2" />
    <hotspot name="hot_3" style="cubeface" url="panos/night.tiles/pano_r.jpg" ath="+90"  atv="0"   zorder="2" />
    <hotspot name="hot_4" style="cubeface" url="panos/night.tiles/pano_b.jpg" ath="+180" atv="0"   zorder="2" />
    <hotspot name="hot_5" style="cubeface" url="panos/night.tiles/pano_u.jpg" ath="0"    atv="-90" zorder="2" />
    <hotspot name="hot_6" style="cubeface" url="panos/night.tiles/pano_d.jpg" ath="0"    atv="+90" zorder="2" />

	</scene>
</krpano>

This post has been edited 2 times, last edit by "nefar1ous" (Nov 28th 2013, 7:52am)


Alexey Tkachenko

Professional

Posts: 760

Location: Sevastopol, Crimea, Russian Federation

Occupation: Interpreting, Building virtual tours

  • Send private message

2

Thursday, November 28th 2013, 10:57am

Hi! What if keep hlookat within the range - from -180 to +180?

Try add this:

Source code

1
<events name="hlookat_check" keep="true" onviewchanged="check_hlookat();"/>


and action:

Source code

1
2
3
4
<action name="hlookat_check" >
if(view.hlookat GT 180, set(view.hlookat, -180););
if(view.hlookat LT -180, set(view.hlookat, 180););
	</action>


Hope this helps.
Regards,

Alexey

3

Thursday, November 28th 2013, 5:40pm

Hi! What if keep hlookat within the range - from -180 to +180?

Try add this:

Source code

1
<events name="hlookat_check" keep="true" onviewchanged="check_hlookat();"/>


and action:

Source code

1
2
3
4
<action name="hlookat_check" >
if(view.hlookat GT 180, set(view.hlookat, -180););
if(view.hlookat LT -180, set(view.hlookat, 180););
	</action>


Hope this helps.


Hey, thanks so much Alexey. That certainly works. Interesting, I thought the view.hlookat needed a workaround (adjust)and was not diretly editable. Been schooled again :)