﻿<krpano>

	<preview type="grid();" />

	<view hlookat="0" vlookat="0" fovtype="MFOV" fov="100" fovmin="60" fovmax="150" />


	<!-- textfield with information about the currently dragged hotspot -->
	<plugin name="hotspot_pos_info"
	        type="text"
	        html="drag the hotspots..."
	        css="font-family:Courier;"
	        padding="8"
	        align="lefttop" x="10" y="10"
	        width="200"
	        enabled="false"
	        />


	<!-- the action for dragging the hotspot - call it once in the ondown event -->
	<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();
		  );
	</action>
	
	<!-- show the xml code of the hotspot position -->
	<action name="print_hotspot_pos"><![CDATA[
		copy(print_ath, ath);
		copy(print_atv, atv);
		roundval(print_ath, 3);
		roundval(print_atv, 3);
		calc(plugin[hotspot_pos_info].html, '&lt;hotspot name="' + name + '"[br]&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;...[br]&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;ath="' + print_ath + '"[br]&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;atv="' + print_atv + '"[br]&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;...[br]&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;/&gt;');
	]]></action>


	<!-- example hotspots -->
	<hotspot name="spot1" url="hotspot.png"                  scale="0.5" ath="-25" atv="+5"  ondown="draghotspot();" />
	<hotspot name="spot2" url="hotspot.png" zoom="true"      scale="0.5" ath="0"   atv="+25" ondown="draghotspot();" />
	<hotspot name="spot3" url="hotspot.png" distorted="true" scale="0.5" ath="+25" atv="+5"  ondown="draghotspot();" />

</krpano>
