Hi,
great work!

I have also started working on it but you were quicker
Note to Klaus: In the future (for this and other html viewer plugins) it would be nice if the javascript viewer could include js files as plugins through the xml, like the flash viewer can load (code-only) swf files as plugin.
of course! I'm already working on that, in the krpanoJS 1.0.8.14 pre-release there is already a first javascript plugin interface, it's not finish yet and there are still some interfaces missing (unloading, visible elements, resizing, ...), but I want to finish it for the final 1.0.8.14, then I will also provide example codes for it,
e.g. here an javascript plugin example code: (works already with the current 1.0.8.14 pre-release)
|
Source code
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
|
/*
krpanoJS javascript plugin template / example
1.0.8.14
*/
var krpanoplugin = function()
{
var krpano = null;
var plugin = null;
// registerplugin - startup point for the plugin
// - krpanointerface = krpano interface object
// - pluginpath = string with the krpano path of the plugin (e.g. "plugin[pluginname]")
// - pluginobject = the plugin object itself (the same as: krpano.get(pluginpath) )
this.registerplugin = function(krpanointerface, pluginpath, pluginobject)
{
krpano = krpanointerface;
plugin = pluginobject;
// say hello
krpano.trace(0,"hello from plugin[" + plugin.name + "]");
// add a global function to krpano (callable from xml by "test1()")
krpano.test1 = test1;
// add a local plugin function to krpano (callable from xml by "plugin[name].test2()" or just "test2()" when called from a plugin event)
plugin.test2 = test2;
// add a local plugin variable/attribute
plugin.var1 = "123";
// add a local plugin variable/attribute with getter/setter functions
plugin._var2 = 123;
plugin.__defineSetter__("var2", function(v){ plugin._var2=v; krpano.trace(0,"var2 was set to "+v); });
plugin.__defineGetter__("var2", function(){ return plugin._var2; });
}
function test1()
{
krpano.trace(0,"test1() called from xml");
krpano.trace(0,"view.hlookat = " + krpano.view.hlookat);
krpano.trace(0,"view.vlookat = " + krpano.view.vlookat);
krpano.trace(0,"view.fov = " + krpano.view.fov);
}
function test2()
{
krpano.trace(0,"test2() called from xml (plugin="+plugin.name+")");
}
};
|
some notes about it:
- only one global javascript variable named "krpanoplugin" is allowed
- all other things must be defined inside that "krpanoplugin" variable
- the krpanoplugin must have a public "registerplugin" function (that will be called by krpano to start the plugin)
and some notes about the current state of the plugin interface:
- the "krpanointerface" has currently only the "call" function, the set/get functions are currently not there,
- but therefore direct access to the krpano objects (e.g. to the <view> tag) is possible,
minimizing of JS code is also possible, but I would recommend the Google Closure Compiler or UglifyJS for it,
a "eval" minimizing may not work eventually...
best regards,
Klaus