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

Monday, January 2nd 2023, 4:41pm

sliding door hotspot

dear forum members



in a recent panorama tour i use image hotspots as sliding doors.

with a simple onclick="tween(ox,-750,4,easeinoutquint)" this works very well.


my wish would now be to start the open-action when the sliding door comes into view.

something like actionstart on look to sliding door-hotspot


thanks for help


klaus

Tuur

Sage

Posts: 3,822

Location: Netherlands

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

  • Send private message

2

Monday, January 2nd 2023, 6:02pm

Hi
Best is do a search on getlooktodistance in the forum and also have a look here:

https://krpano.com/docu/actions/#getlooktodistance

Hope it helps,
Tuur *thumbsup*

3

Monday, January 2nd 2023, 8:18pm

getlooktodistance

i ll have a look.thanks to tuur
lg klaus

4

Tuesday, January 3rd 2023, 2:26pm

sliding door hotspot and getlooktodistance

dear forumpeople


Isn't there a simple example for my problem.
the postings to getlooktodistance are too complicated for me.

I use a hotspot as a sliding door and it should open when the camera looks at it.
What is the standard procedure; what information do I have to read out and how is it passed on.


wbr klaus

example: in the 2nd and the 3d scene my sliding doors are used. currently the doors can be opened with onclick....

https://360.tirol/leo23/

kme

Intermediate

Posts: 308

Location: Belgium

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

  • Send private message

5

Tuesday, January 3rd 2023, 3:12pm

Here is a simple example :

http://krpano.kri-soft.be/examples/getlooktodistance/

basically
  • setup scene with 2 hotspots
  • one hotspot has "click" action associated, the other no action
  • we setup an onviewchanged() event that will check if we look at the second hotspot
  • when event is triggered, we use getlooktodistance with the targethotspot. if the view angle < 20, we change the color. If view angle > 20, we revert the color back


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
	<scene name="scene_1" autoload="true"  title="a1" onstart="">
		<preview type="grid(cube,16,16,512,0xCCCCCC,0x666666,0x999999);" details="16"/>
		<hotspot type="text" html="clickme" name="colorspot" ath="10" atv="0" width="100" height="100" bgcolor="0xff0000" onclick="swapcolor(colorspot)"></hotspot>
		<hotspot type="text" html="lookatme" name="colorspot2" ath="90" atv="0" width="100" height="100" bgcolor="0xff0000"></hotspot>
	</scene>	
	
	<action name="swapcolor" args="name">
		trace(get(name));
		set(hs, get(hotspot[get(name)]));
		if (hs.bgcolor == "0xff0000", set(hs.bgcolor, "0x00ff00"), set(hs.bgcolor,"0xff0000"));
	</action>
	
	<events name="check_viewathotspot_colorspot2" keep="true" onviewchanged="togglehotspot"/>
	
	  <action name="togglehotspot" scope="local">
		getlooktodistance(current_angle, hotspot[colorspot2].ath, hotspot[colorspot2].atv);
		set(hs, get(hotspot[colorspot2]));
		if (current_angle LT 20,
			<!-- dosomething when hotspot is in viewing range -->
			set(hs.bgcolor, "0x00ff00");
			,
			set(hs.bgcolor, "0xff0000");
			);

		trace(get(current_angle));
	  </action>

6

Tuesday, January 3rd 2023, 6:35pm

wonderful

this is the right example for my level
Many Thanks
wbr
klaus



ps now,the "thing" works perfect

https://360.tirol/leo23/

This post has been edited 1 times, last edit by "nikonutsch" (Jan 3rd 2023, 9:26pm)


ramirox3

Intermediate

Posts: 354

Location: La Ceja, Colombia

Occupation: photographer

  • Send private message

7

Tuesday, January 3rd 2023, 11:44pm

Hello KME, I adapted your code to help me show a photo that I have as a hotspot with alpha="0", when going through the assigned angle range. She worked perfectly in a scene where that event occurs only once. In the following scene I have 2 photographs to show at different points,
but it only shows me a photograph, I reverse the order of the codes and it always shows me the one in the last place.

