I am using the JS interface via https://krpano.com/docu/js/#interfaceobject and specifically calling screentosphere(x,y).
It states just below "The spheretoscreen / screentosphere functions will return an object with x, y properties."
The returned object defines x, y, and z properties, but x and y are always NaN and z is always 0.
What am I doing wrong?
I keep getting NaN for both x and y when using screentosphere - what am I doing wrong?
-
-
What am I doing wrong?
Sorry, but that's impossible to say without seeing your example.
That means post a link to your example. -
generateHotspots = function(pano, krpano) {
hotspots = pano.hotspots()
hotspot = hotspots[0]
console.log hotspot //Hotspot model data
krpano.set('x', hotspot.cords.x)
krpano.set('y', hotspot.cords.y)
pos = krpano.screentosphere(krpano.get('x'), krpano.get('y'))
console.log(pos) //Console results: vc {x: NaN, y: NaN, z: 0}
} -
In addition, I just mimicked the source from your example here https://krpano.com/examples/118/e…se/jsmouse.html.
krpano.call("screentosphere(mouse.x, mouse.y, mouseath, mouseatv);")
setInterval(function() {
mouse_at_x = krpano.get("mouse.x");
mouse_at_y = krpano.get("mouse.y");
mouse_at_h = krpano.get("mouseath");
mouse_at_v = krpano.get("mouseatv");
console.log(mouse_at_x, mouse_at_y, mouse_at_h, mouse_at_v)
}, 1000.0 / 30.0);The logging results in proper mouse values, but I still get NaN for h and v values (ex. 815 71 NaN NaN). I am using 1.19-pr6 if that helps (bug? doing it wrong?).
-
function getlookat()
{
var krpano = document.getElementById("krpanoSWFObject");
if (krpano && krpano.get) // it can take some time until krpano is loaded and ready
{
krpano.call("screentosphere(mouse.x, mouse.y, mouseath, mouseatv); js( showmouseinfo() );");
}
}
function showmouseinfo()
{
var krpano = document.getElementById("krpanoSWFObject");
var mouse_at_x = krpano.get("mouse.x");
var mouse_at_y = krpano.get("mouse.y");
var mouse_at_h = krpano.get("mouseath");
var mouse_at_v = krpano.get("mouseatv");
document.getElementById("mouse_x").innerHTML = mouse_at_x + "px";
document.getElementById("mouse_y").innerHTML = mouse_at_y + "px";
document.getElementById("mouse_ath").innerHTML = mouse_at_h.toFixed(2) + "°";
document.getElementById("mouse_atv").innerHTML = mouse_at_v.toFixed(2) + "°";
}
// update mouse info 30 times per second
var lookat_interval = setInterval('getlookat()', 1000.0 / 30.0);
// disable text selection to avoid cursor flickering
window.onload = function()
{
document.onselectstart = function() {return false;} // ie
document.onmousedown = function() {return false;} // mozilla
}
Jetzt mitmachen!
Sie haben noch kein Benutzerkonto auf unserer Seite? Registrieren Sie sich kostenlos und nehmen Sie an unserer Community teil!