Sie sind nicht angemeldet.

Zephyr

Profi

  • »Zephyr« ist der Autor dieses Themas

Beiträge: 1 003

Wohnort: Netherlands

Beruf: Web developer

  • Nachricht senden

1

Samstag, 15. Februar 2020, 14:51

Split hotspot code and scene code

Hi all,

Is it possible to have all the hotspots of different scenes in 1 file, and the scenes in another?

Quellcode

1
2
3
4
<krpano>
   <include url="tour.xm" />
  <include url="hotspots.xml />
</krpano>


for example (not sure if this is possible) by merging scene tags

Quellcode

1
2
3
4
5
6
7
<scene name='test'>
   <view fov="90" />
</scene>

<scene name="test"?
   <hotspot url="poin.png" ath="0" />
</scene>


or perhaps by setting a parent?

Quellcode

1
<hotspot parent="scene[test]" />


atm I have a workaround with javascript that adds hotspots from one file, by listening to the onnewscene event and matching the scene name in both objects. Wondering if there was something smarter that I have missed in newer updates.

a.pu

Schüler

Beiträge: 120

Beruf: software engineer, author of krpano syntax highlighting, bundler and style guide

  • Nachricht senden

2

Samstag, 15. Februar 2020, 15:14

Made a quick check.
Overriding seems to not work this way. Scene code is kept in one big string and interpreted at scene load.
So when we have two scenes with same names but different code, krpano will load the one with more latter declaration.

Tuur

Erleuchteter

Beiträge: 3 839

Wohnort: Netherlands

Beruf: Krpano custom coding / Virtual Tours / Photography / Musician / Recording engineer

  • Nachricht senden

3

Samstag, 15. Februar 2020, 15:18

Hi Zephyr,

long time no see!
I think the only option is to get it all from an array.. with js or krpano.

Tuur *thumbsup*

Zephyr

Profi

  • »Zephyr« ist der Autor dieses Themas

Beiträge: 1 003

Wohnort: Netherlands

Beruf: Web developer

  • Nachricht senden

4

Samstag, 15. Februar 2020, 17:48

Hi Zephyr,

long time no see!
I think the only option is to get it all from an array.. with js or krpano.

Tuur *thumbsup*


Hi Tuur,
Im always lurking, not so much posting anymore :)

Anyway, thats what Im doing now. I create one big hotspots.xml file, and then wrote a custom javascript that places the correct ones on scene load. Works fine, but just wondering if It was possible in another way.


Made a quick check.
Overriding seems to not work this way. Scene code is kept in one big string and interpreted at scene load.
So when we have two scenes with same names but different code, krpano will load the one with more latter declaration.


Thanks for trying it out :)

Do you know if its possible not to load a xml using embedpano, but rather add scenes and images on runtime with javascript?

Tuur

Erleuchteter

Beiträge: 3 839

Wohnort: Netherlands

Beruf: Krpano custom coding / Virtual Tours / Photography / Musician / Recording engineer

  • Nachricht senden

5

Samstag, 15. Februar 2020, 18:15

Isn’t loadxml or loadpanoscene an option for you?

Btw your suggestion for scenes with the same name will fuse could also be nice..
Maybe a new scene type setting ..(?klaus) like:none-pano-assets
Same name and type will overwrite, otherwise merge.

Tuur *thumbsup*

Zephyr

Profi

  • »Zephyr« ist der Autor dieses Themas

Beiträge: 1 003

Wohnort: Netherlands

Beruf: Web developer

  • Nachricht senden

6

Samstag, 15. Februar 2020, 20:48

The loadxml gave me an idea:

Quellcode

1
2
var sceneXML = 'loadxml(<krpano>' + krpano.get('scene[get(xml.scene)].content') +  krpano.get('data[hotspots].content')  + '</krpano>, , MERGE)'
krpano.call('loadxml(' + sceneXML +" )')


It create a xml string with the scene info from one data object (the scene) and hotspots from another

a.pu

Schüler

Beiträge: 120

Beruf: software engineer, author of krpano syntax highlighting, bundler and style guide

  • Nachricht senden

7

Sonntag, 16. Februar 2020, 10:07



Thanks for trying it out :)

Do you know if its possible not to load a xml using embedpano, but rather add scenes and images on runtime with javascript?


why not
you need to clone krpano scene array item via Object.assign() then replace scene code with new xml string and push it into scene array

Scott Witte

Fortgeschrittener

Beiträge: 382

Wohnort: Milwaukee, WI USA

Beruf: Professional Photographer

  • Nachricht senden

8

Montag, 17. Februar 2020, 08:49

Howdy Zephyr,

Maybe it would help if we knew why you want to attempt this. If, for instance, you wanted the version of the hotspot to be dependant on something like language it might be easier to build that code into the hotspot or the scene.

I have done something similar a while back. You might try something like this:

Place an event element inside the scene with an onxmlcomplete attribute to run an action that copies/builds/completes the hotspot(s) based on the hotspots XML file and some condition, perhaps. The "Build_Hotspots" action is separate from the scene and can be coded to do whatever you want. Since the hotspots are built anew each time the scene is loaded you can change them based on it this is the first time the scene is seen or not. Stuff like that.

