首页 > 程序开发 > web前端 > HTML/CSS >

krpanoVR模式(中文汉化版)

2016-11-11

krpano 1 19支持了Web VR功能,允许以VR的方式查看全景图,配合上VR设备可以实现VR效果。krpanoVR模式(中文汉化版)

krpano 1.19支持了Web VR功能,允许以VR的方式查看全景图,配合上VR设备可以实现VR效果。

\

在VR方式查看时,可以对VR进行设置,界面如下

\

可以发现设置界面为全英文界面,对于国内用户不够友好,因此在国内做项目时,需要进行汉化。

在汉化时,我们只需要找到Plugin目录下的WebVR.xml文件,所有的设置文本信息被保存在了该xml文件中,根据需要汉化相应的英文即可。

汉化后如下:

\

已经汉化的WebVR.xml下载

<krpano>  
  
    <!-- load the WebVR plugin and assign it to a &#39;webvr&#39; variable for easier usage -->  
    <plugin name="WebVR" devices="html5" keep="true"  
            url="webvr.js"  
            onloaded="copy(webvr, plugin[WebVR]);"  
            mousespeed="0.00125"  
            multireslock="true"  
            mobilevr_support="true"  
            mobilevr_ipd="63.5"  
            mobilevr_screensize="auto"  
            mobilevr_lens_overlap="1.0"  
            mobilevr_lens_fov="96"  
            mobilevr_lens_dist="0.6"  
            mobilevr_lens_dist2="1|0|0|0"  
            mobilevr_lens_ca="0.0"  
            mobilevr_lens_vign="100"  
            mobilevr_wakelock="true"  
            mobilevr_sensor_mode="3"  
            mobilevr_autocalibration="false"  
            mobilevr_touch_support="true"  
            mobilevr_fake_support="true"  
            vr_cursor="hotspot[vr_cursor]"  
            vr_cursor_enabled="true"  
            vr_cursor_onover="if(handcursor, tween(hotspot[vr_cursor].scale,0.4,0.1); vr_auto_click(get(vr_timeout)); );"  
            vr_cursor_onout="tween(hotspot[vr_cursor].scale,0.3,0.1);"  
            onavailable="webvr_onavailable();"  
            onunavailable=""  
            onunknowndevice="webvr_onunknowndevice();"  
            onentervr="webvr_onen  
