<krpano>
    <!-- 1.20. 新热点模式 -->
    <action name="addJQHotspot">
        <!-- showlog(); -->
        set(hsp_name,%1); 
        set(hsp_type,%2); 
        txtadd(iconUrl,'',%4);
        txtreplace(iconUrl,'|',',');

        <!-- trace('opentype::',%11); -->
        if(%2 LE 1,
             <!-- trace('id==',get(hsp_name),"::",get(iconUrl)); -->
             set(hotspot[get(hsp_name)].type,'image');
             set(hotspot[get(hsp_name)].url,get(iconUrl));
         );
        ifnot(%2 LE 1, set(hotspot[get(hsp_name)].type, 'text'));

        <!-- 其他标签 （0，1，2）-->
    
        set(hotspot[get(hsp_name)].name,%1);
        set(hotspot[get(hsp_name)].hotspottype,%2);
        set(hotspot[get(hsp_name)].hotspottitle,%3);
        set(hotspot[get(hsp_name)].hoverstatus,%9);
        set(hotspot[get(hsp_name)].hotspotStyle,%10);
        set(hotspot[get(hsp_name)].opentype,%11);
        set(hotspot[get(hsp_name)].hotlink,%7);
        set(hotspot[get(hsp_name)].ath,%5);
        set(hotspot[get(hsp_name)].atv,%6);
        set(hotspot[get(hsp_name)].visible,true);
        set(hotspot[get(hsp_name)].alpha,1);
        set(hotspot[get(hsp_name)].scale,1);
  
        set(hotspot[get(hsp_name)].autoalpha,false);
        set(hotspot[get(hsp_name)].distorted,false);
        set(hotspot[get(hsp_name)].border,false);
        <!-- set(hotspot[get(hsp_name)].onclick,'js(__krfn.utils.linkopen(%7,%1)); '); -->
        set(hotspot[get(hsp_name)].onclick,'js(__sdk.Tags.linkopen(%11,%1)); ');
        <!-- set(hotspot[get(hsp_name)].ondown,dragJQhotspot(););
        set(hotspot[get(hsp_name)].onup,js(console.log('0');__krfn.angle.updateHotSpotData(get(xml.scene),get(name),get(ath),get(atv)))); -->

        txtsplit(%10,'|',fontSize,pos,isHover,borderColor,fillColor,textColor,isShowLine,isTextWrap,lineDirection,textDirection,textNumPerLine,duration,frameNumber,framewidth);
        set(hotspot[get(hsp_name)].pos,pos);
        txtadd(hotspot[get(hsp_name)].onloaded,"add_tooltip_label();add_tooltip_dot();");

        if(%2 LE 2,
            set(hotspot[get(hsp_name)].height,%8);
            set(hotspot[get(hsp_name)].width,%8);
            set(hotspot[get(hsp_name)].crop,'');
        
               
                if(%2 == 0,
                txtreplace(iconUrl,'.svg','.png');
                <!-- trace('system::',get(iconUrl)); -->
                set(hotspot[get(hsp_name)].url,get(iconUrl));
                set(hotspot[get(hsp_name)].frameNumber,60);
                
                set(hotspot[get(hsp_name)].duration,1);
                set(hotspot[get(hsp_name)].frameRate,calc(1.0 / 60));
                set(hotspot[get(hsp_name)].framewidth,84);
                );
                if(%2 == 1,
                set(hotspot[get(hsp_name)].url,get(iconUrl));
                set(hotspot[get(hsp_name)].animatiedOn,0);
                );
                if(%2 == 2,
                <!-- trace('ser_frame::',get(framewidth)); -->
                set(hotspot[get(hsp_name)].duration, get(duration));
                set(hotspot[get(hsp_name)].frameRate,calc(duration / frameNumber));
                trace(calc('当前热点序列::' + get(hotspot[get(hsp_name)].hotspottitle)+'::duration::'+get(duration)+'frameNumber::'+get(frameNumber) +'frameRate::'+get(calc(duration / frameNumber))));
                set(hotspot[get(hsp_name)].url,get(iconUrl));
                set(hotspot[get(hsp_name)].framewidth,get(framewidth));
                set(hotspot[get(hsp_name)].frameNumber,get(frameNumber));
                );
        );
        
        <!-- 个性化标签（3） -->
        if(%2 == 3,    
           
            set(hotspot[get(hsp_name)].height,80);
            set(hotspot[get(hsp_name)].width,1);
            set(hotspot[get(hsp_name)].padding,0);
            set(hotspot[get(hsp_name)].background,false);
            txtadd(line,'<div style="background-color: ',get(borderColor),';width:1px;height:80px;"></div>');
            copy(hotspot[get(hsp_name)].html,line);
            <!-- txtadd(hotspot[get(hsp_name)].onloaded,"add_tooltip_label();add_tooltip_dot();"); -->
            if(isShowLine == 1, 
            txtadd(tooltipname, 'tooltip_', get(hsp_name)); 
            txtadd(tooltipdot, 'tooldot_', get(hsp_name)); 
            set(hotspot[get(hsp_name)].visible,false);
            set(layer[get(tooltipname)].visible,false);
            set(layer[get(tooltipdot)].visible,false);
             
            set_label_dir(get(hsp_name),get(lineDirection),0);
            );
           
             if(isShowLine == 0, 
                txtadd(tooltipname, 'tooltip_', get(hsp_name)); 
                txtadd(tooltipdot, 'tooldot_', get(hsp_name)); 
                <!-- set_label_dir(get(hsp_name),get(lineDirection),0); -->
                set(hotspot[get(hsp_name)].width,0);
                <!-- trace('隐藏标线::',get(tooltipdot)); -->
                set(layer[get(tooltipname)].x,0);
                set(layer[get(tooltipname)].y,0);
                set(layer[get(tooltipname)].rotate,0);
                set(hotspot[get(hsp_name)].visible,true);
                set(layer[get(tooltipname)].visible,true);
                set(layer[get(tooltipdot)].visible,false);
             );  
        );
     
        txtadd(hotspot[get(hsp_name)].onloaded,"make_hotsport_animation(get(framewidth),get(framewidth),get(frameRate));");
        <!-- trace('last_add::',hotspot[get(hsp_name)].onloaded); -->
        addhotspot(get(hsp_name));
    </action>

	<action name="make_hotsport_animation">
    <!-- 1 square:(w/h) 2:imageW 3 imageH 4 frameRate -->
       <!-- trace('imagewidth::',imagewidth,'::imageheight::',imageheight); -->
        registerattribute(xframes, calc((imagewidth / %1) BOR 0));
        registerattribute(yframes, calc((imageheight / %2) BOR 0)); 
        registerattribute(frames, calc(xframes * yframes));
        registerattribute(frame, 0); 
        registerattribute(animatiedOn, 1); 
        registerattribute(frameRate, %3);
        <!-- trace('frameRate::',get(frameRate)); -->
        set(crop, '0|0|%1|%2'); 
        clearinterval(calc('crop_anim_' + name));
        <!-- trace('frameRate',get(frameRate));  -->
        if(%3 == '' OR frameRate == 0 OR isNaN(frameRate),
        set(frameRate,calc(1.0 / 60));
        <!-- trace('没有frameRate',get(calc(1.0 / 60)));
        trace('没有frameRate-1',get(frameRate)); -->
        );
        <!-- trace('params::1::',%1,'::2::',%2,'::3::',%3,':frameRate:',get(frameRate));
        trace('xframes1::',get(xframes),'::yframes1::',get(yframes)); -->
   
               
        if(frameRate GE 0,
        setinterval(
            calc('crop_anim_' + name),
            get(frameRate),
            if(loaded, 
                inc(frame); 
               
                <!-- trace('frame::',get(frame),'xframes2::',get(xframes),'::yframes2::',get(yframes)); -->
                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');
 
                if(animatiedOn == 0, 
                 calc(stopAniCrop,'0|0|'+imagewidth+'|'+imageheight +'|');
                 set(crop, stopAniCrop);
                );,
                clearinterval(calc('crop_anim_' + name));
            );
        );
        );   
	</action>

    <action name="add_tooltip_label">
        txtadd(tooltipname, 'tooltip_', get(name)); 
      
        txtsplit(hotspotStyle,'|',fontSize,pos,isHover,borderColor,fillColor,textColor,isShowLine,isTextWrap,lineDirection,textDirection,textNumPerLine,duration,frameNumber);
        txtadd(pName, get(name)); 
        addlayer(get(tooltipname));
        txtadd(layer[get(tooltipname)].parent, 'hotspot[', get(name), ']');
        set(layer[get(tooltipname)].autowidth, true);
        set(layer[get(tooltipname)].width,'prop');
        set(layer[get(tooltipname)].autoheight,true); 
        set(layer[get(tooltipname)].edge,center);
        set(layer[get(tooltipname)].background,false);
        set(layer[get(tooltipname)].pos,pos);
        set(layer[get(tooltipname)].padding,0);
        set(layer[get(tooltipname)].type,'html');
        set(layer[get(tooltipname)].url,'%SWFPATH%/plugins/textfield.swf');
        set(layer[get(tooltipname)].border,false);
        set(layer[get(tooltipname)].align,center);
        copy(layer[get(tooltipname)].hotlink, hotspot[get(name)].hotlink);
        <!-- set(layer[get(tooltipname)].ondown,'dragJQlayer();'); -->
        
        set(layer[get(tooltipname)].onclick,JQlayerClick);
        <!-- set(layer[get(tooltipname)].onup,js(console.log('1');__krfn.angle.updateHotSpotData(get(xml.scene),get(hsName),get(ath),get(atv)))); -->
        <!-- set(hotspot[get(hsp_name)].onup,js(__krfn.angle.updateHotSpotData(get(xml.scene),get(name),get(ath),get(atv)))); -->
        txtadd(labelCode, '<div style="display: flex; align-items: center; justify-content: center; position: relative; border: 1px solid ',get(borderColor),'; padding: 6px 10px; white-space: pre; border-radius: 5px; background: ',get(fillColor),'">','            <div style="text-align: left; font-size:',get(fontSize),'px; color: ',get(textColor),'; line-height: 1.4;">',get(hotspottitle),'</div>
        </div>'); 
        
                                <!-- label方位 -->
        if(get(hotspottype) LE 2,
         copy(hoverstatus,hotspot[get(name)].hoverstatus); 
         <!-- trace('hovering-label::',get(hoverstatus)); -->
        <!-- delayedcall(0.1,
            txtadd(tooltipname, 'tooltip_', get(name)); 
            set_label_pos(get(tooltipname),get(pos));
         ); -->
          if(hoverstatus == 0,
            delayedcall(0.5,
            txtadd(tooltipname, 'tooltip_', get(name)); 
            set_label_pos(get(tooltipname),get(pos));
            );
         );
        if(hoverstatus == 1,
            set(layer[get(tooltipname)].visible,false);
         );
          <!-- 2 hover  -->
        if(hoverstatus == 2,
            <!-- trace('测试'); -->
           set(layer[get(tooltipname)].visible,false);
            delayedcall(0.5,
             txtadd(tooltipname, 'tooltip_', get(name)); 
                set_label_pos(get(tooltipname),get(pos));
                set(layer[get(tooltipname)].visible,false);
            );
            set(hotspot[get(name)].onhover,txtadd(tooltipname, 'tooltip_', get(name)); set(layer[get(tooltipname)].visible,true););
            set(hotspot[get(name)].onout,
             txtadd(tooltipname, 'tooltip_', get(name)); 
             set(layer[get(tooltipname)].visible,false);
            );
         );
       );

        <!-- 个性化标签（3） -->
        if(get(hotspottype) == 3,    
           if(
            isShowLine==1,
            set(layer[get(tooltipname)].direction,get(lineDirection));
            delayedcall(0.2,txtadd(tooltipname, 'tooltip_', get(name)); set_label_dir(get(tooltipname),get(layer[get(tooltipname)].direction),1); );
          );
        );
        copy(layer[get(tooltipname)].html, labelCode);
        
            
    </action>
    <!-- <style name="tooltip_dot_bg" type="container" border-radius="50%" bgcolor="0xFFFFFF" bgalpha="0.9" height="20" width="20" keep="true" /> -->
    <action name='add_tooltip_dot'>
        txtadd(tooldot, 'tooldot_', get(name)); 
        <!-- trace('hey::',get(borderColor)); -->

        <!-- trace('add-dot-type::',get(name),'::',get(hotspottype)); -->
        addlayer(get(tooldot));
        txtadd(layer[get(tooldot)].parent, 'hotspot[', get(name), ']');
        set(layer[get(tooldot)].width,10); 
        set(layer[get(tooldot)].height,10); 
        set(layer[get(tooldot)].padding,0); 
       
        set(layer[get(tooldot)].align,center);
        set(layer[get(tooldot)].type,'text');
        set(layer[get(tooldot)].background,false);
        txtadd(dborderColor,'rgba(255,255,255,0.5)');
        txtadd(dot,'<div style="background-color: ',get(borderColor),';width:10px;height:10px;"></div>');
        copy(layer[get(tooldot)].html,dot);
        set(layer[get(tooldot)].backgroundcolor,get(borderColor)); 
        set(layer[get(tooldot)].backgroundalpha,0.9); 
        set(layer[get(tooldot)].bgroundedge,5);
        set(layer[get(tooldot)].onclick,JQlayerClick);
        <!-- set(layer[get(tooldot)].ondown,'dragJQlayer();'); -->
        set(layer[get(tooldot)].visible,false);
        <!-- set(layer[get(tooldot)].onup,js(console.log('2');__krfn.angle.updateHotSpotData(get(xml.scene),get(hsName),get(ath),get(atv)))); -->

        <!-- 个性化标签（3） -->
        if(get(hotspottype) == 3,    
    
            if(isShowLine ==1,set(layer[get(tooldot)].visible,true);set_label_dir(get(tooldot),get(lineDirection),2););
            if(isShowLine ==0,set(layer[get(tooldot)].visible,false););
                  
        );

    </action>
    <action name='set_label_dir'>
     txtadd(dirItem,'',%1);
     txtadd(lineDirection,'',%2);
     txtadd(dir,'',%3);
     <!-- trace('get-lineDirection::',%2); -->
     <!-- trace('set_label_dir::1::',get(dirItem),'::2::',get(lineDirection),'::3::',get(dir)); -->
     if(
        get(dir)==1,
        <!-- trace('set_label_dir::1::',get(dirItem),'::2::',get(lineDirection),'::3::',get(dir)); -->
        copy(labelWidth,layer[get(dirItem)].width);
        copy(labelHeight,layer[get(dirItem)].height);
  
  
     );

        if(
             get(lineDirection) == 'right-top',
            if(get(dir)==0,set(hotspot[get(dirItem)].rotate,35));
            if(get(dir)==1,add(allHeight,labelHeight,80);div(allHeight,2);mul(allHeight,-1);set(layer[get(dirItem)].rotate,0);set(layer[get(dirItem)].x,0);set(layer[get(dirItem)].y,get(allHeight));set(layer[get(dirItem)].rotate,-35););
            if(get(dir)==2,set(layer[get(dirItem)].x,0);set(layer[get(dirItem)].y,40););
        );
        if(
             get(lineDirection) == 'right-center',
             if(get(dir)==0,set(hotspot[get(dirItem)].rotate,90););
             if(get(dir)==1,
                set(layer[get(dirItem)].rotate,-90);
               add(allWidth,labelWidth,80);
                div(allWidth,2);
                mul(allWidth,-1);
                trace('allWidth::',get(allWidth));
                set(layer[get(dirItem)].x,0);
                set(layer[get(dirItem)].y,get(allWidth));
                );
           
             if(get(dir)==2,set(layer[get(dirItem)].x,0);set(layer[get(dirItem)].y,40););
        );
        if(
             get(lineDirection) == 'right-bottom',
            if(get(dir)==0,set(hotspot[get(dirItem)].rotate,-35));
            if(get(dir)==1,add(allHeight,labelHeight,80);div(allHeight,2);mul(allHeight,1);set(layer[get(dirItem)].rotate,0);set(layer[get(dirItem)].x,0);set(layer[get(dirItem)].y,get(allHeight));set(layer[get(dirItem)].rotate,35););
           if(get(dir)==2,set(layer[get(dirItem)].x,0);set(layer[get(dirItem)].y,-40););
        );
        if(
             get(lineDirection) == 'center-top',
            if(get(dir)==0,
            set(hotspot[get(dirItem)].rotate,0);
            );
            if(get(dir)==1,add(allHeight,labelHeight,80);div(allHeight,2);mul(allHeight,-1);set(layer[get(dirItem)].rotate,0);set(layer[get(dirItem)].x,0);set(layer[get(dirItem)].y,get(allHeight)););
            if(get(dir)==2,set(layer[get(dirItem)].x,0);set(layer[get(dirItem)].y,40););
        );
        if(get(lineDirection) == 'center-bottom',
            if(get(dir)==0,set(hotspot[get(dirItem)].rotate,0));
            if(get(dir)==1,add(allHeight,labelHeight,80);div(allHeight,2);mul(allHeight,1);
               set(layer[get(dirItem)].rotate,0);
               set(layer[get(dirItem)].x,0);
               set(layer[get(dirItem)].y,get(allHeight));     
              );
            if(get(dir)==2,set(layer[get(dirItem)].x,0);set(layer[get(dirItem)].y,-40););
        );
        if( get(lineDirection) == 'left-top',
        <!-- newx = distance * Math.cos(direction) + x
        newy = distance * Math.sin(direction) + y -->
            <!-- showlog(); -->
            if(get(dir)==0,set(hotspot[get(dirItem)].rotate,-35));
            if(get(dir)==1,
            add(allHeight,labelHeight,80);
            div(allHeight,2);mul(allHeight,-1);
            set(rr,calc((Math.PI / 180) * -35));
            <!-- set(newY,calc(allHeight * Math.asin(rr))); -->
            trace('newY',allHeight);
            set(layer[get(dirItem)].rotate,0);
            set(layer[get(dirItem)].x,0);
            set(layer[get(dirItem)].y,get(allHeight));
            set(layer[get(dirItem)].rotate,35););
            if(get(dir)==2,set(layer[get(dirItem)].x,0);set(layer[get(dirItem)].y,40););
        );
        if(
             get(lineDirection) == 'left-center',
             if(get(dir)==0,set(hotspot[get(dirItem)].rotate,90));
             
             if(get(dir)==1,
                set(layer[get(dirItem)].rotate,-90);
               add(allWidth,labelWidth,80);
                div(allWidth,2);
                trace('allWidth::',get(allWidth));
                set(layer[get(dirItem)].x,0);
                set(layer[get(dirItem)].y,get(allWidth));
                );
             if(get(dir)==2,set(layer[get(dirItem)].x,0);set(layer[get(dirItem)].y,-40););
        );
        if(
            get(lineDirection) == 'left-bottom',
            if(get(dir)==0,set(hotspot[get(dirItem)].rotate,35));
            if(get(dir)==1,add(allHeight,labelHeight,80);div(allHeight,2);mul(allHeight,1);set(layer[get(dirItem)].rotate,0);set(layer[get(dirItem)].x,0);set(layer[get(dirItem)].y,get(allHeight));set(layer[get(dirItem)].rotate,-35););
            if(get(dir)==2,set(layer[get(dirItem)].x,0);set(layer[get(dirItem)].y,-40););

        );
          
          if(get(dir)==0, set(hotspot[get(dirItem)].visible,true););
          if(get(dir)==1, set(layer[get(dirItem)].visible,true););
          if(get(dir)==2, set(layer[get(dirItem)].visible,true););

    </action>

    <action name='set_label_pos'>
        <!-- label方位 -->
       <!-- showlog(); -->
       set(posName,%1);
       set(pos,%2);
       copy(hp,posName);
       txtreplace(hp,'tooltip_','');

       copy(hwidth, hotspot[get(hp)].width);
       copy(hheight, hotspot[get(hp)].height);
       <!-- trace('hwidth::',get(hwidth)); -->
       copy(lwidth, layer[get(posName)].width);
       copy(lheight, layer[get(posName)].height);
       trace(calc('当前热点动态宽::' + get(hp)+"::"),get(lwidth));
       trace(calc('当前热点动态高::' + get(hp)+"::"),get(lheight));

        if(
            pos == 'top',
            add(all,lheight,hheight);
            div(dpy,all,2); 
            add(lastPy,dpy,5);
            <!-- trace('dpy::',dpy); -->
            mul(lastPy, -1);
            set(layer[get(posName)].align,center);
            set(layer[get(posName)].y,get(lastPy));
            set(layer[get(posName)].x,0);
        );
         if(
            pos == 'bottom',
            add(all,lheight,hheight);
            div(dpy,all,2); 
            add(lastPy,dpy,5);
            mul(lastPy, 1);
            set(layer[get(posName)].align,center);
            set(layer[get(posName)].y,get(lastPy));
            set(layer[get(posName)].x,0);
        );
        if(
            pos == 'left',
            add(all,lwidth,hwidth);
            div(dpx,all,2); 
            add(lastPx,dpx,10);
            mul(lastPx, -1);
            set(layer[get(posName)].align,center);
            set(layer[get(posName)].x,get(lastPx));
            set(layer[get(posName)].y,0);
        );
        if(
            pos == 'right',
            add(all,lwidth,hwidth);
            div(dpx,all,2); 
            add(lastPx,dpx,10);
            mul(lastPx, 1);
            set(layer[get(posName)].align,center);
            set(layer[get(posName)].x,get(lastPx));
            set(layer[get(posName)].y,0);
        );
    </action>

 

<action name='JQlayerClick'>
       txtadd(clickName, '', get(name)); 
       txtreplace(clickName, 'tooltip_', ''); 
       txtreplace(clickName, 'tooldot_', ''); 
       <!-- trace('opentype::',get(hotspot[get(clickName)].opentype));
       trace('clickName::',get(clickName)); -->
       js(__sdk.Tags.linkopen(get(hotspot[get(clickName)].opentype),get(clickName)));
</action>

</krpano>