(BTW, I'm on the road so my internet interaction may be spotty this week.)

Zephyr

Profi

  • »Zephyr« ist der Autor dieses Themas

Beiträge: 1 003

Wohnort: Netherlands

Beruf: Web developer

  • Nachricht senden

9

Montag, 17. Februar 2020, 10:18

Hi Scott,

The reason I want this, is because I have a client creating the tours via the krpano droplet. He can upload the whole tour to the ftp. Via a custom cms he can place the hotspots. The hotspots are served via hotspots.xml which is server side generated. This way we have a clear seperation of concerns. The client can just upload the tour without worrying. I couldve created something that servers the tour.xml but injects the hotspots serverside but I liked my current approach better.

The client can even download the hotspots.xml and run the tour offline.

The hotspots are placed via some intermediate code, which basicly does what you sketched out. onxmlcomplete triggers a build hotspots action which parses <customhotspot scene='x' ... /> to <hotspot ... /> in the correct scene.

- I could call a api on xmlcomplete to give the correct json information about the hotspots of a scene and parse that. (Benefit would be that the initial load is smaller as I only load what I need)
- I could generate <data tags per scene with its content beging the hotspots, and the instead of a loadscene, I'd do a loadxml that merges the scene xml with the data.xml
- I could let the server do the merging and serve the tour.xml with the hotspots from the database merged while keeping the original tour.xml intact.

Enough possibilities :) I was just curious about other solutions thats more 'native' to krpano. Like the parent system of merging of tags.

10

Montag, 17. Februar 2020, 11:39

hm sorry... but ...

does simple merging not work ?

tour.xml
<include name="hotspots" url="hotspots.xml" keep="true" />
<scene name="test">
</scene>

hotspots.xml
<scene name="test">
<hotspot name="myhotspot" ... />
</scene>

Zephyr

Profi

  • »Zephyr« ist der Autor dieses Themas

Beiträge: 1 003

Wohnort: Netherlands

Beruf: Web developer

  • Nachricht senden

11

Montag, 17. Februar 2020, 12:15


hm sorry... but ...

does simple merging not work ?

tour.xml
<include name="hotspots" url="hotspots.xml" keep="true" />
<scene name="test">
</scene>

hotspots.xml
<scene name="test">
<hotspot name="myhotspot" ... />
</scene>



Made a quick check.
Overriding seems to not work this way. Scene code is kept in one big string and interpreted at scene load.
So when we have two scenes with same names but different code, krpano will load the one with more latter declaration.


Apparently not

Beiträge: 1 857

Beruf: Virtual Tours - Photography - Krpano developer

  • Nachricht senden

12

Montag, 17. Februar 2020, 17:28

If it's a cms being used, just load and create the entire xml structure with the cms. Then no problem. And more things are possible too.
Only thing a little tricky is to discover all the image levels uploaded to generate the right multiresolution.
KRPano Developer: Portfolio ::Gigapixel Tagging Solutions - Porfolio 2 :: Facebook :: Twitter :: reddit.com/r/VirtualTour

13

Donnerstag, 5. März 2020, 22:28

Hi Zephyr,
I split it simply by

Quellcode

1
2
3
4
5
    <scene name="scene_02" 
        title="get:i18n.scene_02.key[title].txt" 
        ...
        <include url="%HTMLPATH%/vtour/panotags/in_scene_02.xml" />
    </scene>


The in_scene_02.xml file is pure hotspots definition like

Quellcode

1
2
3
4
5
6
7
<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<krpano>
  <hotspot name="tg_190511_19420944" style="panotag_hotspot_style" title="Knieža RASTISLAV" subtitle="820 - 870" note="get:i18n.scene_02.key[tg_190511_19420944].note" scenename="scene_02" ath="0.0043" atv="-0.1488" tagsize="0.069">
    <point ath="0.0043" atv="-0.1488"/>
  </hotspot>
...
</krpano>


I created panotags app for dynamic update each scene's hotspots panotags/in_scene_02.xml with node.js but I don't let the user change it now.
Example is here. Go out of the first scene where a little person icon is shown right bottom and you highlight all hotspots/panotags of the scene.

BUT:
I'd like to create mapspots for some of my panotags. How to read my includes in_scene_02.xml from the code? Any help will be highly appreciated.

UPDATE BUT:
Since I needed to access all the panotags/hotposts of all scenes I put my <include my_hotspot.xml> outside of the <scene/>. Now the hotspots are in separate xml files and I enable the scene hotspots on the basis of the new hotpost attribute scenename="my_scene" by an action running onstart event.
Now the hotspots/panotags are in separate xml files and I can load the mapspots of all hotspots and make search/find process over the hotsopts.
I will provide the link as soon as I load data...

Have a great day,
Pavel

Dieser Beitrag wurde bereits 1 mal editiert, zuletzt von »pur« (19. März 2020, 20:56)