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.

herrpedro

Trainee

  • "herrpedro" started this thread

Posts: 145

Location: Lisbon

Occupation: Programmer/analyst

  • Send private message

1

Tuesday, June 23rd 2015, 1:38pm

screen center trigger hotspot hover on mobile

is it possible to trigger "onhover" of some hotspot if the center of the screen is hovering it?
i'd like to show some additional info if the screen center is hovering a polygonal hotspot and i think that it would be a nice replacement for the mouse movement
kind of webvr cursor behavior but only for mobile/touch

thank you for your help

2

Tuesday, June 23rd 2015, 2:48pm

Hi,

a full-shape hit-testing is not that easily possible this way, but when only checking the distance to the hotspots center - e.g. when its lower than 20 degrees, then it might be possible this way:

Here a quick example:

Source code

1
2
3
4
5
6
7
8
9
10
11
12
13
14
<events name="checkhotspots" keep="true" onviewchange="checkhotspots();" />

<action name="checkhotspots">
  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);
    if(d LT 20,
       set(hs.hovering, true);
     ,
       set(hs.hovering, false);
      );
   );
</action>


See also these links:
http://krpano.com/docu/actions/#getlooktodistance
http://krpano.com/docu/xml/#hotspot.getcenter

Best regards,
Klaus

herrpedro

Trainee

  • "herrpedro" started this thread

Posts: 145

Location: Lisbon

Occupation: Programmer/analyst

  • Send private message

3

Tuesday, June 23rd 2015, 6:12pm

thank you so much for the fast response
i added a variable dfov that shrinks with FOV so the center does not grow
initially i got a 120fov so 6º seems ok
with the initial 20 i had a "christmas tree" on my pc since i change the gama and they all lit up :D

.....
div(dfov , view.fov , 20);
if(d LT dfov, .... ...


in desktop the "onout" is not triggered.. added a trace and it shows in log

i'll add an aditional IF for a state change so it does changes hovering to true if already true or false if already false

and does not seem to work on my phone at all (the visual part)
i added a trace to the hs.hovering = true and it traces the hover hotspot correctly
is there any limitation for polygonal hotspots? when i click them it makes the zoom i programmed it to do.. but not hovering

thanks again

herrpedro

Trainee

  • "herrpedro" started this thread

Posts: 145

Location: Lisbon

Occupation: Programmer/analyst

  • Send private message

4

Tuesday, June 23rd 2015, 6:31pm

my last code...
in desktop it starts hovering and visually i get the effect
but does not trigger the onout
in trace i see the start and the end correctly

Source code

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
 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);
		div(dfov , view.fov , 20);
		if(d LT dfov,
			if (!hs.hovering , 
				set(hs.hovering, true);
				trace('started hovering '  , hs.name);
			);
		 ,
			if (hs.hovering , 
				set(hs.hovering, false);
				trace('ended hovering '  , hs.name);
			);
		  );
	   );




i just cheched that my hover is not called on my phone siunce i see the start and ended hover but i dont see 'border alpha' entry
here is my style definition and my action


Source code

1
2
3
	<style name="info_area" handcursor="true" capture="false" alpha="0.1" fillcolor="0x222222" fillalpha="0" borderwidth="4" bordercolor="0xffffff" borderalpha="1" ondown="" onup="" onloaded="" keep="false" visible="true" enabled="true"	onover="tweencall(get(name) ,get(hsname) ,1,1);" onhover="tweencall(get(name) ,get(hsname),1,1);" onout="tweencall(get(name) ,get(hsname), 0.1 ,1);cleartext();" 	onclick="zoomtosubject(get(zoomspot) , get(hspot) , get(vspot));"	></style>

	<action name="tweencall">		tween(hotspot[%1].alpha, %3, %4);		trace('border alpha' , hotspot[%1].name );		showtext(get(data[%2].content) , InfoStyle);	</action>



herrpedro

Trainee

  • "herrpedro" started this thread

Posts: 145

Location: Lisbon

Occupation: Programmer/analyst

  • Send private message

5

Wednesday, June 24th 2015, 5:06pm

found out why it does not trigger the "onout"
because it is out of the center distance.... got to move that out of the "if" distance to center os less than....
but.. still does not work on mobile :(
i'll keep working on this but.. if any of you can help....

6

Tuesday, August 18th 2015, 10:44am

Mobile Cursor

Hi Klaus,

Many congratulations on the new version of the software. I'm so glad that I started working with KrPano because you have never stopped developing and improving it.

I noticed the webVR cursor that you created and realised that that sort of cursor is what I've been really looking for since going into mobile devices. The ability to hover over hotspots without the use of a mouse and communicate something about their function before actually using them gives back a lot of functionality that has been lost in the transition to mobile devices.

What you suggested here is perfect to use on a smart phone unfortunately the code doesn't seem to be transfer between platforms. If I test it on the desktop the trace comes back but if on the iPhone simulator there is no trace coming back. I'm sure there is something straightforward to address here but it would be so helpful if you could doublecheck it and see where the problem lies.

Many thanks,

Nico

Mudin

Beginner

Posts: 27

Location: South Korea

Occupation: VR Developer

  • Send private message

7

Tuesday, March 29th 2016, 10:32am

This is also affecting the 3d arrows

Hello everyone,

Thanks for the code. This is what I needed to hide hotspots and show them when they are near center!
But I have an issue.
So I have got a question. Sorry if it is not reasonable. I am beginner ;)

I want to change alpha of the hotspot that I have created, not the arrows.
Hotspot names are like these: "h1", "h2", .....
I am using string plugin to find the character "h" from each hotspot name to check if it is hotspot I created or arrow

This is the part of the code:

Quoted


<action name="checkhotspots">
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);
plugin[string].txtfind(destVar,get(hs.name),'h');
if(destVar == 0,
if(d LT 20,
set(hs.alpha, "0.9");
,
set(hs.alpha, "0");
);
);
);

</action>
The condition (destVar == 0 ) is never true.

It would be great If I get solution.
Thanks a lot,
Mudin

8

Sunday, June 12th 2016, 9:50am

thank you so much for the fast response
i added a variable dfov that shrinks with FOV so the center does not grow
initially i got a 120fov so 6º seems ok
with the initial 20 i had a "christmas tree" on my pc since i change the gama and they all lit up :D

.....
div(dfov , view.fov , 20);
if(d LT dfov, .... ...


in desktop the "onout" is not triggered.. added a trace and it shows in log

i'll add an aditional IF for a state change so it does changes hovering to true if already true or false if already false

and does not seem to work on my phone at all (the visual part)
i added a trace to the hs.hovering = true and it traces the hover hotspot correctly
is there any limitation for polygonal hotspots? when i click them it makes the zoom i programmed it to do.. but not hovering

thanks again
Hi herrpedro
I would like to do the same things, do you have simple example on this can share?
Many thanks

*smile*