天天看点

krpano plugin interfacekrpano Interface Objectkrpano Plugin Objectkrpano 'Base' Object (the 'base-class' or 'super-class' in programming language)krpano 'Array' and 'Array-Item' Objectskrpano WebGL API

参考: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)