how to make a distorted and draggable hotspot with a hide button (not distorted)
Thanks
Suso
how to make a distorted and draggable hotspot with a hide button (not distorted)
Thanks
Suso
what I want to achieve is that when I drag the hotspot the layer follows the hotspot at the same distance
<hotspot name="spot1" url="1.jpg" ath="0" atv="-0.3016131110635691" scale="0.3" rx="0" ry="49.649999999999935" rz="0" distorted="true" keep="true" ondown="draghotspot()" />
<layer name="button" type="container" align="center" x="140" y="-170" width="30" height="30" bgcolor="0x44AADD" bgalpha="1.0" bgcapture="true" ondown="draglayer()" >
</layer>
<action name="draghotspot">
spheretoscreen(ath, atv, hotspotcenterx, hotspotcentery, calc(mouse.stagex LT stagewidth/2 ? 'l' : 'r')); sub(drag_adjustx, mouse.stagex, hotspotcenterx); sub(drag_adjusty, mouse.stagey, hotspotcentery); asyncloop(pressed, sub(dx, mouse.stagex, drag_adjustx); sub(dy, mouse.stagey, drag_adjusty); screentosphere(dx, dy, ath, atv);
<!-- print_hotspot_pos(); -->
set(layer[val_ath].html, calc:'ATH = ' + hotspot[get(name)].ath); set(layer[val_atv].html, calc:'ATV = ' + hotspot[get(name)].atv); );
</action>
<action name="draglayer">
copy(drag_currentx, x);
copy(drag_currenty, y);
copy(drag_stagex, mouse.stagex);
copy(drag_stagey, mouse.stagey);
indexoftxt(align_contains_right, get(align), 'right');
indexoftxt(align_contains_bottom, get(align), 'bottom');
calc(drag_align_x, align_contains_right GE 0 ? -1 : +1);
calc(drag_align_y, align_contains_bottom GE 0 ? -1 : +1);
asyncloop(pressed,
calc(x, drag_currentx + (mouse.stagex - drag_stagex)*drag_align_x);
calc(y, drag_currenty + (mouse.stagey - drag_stagey)*drag_align_y);
);
</action>
the blue layer would be the hotspot hide button
Thanks
Suso
Try it
layer "button" - edge="center"
hotspot "spot1" - edge="righttop"
Add to action "draghotspot"
asyncloop(pressed,
...
spheretoscreen(ath, atv, h_x, h_y);
set(layer[button].x,get(h_x));
set(layer[button].y,get(h_y));
);
And why not just do it parent="hotspot[spot1]" ?
If you need to permanently bind
<events onviewchanged="spheretoscreen(hotspot[spot1].ath, hotspot[spot1].atv, h_x, h_y);
set(layer[button].x,get(h_x));
set(layer[button].y,get(h_y));
"
/>
Hi San
Thank you very much, I'll try it
Suso
if I have edited the code correctly these are the results:
layer "button" - edge="center"
hotspot "spot1" - edge="righttop"
https://dearte.online/test2/krpano.xml
it could work but when I click on the hotspot the layer goes to the right corner below
--------------------------------------------
this option distorts the layer
parent="hotspot[spot1]"
https://dearte.online/test3/krpano.xml
layer align="lefttop"
hotspot "spot1" - edge="righttop"
If you want to put the button on the upper right corner, then layer align="righttop"
works!!
Best greetings
one last question,
when I turn the panorama the hotspot moves but it is not followed by the layer,
has it this solution?
thanks
Remove everything you have done.
Another solution:
<events onviewchanged="spheretoscreen(hotspot[spot1].ath, hotspot[spot1].atv, h_x, h_y);
set(layer[button].x,get(h_x));
set(layer[button].y,get(h_y));
"
/>
Don’t have an account yet? Register yourself now and be a part of our community!