screentosphere returning wrong result

  • Hi,

    we are using html5 Krpano version(1.16.9)
    in our ios application in some web view component.

    We where trying to convert screen x,y to ath and atv by using screentosphere
    function call (from js function) but it is returning wrong value.

    After a lot researches and suggested solutions our final js function looks like this
    but it still not working normally ...

    function convertXYToAthAtv(x, y){

    //IOS bug fix - Bug: screentosphere wrong in iPhone
    x = x/2;
    y = y/2;

    GLOBAL_KRPANO_OBJECT.call("set(js_x,"+x+")");
    GLOBAL_KRPANO_OBJECT.call("set(js_y,"+y+")");
    GLOBAL_KRPANO_OBJECT.call("screentosphere(js_x,js_y,c_ath,c_atv)");

    var ath = GLOBAL_KRPANO_OBJECT.get("c_ath");
    var atv = GLOBAL_KRPANO_OBJECT.get("c_atv");
    var resultArr = [ath,atv];

    return JSON.stringify(resultArr);
    }

    Can you please helps us and point out what is wrong with it, or how we can make it work normally
    Thanks

  • Hi,

    the 'call' interface is asynchronous - it only puts the given actions into the current actions queue.

    But the get/set interfaces are synchronous.

    When means when calling get(), the screentosphere() action might be not executed yet.

    Either try using the plugin interface - there a direct call to the screentosphere() is available:
    https://krpano.com/docu/plugininterface/#krpanointerface

    Or use a callback back to JS after the screentosphere() call using the js() action.

    Best regards,
    Klaus

  • Hi,

    Thank you for fast answer, but can you please provide example for second case

    how i can detect screentospare is done ? and call js in case of it
    i was trying to do something like this but
    GLOBAL_KRPANO_OBJECT.call("screentosphere(js_x,js_y,c_ath,c_atv); js(setJsAth('c_ath')); js(setJsAtv('c_atv')); ");
    i'm not sure if it logically correct


    Thanks

Jetzt mitmachen!

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