[11天] Krpano 1.19 pr13 xml文件了解
一、 概览
xml文件的根元素需要是<krpano>元素。所有其他元素都必须放置在此元素内。
krpano-xml中的所有xml元素和属性都是可选的,可以多次以任意顺序定义。当同一个元素将被再次定义两次或更多次时,则后面/后面的声明将覆盖以前的。
也可以定义额外的<krpano>内部元素根<krpano>元素本身,用于在krpano作用域声明其他设置。
xml本身只是一个传输格式-这意味着它将只用于传输krpano查看器的数据。解析
xml
时,xml
元素将被转换/映射到krpano内部数据结构中。这意味着在解析之后,内部就不再有xml
了。
<krpano> <include> <preview> <image> <cube> <cubestrip> <sphere> <cylinder> <flat> <fisheye> <depthmap> </image> <view> <area> <display> <control> <cursors> <autorotate> <plugin> <layer> <layer> ... </layer> <hotspot> <style> <events> <action> <contextmenu> <network> <memory> <security> <textstyle> <data> <scene> <set> <debug> </krpano>
<krpano>
这是krpano xml文件的main/root元素。 所有进一步的xml元素都需要在这个元素中定义。
<krpano version="1.20.11" onstart=""> ... </krpano>
onstart
事件将在xml加载和解析之后在开始时直接调用。
<include url="..." />
xml加载过程中的第一步是解析<include>元素。将加载请求的include url文件,加载的xml的内容将替换当前xml中的<include>元素。 加载并解析所有<include>元素后,查看器将开始解析加载的xml数据,并将信息从xml映射到动态运行时数据结构和对象。
<include url="path/name.xml" />
<preview>
定义加载完整全景图像时将显示的小“预览”全景图像的url/文件名。此预览图像应较小(文件大小和图像尺寸),以允许快速加载!
<preview url="previewpano.jpg" />
<image>
使用<image>元素,将定义全景图像。
<preview url="previewpano.jpg" />
查看器支持的图像类型/全景格式:
- Cube
- Cubestrip
- Sphere
- Cylinder
- Flat
- Fisheye
<view>
view元素包含有关当前视图的信息。它可以用来设置启动视图设置。
<view hlookat="0.0" vlookat="0.0" fov="90.0" fovmin="1.0" fovmax="179.0" maxpixelzoom="" />
<area>
注意-所有<layer>或<plugin>元素将放置在此区域内。要将<layer>或<plugin>元素放置在该区域之外,请将该层/插件元素的父属性设置为“STAGE”
<area mode="align" align="lefttop" x="0" y="0" width="100%" height="100%" cliplayers="true" />
<display>
用于调整显示模式和渲染质量/性能的显示设置。
<display autofullscreen="true" stereo="false" stereooverlap="0.0" stereoscale="1.0" monoside="1" anaglyph="false" safearea="auto" mipmapping="auto" loadwhilemoving="auto" framebufferscale="1.0" hotspotvrrendering="natural" hotspotworldscale="2.0" depthmaprendermode="depthmap" depthbuffer="false" depthrange="0.1,100000" surfacesubdiv="100" />
<control>
鼠标和键盘控制设置。
<control mode="drag" dragrelative="true" draginertia="0.1" dragfriction="0.9" movetorelative="true" movetoaccelerate="1.0" movetospeed="10.0" movetofriction="0.8" invert="false" keybaccelerate="0.5" keybspeed="10.0" keybfriction="0.9" keybfovchange="0.75" mousefovchange="1.0" fovspeed="3.0" fovfriction="0.9" zoomtocursor="false" zoomoutcursor="true" disablewheel="false" touchzoom="true" bouncinglimits="false" />
<cursors>
自定义鼠标光标
<cursors standard="default" dragging="move" moving="move" url="" type="8way" move="" drag="" arrow_l="" arrow_r="" arrow_u="" arrow_d="" arrow_lu="" arrow_ru="" arrow_ld="" arrow_rd="" />
<autorotate>
无用户交互时自动旋转/移动/缩放
<autorotate enabled="false" waittime="1.5" speed="10.0" />
<layer>
<plugin>
注意,<layer>或<plugin>元素在内部是完全相同的元素,只是名称不同!建议使用“layer”而不是“plugin”,因为它可以更好地描述元素。“plugin”这个名字来自旧的krpano版本,只是为了向后兼容。
<plugin name="..." type="image" url="..." keep="false" parent="" visible="true" enabled="true" handcursor="true" cursor="pointer" maskchildren="false" scalechildren="false" zorder="" style="" align="" edge="" x="" y="" rotate="0.0" width="" height="" scale="1.0" alpha="1.0" crop="" onovercrop="" ondowncrop="" bgcolor="0x000000" bgalpha="0.0" bgborder="0" bgroundedge="0" bgshadow="" bgcapture="false" onover.addevent="" onhover.addevent="" onout.addevent="" onclick.addevent="" ondown.addevent="" onup.addevent="" onloaded.addevent="" />
<hotspot>
热点是全景中的区域,在鼠标悬停或单击时会做出反应。它们可以用来加载其他全景,链接到其他URL,更改查看...
<hotspot name="..." type="image" url="..." keep="false" renderer="webgl" visible="true" enabled="true" handcursor="true" cursor="pointer" maskchildren="false" zorder="" style="" ath="0.0" atv="0.0" edge="center" zoom="false" distorted="false" rx="0.0" ry="0.0" rz="0.0" width="" height="" scale="1.0" rotate="0.0" alpha="1.0" onover.addevent="" onhover.addevent="" onout.addevent="" ondown.addevent="" onup.addevent="" onclick.addevent="" onloaded.addevent="" />
<style>
元素和样式属性:<style>元素是任何类型属性的集合/存储元素。其他每个具有name属性的xml元素也可以具有style属性。
首次创建xml元素时,在元素中定义的所有属性都将复制到元素本身。这将在应用xml元素本身定义的属性之前完成。
这意味着可以在<style>元素中预定义一些设置,然后用直接在元素中定义的属性覆盖它们
<style name="spotstyle" url="spotimage.png" />
<hotspot name="spot1" style="spotstyle" ... /> <hotspot name="spot2" style="spotstyle" ... />
<events>
krpano事件-它们可用于在特定事件发生时调用操作或函数。有两种类型
global events
local events
<events onenterfullscreen="" onexitfullscreen="" onxmlcomplete="" onpreviewcomplete="" onloadcomplete="" onblendcomplete="" onnewpano="" onremovepano="" onnewscene="" onxmlerror="" onloaderror="" onkeydown="" onkeyup="" onclick="" onsingleclick="" ondoubleclick="" onmousedown="" onmouseup="" onmousewheel="" oncontextmenu="" onidle="" onviewchange="" onviewchanged="" onresize="" onframebufferresize="" onautorotatestart="" onautorotatestop="" onautorotateoneround="" onautorotatechange="" oniphonefullscreen="" gyro_onavailable="" gyro_onunavailable="" gyro_onenable="" gyro_ondisable="" webvr_onavailable="" webvr_onunavailable="" webvr_onunknowndevice="" webvr_onentervr="" webvr_onexitvr="" />
<action>
定义krpano动作。这些操作类似于其他脚本或编程语言中的函数或过程。
可以从任何地方调用这些操作—从事件、其他操作或通过调用接口从外部源(Javascript、Plugins)调用
<action name="..." scope="" args=""> action1(); action2(); ... </action>
<contextmenu>
自定义右键单击上下文菜单:
添加用户定义的项目
将其分配给krpano操作代码
Re-order the 'krpano' item
<contextmenu fullscreen="false"> <item caption="..." onclick="..." /> <item caption="..." onclick="..." /> ... </contextmenu>
<network>
网络设置
<network retrycount="2" />
<memory>
内存使用设置
<memory maxmem="..." devices="..." />
<security>
安全/跨域相关Flashplayer和HTML5设置
<security cors=""> <crossdomainxml url="http://.../crossdomain.xml" /> <crossdomainxml url="..." /> ... <allowdomain domain="www.other-domain.com" /> <allowdomain domain="..." /> ... </security>
<textstyle>
已弃用
<data>
“原始”数据部分。它可以用来存储任何类型的信息或数据。
krpano不会解析其内容。元素的全部内容将存储在结果数据[名称]对象的内容属性中。
krpano不会解析内容本身,但xml语法规则和几个自动xml实体解析过程仍将应用于它!为了避免任何类型的xml语法分析和xml实体解析,请将整个数据内容放在<![CDATA[和]]>标签。这样,就可以使用所有字符和xml标记,而无需解析。
注意-加载其他xml文件时,所有数据标记保持不变,除非在其他xml中再次定义,否则它们将被新标记覆盖。
<data name="..."><![CDATA[ ... ]]></data>
<scene>
场景元素在技术上类似于“内联xml”文件。
<scene name="..." onstart="" autoload="false" ...> ... </scene>
<set>
在xml解析期间设置/定义变量,这可以用来设置或覆盖特殊变量
<set var="..." val="..." />
<debug>
在xml解析期间跟踪/记录某些内容。
注意-只有在启用debugmode设置enabled时,才会显示调试消息!
<debug trace="..." />
参与讨论