Sie sind nicht angemeldet.

Zephyr

Profi

  • »Zephyr« ist der Autor dieses Themas

Beiträge: 1 003

Wohnort: Netherlands

Beruf: Web developer

  • Nachricht senden

1

Donnerstag, 5. Januar 2012, 20:57

Adding properties/nodes/elements to krpano through javascript

I was wondering if it was possible to create actions on the fly through javascript or other properties for that matter like view, display, textstyle etc. I know you can add hotspots and plugins (krpano.call('addplugin(test)"); but was curious about those options.

If that isnt possible, I was wondering if loading an external xml would do the trick. For instance I host a plugin.xml somewhere, then in javascript I get either the content of the xml through ajax and send it like krpano.call("loadxml(" + xmlcontents + ")"); or just send the url directly to krpano and merge with the current xml.

Beiträge: 1 857

Beruf: Virtual Tours - Photography - Krpano developer

  • Nachricht senden

2

Freitag, 6. Januar 2012, 00:19

You mean loadpano. Loadpano loads xml, loadxml loads a pano.. Kidding. It loads xml as a string.
I dont see why you cant create an action in a string and loadpano it and then use it immediately.
KRPano Developer: Portfolio ::Gigapixel Tagging Solutions - Porfolio 2 :: Facebook :: Twitter :: reddit.com/r/VirtualTour

Zephyr

Profi

  • »Zephyr« ist der Autor dieses Themas

Beiträge: 1 003

Wohnort: Netherlands

Beruf: Web developer

  • Nachricht senden

3

Montag, 9. Januar 2012, 19:44

Hmm I was looking for a more direct way :(

4

Donnerstag, 12. Januar 2012, 14:44

Hi,
I was wondering if it was possible to create actions on the fly through javascript or other properties for that matter like view, display, textstyle etc. I know you can add hotspots and plugins (krpano.call('addplugin(test)"); but was curious about those options.
almost everything (expect the <image>) can be set/create dynamically just by setting it,
e.g. to create an action do:

Quellcode

1
set(action[actionname].content, trace(hello from the dynamically created action); );

see also:
http://krpano.com/docu/xml/#action.content

If that isnt possible, I was wondering if loading an external xml would do the trick. For instance I host a plugin.xml somewhere, then in javascript I get either the content of the xml through ajax and send it like krpano.call("loadxml(" + xmlcontents + ")");
that would work too, but a loadxml call will also remove the current <image> and load the new one from the xml,

best regards,
Klaus

Zephyr

Profi

  • »Zephyr« ist der Autor dieses Themas

Beiträge: 1 003

Wohnort: Netherlands

Beruf: Web developer

  • Nachricht senden

5

Donnerstag, 12. Januar 2012, 15:27

how would this work with for instance view? How to create that dynamicly? Or does it always exist in krpano and I only have to alter the defaults?
set('view.fov', 90);

If I for instance would not use a xml file at all. Give krpano a blanco xml file:

Quellcode

1
2
3
<krpano>
  <preview type="grid(CUBE,16,16,512,0xCCCCCC,0xFFFFFF,0x999999);" />
</krpano>


and then control the rest with just javascript. Would I able to recreate a complete tour just using calls/gets/sets?

all the hotspots/plugins/attributes I could either parse a json from a server, translate to a addhotspot, addplugin, set(property, value); or parse the data as xml and send in directly to xml (not sure what would be faster yet).
The image would be possible by forcing a loadxml with the image tag in it (created from server). Im just theorycrafting here, what is your opinion, is it possible? Would it be fast enough?

I see some benefits with this method:
- always live data from a database. 10 people at the same time adding hotspots/plugins, adjusting views etc.
- more secure. Viewing xml, is not as simple as view source
- granually build up your pano, build priorities (show all hotspots before loading plugins).
- precalulation done in javascript (a thumbnails posistion in a gallery, can be calculated more easily)
- integrations with other apis (generate hotspots based on facebookfriends, get the latest retail information so you can set a hotspot with the label " sold" on a specific house")

First I did this with just hotspots and plugins. And altering some basic properties like the fov through javascript. But as more I develop javascript, the lesser xml I write. Im wondering where the line is....Should I be concerned of writing to less xml. I havent noticed any major delays yet ( I put 20 hotspots with a blink of an eye, each with all the properties + custom properties).

6

Donnerstag, 12. Januar 2012, 16:32

Hi,
how would this work with for instance view? How to create that dynamicly? Or does it always exist in krpano and I only have to alter the defaults?
set('view.fov', 90);
the <view> node is always there, just set its attributes to the values you want,


and then control the rest with just javascript. Would I able to recreate a complete tour just using calls/gets/sets?
with expectation of the pano images, everything can be added just by setting it,
the plugins and hotspots needs the calling of addplugin/addhotspot to become visible, but the attributes can be set normally,


Would it be fast enough?
it would be a bit slower of course, because each call is a small overhead, but I can't say how much,

best regards,
Klaus

7

Dienstag, 31. Dezember 2013, 06:01

Add context menu

I want to add context menu to vtour throught javascript plugin, how to do it?

8

Donnerstag, 2. Januar 2014, 13:36

Just like in xml via actions:

e.g.

Quellcode

1
2
krpano.set("contextmenu.item[myitem].caption", "My item...");
krpano.set("contextmenu.item[myitem].onclick", "openurl('...',_blank)");


Best regards,
Klaus