Hi,
I have seen several times examples that try to make a 'floor-hotspot' that automatically moves with the mouse position - and often this seems to be done by using spherical coordinates and some tricky rotations, but that typically results in a not correct looking perspective of the hotspot.
Here a more correct and still very simple solution:
- The hotspot will be '3d-placed' by the tx,ty,tz coordinates (and not by the spherical ath/atv/depth coordinates) and will be defined to be always be parallel-rotated to the floor.
- A custom 'floor-height' will be manually defined. That can be individual for each pano and would be the height of the camera when shooting the pano.
- Then to get the 3d position for the floor hotspot:
- First get the spherical position at the mouse position using the screentosphere action.
- Then convert that spherical position to a 3d unit/direction vector using the spheretospace action with depth=1.
- Then scale that vector to hit the floor - simply by scaling the unit-vector by the factor 'floorheight/unit-vector-y'.
Here as code:
Code
set(floorheight, 160);
screentosphere(mouse.x,mouse.y, h,v);
set(d,1);
spheretospace(h,v,d, x,y,z);
calc(hotspot[name].tx, x*floorheight/y);
calc(hotspot[name].tz, z*floorheight/y);
copy(hotspot[name].ty, floorheight);
This are only a few code-lines and will result it a correctly placed hotspot in 3d space and will look good from all viewing angles.
Additionally having the correct 3d position allows doing other nice things,
- e.g. automatically rotating the hotspot into the target direction,
- changing the alpha depending on the distance,
- or even moving toward the point in 3d-space, but that one would be only useful for depthmapped panos.
Here a full example:
https://krpano.com/releases/1.20.…mouse-position/
And here the example source:
https://krpano.com/viewsource.htm…pot-example.xml
Best regards,
Klaus