embedpano vars object and overriding design_bgcolor or design_bgalpha

  • Hi there,

    I am trying to override skin or layer settings using javascript, but I am not having much luck.

    Can anyone help me with the order of execution when using embedpano and an onready callback function:


    After I call embedpano() I get the following output in the console:

    Code
    krpano ready
    krpano_onready_callback ended
    INFO: preinit action fired
    INFO: onstart action fired
    INFO: skin_settings.design_bgcolor=0x2D3E50


    I would expect "skin_settings.design_bgcolor" to have been changed to "0x00FF00" when I called krpano.set() but it remains as the default from set in vtourskin.xml


    I have also tried setting a layer's bgcolor with JS (in my callback function) but I cannot get this to work either:

    Code
    krpano.set("layer[skin_floorplan_container].bgcolor", "0xFFFFFF");
    krpano.call("trace('layer[skin_floorplan_container].bgcolor=', get(layer[skin_floorplan_container].bgcolor));");


    Console output:

    Code
    INFO: layer[skin_floorplan_container].bgcolor=0x000000

    Do I need to call some a method to get these changes to be registered with krpano and displayed in the browser?

    Hopefully one of you kind people can point me in the right direction!

    Cheers
    Olly

  • Thanks for trying to help indexofrefraction.


    Your first idea does not work here and the second throws an error:
    Uncaught TypeError: Cannot read property 'getItem' of undefined

    Is the layer property of krpano object documented anywhere?

    Is this a bug or user error?

    FWIW I am using v1.20.2...

  • https://krpano.com/docu/plugininterface/#array.getItem

    problem is maybe more that there you dont get the "real" krpano object ...
    try to do this first :

    ...
    krpano = krpano_interface;
    console.log(krpano);
    console.log(krpano.set);
    console.log(krpano.layer);

    if the later show null or undefined, it is not the "real" krpano object...
    i always forget how to get it... will check...

    ahh.. have a look here:
    https://krpano.com/forum/wbb/inde…t=krpano+object

  • Thanks for the pointer to get the "real" krpano object...

    However, krpano.layer.getItem("skin_floorplan_container") returns undefined.

    Does the getItem() selector string require any context?

  • Hi,

    one important note - the onready will be called once the krpano viewer itself is loaded and ready to use. But that doesn't mean that any files, like the startup-xml file are also already loaded at this time.

    Therefore these layers are not defined yet and when you set some values they get overwriten by the loaded xml.

    Try something like this:

    Code
    krpano.set("events.onxmlcomplete", function()
    {
       krpano.set("layer[skin_floorplan_container].bgcolor", 0xFFFFFF); 
    });

    Best regards,
    Klaus

Jetzt mitmachen!

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