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?

    Code
    <krpano>
       <include url="tour.xm" />
      <include url="hotspots.xml />
    </krpano>

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

    Code
    <scene name='test'>
       <view fov="90" />
    </scene>
    
    
    <scene name="test"?
       <hotspot url="poin.png" ath="0" />
    </scene>

    or perhaps by setting a parent?

    Code
    <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.

  • 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.

  • 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?

  • 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*

  • The loadxml gave me an idea:

    Code
    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

  • 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

  • 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.)

  • 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.


  • 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

  • Hi Zephyr,
    I split it simply by

    Code
    <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

    XML
    <?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

    Edited once, last by pur (March 19, 2020 at 8:56 PM).

Participate now!

Don’t have an account yet? Register yourself now and be a part of our community!