Spheretoscreen command not working correctly in 1.0.8.14

  • Hi,

    Spheretoscreen command stopped working when I updated from the beta version.

    I'm trying to call this command from actionscript but the result of it is very confusing...and wrong. If I make an action (containing the spehertoscreen calculation) in the XML-file and call that one from actionscript I get the correct result.

    Have the syntax for calling spheretoscreen from actionscript changed?

    This is what I'm trying to call (and this worked with the beta release):
    krpano.call("spheretoscreen(hotspot[name].ath, hotspot[name].atv, hotspotx, hotspoty)");

    What to do?

    Br,
    Zarillo

  • Hi,

    I use this command for displaying tooltips for hotspots. If the coordinate is in the screen it should draw out the tooltip.

    This is what I have:

    var area:Object = krpano.get("area");
    var tempX:Number;
    krpano.call("spheretoscreen(hotspot["+obj.test+"].ath, hotspot["+obj.test+"].atv, hotspotx, hotspoty)");

    tempX = Number(krpano.get("hotspotx"))+Number(area.x);


    And if the value is between a certain interval then it draws out the tooltip.

    The result I get is either NAN or a value that is incorrect.
    It seems like to spheretoscreen command thinks that the hotspots are located at a different position than they are. And it thinks that they are all located at the same coordinate.

    Let me know if you need more information regarding this problem...

    Best Regards,
    Zarillo

  • Hi,

    are you sure that the hotspotx itself is wrong?

    in your code here - the casing of "area.x" will fail and return NaN when area.x is a percent value (which is it by default, 0%):

    tempX = Number(krpano.get("hotspotx"))+Number(area.x);

    correct would be using the "area.pixelx" values - this are the final pixel values:

    tempX = Number(krpano.get("hotspotx"))+Number(area.pixelx);


    beside of that - the behavior of your code should be the same in all versions...

    best regards,
    Klaus

  • And it thinks that they are all located at the same coordinate.

    I am having a similar issue with spheretoscreen: it always outputs the same x/y coordinates, whatever the h/v coordinates in input. Actually, it always gives the x/y coordinates corresponding to (0°,0°). I am using the latest build (1.0.8.14-2011-10-21). You can try this in javascript for instance in order to reproduce this behaviour:

    Code
    krpano.call("spheretoscreen(0, 0, mousex, mousey)");
    krpano.get("mousex"); krpano.get("mousey");
    krpano.call("spheretoscreen(-30, 0, mousex, mousey)");
    krpano.get("mousex"); krpano.get("mousey");

    Besides, I was wondering if the formulae that are being used for spheretoscreen and screentosphere are publicly available?

  • maybe this helps:

    //not working

    Code
    krpano.call("spheretoscreen(0, 0, testx, testy)");
    console.log(krpano.get("testx")); console.log(krpano.get("testy"));
    krpano.call("spheretoscreen(-30, 0, testx, testy)");
    console.log(krpano.get("testx")); console.log(krpano.get("testy"));

    //works

    Code
    var spherical_coordinates = krpano.get("screentosphere(-30,0)"); 
    var coordinates_array = spherical_coordinates.split(",");
    console.log(spherical_coordinates);
    
    
    var spherical_coordinates = krpano.get("screentosphere(0,0)"); 
    var coordinates_array = spherical_coordinates.split(",");
    console.log(spherical_coordinates);

    seems like the conversion is right, but the setting to another variable has some problems

    Edited 2 times, last by Zephyr (November 17, 2011 at 12:39 PM).

  • Hi,

    see here the documentation:
    https://krpano.com/docu/actions/#screentosphere

    especially that part:

    Quote

    All parameters must be variables, using values is not possible!

    so try:

    Code
    krpano.set("screenx", 0);
    krpano.set("screeny", 0);
    krpano.call("spheretoscreen(screenx, screeny, testx, testy)");
    console.log(krpano.get("testx")); 
    console.log(krpano.get("testy"));

    best regards,
    Klaus

  • Code
    var spherical_coordinates = krpano.get("spheretoscreen(30,0)"); 
    var coordinates_array = spherical_coordinates.split(",");
    console.log(spherical_coordinates);
    Code
    krpano.set("screenx", 30);
    krpano.set("screeny", 0);
    krpano.call("spheretoscreen(screenx, screeny, testx, testy)");
    console.log(krpano.get("testx")); 
    console.log(krpano.get("testy"));

    Unless if you use get, then values are allowed.. both return the same

Participate now!

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