一、krpano動(dòng)作/功能參考
? ? 1.編程邏輯/流量控制
(1)def(variable, type, value*)
定義具有特定類(lèi)型的新變量,并可選地將其設(shè)置為給定值。當(dāng)沒(méi)有給定值且變量已經(jīng)存在時(shí),則具有當(dāng)前值的變量將轉(zhuǎn)換為給定類(lèi)型。
boolean?- true or false
number?- a numeric value
integer?or?int?- an integer value
uint?- an unsigned integer value
string?- text characters
object?- an object with custom properties
array?- a?value-array
example:
def(b, boolean, true);
def(n, number, 123.456);
def(s, string, 'text');
def(obj, object);
def(obj.x, number, 0.0);
def(obj.y, number, 0.0);
(2)set(variable, value);set(object, variable:type=value, variable:type=value, ...);
set()操作是兩種調(diào)用/使用可能性:
當(dāng)使用兩個(gè)參數(shù)調(diào)用時(shí):
這是一個(gè)值的一個(gè)變量的正常集合。
當(dāng)使用三個(gè)或更多參數(shù)調(diào)用時(shí):
這是一個(gè)同時(shí)包含多個(gè)變量的多重集合。
在這里,變量將被設(shè)置或添加到對(duì)象中。
也可以選擇指定變量的類(lèi)型。
object
多個(gè)集合調(diào)用的對(duì)象-在此對(duì)象上將設(shè)置變量。
當(dāng)對(duì)象不存在時(shí),將創(chuàng)建它。
要在特定范圍內(nèi)定義變量,可以在這里使用全局或局部對(duì)象。
variable
變量名。
當(dāng)變量不存在時(shí),將創(chuàng)建該變量。
boolean?- true or false
number?- a numeric value
integer?or?int?- an integer value
uint?- an unsigned integer value
string?- text characters
正常設(shè)置:
set(var1, 'hello');
set(var2, get(var1));
set(fullscreen, true);
set(layer[p1].visible, false);
set(hotspot[h1].scale, 2.5);
set(contextmenu.item[0].caption, 'hello item');
set(events.onxmlcomplete, null);
多組設(shè)置:
set(layer[p1], visible=false, alpha=0.5);
set(hotspot[hs1],
? ? type='text',
? ? ath=0.0,
? ? atv=0.0,
? ? html='Test Text',
? ? css='text-align:center',
? ? bg=false
);
set(global,
? ? test='Test text',
? ? havesomething:boolean=true,
? ? var2:string=get(var1),
? ? value:number=calc(1 + 2*3)
);
(3)action(get(variable), ... )
array[get(variable)]
get:variable" ... />
將變量解析為其值。get(var)操作是一個(gè)特殊操作,只能在調(diào)用其他操作或訪問(wèn)數(shù)組元素時(shí)用作參數(shù)。
當(dāng)變量不存在時(shí),get()將返回null。
注意-有些操作會(huì)自動(dòng)嘗試將其給定參數(shù)解析為其值。對(duì)于這些操作,不需要使用get(var)。
example:
set(dstvar, get(srcvar));
looktohotspot(get(name));
lookto(get(h), get(v), get(f));
showtext(get(msg));
tween(var,get(dstval));
set(pic, spot1);
set(hotspot[get(pic)].visible, false);
trace('xyz=', xyz, ' get(xyz)=', get(xyz));
txtadd(msg, 'fov=', get(view.fov));
action(calc(expression), ... )
array[calc(expression)]
calc:expression" ... />
計(jì)算/求值/將表達(dá)式解析為其值。
calc(expression)操作是一個(gè)特殊操作,只能在調(diào)用其他操作或訪問(wèn)數(shù)組元素時(shí)用作參數(shù)。
存儲(chǔ)結(jié)果的變量。當(dāng)變量不存在時(shí),將創(chuàng)建該變量。數(shù)學(xué)或邏輯表達(dá)式。
set(y_new, calc(y_old - offset1 + offset2));
set(animationtime, calc('%1' == 'instant' ? 0.0 : 0.5));
<layer url="calc:'%CURRENTXML%/skin/' + settings.image1" />
(5)copy(destination, source,typeconversion*)
copy()操作將內(nèi)容從一個(gè)變量復(fù)制到另一個(gè)變量。默認(rèn)情況下,這與:set(destination,get(source))相同。
目標(biāo)變量。當(dāng)變量不存在時(shí),將創(chuàng)建它。
源變量。當(dāng)變量不存在時(shí),將為目標(biāo)變量設(shè)置null。
類(lèi)型轉(zhuǎn)換(可選)
當(dāng)設(shè)置為true(默認(rèn)值)時(shí):
當(dāng)兩個(gè)變量都有不同的類(lèi)型時(shí),源變量的值將轉(zhuǎn)換為目標(biāo)變量的類(lèi)型。
設(shè)置為false時(shí):
將源變量的值和類(lèi)型復(fù)制到目標(biāo)變量。
刪除并移除給定的變量。
參數(shù):變量,任何變量名。
可以一次刪除多個(gè)變量-只需傳遞多個(gè)變量名(用逗號(hào)分隔)。
set(tmp1, ...);set(tmp2, ...);delete(tmp1, tmp2);
(7)if(true/false,yes,no)
if(fullscreen, fullscreensetup(), windowsetup() );
if(fullscreen, set(layer[controls].visible, false) );
if(i LT 10, loop(next) );
if(var === null, set(var,0));
if(hotspot[spot1] === null, trace(there is no spot1 hotspot));
if((varA GT 5) AND (varA LT 10),
? ? trace('varA is between 5 and 10')
? );
if(varA AND varB AND varC, trace('all vars are true') );
if(var1 GT var2,
? ? trace('condition is true');
? ? lookto(100,20,50);
? ,
? ? trace('condition is false');
? ? lookto(0,0,100);
? );
if(a*2+b GT (c+3)*1.5 OR teststring == '123', ...);
if(
? ? test == 1, trace('test is 1'),
? ? test == 2, trace('test is 2'),
? ? test == 3, trace('test is 3'),
? ? trace('test is someting else')
);
(8)delayedcall(delay, actions);delayedcall(id, delay, actions)
在給定的時(shí)間后調(diào)用/執(zhí)行給定的操作。
參數(shù):
id(可選)
delayedcall的可選唯一id。
此id可用于通過(guò)調(diào)用stopdelayedcall(id)來(lái)停止delayedcall。
延遲
執(zhí)行操作前等待的秒數(shù)。
行動(dòng)
延遲后要調(diào)用的操作。
delayedcall(5.0, hidelogo() );
delayedcall(10, looktohotspot(spot1);loadpano(pano2.xml); );
delayedcall(1, showtext('hello');? ? ? );
delayedcall(4, showtext('to the pano'); );
<action name="updatemousepos">
? copy(layer[cursor].x, mouse.x);
? copy(layer[cursor].y, mouse.y);
? delayedcall(0.02, updatemousepos() );
</action>
使用給定的id停止delayedcall。
<events name="introimage_events"
? ? ? ? onnewpano="delayedcall(introimage, 5.0, hide_introimage() );"
? ? ? ? onremovepano="stopdelayedcall(introimage);"
在下一個(gè)處理中調(diào)用/執(zhí)行給定的操作-這意味著在當(dāng)前操作之后,但要盡快。
(11)callwhen(condition, actions);callwhen(id, condition, actions);
在條件為真或?qū)⒊蔀檎鏁r(shí)調(diào)用給定的操作。
當(dāng)條件當(dāng)前不是true時(shí),則callwhen()操作將一直等待,直到條件變?yōu)閠rue。
參數(shù):
id(可選)
callwhen的可選唯一id。
通過(guò)調(diào)用stop callwhen(id),此id可用于停止等待的callwhen。
條件
邏輯表達(dá)式。
callwhen()操作將在每幀中不斷檢查此條件,直到它變?yōu)檎妗?/p>
行動(dòng)
條件為真時(shí)要調(diào)用的操作。
callwhen(plugin[video].loaded, plugin[video].playvideo(...); );
callwhen(plugin[maps].loaded, plugin[maps].setcenter(...); );
(12)stopcallwhen(id);
使用給定的id停止仍在等待的呼叫。
(13)for(startactions, condition, nextactions, loopactions)
首先調(diào)用startactions,然后檢查條件,當(dāng)它為true時(shí),然后調(diào)用loopactions,然后調(diào)用nextactions,然后再次開(kāi)始檢查條件和循環(huán)。
for(set(i,0), i LT 10, inc(i), trace('i=',i) );.
for(set(i,0), i LT layer.count, inc(i),
? trace('layer[',i,'].name=',layer[get(i)].name);
);
(14)loop(condition, loopactions);asyncloop(condition, loopactions, doneactions*);
只要條件為true,就將重復(fù)調(diào)用loopactions。當(dāng)循環(huán)本身完成時(shí),normal loop()操作將繼續(xù)執(zhí)行以下操作。asyncloop()將中間繼續(xù)執(zhí)行以下操作,并每幀執(zhí)行一次loopactions。當(dāng)異步循環(huán)最終完成時(shí),將調(diào)用doneAction。
ondown="asyncloop(pressed, layer[scrollarea].scrollby(+2,0) );"
onover="asyncloop(hovering, updatemousepos(), hideinfo() );"
asyncloop(true, framehandler() )
(15)renderloop(loopactions);stoprenderloop();
renderloop()操作將在每幀執(zhí)行一次loopactions。
要停止循環(huán),需要在loopactions內(nèi)部調(diào)用stoprenderloop()操作。
krpano-Action-Code Example:
renderloop(
? ? if(...done with rendering...,
? ? ? stoprenderloop();? );
);
Javascript-Code Example:
krpano.actions.renderloop(function(){
? ? if(...done with rendering...){
? ? ? krpano.actions.stoprenderloop();
? ? }
});
(16)setinterval(id, delay, actions);clearinterval(id);
重復(fù)調(diào)用/執(zhí)行給定的操作,并在兩個(gè)操作之間有一個(gè)延遲時(shí)間間隔。
此id可用于通過(guò)調(diào)用clearinterval(id)來(lái)停止間隔。
延遲
操作調(diào)用之間等待的秒數(shù)。
使用0作為延遲時(shí),每幀將調(diào)用一次操作。
行動(dòng)
調(diào)用每個(gè)延遲秒的操作。
setinterval(time, 1.0,
? ? jsget(time, (new Date()).toLocaleTimeString(); );
? ? trace('time=',time);
? );
<events onkeydown="setinterval(get(keycode), 0.1, trace(keycode); );"
? ? ? ? onkeyup="clearinterval(get(keycode));"
? ? ? ? />
(17)toggle(variable);
toggle操作在true和false之間切換給定(布爾)變量的值。
toggle(fullscreen);
toggle(layer[button1].visible);
(18)switch(variable);switch(variable, value1, value2, ...);
開(kāi)關(guān)動(dòng)作在幾個(gè)狀態(tài)之間/通過(guò)幾個(gè)狀態(tài)來(lái)切換給定變量的值。每次調(diào)用開(kāi)關(guān)動(dòng)作時(shí),值都將被切換/更改。
當(dāng)只給出沒(méi)有值參數(shù)的變量本身時(shí),變量將在true和false之間切換。
當(dāng)有兩個(gè)或多個(gè)作為參數(shù)給定的值時(shí),變量將切換所有這些值(從左到右)
switch(fullscreen);
switch(layer[button1].visible);
switch(layer[button1].alpha, 1.0, 0.5);
switch(layer[child].parent, button1, button2, button3);
switch(destpos, -100, 0, +100); tween(y,get(destpos));
(19)break();
中斷/停止當(dāng)前流中的操作調(diào)用的執(zhí)行,以及從一個(gè)嵌套級(jí)別向上的操作調(diào)用(例如,當(dāng)在if()調(diào)用內(nèi)部調(diào)用時(shí),也將停止if外部的流)。
當(dāng)在for()或loop()循環(huán)中使用時(shí),break()調(diào)用也將停止該循環(huán)。
(20)exitcall();
直接退出/停止當(dāng)前操作“調(diào)用”。
“調(diào)用”要么是對(duì)<action>的調(diào)用,要么是對(duì)包含action代碼的變量的調(diào)用,要么是對(duì)事件的action代碼的調(diào)用。
(21)callwith(caller, actions);
使用特定的插件/層或熱點(diǎn)元素作為調(diào)用方調(diào)用krpano操作代碼。這可用于直接屬性訪問(wèn)或模擬對(duì)這些元素的事件調(diào)用。
參數(shù):
來(lái)電者
應(yīng)該用作調(diào)用方的元素。
只能是<plugin>/<layer>或<hotspot>元素。
行動(dòng)
任何krpano動(dòng)作代碼。
代碼將在調(diào)用方的“context”中執(zhí)行,這意味著對(duì)其屬性的“直接”訪問(wèn)。
callwith(layer[test], onclick);
callwith(layer[test], trace('test pos=',x,'/',y); );
callwith(layer[test], tween(alpha, 0.0); );
(22)scope(scope, actions);
在特定范圍內(nèi)調(diào)用krpano操作代碼。
scope(localonly, for(set(i,0), i LT 10, inc(i), trace(i)); );
scope(private:my_xml_plugin, trace(internal_var); );
(23)parentscopeset(variable, value)
將變量設(shè)置為a值-類(lèi)似于Set()調(diào)用-但在父操作的范圍內(nèi)。
這可用于將內(nèi)部本地作用域操作的結(jié)果返回/傳遞回外部作用域操作。
將當(dāng)前本地作用域鏈接到給定元素的事件。
當(dāng)調(diào)用該元素的事件(例如onclick)時(shí),事件代碼中將使用相同的作用域。默認(rèn)情況下,事件始終使用全局范圍。
注意-當(dāng)鏈接到一個(gè)作用域時(shí),有必要使用調(diào)用者來(lái)尋址元素作用域本身!
(25)assignstyle(elementname, styles);
將屬性從一個(gè)或多個(gè)<style>元素復(fù)制到自定義元素。
assignstyle(layer[test], 'teststyle');
assignstyle(layer[test], 'style1|style2');
(26)copyattributes(destobject, srcobject)
將所有屬性從一個(gè)對(duì)象復(fù)制到另一個(gè)對(duì)象。
注意-copyattributes()操作的參數(shù)必須是對(duì)象,而不是對(duì)象的名稱(chēng)/路徑!這意味著可能需要使用get()操作來(lái)解析名稱(chēng)/路徑。
copyattributes(get(layer[test]), get(style[style1]));
(27)events.dispatch(eventname, instantly*);
從所有<events>元素分派/調(diào)用給定事件。
參數(shù):
事件名稱(chēng)
事件的名稱(chēng)。
立即(可選)
布爾設(shè)置(默認(rèn)為true或false)。
當(dāng)設(shè)置為true時(shí),將立即調(diào)用和執(zhí)行事件;當(dāng)未設(shè)置或設(shè)置為false時(shí),將在當(dāng)前操作調(diào)用后調(diào)用事件。
<events name="events1" myevent="trace(events1...);" />
<events name="events2" myevent="trace(events2...);" />
events.dispatch(myevent);
(28)tohex(variable, prefix*, length*);tohex(destinationvariable, variable, prefix, length);
將給定變量的內(nèi)容轉(zhuǎn)換為十六進(jìn)制字符串。
可用于創(chuàng)建html/css顏色字符串。
tohex(color,'#',6);
set(color, ...an_external_integer_input...);
tohex(color,'#',6);
txtadd(layer[text1].css,'color:',get(color),';');
(29)tolower(variable);toupper(variable);tolower(destinationvariable, sourcevariable);toupper(destinationvariable, sourcevariable)
將給定變量的內(nèi)容轉(zhuǎn)換為小寫(xiě)或大寫(xiě)。
(30)txtadd(destination, txt1, txt2*, txt3*, ...);
txtadd操作可用于將多個(gè)文本/值添加/連接在一起。
該操作可以與2個(gè)或更多參數(shù)一起使用。當(dāng)只使用兩個(gè)參數(shù)(目的地和文本)時(shí),文本將添加到目的地變量的當(dāng)前值。
參數(shù):
目的地
存儲(chǔ)連接文本的目標(biāo)變量。
當(dāng)變量不存在時(shí),將創(chuàng)建該變量。
txt1,txt2,txt3。。。(可選)
將連接在一起的文本。
如果只使用一個(gè)txt參數(shù),則此文本將添加到當(dāng)前目標(biāo)變量的內(nèi)容中。
注意-當(dāng)應(yīng)該使用變量的內(nèi)容時(shí)-則必須使用get()操作來(lái)解析變量!
txtadd(picfilename,'%CURRENTXML%/pic_',get(pic),'.jpg');
txtadd(crop,'0|',get(ypos),'|333|285');
txtadd(pname, 'thumbbar_image_', get(i));
txtadd(layer[text].html,'[p]',get(data[txt1].content),'[/p]');
txtadd(msg,get(view.fovtype),'=',get(fov),'°');
(31)subtxt(dstvar, srcvar, startpos, len);
subxt操作提取其他文本的一部分。
參數(shù):
將存儲(chǔ)提取文本的目標(biāo)變量。當(dāng)變量不存在時(shí),將創(chuàng)建該變量。包含源文本的變量或文本。文本提取的起始位置。要提取的文本的長(zhǎng)度。
(32)indexoftxt(index, txt, searchtxt, startindex*);
indexoftxt操作給出“txt”字符串中“searchtxt”值第一次出現(xiàn)的位置。將存儲(chǔ)“searchtxt”第一次出現(xiàn)的索引的變量。
如果從未發(fā)生過(guò)“searchtxt”,則為-1。當(dāng)變量不存在時(shí),將創(chuàng)建該變量。
應(yīng)該在其中搜索的文本。要搜索的文本。startindex(可選)開(kāi)始搜索文本的起始索引/位置(默認(rèn)為0)。
(33)txtreplace(var, searchtext, replacetext);txtreplace(dstvar, srcvar, searchtext, replacetext)
txtreplace操作在“var/srcvar”中搜索“searchtext”的所有匹配項(xiàng),并將其替換為“replacetext”。
參數(shù):
變量/srcvar/dstwar要搜索的變量(var,srcvar)和結(jié)果的存儲(chǔ)位置(var,dstvar)。當(dāng)變量不存在時(shí),將創(chuàng)建該變量。
搜索文本
應(yīng)該搜索的文本。
替換文本
將替換“searchtxt”出現(xiàn)的文本。
(34)txtsplit(string, separator, resultingarray);txtsplit(string, separator, var1, var2, ...);
txtsplit操作在“var/srcvar”中搜索所有出現(xiàn)的“searchtext”,并將其替換為“replacetext”。
分隔符或字符串。
resultingarray(使用3個(gè)參數(shù)調(diào)用txtsplit()操作時(shí))
將拆分部分作為“value”屬性包含的數(shù)組變量的名稱(chēng)。
變1,變2。。。(使用4個(gè)或更多參數(shù)調(diào)用txtsplit()操作時(shí))
拆分的結(jié)果將直接分配給給定的變量。
當(dāng)使用null作為變量時(shí),該值將被忽略/跳過(guò)(只能用于提取某些特定值)。
txtsplit('1|2|3', '|', a, b, c);
trace('a=',get(a), ' b=',get(b), ' c=',get(c));
a=1 b=2 c=3
Split into an array:
txtsplit('x|y|z', '|', arr);
for(set(i,0), i LT arr.count, inc(i),
trace('arr[',get(i),'].value=',arr[get(i)].value);
);
Result:
arr[0].value=x
arr[1].value=y
arr[2].value=z
(35)txtjoin(var, separator, array);txtjoin(var, separator, var1, var2, ...);
txtjoin操作濃縮給定數(shù)組或給定變量中的所有元素,并在它們之間插入指定的分隔字符串。
當(dāng)變量不存在時(shí),將創(chuàng)建該變量。
將在元素之間插入的分隔符或字符串。
數(shù)組(使用3個(gè)參數(shù)調(diào)用txtjoin()操作時(shí))
數(shù)組變量的名稱(chēng)。
變1,變2。。。(使用4個(gè)或更多參數(shù)調(diào)用txtjoin()操作時(shí))
要聯(lián)接的變量或值。
txtsplit(image.prealign, '|', rx, ry, rz);
add(ry,90);
txtjoin(image.prealign, '|', rx, ry, rz);
Split into an array:
txtsplit('x|y|z', '|', arr);
for(set(i,0), i LT arr.count, inc(i),
trace('arr[',get(i),'].value=',arr[get(i)].value);
);
Result:
arr[0].value=x
arr[1].value=y
arr[2].value=z
(36)fromcharcode(var, charcode);
fromcharcode操作將給定的字符代碼轉(zhuǎn)換為字符串并存儲(chǔ)在給定的變量中。存儲(chǔ)字符的變量。
當(dāng)變量不存在時(shí),將創(chuàng)建該變量。
字符碼
作為數(shù)字的Unicode字符代碼。
(37)escape(var);escape(var, text);unescape(var);unescape(var, text);
escape和unescape操作是轉(zhuǎn)義給定變量或給定文本的內(nèi)容,然后將結(jié)果存儲(chǔ)到給定變量中。
With text參數(shù)-轉(zhuǎn)義/未轉(zhuǎn)義文本將存儲(chǔ)在其中的變量。將被轉(zhuǎn)義/取消轉(zhuǎn)義的文本。
(38)tween(variable, value, time*, tweentype*, donecall*, updatecall*);
tween操作可用于時(shí)間控制的動(dòng)畫(huà)/變量更改。該操作將動(dòng)態(tài)地將變量的當(dāng)前值更改為給定值??梢酝瑫r(shí)將多個(gè)變量連接在一起。因此,請(qǐng)指定多個(gè)變量、值和由|字符分隔的二十種類(lèi)型。如果指定了多個(gè)變量,但只有一個(gè)值和/或只有一個(gè)tweentype,則所有變量將tween轉(zhuǎn)換為相同的值和/或使用相同的tweentype。對(duì)于所有給定的變量,時(shí)間、完成和更新調(diào)用將始終相同。
Parameters:{variable,value,time,tweentype,donecall?,updatecall?}
tween(scale,2);
tween(rotate,90);
tween(width,50%);
onover="tween(alpha,0.7,distance(0.3,0.2));"
onout="tween(alpha,1.0,distance(0.3,0.2));"
set(alpha,0);
set(visible,true);
tween(alpha, 1.0 ,0.3);
tween(layer[logo].width, get(destwidth));
set(layer[image].enabled,false);
tween(layer[image].alpha,0.0,0.5,default,removeplugin(image));
set(view.stereographic,true);
tween(view.vlookat, 90.0, 2.0);
tween(view.fisheye, 1.0, 2.0);
tween(view.fov, 150.0, 2.0);
stoptween操作停止當(dāng)前正在運(yùn)行的tween操作。
ondown="tween(layer[text].y, 10, distance(400,0.7), linear);"
onup="stoptween(layer[text].y);"
(40)tweentypes;https://krpano.com/docu/actions/#setinterval
(41)loadpano(xmlpath, vars*, flags*, blend*)
loadscene(scenename, vars*, flags*, blend*)
loadpanoscene(xmlpath, scenename, vars*, flags*, blend*)
loadxml(xmlstring, vars*, flags*, blend*)
loadpano(pano2.xml);
loadpano(pano2.xml, null, MERGE, BLEND(1));
loadscene(scene1);
loadscene(scene1, null, MERGE, BLEND(1));
loadxml('<krpano><image><sphere url="pano.jpg"/></image></krpano>');
loadxml(get(data[xml].content), null, KEEPALL);
loadpano('%VIEWER%/pano.xml', null, MERGE, BLEND(2));
loadpano(sphere.xml, image.hfov=1.0&view.limitview=fullrange);
openurl('https://krpano.com',_self);
openurl('help.html');
(43)lookat(h, v, fov*, distortion*, architectural*, pannini*)
看這個(gè)全景位置。
Parameters:{h,v,fov,distortion,architectural,pannini?}
lookat(0,0);
lookat(0,0,90);
loadpano(pano.xml);
lookat(45.1, -20.2, 110.0);
(44)lookto(toH,toV,fov*,motiontype*,shortestway*,nonblocking*,donecall*)
looktohotspot(hotspotname*, fov*, motiontype*, shortestway*)
將視圖從當(dāng)前查看位置移動(dòng)到給定位置。
注意-在移動(dòng)過(guò)程中,用戶(hù)界面和所有其他操作都被阻止。這意味著下一個(gè)操作將在當(dāng)前操作完成時(shí)執(zhí)行。oninterrupt操作可用于使用戶(hù)能夠中斷這些操作。
Parameters:{toH,toV,hotspotname?,fov?,motiontype?、shortestway,nonblocking?,donecall}
moveto(100.0,5,linear(10));
zoomto(130,smooth());
lookto(33,-22,30,smooth(100,50,20));
looktohotspot(hotspot1);
looktohotspot(hotspot2, 40);
looktohotspot(hotspot3, 25, smooth(100,50,20));
looktohotspot(get(name));
(45)adjusthlookat(desthlookat);
調(diào)整手動(dòng)粗花呢的view.hlookat值。
它修復(fù)了360度環(huán)繞,以最短的方式到達(dá)desthlookat。
參數(shù):
當(dāng)desthlookat是變量名時(shí),將自動(dòng)使用該變量的值。
current view.hlookat變量將調(diào)整(不更改當(dāng)前視圖)為該值旁邊的變量。
adjusthlookat(140);
tween(view.hlookat, 140);
(46)adjust360(source_ath, target_ath);
將源路徑變量調(diào)整為最短的水平360度(相對(duì)于目標(biāo)路徑變量)。
源/開(kāi)始路徑值。
source路徑必須是變量的名稱(chēng)。
目標(biāo)路徑
目標(biāo)/目標(biāo)ath值。
當(dāng)desthlookat是變量名時(shí),將自動(dòng)使用該變量的值。
將熱點(diǎn)移動(dòng)到當(dāng)前水平查看位置:
adjust360(hotspot[test].ath, view.hlookat);
tween(hotspot[test].ath, get(view.hlookat), 1.0);
(47)getlooktodistance(result, toH, toV, fromH*, fromV*)
獲取fromH/fromV和toH/toV觀察點(diǎn)之間的球面距離(以度為單位)。結(jié)果將始終介于0.0和180.0之間(在球體上不可能超過(guò)180度的距離)。
Parameters:{result,toH,toV,fromH?,fromV?}
(48)stoplookto();
停止非阻塞的lookto/looktohotspot/moveto/zoomto操作。
(49)stopmovements();
立即停止所有用戶(hù)驅(qū)動(dòng)(通過(guò)鼠標(biāo)、鍵盤(pán)或觸摸)的平移和縮放運(yùn)動(dòng)。
(50)wait(parameter);
等待幾秒鐘或等待事件。
注意-用戶(hù)界面和以下所有操作將在等待期間被阻止。這意味著當(dāng)當(dāng)前等待操作完成時(shí),將執(zhí)行當(dāng)前調(diào)用中的下一個(gè)操作。oninterrupt操作可用于使此操作可被用戶(hù)中斷。
oninterrupt(break);
lookto(150,30,70);
wait(3);
lookto(242,0,150);
lookto(280,-10,50);
wait(3);
loadpano(pano2.xml,null,MERGE,BLEND(2));
lookat(100,50,5);
wait(BLEND);
lookto(100,50,150);
(51)oninterrupt(actions);
此操作可在啟動(dòng)一組阻止用戶(hù)界面的操作(如lookto、looktohotspot、moveto、zoomto、wait和tween with wait as donecall)之前使用。當(dāng)這些操作中的任何一個(gè)被用戶(hù)中斷時(shí)(例如,通過(guò)單擊),這些操作將停止,并執(zhí)行在oninterrupt操作中定義的操作。
oninterrupt(break);
lookto(150,30,70);
wait(3);
lookto(242,0,150);
lookto(280,-10,50);
wait(3);
oninterrupt( trace(user interrupt); );
lookto(0,0,90);
lookto(90,0,90);
lookto(180,0,90);
lookto(270,0,90);
lookto(0,0,90);
(52)screentosphere(x,y, h,v);spheretoscreen(h,v, x,y, stereoside*)
屏幕坐標(biāo)和球面坐標(biāo)之間的轉(zhuǎn)換操作。
screentosphere操作將x/y變量轉(zhuǎn)換為h/v變量,spheretoscreen操作將h/v變量轉(zhuǎn)換為x/y變量。
參數(shù):
x/y軸
以左上邊緣像素為單位顯示屏幕坐標(biāo)的變量。
高壓
以度(360x180)為單位的球坐標(biāo)變量。
立體(可選)
對(duì)于立體渲染-定義坐標(biāo)應(yīng)映射到哪個(gè)屏幕邊。可能的設(shè)置:l表示左側(cè),r表示右側(cè),或未設(shè)置/未定義正常的非立體屏幕坐標(biāo)。
筆記:
x,y,h,v參數(shù)必須是變量名,不能使用值!
當(dāng)變量不存在時(shí),將創(chuàng)建它。
screentosphere(mouse.x, mouse.y, toh, tov);
(53)screentolayer(layer, screenx,screeny, layerx,layery);layertoscreen(layer, layerx,layery, screenx,screeny)
用于在屏幕/階段和相對(duì)<layer>坐標(biāo)之間轉(zhuǎn)換的操作。
screentolayer(bar, mouse.stagex,mouse.stagey, lx,ly);
div(fill, lx, layer[bar].pixelwidth);
mul(fill, 100);
clamp(fill, 0, 100);
txtadd(layer[barfill].width, get(fill), '%');
(54)spheretospace(h,v,depth, x,y,z);spacetosphere(x,y,z, h,v,depth)
用于在球面坐標(biāo)和XYZ三維空間坐標(biāo)之間轉(zhuǎn)換的操作。將熱點(diǎn)位置從球面坐標(biāo)轉(zhuǎn)換為空間坐標(biāo):
spheretospace(ath,atv,depth, tx,ty,tz);
set(ath,0);
set(atv,0);
set(depth,0);
and back:
spacetosphere(tx,ty,tz, ath,atv,depth);
set(tx,0);
set(ty,0);
(55)remapfovtype(fov, srcfovtype, dstfovtype);remapfovtype(fov, srcfovtype, dstfovtype, width, height)
將一個(gè)fov值從一個(gè)fov類(lèi)型重新映射到另一個(gè)fov類(lèi)型。
當(dāng)改變視場(chǎng)類(lèi)型,同時(shí),重新映射視場(chǎng)時(shí),結(jié)果的全景縮放將保持不變。
Parameters:{fov,srcfovtype,dstfovtype,width?,height}
set(view.fovtype, HFOV);
set(view.fov, 90);
set(view.fovtype, VFOV);
remapfovtype(view.fov, HFOV, VFOV);
(56)