krpano Javascript接口说明文档(1.22-1.21)

krpano Javascript接口Version 1.22

程序入口点 – 获取krpano接口对象

获取krpano接口对象的最佳推荐方法是使用 embedpano() 函数的 onready 回调:

另一种方法是使用 document.getElementById(id)和在 embedpano() 调用中设置的 id

不过,不建议使用这种方法–根据代码/应用程序结构的不同,当第一次使用 getElementById() 时,可能还没有调用 embedpano()。

此外,krpano 接口对象还可以在以下文件中使用:

 

krpano接口对象

krpano 接口对象是 krpano 的直接接口。它可以直接访问整个 krpano 结构以及其中的所有变量/设置和函数。所有 xml 节点和属性也可映射到这里。

基础/核心接口函数:传统接口

高级函数:

  • krpano.trace(code, message)
  • krpano.resolveExpression(expression, caller*)
  • krpano.toBoolean(var)或者 krpano.BOOLEAN(var)
  • krpano.roundNumber(var, dp=0)
  • krpano.clampNumber(value, min, max)
  • krpano.unload()

扩展函数:

  • krpano.registerType(type, callback)

实用函数:

  • krpano.utils.wildcmp(template, text)
  • krpano.utils.spliturl(url)
  • krpano.utils.buildurl(urlinfo, urlmods)

事件函数:

  • krpano.events.addListener(eventname, callback, once*)
  • krpano.events.removeListener(eventname, callback)
  • krpano.events.dispatch(eventname, instantly*)

直接使用 Javascript API 进行操作的krpano动作:

  • krpano.tween(object, object, …)
  • krpano.stoptween(object, …)
  • id = krpano.delayedcall(time, callback)
  • krpano.stopdelayedcall(id)
  • krpano.asyncloop(callback)
  • krpano.copyattributes(object, object)
  • krpano.callwith(object, actioncode)

加载:

  • krpano.parsePath(url)
  • krpano.loadFile(url, donecallback, errorcallback*)
  • krpano.sendRequest(request, callback)
  • krpano.mergeCallbacks(tasks, done)

特殊路径解析/加载拦截:

  • krpano.customParsePath
  • krpano.customParseTilePath

坐标转换函数:

  • krpano.screentosphere(x,y)
  • krpano.spheretoscreen(h,v)
  • krpano.spheretospace(h,v,depth)
  • krpano.spacetosphere(x,y,z)
  • krpano.actions.screentolayer(layer,x,y)
  • krpano.actions.layertoscreen(layer,x,y)
  • krpano.view.syncto(otherview)
  • krpano.view.unproject(x,y,d,rotated)
  • krpano.view.remapfovtype(fov,srcfovtype,destfovtype,w,h)
  • krpano.view.fovtoscale(fov,fovtype,w,h)
  • krpano.view.resetlimits()

交互式编程:

  • krpano.addChangeListener(object, key, callback)
  • krpano.removeChangeListener(object, key, callback)
  • krpano.actions.link(object, varname, …)
  • krpano.actions.unlink(object, varname)
  • krpano.actions.linkstyle(object, styles)
  • krpano.actions.onchange(object, var, callback)
  • krpano.actions.removeonchange(object, var)

表达式函数:

  • krpano.functions.*

直接访问数据结构:

  • krpano.*– all static and dynamic global variables.
  • krpano.actions.*– all krpano Actions as Functions.
  • krpano.actions.actioncaller– the caller of the current action.
  • krpano.mouse.*– mouse/touch information
  • krpano.gesture.*– multi-touch gestures
  • krpano.device.*– device/system information
  • krpano.browser.*– browser information
  • krpano.xml.*– information about the current xml file
  • krpano.image.* – the current pano image
  • krpano.image.reset()– reset the viewing-range limits
  • krpano.view.*– the current view settings
  • krpano.view.resetlimits()– multi-touch gestures
  • krpano.view.update()– instantly update the viewing-range limits
  • krpano.area.*– the screen area/window for the pano-view
  • krpano.display.*– display / rendering settings
  • krpano.display.requestresize()  – request a resize event
  • krpano.display.layout.update()– – instantly update all layers and hotspots
  • krpano.control.*– mouse/touch and keyboard control settings
  • krpano.cursors.*– – customize the mouse cursor.
  • krpano.autorotate.*–  automatic rotation / moving / zooming
  • krpano.contextmenu.*  – – the contextmenu settings
  • krpano.contextmenu.items–   Array of the contextmenu items
  • krpano.network.* – network settings and paths
  • krpano.memory.*  – – the contextmenu settings
  • krpano.contextmenu.*  – – the contextmenu settingsk