tervr();"  
                onexitvr="webvr_onexitvr();"  
                />  
  
          
        <!-- a custom xml data structure with the supported VR headsets -->  
        <vrheadsets>  
            <headset name="cb1" caption="Cardboard A"   overlap="1.10" fov="96.0"  dist="1.00" dist2="1|0|0|0" ca="0.000" vig="100" />  
            <headset name="cb2" caption="Cardboard B"   overlap="1.00" fov="96.0"  dist="0.60" dist2="1|0|0|0" ca="0.000" vig="100" />  
            <headset name="gvr" caption="GearVR"        overlap="1.00" fov="112.0" dist="0.95" dist2="1|0|0|0" ca="0.090" vig="100" />  
            <headset name="hom" caption="HOMiDO"        overlap="1.00" fov="101.0" dist="1.10" dist2="1|0|0|0" ca="0.075" vig="100" />  
            <headset name="one" caption="VR ONE"        overlap="1.00" fov="109.9" dist="0.00" dist2="1.139|0.093|0.018|0.207" ca="0.090" vig="35" />  
            <headset name="ccr" caption="ColorCross VR" overlap="1.00" fov="70.0"  dist="0.65" dist2="1|0|0|0" ca="0.000" vig="100" />  
            <headset name="nod" caption="No Distortion" overlap="1.00" fov="96.0"  dist="0.00" dist2="1|0|0|0" ca="0.000" vig="100" />  
        </vrheadsets>  
  
  
        <!-- the VR cursor hotspot -->  
        <hotspot name="vr_cursor" keep="true"  
                 url="webvr_cursor_80x80_17f.png"  
                 visible="false"  
                 enabled="false"  
                 distorted="true"  
                 crop="0|0|80|80"  
                 scale="0.3"  
                 depth="1000"  
                 />  
  
  
        <!-- vr_auto_click() - call this action in the onover event of a  
             hotspot to trigger automatically a click after some time.  -->  
        <action name="vr_auto_click">  
            if(webvr.isenabled,  
                if(%1 != null, set(vr_aclk_timeout, %1), set(vr_aclk_timeout, 2000));  
                copy(vr_aclk_t1, timertick);  
                set(vr_aclk_waiting, true);  
                copy(vr_aclk_hotspot, name);  
                set(hotspot[vr_cursor].crop,&#39;0|0|80|80&#39;);  
  
                asyncloop(vr_aclk_waiting AND vr_aclk_hotspot == name,  
                    sub(dt, timertick,vr_aclk_t1);  
  
                    if(!hovering,  
                        set(vr_aclk_waiting, false);  
                        set(hotspot[vr_cursor].crop,&#39;0|0|80|80&#39;);  
                      ,  
                        div(f, dt, vr_aclk_timeout);  
                        mul(f, 16);  
                        roundval(f);  
                        Math.min(f, 16);  
                        mul(f, 80);  
  
                        txtadd(hotspot[vr_cursor].crop,get(f),&#39;|0|80|80&#39;);  
  
                        <!-- wait another 100ms delay after finishing the animation before doing the click -->  
                        sub(dt, 100);  
                        if(dt GT vr_aclk_timeout,  
                            set(vr_aclk_waiting,false);  
                            set(hotspot[vr_cursor].crop,&#39;0|0|80|80&#39;);  
                            <!-- call onclick -->  
                            onclick();  
                          );  
                      );  
                    );  
              );  
        </action>  
  
  
        <!-- by pressing SPACE the Oculus Rift could be re-centered -->  
        <events name="webvr_events" devices="html5" keep="true"  
                onkeydown="if(webvr AND webvr.isenabled AND keycode==32, webvr.resetSensor() );"  
                onmousedown="if(webvr AND webvr.isenabled, webvr_showbuttons() );"  
                />  
  
  
        <!-- when WebVR support is available show an EnterVR button -->  
        <action name="webvr_onavailable">  
            webvr.loadsettings();  
            delayedcall(0.5, tween(layer[webvr_enterbutton].alpha,1.0); );  
        </action>  
          
          
        <action name="webvr_onunknowndevice">  
            if(webvr.isfake AND device.desktop AND webvr.havesettings == false,  
                <!-- set the &#39;no distortion&#39; headset for fake desktop usage -->  
                set(webvr.mobilevr_lens_overlap, 1.0);  
                set(webvr.mobilevr_lens_fov, 96.0);  
                set(webvr.mobilevr_lens_dist, 0.0);  
                set(webvr.mobilevr_lens_dist2, &#39;1|0|0|0&#39;);  
                set(webvr.mobilevr_lens_ca, 0.0);  
                set(webvr.mobilevr_lens_vign, 100);  
              ,  
                set(ask_user_for_screensize,true);  
              );  
        </action>  
  
  
        <action name="webvr_onentervr">  
            tween(layer[webvr_enterbutton].alpha,0,0);  
  
            webvr_showbuttons();  
            webvr_hide_all_non_vr_layers();  
  
            <!-- when the screen size is unknown an no custom size is set, open the setup screen on entering the VR mode -->  
            if(webvr.ismobilevr == true AND !webvr.isfake AND ask_user_for_screensize == true AND webvr.mobilevr_screensize == &#39;auto&#39;,  
                set(ask_user_for_screensize, false);  
                vr_setup();  
              );  
            if(webvr.isfake,  
                webvr_show_fakemode_info(true);  
              );  
        </action>  
  
  
        <action name="webvr_onexitvr">  
            stopdelayedcall(vr_button_fadeout);  
  
            tween(layer[webvr_enterbutton].alpha,1);  
            tween(layer[webvr_exitbutton].alpha,0);  
            tween(layer[webvr_setupbutton].alpha,0);  
              
            webvr_show_fakemode_info(false);  
  
            webvr_restore_layers();  
        </action>  
  
  
        <action name="webvr_hide_all_non_vr_layers">  
            for(set(i,0), i LT layer.count, inc(i),  
                copy(lr, layer[get(i)]);  
                if(lr.vr !== true,  
                    copy(lr.vr_backup_visible, lr.visible);  
                    set(lr.visible, false);  
                  );  
              );  
        </action>  
  
        <action name="webvr_restore_layers">  
            for(set(i,0), i LT layer.count, inc(i),  
                copy(lr, layer[get(i)]);  
                if(lr.vr_backup_visible,  
                    copy(lr.visible, lr.vr_backup_visible);  
                    delete(lr.vr_backup_visible);  
                  );  
              );  
        </action>  
          
        <action name="webvr_show_fakemode_info">  
            if(&#39;%1&#39; == &#39;true&#39;,  
                addlayer(webvr_fakemode_info);  
                set(layer[webvr_fakemode_info].url, &#39;%SWFPATH%/plugins/textfield.swf&#39;);  
                set(layer[webvr_fakemode_info].keep, true);  
                set(layer[webvr_fakemode_info].align, &#39;bottom&#39;);  
                set(layer[webvr_fakemode_info].y, 80);  
                set(layer[webvr_fakemode_info].background, false);  
                set(layer[webvr_fakemode_info].css, &#39;color:#FFFFFF;text-align:center;&#39;);  
                set(layer[webvr_fakemode_info].html, &#39;这是在web端模拟的VR场景,请使用VR头戴装备和移动设备来进行观看。&#39;);  
              ,  
                removelayer(webvr_fakemode_info);  
              );  
        </action>  
          
          
        <!-- ensure the same scaling on mobiles (regardless if mobilescale is 0.5 or 1.0) -->  
        <krpano webvr_setup_scale="calc:(1.0 + 1.0*(device.mobile AND stagescale LT 1.0)) / (1.0 + 1.0*device.mobile)"  
                webvr_button_scale.normal="1.0"  
                webvr_button_scale.mobile="1.6"  
                />  
  
          
        <!-- the EnterVR/ExitVR and SetupVR buttons -->  
        <style name="webvr_button_style"  
               url="%SWFPATH%/plugins/textfield.swf"  
               backgroundcolor="0x000000"  
               backgroundalpha="0.5"  
               roundedge="calc:9*webvr_setup_scale*webvr_button_scale"  
               css="calc:&#39;color:#FFFFFF;font-size:&#39; + 20*webvr_setup_scale*webvr_button_scale + &#39;px;&#39;"  
               padding="calc:6*webvr_setup_scale*webvr_button_scale + &#39; &#39; + 10*webvr_setup_scale*webvr_button_scale"  
               />  
          
        <layer name="webvr_enterbutton" keep="true" vr="true"  
               style="webvr_button_style"  
               html="Enter VR"  
               align="top" y="24"  
               autoalpha="true" alpha="0.0"  
               onclick="webvr.enterVR();"  
               />  
  
        <layer name="webvr_exitbutton" keep="true" vr="true"  
               style="webvr_button_style"  
               html="退出VR"  
               align="top" y="24"  
               autoalpha="true" alpha="0.0"  
               onclick="webvr.exitVR();"  
               />  
  
        <layer name="webvr_setupbutton" keep="true" vr="true"  
               style="webvr_button_style"  
               html="VR 设置"  
               align="bottom" y="24"  
               autoalpha="true" alpha="0.0"  
               onclick="vr_setup()"  
               />  
  
  
        <action name="webvr_showbuttons">  
            stopdelayedcall(vr_button_fadeout);  
            if(webvr.ismobilevr,  
                tween(layer[webvr_exitbutton].alpha|layer[webvr_setupbutton].alpha, 1.0|1.0, 0.25);  
                delayedcall(vr_button_fadeout, 3.0, tween(layer[webvr_exitbutton].alpha|layer[webvr_setupbutton].alpha, 0.0|0.0, 1.0); );  
              ,  
                tween(layer[webvr_exitbutton].alpha, 1.0, 0.25);  
                delayedcall(vr_button_fadeout, 3.0, tween(layer[webvr_exitbutton].alpha, 0.0, 1.0); );  
              );  
        </action>  
  
  
  
        <!-- 
            VR Setup 
        -->  
  
        <action name="vr_setup">  
            <!-- disable cursor -->  
            set(webvr.vr_cursor_enabled, false);  
              
            <!-- hide VR buttons -->  
            tween(layer[webvr_exitbutton].alpha,0);  
            tween(layer[webvr_setupbutton].alpha,0);  
              
            <!-- create background layer -->  
            addlayer(vr_setup_bg);  
            set(layer[vr_setup_bg].type, container);  
            set(layer[vr_setup_bg].bgcolor, 0x000000);  
            set(layer[vr_setup_bg].bgalpha, 0.5);  
            set(layer[vr_setup_bg].bgcapture, true);  
            set(layer[vr_setup_bg].handcursor, false);  
            set(layer[vr_setup_bg].align, lefttop);  
            set(layer[vr_setup_bg].width, 100%);  
            set(layer[vr_setup_bg].height, 100%);  
            set(layer[vr_setup_bg].zorder, 99999);  
              
            <!-- get and prepare device infos and settings -->  
            copy(i_screensize, webvr.mobilevr_screensize);  
            if(i_screensize == &#39;auto&#39;, copy(i_screensize, webvr.devicesize));  
            if(i_screensize LE 0, set(i_screensize, 5.0));  
            roundval(i_screensize, 1);  
            txtadd(i_screensize, &#39; 英寸&#39;);  
  
            copy(i_ipd, webvr.mobilevr_ipd);  
            roundval(i_ipd, 1);  
            txtadd(i_ipd, &#39; 毫米&#39;);  
  
            copy(i_fov, webvr.mobilevr_lens_fov);  
            roundval(i_fov, 1);  
  
            copy(i_dist, webvr.mobilevr_lens_dist);  
            roundval(i_dist, 2);  
              
            copy(i_dist2, webvr.mobilevr_lens_dist2);  
            txtsplit(i_dist2, &#39;|&#39;, i_dist2_k1, i_dist2_k2, i_dist2_k3, i_dist2_k4);  
            mul(i_dist2_k1,1);  
            mul(i_dist2_k2,10);  
            mul(i_dist2_k3,10);  
            mul(i_dist2_k4,10);  
            roundval(i_dist2_k1,2);  
            roundval(i_dist2_k2,2);  
            roundval(i_dist2_k3,2);  
            roundval(i_dist2_k4,2);  
  
            copy(i_vig, webvr.mobilevr_lens_vign);  
            roundval(i_vig, 0);  
              
            copy(i_overlap, webvr.mobilevr_lens_overlap);  
            roundval(i_overlap, 2);  
              
            copy(i_ca, webvr.mobilevr_lens_ca);  
            roundval(i_ca, 3);  
  
            set(i_headset, &#39;Custom&#39;);  
            for(set(i,0), i LT vrheadsets.headset.count, inc(i),  
                copy(hs, vrheadsets.headset[get(i)]);  
                if(i_overlap == hs.overlap AND i_fov == hs.fov AND i_dist == hs.dist AND i_dist2 == hs.dist2 AND i_ca == hs.ca AND i_vig == hs.vig , copy(i_headset, hs.caption));  
               );  
  
            <!-- when the screen size is unknown, mark it red -->  
            set(known_size, true);  
            set(sizcol, #FFFFFF);  
            copy(i_devicename, webvr.devicename);  
              
            if(i_devicename == &#39;Unknown&#39;,  
                set(i_devicename, &#39;未知设备&#39;);  
                if(webvr.mobilevr_screensize == &#39;auto&#39;,  
                    set(sizcol, #AA0000);  
                    set(known_size, false);  
                  ,  
                    set(i_devicename, &#39;自定义&#39;);  
                  );  
              );  
  
              
            <!-- create layer for the main menu -->  
            addlayer(vr_setup_m1);  
            set(layer[vr_setup_m1].type, container);  
            set(layer[vr_setup_m1].parent, vr_setup_bg);  
            set(layer[vr_setup_m1].align, lefttop);  
            set(layer[vr_setup_m1].width, 100%);  
            set(layer[vr_setup_m1].height, 100%);  
              
            <!-- create layer for the headset customization menu -->  
            addlayer(vr_setup_m3);  
            set(layer[vr_setup_m3].type, container);  
            set(layer[vr_setup_m3].parent, vr_setup_bg);  
            set(layer[vr_setup_m3].align, lefttop);  
            set(layer[vr_setup_m3].width, 100%);  
            set(layer[vr_setup_m3].height, 100%);  
            set(layer[vr_setup_m3].visible, false);  
              
            <!-- create layer for the calibration menu -->  
            addlayer(vr_setup_m2);  
            set(layer[vr_setup_m2].type, container);  
            set(layer[vr_setup_m2].parent, vr_setup_bg);  
            set(layer[vr_setup_m2].align, lefttop);  
            set(layer[vr_setup_m2].width, 100%);  
            set(layer[vr_setup_m2].height, 100%);  
            set(layer[vr_setup_m2].visible, false);  
              
            <!-- create the text elements -->  
            set(vr_setup_text_parent, &#39;vr_setup_m1&#39;);  
            vr_setup_createtext(vr_setup_title, &#39;VR设置&#39;,       center, center, 0, -225, #FFFFFF,     false);  
  
            vr_setup_createtext(vr_setup_dvn1, &#39;设备:&#39;,         center, right,  0, -145, #FFFFFF,     true, vr_setup_select(&#39;screen&#39;) );  
            vr_setup_createtext(vr_setup_dvn2, get(i_devicename), center, left,   0, -145, get(sizcol), true, vr_setup_select(&#39;screen&#39;) );  
            vr_setup_createtext(vr_setup_siz1, &#39;屏幕尺寸:&#39;,     center, right,  0, -105, #FFFFFF,     true, vr_setup_select(&#39;screen&#39;) );  
            vr_setup_createtext(vr_setup_siz2, get(i_screensize), center, left,   0, -105, get(sizcol), true, vr_setup_select(&#39;screen&#39;) );  
  
            vr_setup_createtext(vr_setup_ipd1, &#39;瞳间距离:&#39;,            center, right,  0,  -35, #FFFFFF,     true, vr_setup_select(&#39;ipd&#39;) );  
            vr_setup_createtext(vr_setup_ipd2, get(i_ipd),        center, left,   0,  -35, #FFFFFF,     true, vr_setup_select(&#39;ipd&#39;) );  
  
            vr_setup_createtext(vr_setup_hmd1, &#39;VR设备:&#39;,     center, right,  0,  +35, #FFFFFF,     true, vr_setup_select(&#39;headset&#39;) );  
            vr_setup_createtext(vr_setup_hmd2, get(i_headset),    center, left,   0,  +35, #FFFFFF,     true, vr_setup_select(&#39;headset&#39;) );  
              
            vr_setup_createtext(vr_setup_hmd3, &#39;VR设备自定义&#39;,       center, center, 0,  +75, #FFFFFF,     true, set(background,true), set(background,false), vr_setup_customize_headset() );  
  
              
  
            if(webvr.iswebvr == false,  
                vr_setup_createtext(vr_setup_cal, &#39;陀螺仪校准&#39;,   center, center,    0, +145, #FFFFFF,     true, set(background,true), set(background,false), vr_setup_calibration() );  
              );  
  
            vr_setup_createtext(vr_setup_sav, &#39;保存&#39;,          center, center, -200, +225, #FFFFFF,     true, set(background,true), set(background,false), vr_setup_save() );  
            vr_setup_createtext(vr_setup_rst, &#39;恢复默认值&#39;,         center, center,    0, +225, #FFFFFF,     true, set(background,true), set(background,false), vr_setup_reset() );  
            vr_setup_createtext(vr_setup_cls, &#39;关闭&#39;,         center, center, +200, +225, #FFFFFF,     true, set(background,true), set(background,false), vr_setup_close() );  
              
            <!-- and the adjusting buttons -->  
            vr_setup_createbutton(vr_setup_btn1, &#39;<&#39;, left,  left,  5%, -35, #FFFFFF, true, null);  
            vr_setup_createbutton(vr_setup_btn2, &#39;>&#39;, right, right, 5%, -35, #FFFFFF, true, null);  
              
              
            <!-- create the customize_headset text elements -->  
            set(vr_setup_text_parent, &#39;vr_setup_m3&#39;);  
            vr_setup_createtext(vr_setup_m31, &#39;VR HEADSET&#39;, center, center, 0, -225, #FFFFFF, false);  
              
            vr_setup_createtext(vr_setup_fov1,  &#39;视角宽度:&#39;,           center, right,  0,  -80,  #FFFFFF,    true, vr_setup_select(&#39;fov&#39;) );  
            vr_setup_createtext(vr_setup_fov2, get(i_fov),        center, left,   0,  -80,  #FFFFFF,    true, vr_setup_select(&#39;fov&#39;) );  
            vr_setup_createtext(vr_setup_dst1, &#39;形变强度:&#39;,     center, right,  0,  -32,  #FFFFFF,    true, vr_setup_select(&#39;dist&#39;) );  
            vr_setup_createtext(vr_setup_dst2, get(i_dist),       center, left,   0,  -32,  #FFFFFF,    true, vr_setup_select(&#39;dist&#39;) );  
            vr_setup_createtext(vr_setup_d2tx, &#39;形变强度微调:&#39;,          center, right,  0,  +16,  #FFFFFF,    true, vr_setup_select(&#39;dist2k1&#39;) );  
            vr_setup_createtext(vr_setup_d2k1, get(i_dist2_k1),   center, left,   0,  +16,  #FFFFFF,    true, vr_setup_select(&#39;dist2k1&#39;) );  
            vr_setup_createtext(vr_setup_d2k2, get(i_dist2_k2),   center, left, +100, +16,  #FFFFFF,    true, vr_setup_select(&#39;dist2k2&#39;) );  
            vr_setup_createtext(vr_setup_d2k3, get(i_dist2_k3),   center, left, +200, +16,  #FFFFFF,    true, vr_setup_select(&#39;dist2k3&#39;) );  
            vr_setup_createtext(vr_setup_d2k4, get(i_dist2_k4),   center, left, +300, +16,  #FFFFFF,    true, vr_setup_select(&#39;dist2k4&#39;) );  
              
              
            vr_setup_createtext(vr_setup_cac1, &#39;相差校准:&#39;,        center, right,  0,  +64,  #FFFFFF,    true, vr_setup_select(&#39;ca&#39;) );  
            vr_setup_createtext(vr_setup_cac2, get(i_ca),         center, left,   0,  +64,  #FFFFFF,    true, vr_setup_select(&#39;ca&#39;) );  
            vr_setup_createtext(vr_setup_vig1, &#39;装饰边框:&#39;,       center, right,  0, +112,  #FFFFFF,    true, vr_setup_select(&#39;vignette&#39;) );  
            vr_setup_createtext(vr_setup_vig2, get(i_vig),        center, left,   0, +112,  #FFFFFF,    true, vr_setup_select(&#39;vignette&#39;) );  
            vr_setup_createtext(vr_setup_olp1, &#39;重叠:&#39;,        center, right,  0, +160,  #FFFFFF,    true, vr_setup_select(&#39;overlap&#39;) );  
            vr_setup_createtext(vr_setup_olp2, get(i_overlap),    center, left,   0, +160,  #FFFFFF,    true, vr_setup_select(&#39;overlap&#39;) );  
                      
            vr_setup_createtext(vr_setup_m35, &#39;关闭&#39;,       center, center, 0, +225, #FFFFFF, true, set(background,true), set(background,false), vr_setup_close_sub_menus() );  
              
              
            <!-- create the calibration text elements -->  
            set(vr_setup_text_parent, &#39;vr_setup_m2&#39;);  
            vr_setup_createtext(vr_setup_cb1, &#39;陀螺仪校准&#39;, center, center, 0, -225, #FFFFFF, false);  
            vr_setup_createtext(vr_setup_cb2, &#39;请把设备水平放置[br]点击校准按钮[br]进行陀螺仪校准.&#39;, center, center, 0, -95, #FFFFFF, false, vr_setup_select(&#39;screen&#39;) );  
            vr_setup_createtext(vr_setup_cb3, &#39;校准&#39;,   center, center, 0,  +55, #FFFFFF, true, set(background,true), set(background,false), vr_setup_do_calibration() );  
            vr_setup_createtext(vr_setup_cb4, &#39;重置&#39;,       center, center, 0, +125, #FFFFFF, true, set(background,true), set(background,false), webvr.resetcalibration() );  
            vr_setup_createtext(vr_setup_cb5, &#39;关闭&#39;,       center, center, 0, +225, #FFFFFF, true, set(background,true), set(background,false), vr_setup_close_sub_menus() );  
              
            vr_setup_createtext(vr_setup_cb6, &#39;校准中...&#39;,      bottom, center, 0, 40, #FFFFFF, false, null );  
            vr_setup_createtext(vr_setup_cb7, &#39;校准完成.&#39;,   bottom, center, 0, 40, #FFFFFF, false, null );  
            vr_setup_createtext(vr_setup_cb8, &#39;校准失败!&#39;, bottom, center, 0, 40, #FFFFFF, false, null );  
            set(layer[vr_setup_cb6].autoalpha, true);  
            set(layer[vr_setup_cb7].autoalpha, true);  
            set(layer[vr_setup_cb8].autoalpha, true);  
            set(layer[vr_setup_cb6].alpha, 0.0);  
            set(layer[vr_setup_cb7].alpha, 0.0);  
            set(layer[vr_setup_cb8].alpha, 0.0);  
              
              
            <!-- pre-select the screen size for adjusting when it is unknown, otherwise the IPD -->  
            if(known_size == false,  
                vr_setup_select(&#39;screen&#39;, true);  
              ,  
                vr_setup_select(&#39;ipd&#39;, true);  
              );  
        </action>  
  
  
        <action name="vr_setup_createtext">  
            <!--  
                %1 = name  
                %2 = text  
                %3 = align  
                %4 = edge  
                %5 = x  
                %6 = y  
                %7 = color  
                %8 = enabled  
                %9 = ondown  
                %10 = onup  
                %11 = onclick  
            -->  
            addlayer(%1);  
            set(layer[%1].parent, get(vr_setup_text_parent));  
            set(layer[%1].url, &#39;%SWFPATH%/plugins/textfield.swf&#39;);  
            set(layer[%1].css, calc(&#39;text-align:%3;color:%7;font-size:&#39;+40*webvr_setup_scale+&#39;px;font-weight:bold;&#39;));  
            set(layer[%1].padding, calc(0 + &#39; &#39; + 8*webvr_setup_scale));  
            set(layer[%1].roundedge, calc(8*webvr_setup_scale));  
            set(layer[%1].background, false);  
            set(layer[%1].backgroundcolor, 0xFFFFFF);  
            set(layer[%1].backgroundalpha, 0.25);  
            set(layer[%1].align, %3);  
            set(layer[%1].edge, %4);  
            set(layer[%1].x, calc(%5 * webvr_setup_scale));  
            set(layer[%1].y, calc(%6 * webvr_setup_scale));  
            set(layer[%1].html, %2);  
            set(layer[%1].enabled, %8);  
            set(layer[%1].ondown, %9);  
            set(layer[%1].onup, %10);  
            set(layer[%1].onclick, %11);  
        </action>  
  
  
        <action name="vr_setup_createbutton">  
            vr_setup_createtext(%1,%2,%3,%4,%5,%6,%7,%8,%9);  
            set(layer[%1].css, calc(&#39;vertical-align:middle;text-align:center;color:%7;font-size:&#39;+60*webvr_setup_scale+&#39;px;font-weight:bold;&#39;));  
            set(layer[%1].background, true);  
            set(layer[%1].padding, 0);  
            set(layer[%1].roundedge, calc(40 * webvr_setup_scale));  
            set(layer[%1].width, calc(70 * webvr_setup_scale));  
            set(layer[%1].height, calc(70 * webvr_setup_scale));  
            set(layer[%1].vcenter, true);  
        </action>  
  
  
        <action name="vr_setup_reset">  
            <!-- reset to the defaults -->  
            set(webvr.mobilevr_screensize, &#39;auto&#39;);  
            copy(i_screensize, webvr.devicesize);  
            if(i_screensize LE 0, set(i_screensize, 5.0); );  
            roundval(i_screensize, 1);  
            set(layer[vr_setup_dvn2].html, get(webvr.devicename));  
            txtadd(layer[vr_setup_siz2].html, get(i_screensize), &#39; 英寸&#39;);  
  
            set(webvr.mobilevr_ipd, 63.5);  
            copy(i_ipd, webvr.mobilevr_ipd);  
            roundval(i_ipd, 1);  
            txtadd(layer[vr_setup_ipd2].html, get(i_ipd), &#39; mm&#39;);  
  
            <!-- set fake custom lens settings and call &#39;next&#39; headset to switch to the default &#39;Cardboard&#39; settings -->  
            set(webvr.mobilevr_lens_fov, 100);  
            set(webvr.mobilevr_lens_dist, 0.5);  
            set(webvr.mobilevr_lens_dist2, &#39;1|0|0|0&#39;);  
            set(webvr.mobilevr_lens_vign, 100);  
            set(webvr.mobilevr_lens_overlap, 1.0);  
            set(webvr.mobilevr_lens_ca, 0.0);  
              
            if(webvr.isfake AND device.desktop,  
                <!-- select &#39;no distortion&#39; headset for fake desktop usage -->  
                vr_setup_change_headset(-1);  
              ,  
                <!-- select &#39;Cardboard A&#39; headset for Mobile-VR usage -->  
                vr_setup_change_headset(+1);      
              );  
  
            vr_setup_select(get(selected_var));  
        </action>  
  
  
        <action name="vr_setup_close">  
            <!-- 2. parameter == true => remove children elements too -->  
            removelayer(vr_setup_bg, true);  
              
            <!-- enable cursor -->  
            set(webvr.vr_cursor_enabled, true);  
        </action>  
  
  
        <action name="vr_setup_save">  
            webvr.saveSettings();  
            vr_setup_close();  
        </action>  
          
          
        <action name="vr_setup_customize_headset">  
            set(layer[vr_setup_bg].bgalpha, 0.1);  
              
            set(layer[vr_setup_m1].visible,false);  
            set(layer[vr_setup_m2].visible,false);  
            set(layer[vr_setup_m3].visible,true);  
              
            set(layer[vr_setup_hmd1].parent, vr_setup_m3);  
            set(layer[vr_setup_hmd2].parent, vr_setup_m3);  
            set(layer[vr_setup_btn1].parent, vr_setup_m3);  
            set(layer[vr_setup_btn2].parent, vr_setup_m3);  
              
            set(layer[vr_setup_hmd1].y, calc(-145 * webvr_setup_scale));  
            set(layer[vr_setup_hmd2].y, calc(-145 * webvr_setup_scale));  
              
            copy(old_selection, selected_var);  
            vr_setup_select(&#39;headset&#39;);  
        </action>  
          
          
  
        <action name="vr_setup_calibration">  
            set(layer[vr_setup_m1].visible,false);  
            set(layer[vr_setup_m2].visible,true);  
        </action>  
          
        <action name="vr_setup_close_sub_menus">  
            set(layer[vr_setup_bg].bgalpha, 0.5);  
              
            set(layer[vr_setup_m1].visible,true);  
            set(layer[vr_setup_m2].visible,false);  
            set(layer[vr_setup_m3].visible,false);  
              
            set(layer[vr_setup_hmd1].parent, vr_setup_m1);  
            set(layer[vr_setup_hmd2].parent, vr_setup_m1);  
            set(layer[vr_setup_btn1].parent, vr_setup_m1);  
            set(layer[vr_setup_btn2].parent, vr_setup_m1);  
              
            set(layer[vr_setup_hmd1].y, calc(+35 * webvr_setup_scale));  
            set(layer[vr_setup_hmd2].y, calc(+35 * webvr_setup_scale));  
              
            if(old_selection,  
                vr_setup_select(get(old_selection));  
                delete(old_selection);  
              );  
        </action>  
          
        <action name="vr_setup_do_calibration">  
            if(!webvr.isfake,  
                tween(layer[vr_setup_cb6].alpha, 1.0, 0.1);  
                tween(layer[vr_setup_cb7].alpha, 0.0, 0.1);  
                tween(layer[vr_setup_cb8].alpha, 0.0, 0.1);  
                webvr.calibrate(  
                    tween(layer[vr_setup_cb6].alpha, 0.0, 0.1);  
                    tween(layer[vr_setup_cb7].alpha, 1.0, 0.1);  
                    delayedcall(2.0, tween(layer[vr_setup_cb7].alpha, 0.0, 0.25) );  
                  ,  
                    tween(layer[vr_setup_cb6].alpha, 0.0, 0.1);  
                    tween(layer[vr_setup_cb8].alpha, 1.0, 0.1);  
                    delayedcall(2.0, tween(layer[vr_setup_cb8].alpha, 0.0, 0.25) );  
                  );  
              );  
        </action>  
  
        <action name="vr_setup_update_dist2">  
            txtadd(webvr.mobilevr_lens_dist2, get(i_dist2_k1), &#39;|&#39;, calc(i_dist2_k2/10.0), &#39;|&#39;, calc(i_dist2_k3/10.0), &#39;|&#39;, calc(i_dist2_k4/10.0));  
            vr_setup_change_headset(0);  
        </action>  
  
        <action name="vr_setup_select">  
            <!-- select a setting for adjusting -->  
            set(layer[vr_setup_siz2].background, false);  
            set(layer[vr_setup_ipd2].background, false);  
            set(layer[vr_setup_hmd2].background, false);  
            set(layer[vr_setup_fov2].background, false);  
            set(layer[vr_setup_dst2].background, false);  
            set(layer[vr_setup_d2k1].background, false);  
            set(layer[vr_setup_d2k2].background, false);  
            set(layer[vr_setup_d2k3].background, false);  
            set(layer[vr_setup_d2k4].background, false);  
            set(layer[vr_setup_vig2].background, false);  
            set(layer[vr_setup_cac2].background, false);  
            set(layer[vr_setup_olp2].background, false);  
  
            set(selected_setting, null);  
            delete(selected_var_value);  
  
            set(layer[vr_setup_btn1].ondown, vr_setup_change_ondown(-1) );  
            set(layer[vr_setup_btn2].ondown, vr_setup_change_ondown(+1) );  
            set(selected_var_callback, null);  
  
            set(selected_var, %1);  
  
            if(selected_var == &#39;screen&#39;,  
                set(selected_setting,      vr_setup_siz2);  
                set(selected_var_name,     &#39;webvr.mobilevr_screensize&#39;);  
                set(selected_var_postfix,  &#39; inch&#39;);  
                copy(selected_var_value,   get(selected_var_name));  
                if(selected_var_value == &#39;auto&#39;, copy(selected_var_value, webvr.devicesize));  
                if(selected_var_value LE 0, set(selected_var_value, 5.0));  
                set(selected_var_step,     0.1);  
                set(selected_var_min,      4);  
                set(selected_var_max,      10);  
                set(selected_var_round,    1);  
                set(selected_var_callback, vr_setup_change_screen() );  
              );  
  
            if(selected_var == &#39;ipd&#39;,  
                set(selected_setting,      vr_setup_ipd2);  
                set(selected_var_name,     &#39;webvr.mobilevr_ipd&#39;);  
                set(selected_var_postfix,  &#39; mm&#39;);  
                copy(selected_var_value,   get(selected_var_name));  
                set(selected_var_step,     0.1);  
                set(selected_var_min,      40);  
                set(selected_var_max,      80);  
                set(selected_var_round,    1);  
              );  
  
            if(selected_var == &#39;headset&#39;,  
                set(selected_setting,      vr_setup_hmd2);  
                set(layer[vr_setup_btn1].ondown, vr_setup_change_headset(-1) );  
                set(layer[vr_setup_btn2].ondown, vr_setup_change_headset(+1) );  
              );  
  
            if(selected_var == &#39;fov&#39;,  
                set(selected_setting,      vr_setup_fov2);  
                set(selected_var_name,     &#39;webvr.mobilevr_lens_fov&#39;);  
                set(selected_var_postfix,  &#39;&#39;);  
                copy(selected_var_value,   get(selected_var_name));  
                set(selected_var_step,     0.1);  
                set(selected_var_min,      40);  
                set(selected_var_max,      179);  
                set(selected_var_round,    1);  
                set(selected_var_callback, vr_setup_change_headset(0) );  
              );  
  
            if(selected_var == &#39;dist&#39;,  
                set(selected_setting,      vr_setup_dst2);  
                set(selected_var_name,     &#39;webvr.mobilevr_lens_dist&#39;);  
                set(selected_var_postfix,  &#39;&#39;);  
                copy(selected_var_value,   get(selected_var_name));  
                set(selected_var_step,     0.01);  
                set(selected_var_min,      0);  
                set(selected_var_max,      5);  
                set(selected_var_round,    2);  
                set(selected_var_callback, vr_setup_change_headset(0) );  
              );  
              
            if(selected_var == &#39;dist2k1&#39;,  
                set(selected_setting,      vr_setup_d2k1);  
                set(selected_var_name,     &#39;i_dist2_k1&#39;);  
                set(selected_var_postfix,  &#39;&#39;);  
                copy(selected_var_value,   get(selected_var_name));  
                set(selected_var_step,     0.01);  
                set(selected_var_min,      -9);  
                set(selected_var_max,      +9);  
                set(selected_var_round,    2);  
                set(selected_var_callback, vr_setup_update_dist2() );  
              );  
              
            if(selected_var == &#39;dist2k2&#39;,  
                set(selected_setting,      vr_setup_d2k2);  
                set(selected_var_name,     &#39;i_dist2_k2&#39;);  
                set(selected_var_postfix,  &#39;&#39;);  
                copy(selected_var_value,   get(selected_var_name));  
                set(selected_var_step,     0.01);  
                set(selected_var_min,      -9);  
                set(selected_var_max,      +9);  
                set(selected_var_round,    2);  
                set(selected_var_callback, vr_setup_update_dist2() );  
              );  
              
            if(selected_var == &#39;dist2k3&#39;,  
                set(selected_setting,      vr_setup_d2k3);  
                set(selected_var_name,     &#39;i_dist2_k3&#39;);  
                set(selected_var_postfix,  &#39;&#39;);  
                copy(selected_var_value,   get(selected_var_name));  
                set(selected_var_step,     0.01);  
                set(selected_var_min,      -9);  
                set(selected_var_max,      +9);  
                set(selected_var_round,    2);  
                set(selected_var_callback, vr_setup_update_dist2() );  
              );  
  
            if(selected_var == &#39;dist2k4&#39;,  
                set(selected_setting,      vr_setup_d2k4);  
                set(selected_var_name,     &#39;i_dist2_k4&#39;);  
                set(selected_var_postfix,  &#39;&#39;);  
                copy(selected_var_value,   get(selected_var_name));  
                set(selected_var_step,     0.01);  
                set(selected_var_min,      -9);  
                set(selected_var_max,      +9);  
                set(selected_var_round,    2);  
                set(selected_var_callback, vr_setup_update_dist2() );  
              );  
  
            if(selected_var == &#39;vignette&#39;,  
                set(selected_setting,      vr_setup_vig2);  
                set(selected_var_name,     &#39;webvr.mobilevr_lens_vign&#39;);  
                set(selected_var_postfix,  &#39;&#39;);  
                copy(selected_var_value,   get(selected_var_name));  
                set(selected_var_step,     1);  
                set(selected_var_min,      10);  
                set(selected_var_max,      200);  
                set(selected_var_round,    0);  
                set(selected_var_callback, vr_setup_change_headset(0) );  
              );  
  
            if(selected_var == &#39;ca&#39;,  
                set(selected_setting,      vr_setup_cac2);  
                set(selected_var_name,     &#39;webvr.mobilevr_lens_ca&#39;);  
                set(selected_var_postfix,  &#39;&#39;);  
                copy(selected_var_value,   get(selected_var_name));  
                set(selected_var_step,     0.01);  
                set(selected_var_min,      -1.0);  
                set(selected_var_max,      +1.0);  
                set(selected_var_round,    2);  
                set(selected_var_callback, vr_setup_change_headset(0) );  
              );  
                
            if(selected_var == &#39;overlap&#39;,  
                set(selected_setting,      vr_setup_olp2);  
                set(selected_var_name,     &#39;webvr.mobilevr_lens_overlap&#39;);  
                set(selected_var_postfix,  &#39;&#39;);  
                copy(selected_var_value,   get(selected_var_name));  
                set(selected_var_step,     0.01);  
                set(selected_var_min,      0.5);  
                set(selected_var_max,      2.0);  
                set(selected_var_round,    2);  
                set(selected_var_callback, vr_setup_change_headset(0) );  
              );  
  
            if(selected_setting != null,  
                set(layer[get(selected_setting)].background, true);  
                if(%2 == true,  
                    set(layer[vr_setup_btn1].y, get(layer[get(selected_setting)].y));  
                    set(layer[vr_setup_btn2].y, get(layer[get(selected_setting)].y));  
                  ,  
                    tween(layer[vr_setup_btn1].y, get(layer[get(selected_setting)].y));  
                    tween(layer[vr_setup_btn2].y, get(layer[get(selected_setting)].y));  
                  );  
              );  
        </action>  
  
  
        <action name="vr_setup_change_screen">  
            set(layer[vr_setup_dvn2].html, &#39;自定义&#39;);  
            set(layer[vr_setup_dvn2].css, calc(&#39;color:#FFFFFF;font-size:&#39;+40*webvr_setup_scale+&#39;px;font-weight:bold;&#39;));  
            set(layer[vr_setup_siz2].css, calc(&#39;color:#FFFFFF;font-size:&#39;+40*webvr_setup_scale+&#39;px;font-weight:bold;&#39;));  
        </action>  
  
  
        <action name="vr_setup_change_ondown">  
            copy(t0,timertick);  
            set(t1,0);  
            asyncloop(pressed,  
                copy(t2,timertick);  
                sub(dt,t2,t1);  
                if(dt GT 100,  
                    copy(t1,t2);  
                    sub(dt,t1,t0);  
                    div(dt,1000);  
                    Math.max(dt,1);  
                    mul(dt,%1);  
                    vr_setup_adjust(get(dt));  
                  );  
              );  
        </action>  
  
  
        <action name="vr_setup_adjust">  
            if(selected_setting != null,  
                mul(change, selected_var_step, %1);  
                add(selected_var_value, change);  
                Math.max(selected_var_value, selected_var_min);  
                Math.min(selected_var_value, selected_var_max);  
                roundval(selected_var_value, get(selected_var_round));  
                tween(get(selected_var_name), get(selected_var_value), 0.1);  
                txtadd(layer[get(selected_setting)].html, get(selected_var_value), get(selected_var_postfix));  
                if(selected_var_callback != null, selected_var_callback());  
              );  
        </action>  
  
  
        <action name="vr_setup_change_headset">  
            set(i_headset, &#39;Custom&#39;);  
            if(%1 != 0,  
                copy(i_fov, webvr.mobilevr_lens_fov);  
                roundval(i_fov, 1);  
                copy(i_dist, webvr.mobilevr_lens_dist);  
                roundval(i_dist, 2);  
                copy(i_dist2, webvr.mobilevr_lens_dist2);  
                copy(i_vig, webvr.mobilevr_lens_vign);  
                roundval(i_vig, 0);  
                copy(i_ca, webvr.mobilevr_lens_ca);  
                roundval(i_ca, 3);  
                copy(i_overlap, webvr.mobilevr_lens_overlap);  
                roundval(i_overlap, 2);  
                set(i_hsindex, -1);  
                copy(i_hscount, vrheadsets.headset.count);  
                for(set(i,0), i LT i_hscount, inc(i),  
                    copy(hs, vrheadsets.headset[get(i)]);  
                    if(i_overlap == hs.overlap AND i_fov == hs.fov AND i_dist == hs.dist AND i_dist2 == hs.dist2 AND i_ca == hs.ca AND i_vig == hs.vig , copy(i_hsindex, i); copy(i_headset, hs.caption); );  
                   );  
  
                if(%1 GT 0,  
                    <!-- loop right -->  
                    add(i_hsindex, 1);  
                    if(i_hsindex GE i_hscount, set(i_hsindex,0));  
                  ,  
                    <!-- loop left -->  
                    sub(i_hsindex, 1);  
                    if(i_hsindex LT 0, sub(i_hsindex,i_hscount,1));  
                  );  
  
                copy(hs, vrheadsets.headset[get(i_hsindex)]);  
                copy(i_headset, hs.caption);  
                copy(i_overlap, hs.overlap);  
                copy(i_fov,     hs.fov);  
                copy(i_dist,    hs.dist);  
                copy(i_dist2,   hs.dist2);  
                copy(i_ca,      hs.ca);  
                copy(i_vig,     hs.vig);  
              );  
  
            copy(layer[vr_setup_hmd2].html, i_headset);  
            if(%1 != 0,  
                copy(webvr.mobilevr_lens_overlap, i_overlap);  
                copy(webvr.mobilevr_lens_fov, i_fov);  
                copy(webvr.mobilevr_lens_dist, i_dist);  
                copy(webvr.mobilevr_lens_dist2, i_dist2);  
                copy(webvr.mobilevr_lens_ca, i_ca);  
                copy(webvr.mobilevr_lens_vign, i_vig);  
                copy(layer[vr_setup_olp2].html, i_overlap);  
                copy(layer[vr_setup_fov2].html, i_fov);  
                copy(layer[vr_setup_dst2].html, i_dist);  
                  
                txtsplit(i_dist2, &#39;|&#39;, i_dist2_k1, i_dist2_k2, i_dist2_k3, i_dist2_k4);  
                mul(i_dist2_k1,1);  
                mul(i_dist2_k2,10);  
                mul(i_dist2_k3,10);  
                mul(i_dist2_k4,10);  
                roundval(i_dist2_k1,2);  
                roundval(i_dist2_k2,2);  
                roundval(i_dist2_k3,2);  
                roundval(i_dist2_k4,2);  
                copy(layer[vr_setup_d2k1].html, i_dist2_k1);  
                copy(layer[vr_setup_d2k2].html, i_dist2_k2);  
                copy(layer[vr_setup_d2k3].html, i_dist2_k3);  
                copy(layer[vr_setup_d2k4].html, i_dist2_k4);  
                  
                copy(layer[vr_setup_cac2].html, i_ca);  
                copy(layer[vr_setup_vig2].html, i_vig);  
              );  
        </action>  
  
    </krpano>

替换webvr.xml

相关文章
最新文章
热点推荐