You are not logged in.

Zephyr

Professional

  • "Zephyr" started this thread

Posts: 1,003

Location: Netherlands

Occupation: Web developer

  • Send private message

1

Saturday, February 15th 2020, 2:51pm

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?

Source code

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

Source code

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?

Source code

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

Trainee

Posts: 93

Location: Default city, Russia

Occupation: Vtour dev, design, UX and photography

  • Send private message

2

Saturday, February 15th 2020, 3:14pm

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

Sage

Posts: 3,263

Location: Netherlands

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

  • Send private message

3

Saturday, February 15th 2020, 3:18pm

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*
http://www.virtualtuur.com
Skype:studiotuur

Zephyr

Professional

  • "Zephyr" started this thread

Posts: 1,003

Location: Netherlands

Occupation: Web developer

  • Send private message

4

Saturday, February 15th 2020, 5:48pm

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

Sage

Posts: 3,263

Location: Netherlands

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

  • Send private message

5

Saturday, February 15th 2020, 6:15pm

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*
http://www.virtualtuur.com
Skype:studiotuur

Zephyr

Professional

  • "Zephyr" started this thread

Posts: 1,003

Location: Netherlands

Occupation: Web developer

  • Send private message

6

Saturday, February 15th 2020, 8:48pm

The loadxml gave me an idea:

Source code

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

Trainee

Posts: 93

Location: Default city, Russia

Occupation: Vtour dev, design, UX and photography

  • Send private message

7

Sunday, February 16th 2020, 10:07am



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

Intermediate

Posts: 307

Location: Milwaukee, WI USA

Occupation: Professional Photographer

  • Send private message

8

Monday, February 17th 2020, 8:49am

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

Professional

  • "Zephyr" started this thread

Posts: 1,003

Location: Netherlands

Occupation: Web developer

  • Send private message

9

Monday, February 17th 2020, 10:18am

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

Monday, February 17th 2020, 11:39am

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

Professional

  • "Zephyr" started this thread

Posts: 1,003

Location: Netherlands

Occupation: Web developer

  • Send private message

11

Monday, February 17th 2020, 12:15pm


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

Posts: 1,852

Occupation: Virtual Tours - Photography - Krpano developer

  • Send private message

12

Monday, February 17th 2020, 5:28pm

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

Thursday, March 5th 2020, 10:28pm

Hi Zephyr,
I split it simply by

Source code

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

Source code

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

This post has been edited 1 times, last edit by "pur" (Mar 19th 2020, 8:56pm)