JavaScript API hotspot follow click

Q&A about the latest versions
Post Reply
alfredo
Posts: 1
Joined: Tue May 10, 2022 1:16 pm

I am trying to move an added hotspot by following the mouse click on the screen.
I'm using this function

Code: Select all

pano.getPositionRawAngles(x:Number,y:Number):Object
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

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   );
	
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
Post Reply