截至krpano 1.19 pr5,在VR中支持的熱點只有distorted爲true的圖像熱點,這些圖像熱點可能是鏈接到其它場景,或者是彈出圖片,如果是後者的話,在VR中是有問題的,我們希望在VR下,這些用途爲彈出圖片的熱點不要顯示,只在正常模式下顯示。
我們有下面兩種用途的熱點:
|
<hotspotname="spot2"style="skin_hotspotstyle"ath="42.657"atv="24.198"linkedscene="scene_02mt"/>
<hotspotname="spot3"style="hotspotstyle|normalhs" ath="22.657"atv="14.198"onclick="openpic()"/>
|
spot2是用於鏈接到其它scene裏的,而spot3是彈出圖片的。我們給spot3加了一個style爲normalhs,如下。在這個例子中,所有不想在VR中顯示的但distorted爲true的圖像熱點,我們都加上這個設置:
|
<style name="normalhs"normal="false"onloaded="if(webvr.isenabled,set(visible,false),set(visible,true));" />
|
注意,如果所加的熱點本身有onloaded。例如,
|
<hotspotname="spot3"style="hotspotstyle" ath="22.657"atv="14.198"onclick="openpic()"onloaded="otheraction();"/>
|
這樣的話,需要把normalhs單獨寫出來。寫成
|
<hotspotname="spot3"style="hotspotstyle" ath="22.657"atv="14.198"onclick="openpic()"normal="false"onloaded="if(webvr.isenabled,set(visible,false),set(visible,true));otheraction();" />
|
然後tour.xml加入下面代碼,在scene外,上面style元素也一樣是放在scene外面。
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
|
<action name="normalhs_enterVR">
for(set(i,0),i
LThotspot.count,inc(i),
if(hotspot[get(i)].normal==
false,
set(hotspot[get(i)].visible,false);
);
);
</action>
<action name="normalhs_exitVR">
for(set(i,0),i
LThotspot.count,inc(i),
if(hotspot[get(i)].normal==
false,
set(hotspot[get(i)].visible,true);
);
);
</action>
|
這兩段action就是控制進入VR和退出VR是控制那些含有normal屬性且數值爲false的熱點的顯示和隱藏。我們在代碼中使用了循環,然後對屬性進行了判斷,然後設置其visible。
另外在tour.xml加入下面代碼(一定要在第三行include代碼的後面寫,這樣才能覆蓋掉vtourskin裏面的webvr插件設定),將normalhs_enterVR和normalhs_exitVR的調用分別加入到onentervr和onexitvr兩個事件當中。
|
<pluginname="WebVR"keep="true"devices="html5"
pluginurl="%SWFPATH%/plugins/webvr.js"
url=""
multireslock.desktop="true"
multireslock.mobile.or.tablet="false"
mobilevr_support="true"
mobilevr_fake_support="true"
onavailable="removelayer(webvr_enterbutton); skin_arrange_buttons(); webvr_onavailable();"
onentervr="normalhs_enterVR();skin_showloading(false); webvr_onentervr(); webvr_setup(); skin_reloadscene_webvr();"
onexitvr="webvr_onexitvr(); webvr_setup(); skin_reloadscene_webvr();normalhs_exitVR();"
/>
|
參考:sparselight.cn