Spacial Events Plugin for krpano
This plugin enriches your hotspots with some extra events and properties, and provides some extra useful krpano actions related to the spacial environment.
Online demo: https://krpano.kri-soft.be/spacial/
Do something when (not) looking at hotspots
<hotspot name="myhotspot" lookatrange="30" onlookat="dosomething()" onlookout="dosomethingelse()" />
Where:
lookatrange: the angle on when the actions should be triggered (value: 0-180)
onlookat: action to execute when view enters the range
onlookout: action to execute when the view leaves the range
Do something when the hotspot becomes (not) visible
<hotspot name="myhotspot" hittest="true" onvisiblein="dosomething()" onvisibleout="dosomethingelse()" />
Where:
hittest: perform hittesting for this hotspot (true/false)
onvisiblein: action to execute when hotspot becomes visible from the current camera view (not blocked by 3D geometry)
onvisibleout: action to execute when the hotspot becomes invisible from the current view (blocked by 3D geometry)
Do something when you get far/close to a hotspot
<hotspot geofencedistance="750" ongeofencein="dosomething()" ongeofenceout="dosomethingelse()" />
geofencedistance: the distance to the camera
ongeofencein: the action to execute when the viewer is entering the geofencedistance from the hotspot
ongeofenceout: the action to execute when the viewer is leaving the geofencedistance from the hotspot
Additional properties available for the hotspot:
When lookatrange > 0, these are set:
- hotspot[name].lookstate: 0/1: 0: the hotspot is currently not in range of the view, 1=the hotspot is currently in range of the view
- hotspot[name].anglefromcam: the current angle for the hotspot as seen from the camera (0-180)
When hittest is true, these are set:
- hotspot[name].inview: 0/1: 0=the hotspot is currently not visible, 1=the hotspot is currently visible
when geofencedistance > 0, these are set:
- hotspot[name].geofencestate: 0/1: 0 = the viewer is currently not within the geofence, 1 = the viewer is currently within the geofence
- hotspot[name].distancefromcam: distance between viewer and the hotspot
Extra actions available in krpano:
-
getdistancebetweenpoints(x1, y1, z1, x2, y2, z2): calculates the distance between 2 given pointsusage example:
set(distance, calc(getdistancebetweenpoints(x1, y1, z1, x2, y2, z2)));