Sie sind nicht angemeldet.

1

Montag, 2. Januar 2023, 16:41

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

Erleuchteter

Beiträge: 3 839

Wohnort: Netherlands

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

  • Nachricht senden

2

Montag, 2. Januar 2023, 18:02

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

Montag, 2. Januar 2023, 20:18

getlooktodistance

i ll have a look.thanks to tuur
lg klaus

4

Dienstag, 3. Januar 2023, 14:26

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

Fortgeschrittener

Beiträge: 310

Wohnort: Belgium

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

  • Nachricht senden

5

Dienstag, 3. Januar 2023, 15:12

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


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
	<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

Dienstag, 3. Januar 2023, 18:35

wonderful

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



ps now,the "thing" works perfect

https://360.tirol/leo23/

Dieser Beitrag wurde bereits 1 mal editiert, zuletzt von »nikonutsch« (3. Januar 2023, 21:26)


ramirox3

Fortgeschrittener

Beiträge: 354

Wohnort: La Ceja, Colombia

Beruf: photographer

  • Nachricht senden

7

Dienstag, 3. Januar 2023, 23:44

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

Fortgeschrittener

Beiträge: 310

Wohnort: Belgium

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

  • Nachricht senden

8

Mittwoch, 4. Januar 2023, 09:17

First, you have a typo:

Quellcode

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):

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
<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

Fortgeschrittener

Beiträge: 354

Wohnort: La Ceja, Colombia

Beruf: photographer

  • Nachricht senden

9

Mittwoch, 4. Januar 2023, 14:22

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

Fortgeschrittener

Beiträge: 310

Wohnort: Belgium

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

  • Nachricht senden

10

Mittwoch, 4. Januar 2023, 14:49

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

11

Mittwoch, 4. Januar 2023, 15:44

Hello, can you just add doors to the hotspot

Quellcode

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

Quellcode

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()) );					
"

Dieser Beitrag wurde bereits 2 mal editiert, zuletzt von »San7« (4. Januar 2023, 19:35)


12

Sonntag, 8. Januar 2023, 14:24

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

13

Sonntag, 8. Januar 2023, 14:50

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

Montag, 9. Januar 2023, 18:13

a new problem

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



Quellcode

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

Quellcode

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

Dieser Beitrag wurde bereits 2 mal editiert, zuletzt von »nikonutsch« (10. Januar 2023, 11:49)


15

Montag, 9. Januar 2023, 19:07

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);

Dieser Beitrag wurde bereits 3 mal editiert, zuletzt von »indexofrefraction« (9. Januar 2023, 23:25)


16

Dienstag, 10. Januar 2023, 12:31

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

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
<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" 

/>
	



Quellcode

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>


Dieser Beitrag wurde bereits 3 mal editiert, zuletzt von »nikonutsch« (10. Januar 2023, 13:07)