kRpano 360动态热点添加方式

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


	
		
		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));
			  );
		  );
	
 
pro13以后的版本使用的代码:

	
	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));
		);
	);

	
	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));
		);
	);

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

url="explosion.png"  onloaded="do_crop_animation(100,100, 60)"
 
 


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

点击查看:案例展示

你可能感兴趣的:(kRpano 360动态热点添加方式)