You are not logged in.

1

Thursday, August 25th 2022, 3:06pm

Is it possible to get width and height of a hotspot if those attributes are NOT set

I have some image and video hotspots that I am using as image and video popups in VR Devices. It looks like the following (a video popup):




Here I want to place a close button top-center but the problem is that I am not able to position the close button based on height of the popup as I am not setting any explicit width/height for popup, it has to be based on the image/video original size.

My question is, is it possible to get native width/height/bounding-rectangle of a hotspot to calculate the position of the close button like ath + height/2 or so?

Any other idea to solve this close button position is also obviously a great help. I saw that layers or parent-child has issues in VR thats why I am trying flat / single level of hotspots.

This is the code I use to add close button: hotspot[popup] is the video/image popup shown in above image

Source code

1
2
3
4
5
6
7
8
9
10
11
12
13
14
          <!-- ADD CLOSE BUTTON -->
          addhotspot(popup_close);
          set(hotspot[popup_close].url,'https://....../close.png');
          set(hotspot[popup_close].distorted,true);
          set(hotspot[popup_close].alpha,0);
          set(hotspot[popup_close].edge,bottom);
          set(hotspot[popup_close].depth,900);
          set(hotspot[popup_close].tx,0); 
          set(hotspot[popup_close].ty,-300); <!-- Calculate using hotspot[popup].nativeHeight??? -!>
          trace(get(hotspot[popup].width));
          set(hotspot[popup_close].ath,get(hotspot[popup].ath));
          set(hotspot[popup_close].atv,get(hotspot[popup].atv));
          set(hotspot[popup_close].onclick,removepopuphotspot());
          tween(hotspot[popup_close].alpha,1, 2);



Peace,

Tuur

Sage

Posts: 3,839

Location: Netherlands

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

  • Send private message

2

Thursday, August 25th 2022, 5:52pm

Hi,

On phone now... but did you try with pixelwidth /..height?

Tuur *thumbsup*

San7

Professional

Posts: 626

Occupation: coding in krpano

  • Send private message

3

Wednesday, August 31st 2022, 9:15am

Hi,
If you install the video (picture) by ath atv, then I do not advise you to touch the parameters tx ty tz. Work in one coordinate system.
If in spherical then try this code:

Source code

1
2
3
4
5
6
7
8
copy(popup, hotspot[popup]);
addhotspot('popup_close', pc);
set(pc, url='https://..../close.png', distorted=true, alpha=0, edge=bottom, onclick=removepopuphotspot() ); 
calc(pc.ox, popup.pixelwidth / 2 - 5 );  		    
calc(pc.oy, - (popup.pixelheight / 2 - 5 ) ); 
copy(pc.ath, popup.ath);
copy(pc.atv, popup.atv); 
tween(pc.alpha, 1, 2);

-5 - is the offset of the hotspot from the top right corner.

For Cartesian coordinates, another principle of calculation