參考:krpano官網krpanowebglapi篇
有兩種類型plugins:
- 用于krpano html5 viewer 的 HTML5 Javascript plugins (.js)
- 用于krpano flashviewer 的Flash Actionscript3 plugins (.swf)
HTML5和Flash的基礎 plugin-to-krpano和 krpano-to-plugin接口幾乎是一樣的,隻有系統和語言特定的代碼不同。
插件的基礎結構含有以下的公共函數:
- registerplugin函數 - 插件被加載的時候,該插件從krpano中被調用,該函數提供了 krpano Interface Object 和 krpano Plugin Object.
- unloadplugin 函數- 插件解除安裝的時候,方法将會運作. 插件添加的所有元素和事件都會被移除
- onresize - 根據螢幕大小改變插件尺寸
插件本身将自定義的屬性和或函數直接添加/設定到krpano對象或者插件對象中
對于設定從xml中傳遞過來的屬性,提供了registeratribute函數,他可以使屬性既有預設值又可接收從xml傳遞來的數值。自動調用get和set方法
The krpano Plugin Interface
krpanoplugin.registerplugin(krpanointerface, pluginpath, pluginobject)
krpanoplugin.unloadplugin()
krpanoplugin.onresize(width, height)
krpano Interface Object
krpano對象(是在registerplugin(krpanointerface, pluginpath, pluginobject)方法中krpanointerface擷取的),提供整個結構和所有方法。所有映射的xml節點、數組、對象和屬性都可以直接使用它通路。此外,它還提供了一些資料通路、操作代碼調用/執行等功能:
set
當變量或者路徑不存在,将會建立變量或者路徑,功能類似于xml的set()action
krpano.set(variable, value)
//點選隐藏自身元素
set(visible,false)
//點選隐藏****元素
set(plugin[****].visible,false)
set(layer[fengxiang].visible,false);
//擷取元素透明度0.3
set(layer[skin_btn_next].alpha, 0.3);
set(layer[get(thumbtext)].keep, true);
get
當變量不存在,傳回null
krpano.get(variable)
call
當作業系統目前未被阻止時,将直接執行給定的操作。
krpano.call(actionscode, callerobject*)
set(x,1)替換set(plugin[name].x,1).
trace
當變量不存在,傳回null
krpano.trace(code, message)
code = numeric code of the message-type:
- 0 = DEBUG message - will be only shown with enabled debugmode
- 1 = INFO message
- 2 = WARNING message
- 3 = ERROR message - will also open the log automatically.
- 4 = FATAL ERROR - this message will be shown in the middle of the viewer.
parsepath
krpano.parsepath(path)
loadFile
krpano.loadFile(file, donecallback, errorcallback*)
screentosphere\spheretoscreen
krpano.screentosphere(x,y)
krpano.spheretoscreen(h,v)
spheretospace\spacetosphere
krpano.spheretospace(h,v,depth)
krpano.spacetosphere(x,y,z)
customParsePath
krpano.customParsePath = function(url)
customParseTilePath
krpano.customParseTilePath = function(url,cube,level,h,v,stereo,image)
krpano Plugin Object
plugin對象(是在registerplugin(krpanointerface, pluginpath, pluginobject)方法中pluginobject擷取的),<plugin >
plugin.sprite
plugin.videoDOM
plugin.registercontentsize(width, height)
plugin.updatepos()
plugin.getfullpath()
plugin._assignEvents(htmlelement, mode)
krpano 'Base' Object (the 'base-class' or 'super-class' in programming language)
object.registerattribute(attributename, default, setter*, getter*)
object.removeattribute(attributename)
object.getattributes()
object.createobject(objectname)
object.removeobject(objectname)
object.createarray(arrayname)
object.removearray(arrayname)
krpano 'Array' and 'Array-Item' Objects
array.count
array.createItem(name or index) or
array.createarrayitem(name or index) (callable from xml)
array.insertItem(name, index) or
array.insertarrayitem(name, index) (callable from xml)
array.getItem(name or index)
array.renameItem(oldname, newname)
array.removeItem(name or index) or
array.removearrayitem(name or index) (callable from xml)
array.getArray()
arrayitem.name
arrayitem.index
krpano WebGL API
krpano.webGL
krpano.webGL.canvas
krpano.webGL.context
krpano.webGL.createPostProcessingShader(source, uniforms, name, onrendercallback)
krpano.webGL.ppShaderArray
krpano.webGL.ppShaderArray2
krpano.webGL.useShader(shader)
krpano.webGL.deleteShader(shader)
krpano.webGL.restoreProgram()
krpano.webGL.makeScreenshot(width, height, hotspots, type, jpegquality, crop, sizeinfo, cache)