Scripting / Programming krpano from XML
- there is no need for external progamming tools
- everything is controlled from xml files
- programming experiences are not needed but would be helpfull
Topics:
- XML Interface / Access
- get / set / call Interface
- Events / Actions
- Special Interfaces
XML Interface / Access
example - this xml code:
<krpano>
<view hlookat="0"
vlookat="0"
fov="90"
/>
</krpano>
is mapped to:
view.hlookat = 0
view.vlookat = 0
view.fov = 90
example - this xml code with more plugin subnodes:
<krpano>
<plugin name="plugin1" url="url1.jpg" />
<plugin name="plugin2" url="url2.jpg" />
</krpano>
is mapped to:
plugin[plugin1].url = url1.jpg
plugin[plugin2].url = url2.jpg
get / set / call Interface
these are the basic interfaces to the krpano structure,
it can be used from XML, from Actionscript Plugins and also from Javascript
- set(variable, value)
changes the value of a variable
- get(variable)
reads the value of the variable and returns it
NOTES for Plugin / Javascript developers: the return is type correct: Number, Boolean, String and Object.
So sometimes casting would be necessary when checking a value, e.g. when creating a new variable with the value "true",
it doesn't know the type of the variable and generates a String object instead of a Boolean, only if the variable
already exists the type can be checked and automatically converted.
- call(actions)
calls and executes a set of actions / commands
Events / Actions
it interacts with user, the viewer sends events, these events can be
assigned with action calls, there are currently following events:
these events can be assigned with a set of
actions / commands or direct linked to AS3 function (from plugins)
Special Interfaces
some special variables which can be accessed with the
get /set Interface:
-
fullscreen
set or get the state of the fullscreen mode
when set to "true" - the viewer switches to fullscreen
and when set to "false" - it switches back to normal mode
-
hlookat_moveforce (old name: movevectorx)
vlookat_moveforce (old name: movevectory)
fov_moveforce (old name: movevectorz)
a move / motion force vector to change the direction / zoom of the view
constantly, as long a value is set the view keeps moving, the amount
of the value controls the moving speed, but the moving speed depends also on the
"control.keybaccelerate", "control.keybspeed" and "control.keybfriction"
parameters.
-
userinterface
enables or disables the user inteface (mouse and keyboard controls)
possible values: true or false
-
lockmultireslevel
- lock a specific multiresolution level (0-n)
- disables automatic level selection
- set to "current" to lock current level
- set to "-1" to restore automatic level selection
more special functions:
(they can be only read via the get()-interface)
-
screentosphere(screenx,screeny)
- converts screen coordinates (x/y) to spherical coordinates (h/v)
- screen coordinates are pixel distances from left/top edge
- spherical coordinates are in range -180 to +180 (horizontal) and -90 to +90 (vertical)
- the return value is a String with the spherical coordinates separated by a comma ','
Example - usage from Actionscript:
var sx:Number = event.stageX;
var sy:Number = event.stageY;
var hvs:String = krpano.get("screentosphere("+sx+","+sy+")");
var hva:Array = hvs.split(",");
var ath:Number = Number( hva[0] );
var atv:Number = Number( hva[1] );
-
has_mousewheel_event()
- special function for the Javascript Mousewheel fixes
- it returns "true" when a mouse wheel event has happend on the viewer