<events name="check_viewathotspot_oapv_foto" keep="true" onviewchanged="togglehotspot"/>
<action name="togglehotspot" scope="local">

getlooktodistance(current_angle, hotspot[oapv_foto].ath,
hotspot[oapv_photo].atv);
set(hs, get(hotspot[oapv_foto]));

if (current_angle LT 30,
<!-- dosomething when hotspot is in viewing range -->
set(hs.alpha, "1");
,
set(hs.alpha, "0");
);

trace(get(current_angle));
</action>

<events name="check_viewathotspot_ao_f" keep="true" onviewchanged="togglehotspot"/>
<action name="togglehotspot" scope="local">

getlooktodistance(current_angle, hotspot[ao_f].ath, hotspot[ao_f].atv);
set(hs, get(hotspot[ao_f]));

if (current_angle LT 30,
<!-- dosomething when hotspot is in viewing range -->
set(hs.alpha, "1");
,
set(hs.alpha, "0");
);

trace(get(current_angle));
</action>


I placed this action outside the scenes:
<action name="swapalpha" args="name">
trace(get(name));
set(hs, get(hotspot[get(name)]));
if (hs.alpha == "0", set(hs.alpha, "1"), set(hs.alpha,"0"));
</action>

What am I doing wrong?

kme

Intermediate

Posts: 308

Location: Belgium

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

  • Send private message

8

Wednesday, January 4th 2023, 9:17am

First, you have a typo:

Source code

1
getlooktodistance(current_angle, hotspot[oapv_foto].ath, hotspot[oapv_photo].atv);


foto / photo ;-)

But I think your problem is because krpano only allows for one onviewchanged() event to be defined, so my suggestion would be to put both the checks inside the same action and only define one event.

So something like this (untested):

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
<events name="check_viewathotspot" keep="true" onviewchanged="togglehotspot"/>
<action name="togglehotspot" scope="local">

	getlooktodistance(current_angle, hotspot[oapv_foto].ath,hotspot[oapv_foto].atv);
	set(hs, get(hotspot[oapv_foto]));

	if (current_angle LT 30,
	<!-- dosomething when hotspot is in viewing range -->
	set(hs.alpha, "1");
	,
	set(hs.alpha, "0");
	);

	trace(get(current_angle));

	getlooktodistance(current_angle, hotspot[ao_f].ath, hotspot[ao_f].atv);
	set(hs, get(hotspot[ao_f]));

	if (current_angle LT 30,
	<!-- dosomething when hotspot is in viewing range -->
	set(hs.alpha, "1");
	,
	set(hs.alpha, "0");
	);

	trace(get(current_angle));
</action>

ramirox3

Intermediate

Posts: 354

Location: La Ceja, Colombia

Occupation: photographer

  • Send private message

9

Wednesday, January 4th 2023, 2:22pm

Thank you. Kme *thumbsup* *thumbup*
Work perfectly.
I tried many variants.
I was very close to the solution, but my level of coding is my limitation *wacko* *whistling*

kme

Intermediate

Posts: 308

Location: Belgium

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

  • Send private message

10

Wednesday, January 4th 2023, 2:49pm

Glad it was useful! Feel free to reach out if you need help...

San7

Professional

Posts: 621

Occupation: coding in krpano

  • Send private message

11

Wednesday, January 4th 2023, 3:44pm

Hello, can you just add doors to the hotspot

Source code

1
2
3
4
5
6
7
8
9
onloaded="drag()" ox="0"	 
drag="adjusthlookat(10);
   if( (ath LT calc(view.hlookat + 30)) AND (ath GT calc(view.hlookat - 30)), 
     if(ox == 0, tween(ox, -750)); 	
     ,	
     if(ox == -750, tween(ox, 0));	
   );	 
  delayedcall(0.01, if(drag, drag()) );					
" 


or so

Source code

1
2
3
4
5
6
7
8
9
onloaded="drag()" ox="0" 
drag="getlooktodistance(cur_angle, ath, atv); 
 if( cur_angle LE 30,  
  tween(ox, -200); 	
  ,	
  tween(ox, 0);	
 );	 
