Hotspots on a flat image don't maintain position in WebVR

  • Hi all,

    I'm new to KRPano so trying to get me head around its functionality.

    I've started with the WebVR example and adapting it to my needs. I've changed the opening scene to a flat image of a map with hotspots. Hotspot positions are -1 to 1 based on the FOV from what I've read but when WebVR is enabled the FOV is larger so the positions are now -180 to 180.

    I've added this to the hotspot creation function to change the ath and atv when entering and exiting vr.

    Code
    onentervr='set(ath=get(athVR)); set(atv=get(atvVR));'
    onexitvr='set(ath=get(ath)); set(atv=get(atv));'

    This is the function for creating the hotspot:


    Code
    <action name="add_example_thumb" depth="off" scope="local" args="title, athVR, ath, atvVR, atv, thumburl, clickaction">	addhotspot(auto,thumb);
    	set(thumb, distorted=false, zorder=1, capture=false, edge="center", flying="0", zoom="false", distorted="false", url=get(thumburl), width=32, height=24, ath=get(ath), atv=get(atv), depth=300, scale=1, onover=tween(depth,300), onout=tween(depth,300), clickaction=get(clickaction), onclick='set(enabled,false); clickaction();', onentervr='set(ath=get(athVR)); set(atv=get(atvVR));', onexitvr='set(ath=get(ath)); set(atv=get(atv));');
    	set(thumb, autoalpha=true, alpha=0);
    	set(global.hotspots[get(global.hotspots.length)],get(local));</action>

    When I enter VR hotspot positions never change so I'm assuming the onentervr and onexitvr are never called.

    Does anyone know what the solution is?
    Thanks

  • Code
    onentervr='set(ath=get(athVR)); set(atv=get(atvVR));'
    onexitvr='set(ath=get(ath)); set(atv=get(atv));'

    the 2nd line makes no sense, it sets just ath=ath..
    if it was changed before (athVR) this won't restore the original value

    Zitat

    .. onentervr and onexitvr are never called.


    where do you add these attributes ? on the hotspot? that doesn't work

    you must create an event ( webvr_onenter/exitvr )
    https://krpano.com/docu/xml/#events
    and process all your hotspots

    Code
    <events name="myevent" webvr_onenter="myonenter();" webvr_onexit="myonexit();" keep="true" />
    <action name="myonenter"> ... </action>
    <action name="myonexit"> ... </action>
  • Thanks for the help Index!

    I've added the event like you mentioned

    Code
    <events name="myevent" webvr_onentervr="myonenter();" webvr_onexitvr="myonexit();" keep="true" />

    and the actions for the two functions


    Code
    <action name="myonenter" scope="local">	
    	trace('ENTERED VR - Start');	
    	for(set(i,0), i LT global.hotspots.length, inc(i),	
    		scope(get(global.hotspots[get(i)]),	
    			set(hotspot[get(i)].ath, 90);
    			set(hotspot[get(i)].atv, 90);	
    		);	
    	);	
    	trace('ENTERED VR - End');
     </action>

    The functions are being called which is great, but I can't figure out how to change the atv and ath for the hotspots.

    Looking at my original post each hotspot contains a thumb and a text so I assume I have to change atv and ath for both but I can't figure this out even with the help of the documentation and forum posts.

    Any help would be greatly appreciated!

    3 Mal editiert, zuletzt von vedders (7. September 2022 um 17:28)

  • smth like this should work

    https://krpano.com/docu/xml/#action.scope

Jetzt mitmachen!

Sie haben noch kein Benutzerkonto auf unserer Seite? Registrieren Sie sich kostenlos und nehmen Sie an unserer Community teil!