kRpano 360动态热点添加方式

一、当要使用动态热点或动态layer时,首先要在主xml(tour.xml)空白处的scene标签的外面,放入以下动作代码:

<!-- pro12之前版本使用的动态热点动作代码 -->
	<action name="do_crop_animation">
		<!-- 为热点注册属性 -->
		registerattribute(xframes, calc((imagewidth / %1) BOR 0));
		registerattribute(yframes, calc((imageheight / %2) BOR 0));
		registerattribute(frames, calc(xframes * yframes));
		registerattribute(frame, 0);


		set(crop, '0|0|%1|%2');


		setinterval(calc('crop_anim_' + name), calc(1.0 / %3),
			if(loaded,
				inc(frame);
				if(frame GE frames, if(onlastframe !== null, onlastframe() ); set(frame,0); );
				mod(xpos, frame, xframes);
				div(ypos, frame, xframes);
				Math.floor(ypos);
				mul(xpos, %1);
				mul(ypos, %2);
				calc(crop, xpos + '|' + ypos + '|%1|%2');
			  ,
				clearinterval(calc('crop_anim_' + name));
			  );
		  );
	</action>
pro13以后的版本使用的代码:
<action name="do_crop_animation" scope="local" args="framewidth, frameheight, framerate">
	<!-- 定义局部变量 -->
	calc(local.xframes, (caller.imagewidth /framewidth) BOR 0);
	calc(local.frames, xframes * ((caller.imageheight / frameheight) BOR 0));
	def(local.frame, integer, 0);
	
	<!-- 设置第一帧 -->
	calc(caller.crop, '0|0|' + framewidth + '|' + frameheight);
	
	<!-- 动画部分 -->
	setinterval(calc('crop_anim_' + caller.name), calc(1.0 / framerate),
		if(caller.loaded,
			inc(frame);
			if(frame GE frames, if(caller.onlastframe !== null, callwith(caller, onlastframe() ) ); set(frame,0); );
			mod(xpos, frame, xframes);
			div(ypos, frame, xframes);
			Math.floor(ypos);
			mul(xpos, framewidth);
			mul(ypos, frameheight);
			calc(caller.crop, xpos + '|' + ypos + '|' + framewidth + '|' + frameheight);
		  ,
			<!-- 当热点移除时停止动画 -->
			clearinterval(calc('crop_anim_' + caller.name));
		);
	);
</action>

二、在自动生成的动态热点中加入如下代码


url="explosion.png"  onloaded="do_crop_animation(100,100, 60)"
例如:
<hotspot name="spot1" style="skin_hotspotstyle" ath="13.104" atv="-6.620" linkedscene="scene_11" url="explosion.png"  onloaded="do_crop_animation(64,64, 60)"/>

url中是png序列图片的路径,要使用正确。



点击查看:案例展示


猜你喜欢

转载自blog.csdn.net/fanhu6816/article/details/78258102