delayedcall(0.01, if(drag, drag()) );					
"

This post has been edited 2 times, last edit by "San7" (Jan 4th 2023, 7:35pm)


12

Sunday, January 8th 2023, 2:24pm

dear San7
thank you for this great solution. it makes working with a lot of hotspots much easier!!!!!!!!!!!!!

San7

Professional

Posts: 621

Occupation: coding in krpano

  • Send private message

13

Sunday, January 8th 2023, 2:50pm

dear San7
thank you for this great solution. it makes working with a lot of hotspots much easier!!!!!!!!!!!!!

*smile*
You can add this code to the style and use it for all hotspots.
And also write the offset value ox into a separate attribute in the hotspot and set it for each door individually. The code will become much shorter
*thumbsup*

14

Monday, January 9th 2023, 6:13pm

a new problem

with this code i can get all hotspots with x at the beginning of the title



Source code

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
<events name="check_viewathotspot" keep="true" onviewchanged="slideingdoor"/>
<action name="slideingdoor">
for(set(i,0), i LT hotspot.count, inc(i),
copy(hs,hotspot[get(i)]);
hs.getcenter(hs_h, hs_v);
getlooktodistance(d, hs_h, hs_v);
subtxt(destVar,get(hs.name),0, 1);
if(destVar == "x",
if(d LT 40,
set(hs.ox, 200);
,
set(hs.ox, -200);
);
);
);

</action>

but when i try a tween instead of set, nothing happens any more

Source code

1
2
3
4
5
6
7
8
9
10
11
<action name="slideingdoor">
for(set(i,0), i LT hotspot.count, inc(i),
copy(hs,hotspot[get(i)]);
hs.getcenter(hs_h, hs_v);
getlooktodistance(d, hs_h, hs_v);
subtxt(destVar,get(hs.name),0, 1);
if(destVar == "x",
if(d LT 40,
tween(hs.ox, 200,3); ,
tween(hs.ox, -200,3); );); );
</action>



there is a problem with this code. it doesn't work

wbr klaus

This post has been edited 2 times, last edit by "nikonutsch" (Jan 10th 2023, 11:49am)


15

Monday, January 9th 2023, 7:07pm

with this code i can get all hotspots with x at the beginning of the title

hi... just fyi..
best use the source code button (#) if you post code.
otherwise yr code is difficult to read and people wont help.

about the tween... this probably works
tween(hotspot[get(hs.name)].ox, -200,3);

This post has been edited 3 times, last edit by "indexofrefraction" (Jan 9th 2023, 11:25pm)


16

Tuesday, January 10th 2023, 12:31pm

thanks everyone for the great help

Finally, I added a variable so and sc to the door hotspots in order to use different opening states of the sliding doors

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
<hotspot name="x_sd1"
 type="image"
 url="skin/türop1.jpg"
 keep="false"
 renderer="webgl"
 visible="true"
 enabled="true"
 capture="false" 
 handcursor="true"
 cursor="pointer"
 maskchildren="false"
 zorder=""
 style=""
 ath="00" atv="0.000"
 edge="center"
 zoom="false"
 distorted="true"
 rx="0.0" ry="0.0" rz="0.0"
 width="500" height="800"
 scale="1"
 rotate="0"
 alpha="1"
 so="-1500"
 sc="1100" 

/>
	



Source code

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
<events name="check_viewathotspot" keep="true" onviewchanged="slidingdoor"/>
<action name="slidingdoor">
for(set(i,0), i LT hotspot.count, inc(i),
copy(hs,hotspot[get(i)]);
hs.getcenter(hs_h, hs_v);
getlooktodistance(d, hs_h, hs_v);
subtxt(destVar,get(hs.name),0, 1);
if(destVar == "x",
if(d LT 40,
tween(hotspot[get(hs.name)].ox, get(hotspot[get(hs.name)].so) ,3);
,
tween(hotspot[get(hs.name)].ox, get(hotspot[get(hs.name)].sc) ,3);
);
);
);

</action>


This post has been edited 3 times, last edit by "nikonutsch" (Jan 10th 2023, 1:07pm)