krpano has a small and simple dynamic scripting language.
With it krpano can be customized in many ways.
A command or function is called 'action' in krpano.
It's possible to use existing actions and also to define new ones.
The scripting language is dynamic and untyped by default, only
some predefined variables are typed, but that is normally not relevant because inside the
scripts all type conversions will be done automatically.
This documentation is about global krpano variables and objects, about the actions calling syntax and about all pre-defined krpano actions / functions.
action(parameters);
action(parameters); // this is a single-line comment
action(parameters); /* a multi-line comment
action(parameters); */
action(parameters); <!-- a xml comment
action(parameters); -->
action(parameters);
There a single-line comments, starting from // to the next line-break.
Multi-line comments from /* to */.
And xml-comments from <!-- to -->.
These comments work only when the related code was defined in a xml file,
there they will get stripped away already during the xml-parsing.
Note - inside CDATA tags these comments will not work!
The expression syntax will be used in variable assignments, in if() checks,
for the callwhen() action,
in conditional loops (for, loop, asyncloop)
and in the calc() action.
It can be used to evaluate logical conditions, calculate mathematical expressions or to concatenate strings.
The basic syntax is:
a OPERATOR b
Where the a or b terms can be either:
variables,
values,
strings (inside single-quotes ' or double-quotes "),
* Note - due of xml syntax limitations, the usage of the characters <, >, &
might be not possible (e.g. inside xml attributes or inside xml elements without CDATA tag).
Therefore it's recommended to use the alternative syntax.
Returns a String with a hexadecimal Color value, that means with a 0x prefix (*or a custom one) and padded zeros when necessary (e.g. "0x00FF00" for a Green color value).
Returns a String of a number rounded to given decimal places (dp).
When using -1 for dp, an automatic number of decimal places will be used, from 1 to 6, no trailing zeros.
Get the value of a Javascript variable or the result of a Javascript expression or the return value from a Javascript function call.
When there is a code error, undefined will be returned.
Look up the given word in the <languages> translation tables
with the current language or the
defaultlanguage when not available in the current language.
When using non-strict comparisons (by using == or
!= when the strict mode setting is false)
then it will be assumed that the given values are either variables or strings.
That means when a variable with the given name exists, then the value of that variable will be used in the comparison.
But when the variable doesn't exists, then the given name will be used as string.
In strict comparisons the strings must be explicitly marked by quotes.
Variables will resolve either to their value or to null if they don't exists.
Every xml element with a name attribute is an element / item of an Array.
The name of the xml element is the name of the Array and the name attribute defines the name of the Array element / item.
An Array in krpano is always an Array of objects.
Such Array-item object can contain any kind of custom properties / attributes.
Arrays can be predefined or defined dynamically at runtime by setting an Array item value - when setting an item value the first time, then automatically an Array will be created.
Static XML Syntax: (when defining in the xml structure)
The global object allows directly accessing the global variable scope.
The usage of global can be necessary inside local- or layer/hotspot scope
code to be able to access a global variable when a variable with the same name is already defined the current scope.
The local object is only available inside local-scope actions
and allows directly accessing the current local variable scope.
This can be used to ensure defining new variables at the local scope when there might be already global variables with the same names.
The mouse.downx and mouse.downy variables store the position where the mouse button was last pressed down (for left and right buttons).
The coordinates itself are relative to the left top edge of the area.
The mouse.clickx and mouse.clicky variables are special case ones -
they store the position where the click from onsingleclick or ondoubleclick events had happend.
The coordinates itself are relative to the left top edge of the area.
gesture.dt
- the delta time in milliseconds between the events.
Note - if dt is greater than 0 in the start event, then this is the time between the first touch of both fingers
and the first movement.
gesture.touches - a Javascript Array of {id,x,y} Objects that contain the current multi-touch points.
The 'raw' unscaled and non-rounded delta values of the mouse wheel rotation.
The normal wheeldelta values are limited to integer values and
can be too inaccurate for some usages (plugins).
The fullscreen variable can be used to check or to change the current state of the fullscreen mode.
When the variable will be changed, then also the fullscreen mode will be changed.
Before using the fullscreen setting, it should be verified if the current browser / device actually supports
the fullscreen mode. This can be done with the xml fullscreensupport devices setting
and the device.fullscreensupport variable.
Due HTML5 security limitations the switching to the fullscreen mode
will be only possible as reaction to an user input like a mouse click or a keypress!
That means it's only possible switch to fullscreen mode in an onclick or onkeydown event!
When the HTML5 fullscreen mode is not supported by the browser (like on iOS),
then the fullscreen setting will only change the size of the viewer HTML element to match the size of the
full browser window.
Due technical limitations this will not work from inside an <iframe> and can be problematic in nested HTML structures.
When trying to use the HTML5 fullscreen mode from within an <iframe>,
it is necessary to add the allowfullscreen parameter
to the <iframe> declaration. This tells the browser that this iframe is allowed to switch to Fullscreen mode.
A global overall scaling setting.
The stagescale setting will scale all krpano elements and sizes.
By scaling all elements, the krpano stage-size (screen-size / resolution) itself will be scaled inversely by this value -
e.g. a value of 0.5 will scale-down all elements by 50% while increasing the internal stage-sizes by 200% at the same time.
Basic device type detection: device.desktop, device.tablet or device.mobile.
Note - only one of these three can be set to true!
The device.normal device is a combined setting and true for desktop and tablet devices.
This can be used to apply the same to the 'larger' desktop and tablet devices and used as opposite to 'smaller' mobile devices.
For detecting dedicated VR Browsers, that means Browsers that are itself also running in VR,
e.g. the Meta Quest Browser (Oculus Browser) or Firefox Reality for the Meta Quest (Oculus Quest) or
Safari inside an Apple Vision headset.
device.multiressupport - Is using multi-resolution images possible?
device.panovideosupport - Is using videos as panoramic image possible? Depends on WebGL and if using videos as texture is possible.
device.depthmapsupport -
Is using 3D Depthmaps possible. Depends on certain WebGL features.
device.fullscreensupport -
Is the HTML5 fullscreen mode be supported by the Browser and is it available?
The availability inside iframes depends on the allowfullscreen setting!
All settings (except fullscreensupport, which depends on iOS and iframe restrictons) should be available on all modern devices and browsers.
Only very old devices and browsers might fail here.
device.pixelratio - The physical pixels to CSS pixels ratio.
Same as window.devicePixelRatio.
device.fractionalscaling - Is pixelratio a fractional value?
Can be used to workaround layout problems on such devices or when using fractional page-zooms.
Note - mouse and touch can be set at the same time when the device is supporting both (e.g. desktop devices with touch-screens).
Note - in recent browsers, it is no longer possible to detect if a desktop- or laptop-system has a touchscreen and touchsupport.
In such case the device.touch value will be false, but touchsupport could be still available.
An interactive setting to detect if the current user-interaction event (ondown, onup, onclick, mouse-moving, dragging, ...)
was caused by a touch or a mouse input.
These variables can be used to set a force to move the view / the pano.
Their main usage is for keyboard or button movement control.
When they will be set to a value other than 0.0, the view will start slowly accelerating (controlled by
control.keybaccelerate) and then move with a maximum speed
(controlled by control.keybspeed) until they will be set back to 0.0, then
the movement will slow down (controlled by control.keybfriction).
Lock the automatic multi-resolution level selection to a fixed level.
Set lockmultireslevel to "current" to lock the level to the current level.
To release the level locking set lockmultireslevel back to "-1".
The current loading progress as linear value from 0.0 to 1.0.
It could be used to create custom loading animations - e.g.
use the onxmlcomplete event for starting the loading animation,
and the onloadcomplete event for stopping it.
The xml.content variable contains the xml-content of the last loaded pano.
When a <scene> gets loaded or
loadxml() be used, then the variable contains only the scene-xml-code or the given loadxml() xml-code.
The xml.filecontent variable contains the content of the last loaded xml file.
The content will not change when loading a new pano via loadscene() or loadxml().
A backup of the values from the initial <view> element defined in the current xml or scene.
E.g. get the initial view.hlookat value via xml.view.hlookat.
Note - only the values that were defined in the xml are stored here, no default values.
That means before using a value from that object, it would be necessary to check if these variables actually exists
- e.g. via if(xml.view.fov !== null, ...);.
When no value will be given and the variable already exsits,
then the variable with its current value will be converted to the given type.
When no value will be given and the variable doesn't exsits, then
these the default values are used: boolean=false, number=NaN (Not a Number), integer=0, string=null.
When the type is object or array, then either no value must be set (to create an empty Object or Array)
or a String with the Object properties or Array values (in Javascript syntax).
The get(var) action is a special action that can be only used as parameter
when calling other actions or when accessing array elements.
As shorter syntax also just *var can be used.
Parameters:
variable
Any variable.
When the variable doesn't exists, get() will return null.
Note - some actions are automatically trying to resolve their given parameters to their values.
For these actions using get(var) would be not necessary.
Note:
When using a calc(variable, expression) call in a 'callback' parameter (e.g. in an if or delayedcall action),
make sure to terminate its call with a ';' to allow differing that call to 'calc(expression)' that would resolve the expression and pass only the result
to the called action.
The copy() action copies the content from one variable to the other one.
By default this is the same as:
set(destination, get(source)).
Parameters:
destination
The destination variable.
When the variable doesn't exists, it will be created.
source
The source variable.
When the variable doesn't exists, null will be set to the destination variable.
typeconversion(optionally)
When set to true (the default):
When both variables have different types, then the value of the source variable will be converted to the type of the destination variable.
When set to false:
Copy the value and the type of the source variable to the destination variable.
Calls the given actions when the condition is true or when it will become true.
When the condition is currently not true, then the callwhen() action will wait as long until the condition will become true.
Parameters:
id(optionally)
An optional unique id for the callwhen.
This id can be used to stop a waiting callwhen by calling stopcallwhen(id).
First the startactions will be called, then the condition be checked and when it is true -
then the loopactions will be called, then the nextactions and then it starts checking
the condition and the loop again.
Parameters:
startactions
The actions that will be called / executed before the for loop starts.
As long as the condition is true the loopactions will be called repeatedly.
The normal loop() action will continue with the following actions when the loop itself is done.
The asyncloop() will continue intermediately with the following actions and execute the
loopactions once per frame. When the async looping is finally done, then the doneactions will be called.
For Javascript usage there is also a special API where a callback function can be used.
This function will be called as long once per frame until the function returns false.
The renderloop() action will execute the loopactions once every frame.
To stop the loop the stoprenderloop() action need to be called inside the loopactions.
Parameters:
loopactions
The actions that will be repeatedly called / executed every frame.
Can be a krpano action-code string or
a Javascript function that returns true (=keep looping) or false (=stop looping).
Examples
krpano-Action-Code Example:
renderloop(
... do something ...
if(...done with rendering...,
stoprenderloop();
);
);
The switch action switches the value of the given variable between / through several states.
Every time when the switch action will be called the value will be switched / changed.
When only the variable itself without value parameters will be given, then the variable will
be switched between true and false.
When there are two or more values given as parameters, then the variable will switch through all
the values (starting from the current value and then to right and then starting over again at the end).
Break / stop the execution of action calls from the current flow and the also the action calls from one nesting level up
(e.g. when called inside an if() call then also the flow outside that if will be stopped).
When used inside a for() or loop() loop, the break() call will also stop that loop.
Call krpano action code with using a specific plugin / layer or hotspot element as caller.
This can be used for direct property access or to simulate event calls on these elements.
Parameters:
caller
The element that should be used as caller.
Can be either a String with the name/path of the element or directly the element Object itself.
Can be only a <plugin> / <layer> or <hotspot> element - or null.
The value null can be used to remove the current caller and to use the global scope.
actions
Any krpano action code.
The code will be executed in the 'context' of the caller - that means 'direct' access to its properties.
Set a variable to the a value - like a set() call - but in the scope of the parent action.
This could be used to return / pass back a result from an inner local scope action to an outer one.
Parameters:
variable
The variable name.
The variable will be created when it doesn't exists.
value
The new value for this variable.
When the variable already exists, then the value will be converted to the type of that variable.
Link the current local scope to the events of the given element.
When an event of that element (e.g. onclick) will be called, then the same scope will be used
in the event code. By default events are always using the global scope.
Note - when having linked to a scope, it is necessary to use caller to address the element scope itself!
Link a variable to an other variable or let the value
be automatically calculated using an expression when one or more other variables are changing or
when certain events are triggered.
Same as the xml link:... syntax.
See also the notes there!.
Parameters:
variable
The name or path of a krpano variable that should get linked.
object and varname
Any object and the name or the variable/property that should get linked.
sourcevariable
The name or path of a krpano variable that should be the source.
When this variable changes, the current variable will also change.
var1|var2:expression
Link to one or more variables and use an expression to calculate the value.
When linking to multiple variables, they must be separated by
| or , characters.
The expression need to be defined after a : character.
events:expression
Link to one or more events and use an expression to calculate the value.
The synax for the events is event.EVENTNAME, where EVENTNAME can be any of the krpano events.
When linking to multiple events, they must be separated by
| or , characters.
The expression need to be defined after a : character.
Automatically call actions or a JS Function when the content of a variables changes.
Notes:
Could be used multiple times on one variable,
but when calling removeonchange(), then all onchange callbacks will be removed.
When onchange() is getting called from a layer or hotspot event -
or by using callwith(),
then that layer/hotspot object will be the variable scope for direct access.
Otherwise the Object where the variable is defined, will be the variable scope and allow direct access to the variable without using the 'full-path'.
Automatically link to all variables defined in the <style>.
That means when a value inside the <style> changes, then automatically the value at the element will change too.
Parameters:
elementname or object
Either the name/path of a krpano element or directly the element Object itself.
Copy all attributes from one object to another one.
Note - the parameters of the copyattributes() action need to be the objects, not the names/paths of the objects!
That means it might be necessary to use the get() action to resolve the names/paths.
Parameters:
destobject
The destination object - the object where the attributes will be copied to.
Existing attributes will be overwritten.
srcobject
The source object - all attributes from that object will be copied to the destination object.
Dispatches / calls the given event listeners from all <events> elements.
Parameters:
eventname
The name of the event.
Can be also any custom name, when event listeners for that name are used.
instantly(optionally)
A Boolean setting (true or false, false by default).
When set to true, the events will be called and executed instantly,
when not set or set to false, the events will be called after the current actions calls.
Remove the input focus from the current viewer.
That will also stop any movement frictions, release pressed keyboard-keys and close an open contextmenu.
These actions increase or decrease variable (with saturation or limiting).
Parameters:
variable
The variable to increase or decrease.
byvalue(optionally)
Increase or decrease the variable by this value.
When not set, the variable will be increased or decreased by 1.
max / min(optionally)
Defines maximum and minimum values.
When one limit will be reached then the value will be set back to the other limit value.
This can be used to let the varibale either wrap around
a defined range or to clip at at specific limit (with min=max).
Note - The inc() and dec() actions will convert the variable type to 'integer'!
The Math object provides constants and actions for mathematical calculations.
The most Math actions can be called in two ways - either by just passing the name of the variable - then
variable will be used as parameter and the result of the calculation will be stored back to the variable,
or by specifying an additionally parameter where the result should be stored.
The txtadd action can be used to add/connect several texts / values together.
The action can be used with 2 or more parameters. When using only two parameters (destination and a text)
then the text will be added to current value of the destination variable.
Parameters:
destination
The destination variable where the connected text will be stored.
The variable will be created when it doesn't exists.
txt1, txt2, txt3, ... (optionally)
The texts that will be connected together.
When using only one txt parameter then this text will be added to the content of current destination variable.
Note - when the content of a variable should be used - then the get()
action must be used to resolve the variable!
The tween action can be used for a time-controlled animation / change of a variable.
The action will dynamically change the current value of the variable to the given value.
Color support:
When tweening a variable with a name that contains the word 'color', then the values will be automatically
interpreted as 32bit ARGB colors and each color channel will be processed individually.
Relative sizes support (percent-sizes and negative width/height values):
When tweening a 'size-based' variable from a layer or hotspot (e.g. width, height, or x, y, ox, oy),
then automatically convert between the relative and the absolute size depending on the target value.
Multi-value support: Some variables (e.g. like image.prealign or
layer.bgborder) can contain
multiple values separated by a | or a , or a space character.
The detection and format of such variables is based on the target value.
Example values: 1.0|2.0|3.0 or 4,5,6 or 3 0xFF0000 1.0.
Multi-variable support: It is possible to tween several variables together at once.
When all variables are from the same Object, the' Object API' can be used.
Otherwiese the variables, values and tweentypes can separated by | characters.
Javascript API:
With the Javascript API an Object that ones properties should be changed can be selected and
a 'Destination' Object be given with the properties and values that should be changed/tweened to.
Parameters:
variable
The variable that should be changed.
Use the | character to specify several variables.
When the variable name contains the word 'color', then process the variable value as 32bit ARGB color value.
value
The destination value for this variable.
When tweening percent values - add a '%' character to the value.
Use the | character to specify several values for several variables.
Note - to tween to the value of another variable or to the result of an expression,
the get() or or calc() actions can be used.
Note (Object API only) - when using expressions, the special keyword this
is available to access the Object itself.
objectpath(Object API)
The name/path to the Object (e.g. "hotspot[spot1]" or "view").
If getting called from a layer or hotspot event and that layer/hotspot should be changed,
then the objectpath could be skipped or the name caller be used to address it.
object(Javascript API)
The Object whose properties are to be changed/tweened.
destobject(Javascript API)
An Object with properties and their destination values.
This Object should have one or more properties that the original Object also have.
The properties from the original Object will then be tweened to the given values.
The time in seconds for the change from the current value to the destination value
(0.5 seconds by default).
Instead of using a fixed time for the change it is possible to define
the maximum moving distance for the value and a time for that distance (not supported when tweening multiple variables).
This allows to use a short time for a short distance and long time for a long distance.
This can be done by using the distance function (non JS API only):
distance(maxdistance,maxtime)
maxdistance - the maximum distance between the start and the destination value
maxtime - the time in seconds for this maximum distance
tweentype(optionally) / type(Object API)
The tweening / interpolation type (easeOutQuad by default).
See here for all available tween types: tweentypes.
Can also be an Object with individual tweentypes per property (Javascript API).
ondone(optionally)
The action commands that should be executed when the tween is done and the destination value has been reached.
Instead of normal actions, it is also possible to use the special keyword WAIT here.
In this case the user interface and the execution of the following actions will be
blocked until the destination value has been reached.
The oninterrupt action can be used to make this action interruptable by the user.
onupdate(optionally)
These action will be called every time (=every frame!) when the value will be updated / changed!
The 3D transition will start automatically once the new pano is loaded and ready.
When set and during the 3D transition is running, the have3dtransition variable will be true.
Parameters:
ref and dx, dy, dz or h, v, d
The reference for the given 3D coordinates:
ref="image" (default)
For panos without Depthmapping or a 3D-Model the dx, dy, dz values are defining the 3D moving direction.
The length of the 3D direction vector defines the zooming distance and should be typically between 500 and 1000.
For panos with Depthmapping or a 3D-Model the dx, dy, dz values are a relative offset to the image 3D position of the next pano.
ref="world"
The dx, dy, dz values are defining an absolute 3D world position.
Only for Depthmapped / 3D-Model panos.
ref="sphere"
The h, v, d values are defining a spherical position as direction and a distance (1000.0 by default) for zooming.
Only for panos without Depthmapping or a 3D-Model.
mblur(optionally)
Strengh of the motion blur effect: 0.0 to 0.9.
The default is 0.5.
hlookatoffset(optionally)
An optional offset for the horizontal looking direction (view.hlookat).
Can be used when the panos are not aligned together (different Norths).
The default is 0.0.
delay(optionally)
An optional delay in seconds before starting with the 3D-transition.
By default or when set to 0.0, the 3D-transition starts together with the pano-blending.
time(optionally)
An optional duration time in seconds for the 3D-transition.
By default or when set to 0.0, the time will be automatically the same that will be set in the BLEND(blendtime) parameter.
Note - only the layer, plugin, hotspot and event elements with keep="true"
will be kept when loading new panos!
Parameters:
xmlpath(for loadpano)
The path/url of the new pano xml file to be loaded (use null for none).
When a relative path will be used then the file will be loaded from the
basedir folder, which is %FIRSTXML% by default.
That means that the paths in all loadpano calls are relative to the first loaded xml file.
xmlstring(for loadxml)
The content of a xml file as string / text to be loaded (should be escaped).
scenename(for loadscene)
The name of the <scene> element that should to be loaded.
These variables will be set after parsing / resolving the xml but before starting to load the pano images.
This way these variables can be used either to overwrite settings from the xml or to set addtional ones.
Variables can be defined as var1=val1 pairs separated by &.
Note - When the selected blending mode will be not supported, e.g.
when using a transparent background or
when using a 'WebGL only' mode and only CSS3D is available,
then automatically the BLEND() mode will be used instead.
loaddone(optionally)
Actions code or a Javascript function to call when the loading is done.
loaderror(optionally)
Actions code or a Javascript function to call when the loading failed.
When not set or set to null, the error will be either handled by the onxmlerror event
or show a fatal-error message.
Should be used before a loadpanoimage() call to create an new image object.
When the image object is already used for rendering a pano, then calling loadpanoimage() will fail with an error.
Parameters:
options(optionally)
When options is set to copy then all basic settings from
the current <image> element are copied to the new one.
This will not change any current elements or trigger any events.
Only <actions> with autorun="preinit" will get called.
If the xml contains <image> elements, then they will be skipped.
Parameters:
url
The url of the xml file to load and include.
string
The xml code to include as string.
loaddone(optionally)
Actions code or a Javascript function to call when the loading is done.
loaderror(optionally)
Actions code or a Javascript function to call when the loading failed.
When not set or set to null, the error will be either handled by the onxmlerror event
or show a fatal-error message.
The Javascript code will run within the krpano context and have direct access to all krpano objects and variables
(same as in type="Javascript"<actions> elements).
Parameters:
url
The url of the js file to load and execute.
Different to Javascript files loaded directly by the browser (using <script> in the HTML code), these js files can be encrypted using the krpano tools.
Optionally it is also possible to load several js files at once.
For this the urls need to be separated by a pipe | character.
The file loading will be done in parallel but the resulting Javascript code execution will be
done when all files are loaded and in the same order as the files were requested.
Example:
loadjs('file1.js|file2.js|file3.js');
When called directly from Javascript it is also possible to pass the files as Array:
Move the view from current looking position to the given position.
Note - the user-interface and all following actions are blocked during the movement (except the nonblocking parameter of the lookto call is true).
That means the next action will be only executed when the current lookto action has been finished.
To allow the user to interrupt the movement and the blocked user interface and to take control again, the oninterrupt() action can be used.
Parameters:
h / v(lookto, moveto)
The horizontal and vertical looking direction (view.hlookat / view.vlookat)
in spherical coordinates in degrees (-180 to +180, wraparound possible and -90 to +90).
x / y / z(lookto3d)
The 3D-position to look to from the current 3D-position.
hotspotname(for looktohotspot, optionally)
The name of the hotspot.
This will be use the hotspot position (ath/atv) as destination position.
When no name will be defined and looktohotspot() will be called from a hotspot element then
that hotspot itself will be used.
fov(optionally)
The destination fov (0 to 179).
The looktohotspot action will use automatically the size of the hotspot as destination fov
when the fov was not set. The other actions keep the current fov when not set.
motiontype(optionally)
The type of the motion.
Possible settings:
linear(speed) - a linear motion
speed = moving speed in degrees/second
smooth(accel,break,maxspeed) - accelerated smooth movement (=default)
accel = acceleration in degrees/secondĀ² (default=720)
break = negative acceleration in degrees/secondĀ² (default=-720)
maxspeed = maximum moving speed in degrees/second (default=720)
The use the shortest possible way from the current to the destination position.
Possible settings: true or false (default=true).
nonblocking(optionally, lookto only)
When set to true, then the lookto action will not wait for completing the movement
before continue executing the the following actions. The user-interface will also be not blocked.
When the lookto movement is done then the ondone action will be called (when defined).
To stop/interrupt a lookto animation, the stoplookto() action can be anytime called.
ondone(optionally, lookto only, only when nonblocking is true)
This action will be called when the nonblocking lookto movement is done.
Get the spherical distance between the fromH / fromV and toH / toV lookto points (in degrees).
The result will be always between 0.0 and 180.0 (more than 180 degree distance is not possible on a sphere).
Parameters:
result
The name of the variable where the distance value will be stored.
The variable will be created when it doesn't exists.
When calling this function directly by Javascript, the result parameter can be null, the result will be returned as Javascript return value in this case.
toH
Horizontal looking-to position (-180 to +180, wraparound possible).
Can be a variable name or a value.
toV
Vertical looking-to position (-90 to +90).
Can be a variable name or a value.
fromH(optionally)
Horizontal looking-from position (-180 to +180, wraparound possible).
Can be a variable name or a value.
When not defined, the current horizontal looking direction (view.hlookat) will be used by default.
fromV(optionally)
Vertical looking-from position (-90 to +90).
Can be a variable name or a value.
When not defined, the current vertical looking direction (view.vlookat) will be used by default.
Note - The user interface and all following actions will be blocked during the waiting. That means
the next action in the current call will be executed when the current wait action is done. The oninterrupt
action can be used to make this action interruptable by the user.
Parameters:
parameter
any number - this the time the action will wait in seconds
LOAD - wait until loading is finished
BLEND - wait until loading and blending are finished
This action can be used before calling actions that are blocking the user interface (like
wait,
lookto,
looktohotspot,
moveto,
zoomto
or tween with WAIT as ondone).
When any of these actions will get interrupted by the user (e.g. by a click) then the these
actions will be stopped and the given actions be called.
Parameters:
actions
The action commands to call on a user interrupt.
Addtionally there is a special command possible here: break - this will just break the current actions.
Actions for converting between screen and spherical coordinates.
The screentosphere action will convert the x/y variables to the h/v variables and
the spheretoscreen action the h/v variables to the x/y variables.
Parameters:
x / y - Screen coordinates in pixels from the left top edge.
h / v - Spherical coordinates in degrees.
stereoside(optionally)
For stereo rendering - define to which screen side the coordinates should be mapped.
Possible settings: l for the left side or r
for right side or not-set/undefined for normal non-stereo screen coordinates.
Javascript Return:
p - An object with x, y properties.
Spheretoscreen Notes:
When the given spherical coordinates can't be converted to screen coordinates, e.g. when 'behind' the screen,
then the resulting values will be NaN (Not-a-Number). The Javascript call will return null in this case.
By finding the hit/intersection-point between a ray and the depthmap / 3D-model surface or hotspots.
Either from a 2D-point on the screen or from any point in 3D-space.
The parameters will be parsed by krpano before calling the Javascript function. Use get(var) or calc(expression)
in the parameters to access krpano variables.
Directly call any kind of Javascript code from events (or code defined in variables).
When a called action code string starts with js: it will be considered to be Javascript code.
Inside the Javascript code these objects are available for a two-way communication:
krpano
The krpano Interface object (allows additionally also direct Javascript access to all whole krpano structure and all functions there).
caller - the object of the <layer>, <plugin> or <hotspot> element that has called that action.
Show / trace details (value and type) about a variable in the output log.
When the variable is an object, then also all object properties will be shown.
Notes:
Debug messages will be only shown when the debugmode setting is enabled.
Consider enabling the consolelog setting in the HTML file
to see these messages also in the browser console.
Doing many traces is affecting the rendering performance!
Especially avoid constantly tracing messages every frame!