– memory usage settings
krpano.security.* – security settings

 

Predefined krpano Arrays:
krpano.layer.* – all <layer> elements
krpano.hotspot.* – all <hotspot> elements
krpano.scene.* – all <scene> elements
krpano.action.* – all <action> elements
krpano.events.* – all <events> elements
krpano.data.* – all <data> elements
krpano.style.* – all <style> elements
krpano.cssstyles.* – all <cssstyles> elements

Base Object API:
object.registerattribute(attributename, default, setter, getter)
object.registerattribute(attributename, default, setter)
object.registerattribute(attributename, default)
object.removeattribute(attributename)
object.getattributes()
object.setattributes(object,object2*,object3*,…)
object.setvars(object,object2*,object3*,…)
object.createobject(objectname)
object.removeobject(objectname)
object.createarray(arrayname)
object.removearray(arrayname)
Array Object API:
array.createItem(name or index)
array.createarrayitem(name or index)
array.insertItem(name, index)
array.createarrayitem(name, index)
array.getItem(name or index)
array.renameItem(oldname, newname)
array.renamearrayitem(oldname, newname)
array.removeItem(name or index)
array.removearrayitem(name or index)
array.addChangeListener(callback)
array.removeChangeListener(callback)
array.getArray()
array.forEach(callback)
WebGL API:
krpano.webGL.canvas
krpano.webGL.context
krpano.webGL.projectionMatrix
krpano.webGL.depthbufferbits
krpano.webGL.addListener(eventname, callback)
krpano.webGL.removeListener(eventname, callback)
krpano.webGL.createPostProcessingShader(source, uniforms, name, callback
krpano.webGL.ppShaderArray
krpano.webGL.ppShaderArray2
krpano.webGL.useShader(shader)
krpano.webGL.deleteShader(shader)
krpano.webGL.restoreProgram()
krpano.webGL.resetState()
krpano.webGL.redirectBackbuffer(…)
krpano.webGL.makeScreenshot(…)

krpano.spheretospace()

  • krpano.spacetosphere()

Javascript Polyfills

注意 – 当下面的函数在浏览器中不可用时,krpano viewer会自动为这些 Javascript 函数安装 Polyfills

  • Object.prototype.__defineGetter__()
  • Object.prototype.__defineSetter__()
  • Object.assign()
  • String.prototype.trim()
  • Array.prototype.forEach()

 

krpano插件接口


var krpano = document.getElementById(“mypano”);
console.log( krpano.version );
However, this way would not be recommended – depending on your code/application structure, the embedpano() may not have been called yet when getElementById() is used for the first time.

Additionally the krpano Interface Object is also available in:
krpano Javascript Plugins,
Javascript <action> Elements,
in the js(), jscall() or jsget() actions,
in Actioncode that starts with js:
and inside Javascript files loaded with the loadjs() action.

  • 使用 embedding script 的 onready 回调函数(推荐方法)
  • 或通过Javascript 调用: document.getElementById(id)
    id参数是viewer的唯一性id(默认为”krpanoSWFObject“)可在embedding script中进行设置。

微信全景结合二维码识别

krpano制作的全景在国内应用最多的场景就是在微信上展示。因为微信与微信公众号有着密不可分的关系,客户希望在展示全景的同时也希望用户能够关注其公众号。关注公众号的办法很多,其中一种就是在微信中长按二维码进行识别,然后跳转到其公众号页面中。

因此以下都是按照HTML5的情况进行讲解:

以下隐藏内容只提供VIP赞助会员,VIP会员说明请查看置顶文章

(更多…)

krpano中获取用户输入文本的方法(支持全屏)

说明

此处的用法是运用js接口制作的一个小小插件,可以在xml文件调用js插件,然后在全景中获取用户所输入的文本。因为该插件是在xml内调用,属于krpano的元素,因此在krpano全屏时不会被放在后面,因此不会消失。

以下隐藏内容只提供VIP赞助会员,VIP会员说明请查看置顶文章

(更多…)