﻿<!--
	krpano - flyout hotspots example
-->
<krpano>

	<!-- use only a grid preview pano -->
	<preview type="grid(cube,16,16,512,0xCCCCCC,0xFFFFFF,0x999999);" />

	<!-- view settings -->
	<view hlookat="12" vlookat="40" fov="105" />


	<!-- use a <style> to share the same attriubtes for all hotspots -->
	<style name="flyoutimage"
	       distorted="true"
	       flying="0.0"
	       backup_state=""
	       backup_zorder=""
	       flying_state="in"
	       capture="false"
	       onclick="flyout_hotspot()"
	       />


	<hotspot name="spot1" style="flyoutimage"
	         url="image1.jpg"
	         zorder="1"
	         ath="45"
	         atv="54"
	         scale="0.4"
	         rx="-22.5" ry="-26.25" rz="-50.1"
	         />

	<hotspot name="spot2" style="flyoutimage"
	         url="image2.jpg"
	         zorder="2"
	         ath="60"
	         atv="54"
	         scale="0.4"
	         rx="-22.5" ry="-26.25" rz="-50.1"
	         />

	<hotspot name="spot3" style="flyoutimage"
	         url="image3.jpg"
	         zorder="3"
	         ath="75"
	         atv="58"
	         scale="0.4"
	         rx="-22.5" ry="-26.25" rz="-50.1"
	         />


	<!-- flyout hotspot actions -->
	<action name="flyout_hotspot">
		for(set(i,0), i LT hotspot.count, inc(i),
			copy(hs, hotspot[get(i)]);
			if(hs.name != name AND hs.style == 'flyoutimage' AND (hs.flying_state == 'out' OR hs.flying_state == 'flyingout'),
				callwith(hs, flyout_hotspot() );
			  );
		  );

		if(flying_state == 'flyingout',
			set(flying_state, 'flyingin');
		  ,
			if(flying_state == 'flyingin',
				set(flying_state, 'flyingout');
		  	  );
		  );

		if(flying_state == 'in',
			calc(backup_state, '0.0|' + rx + '|' + ry + '|' + rz + '|' + scale);
			copy(backup_zorder, zorder);
			set(flying_state, 'flyingout');
		  );

		if(flying_state == 'out',
			set(flying_state, 'flyingin');
		  );

		if(flying_state == 'flyingout',
			set(zorder, 99);
			tween(flying|rx|ry|rz|scale, '1.0|0.0|0.0|0.0|1.0', 0.5, default, set(flying_state,'out'); set(capture,true); );
		  );

		if(flying_state == 'flyingin',
			sub(zorder,1);
			set(capture,false);
			tween(flying|rx|ry|rz|scale, get(backup_state), 0.5, default, set(flying_state,'in'); copy(zorder,backup_zorder); );
		  );
	</action>

</krpano>

