Sie sind nicht angemeldet.

1

Sonntag, 23. Januar 2022, 15:12

Get the hotspot name in onclick

Hello there,

I'm creating an action that will have several interactions with the same hotspot.
Would it be possible to identify the hotspot at the moment it is clicked and called to action?

So I can default to all hotspots

Quellcode

1
2
3
4
5
6
7
8
9
10
<action name="modal_Andares" >
		if(device.desktop,
			if(hotspot[diferenciado12].state == 'closed',
				set(hotspot[diferenciado12].state, 'opened');
				looktohotspot(diferenciado12, 35, tween(linear,1.4));				
				tween(hotspot[diferenciado12].fillalpha, 0.4);				
				tween(hotspot[diferenciado12].fillcolor, 0xfff200);				
			);			
		);		
	</action>


Best regards,

2

Sonntag, 23. Januar 2022, 16:03

three options below:

Quellcode

1
2
3
4
5
6
7
8
9
10
11
12
13
14
<hotspot name="test1" ... onclick="myaction1(get(name));" />
<action name="myaction1">
trace('you just clicked the hotspot ',%1);
</action>

<hotspot name="test2" ... onclick="myaction2(get(name));" />
<action name="myaction2" scope="local" args="name">
trace('you just clicked the hotspot ',name);
</action>

<hotspot name="test3" ... onclick="myaction3();" />
<action name="myaction3" scope="local">
trace('you just clicked the hotspot ',caller.name);
</action>

3

Dienstag, 25. Januar 2022, 11:20

Thank you very much for your help, but I still don't know how to finish the action.


Quellcode

1
2
3
4
5
6
7
8
9
10
<action name="myaction3" scope="local">
	trace('you just clicked the hotspot ',caller.name);
	if(hotspot[What do I put here?].state == 'closed',
				set(hotspot[What do I put here?].state, 'opened');
				tween(hotspot[What do I put here?].fillcolor, 0xfff200);
				tween(hotspot[What do I put here?].fillalpha, 0.4);
				looktohotspot(What do I put here?, 35, tween(linear,1));				
			);
	
	</action>

Tuur

Erleuchteter

Beiträge: 3 839

Wohnort: Netherlands

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

  • Nachricht senden

4

Dienstag, 25. Januar 2022, 12:06

Hi,

Instead of
hotspot[What do I put here?]
You use:
caller

if(caller.state

caller.fillalpha
Etc
https://krpano.com/docu/xml/#action.scope

Hooe it helps,
Tuur *thumbsup*

5

Dienstag, 25. Januar 2022, 12:25

not sure tween can take the caller directly...
if not, try the 2nd variant

Quellcode

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
<action name="myaction3" scope="local">
	trace('you just clicked the hotspot ',caller.name);
	if(caller.state == 'closed',
		set(caller.state, 'opened');
		tween(caller.fillcolor, 0xfff200);
		tween(caller.fillalpha, 0.4);
		looktohotspot(get(caller.name), 35, tween(linear,1));				
	);
</action>

<action name="myaction3" scope="local">
	trace('you just clicked the hotspot ',caller.name);
	if(caller.state == 'closed',
		set(caller.state, 'opened');
		tween(hotspot[get(caller.name)].fillcolor, 0xfff200);
		tween(hotspot[get(caller.name)].fillalpha, 0.4);
		looktohotspot(get(caller.name), 35, tween(linear,1));				
	);
</action>

6

Freitag, 28. Januar 2022, 14:31

Your help is being extraordinary.

The above action worked perfectly. But now another question has arisen...

How do I close any hotspot that are open (may have more than one)?

Quellcode

1
2
3
4
5
6
7
<action name="close_modal" >
	if(ANYhotspot.state == 'opened',
		set(ALLhotspot.state, 'closed');		
		tween(global.plugin[pp_blur].range, 0.0);
		tween(view.fov, get(xml.view.fov), 2.0, easeOutQuad);
	);
	</action>

7

Freitag, 28. Januar 2022, 17:19

Quellcode

1
2
3
4
5
6
7
8
9
10
11
12
13
<action name="close_all_modals" scope="local">
	set(local.count,0);
	for(set(i,0), i LT hotspot.count, inc(i),
		if(hotspot[get(i)].state == 'opened',
			set(hotspot[get(i)].state, 'closed');	
			inc(count);	
		);
	);
	if(count,
		tween(plugin[pp_blur].range, 0.0);
		tween(view.fov, get(xml.view.fov), 2.0, easeOutQuad);
	);
</action>

8

Freitag, 28. Januar 2022, 19:42

No words to thank you for your great help

Best Regards

9

Samstag, 29. Januar 2022, 09:48

denada :)
note: the tweens are not hotspot related so its not necessary to do them for every hotspot.
therefore i count the open hotspots and only do the tweens once if count > 0

Dieser Beitrag wurde bereits 1 mal editiert, zuletzt von »indexofrefraction« (29. Januar 2022, 18:29)


Ähnliche Themen