Hi,
I'm getting different results on the javascript version compared to the flash version of krpano.
This is called from javascript:
Works on Flash, not on KrpanoJS, Note: I put values in there, not variables:
var mousex = krpano.get("mouse.x");
var mousey = krpano.get("mouse.y");
var spherical_coordinates = krpano.get("screentosphere("+mousex+","+mousey+")"); //convert x/y in ath/atv
var coordinates_array = spherical_coordinates.split(",");
According to the docs, you need to put variables in there, not values. But since I got an array returned, I though I dont have to provide the other 2 parameters (the variables krpano will set)
So I put variables in there:
var spherical_coordinates = krpano.get("screentosphere(mouse.x, mouse.y)"); //convert x/y in ath/atv
var coordinates_array = spherical_coordinates.split(",");
But I get a ["NaN", "NaN"] in flash, and a null on KrpanoJS
This works on both, but the variables arent available yet after the call..
krpano.call("screentosphere(mouse.x, mouse.y, sphere_horizontal, sphere_vertical)"); //convert x/y in ath/atv
var _ath = krpano.get('sphere_horizontal');
var _atv = krpano.get('sphere_vertical');
first I though because screentosphere needs some time to calculate. But doing a
I get the same problem. The variable isnt available right after the call, but doing the same get command in the terminal gives me the 10.
Directly setting works though. But since I have to use a call for the screentosphere, I can't use a get :(
So my question, what is the right way, that works on both KrpanoJS and SWF, so that given an x/y coordinate, returns the ath/atv immedietly.
other question, but not important, why does screentosphere expect different values in different context?
Update:
Ok stranger results:
krpano.call("screentosphere(mouse.x, mouse.y, sphere_horizontal, sphere_vertical); showlog(); trace(sphere_horizontal)"); //convert x/y in ath/atv
var _ath = krpano.get('sphere_horizontal');
var _atv = krpano.get('sphere_vertical');
krpano.call('trace(js: '+_ath+')');
Tracelog:
the trace that gets called later, doesnt have the same value...