Is it worth it to keep the number of plugins (or layers) low?

  • Hi all!

    I'm playing a little bit with the new features added to the version 8.0.15
    The new sub-layering <layer> feature looks extremely interesting to me, as I've always struggled using parent/children attributes due unwanted inheritances.
    The thing is,I like to keep things tidy, and I use addplugin and removeplugin, now addlayer and removelayer *wink* a lot for several reasons.

    If a virtual tour has a 'Show Map' button, rather than show (make it visible="true") a floorplan added when the scene loaded, I prefer to create on-the-fly and show it when the button is clicked.
    For this reason, I most of the layers in my virtual tours are added using addlayer action. They are functions that I can call several times. And also it is possible to add if and for statements to it.
    And when the 'Hide Map' button is clicked, I prefer remove the floorplan and all its elements, rather than make them invisible.
    I always thought that keeping the number of layers low would help to increase a virtual tour performance.

    So my first question is : is it possible to apply this sub-layering system using addlayer actions?

    I haven't found anything indicating that this is possible.

    Second question: is my approach really worth it? Or should I adopt the <layer> approach, making things visible="false' enabled="false" instead of removing them?

    Thank you!!!

  • Hi,

    Sublayers still work dynamicly by setting the parent, It's the only way I think.

    And as of your question, what's the best way. I can only answer with, it depends on the situation and what you find handy.

    If you have 1 map with fixed maphotspots, I'd say use layers and set visible to false. The benefit is, when the user clicks, the map is already loaded, also when reading back on the code, it's clear what happens, there's no magic adding
    If you have multiple maps I tend to use either dynamicly create the map on click (sometimes I already created a container with the first map preloaded). having a plugin called map_1 map_2 map_3 is ugly. I usually create some sort of data object with all maps

    Code
    <maps>
       <map name="map_1" url="">
              <spots>
                   <spot x="0" y="0" >
              </spots>
       </map>
    </maps>

    This way I combine structure with dynamicly adding stuff. Easy to adjust and max performance.

    Performance wise I shouldnt worry till you hit that mark. It's more about maintaining and re-using code. Don't repeat yourself

    Atm Im alsoo busy creating a droplet based on the new krpano layer style and scrollmasks, and gotta say I love it :) Alsoo don't forget using styles! Escpecially in combination with custom attributes It's awesome placing hotspot like this:

    Code
    <hotspot ath="0" atv="0" style="hotspot_style" tooltip="Hello" scene="3" />
    
    
    <style
       name="hotspot_style"
       onhover="showtext(get(tooltip))" url="test.png"
      onclick="loadscene(get(scene));"
    />

    It's so easy to read, and adjusting stuff.

  • Thanks for your reply zaphir,

    I definitely haven't make the most of the fact that the krpano programming language is written in xml.
    I've used styles in various occasions, but I rarely have used custom attributes.
    Your data object is also very clever!

    Something interesting I've found out running grep within krpano 8.0.15 folder is that Klaus only used addlayer or addplugin actions to add dynamically thumbnails or image gallery items.

    So yes, I'm going to use the sub-layering feature and xml capabilities in my next project. It's the way forward.

    Cheers!

Jetzt mitmachen!

Sie haben noch kein Benutzerkonto auf unserer Seite? Registrieren Sie sich kostenlos und nehmen Sie an unserer Community teil!