JavaScript API hotspot follow click
Posted: Wed May 11, 2022 11:36 am
I am trying to move an added hotspot by following the mouse click on the screen.
I'm using this function
It is all very precise until you begin to rotate the panorama or start view has non-zero tilit .
With a tilt = 0 everything is ok.
As the tilt increases (- / +) accuracy is lost
The code to move the hot spot
There is a way to improve accuracy with non-zero tilit?
Here https://www.cervellati.com/hotspotfollow/ is a working example exported from pano2vr7 beta
I'm using this function
Code: Select all
pano.getPositionRawAngles(x:Number,y:Number):Object
With a tilt = 0 everything is ok.
As the tilt increases (- / +) accuracy is lost
The code to move the hot spot
Code: Select all
var pan = pano.getPan();
var tilt = pano.getTilt();
if( pan < 0 ) { pan = pan + 360 ; }
// Click position in pixel
var offset = $(this).offset();
var ex = e.pageX - offset.left;
var ey = e.pageY - offset.top;
var myscreensize = pano.getViewerSize();
var newex = (myscreensize['width'] - ex) + 25 ; // 25px half width of pointer.png
var newey = ey - 25 ; // 25px half height of pointer.png
var myposition = pano.getPositionRawAngles(newex,newey);
var mypositionpan = myposition['pan'];
mypositionpan = mypositionpan + pan ;
var mypositiontilt = myposition['tilt'];
mypositiontilt = mypositiontilt + tilt ;
// Move hotspt
pano.updateHotspot("myid",mypositionpan , mypositiontilt );
Here https://www.cervellati.com/hotspotfollow/ is a working example exported from pano2vr7 beta