Hiding animated hotspots / stopping delayedcall / scope of variables.

  • Hello everyone,


    I am currently building a presentation with krpano. It was decided that during the presentations introduction the view should be clean and not have animations. Hotspots in the tour are animated, so they are to be hidden in the first scene until made visible by user interaction. The hotspots are animated with:


    Code
    <action name="hotspot_animate"> inc(frame,1,get(frames),0);mul(ypos,frame,frameheight);
    txtadd(crop,'0|',get(ypos),'|',get(framewidth),'|',get(frameheight));
    delayedcall(0.05, hotspot_animate() ; 
    </action>


    The above sits in the tour.xml in the <krpano> tag. AFAIK it is therefore defined globally.

    I tried the obvious, defined in the tour.xml within <krpano>:


    Code
    <action name="showhotspot"> tween(hotspot[%1].alpha, 1, 0.5, default, set(hotspot[%1].visible,true));
    tween(hotspot[%1].scale, 0.3);</action><action name="hidehotspot"> tween(hotspot[%1].alpha, 0, 0.5, default, set(hotspot[%1].visible,false));
    tween(hotspot[%1].scale, 0.5);</action>

    and a hotspot within <scene> calling the above action onclick.

    After also failing to employ <events>, in all sorts of variations of onxmlcomplete, onloaded...:

    Code
    <events   name="startview" keep="false"      	onxmlcomplete="hidehotspot(hotspot1);"     />


    I then tried the obvious again, calling for it from the <scene> tag, using onstart. This didn't work for me either. I blamed that on the hotspot being animated and the delayedcall perhaps overwriting it.

    The closest route to go from here seemed to stop the delayed call from the hotspot animation snippet and restart it upon user interaction.

    So the snipped was amended to read the following:


    Code
    <action name="hotspot_animate"> inc(frame,1,get(frames),0);
    mul(ypos,frame,frameheight);
    txtadd(crop,'0|',get(ypos),'|',get(framewidth),'|',get(frameheight));
    delayedcall(0.05, if(stopdelayedcall!=true, hotspot_animate() ;  </action>

    and added to the <scene> accordingly:

    Code
    onstart="set(stopdelayedcall, true);"

    and the hotspot:

    Code
    <hotspot name="infospot19"
    url="hotspots/TrainingAcademy.png"
    ath="0"
    atv="20"
    scale="0.3"
    onclick="set(stopdelayedcall, false);" />

    Needless to say: It did not work, other than the start scene being free of animations. I tried the <events> tag again, tried doubling down on it by calling hotspot_animate() after setting the variable false again and worked through all variations of

    https://krpano.com/docu/actions/#set[/color]
    and paying special attention to
    https://krpano.com/docu/actions/#local[/color]
    and of course tried the full definition of

    Code
    set(global, stopdelayedcall:boolean=false);

    as well as using a string and quotes.


    One thing I did notice: If I open the tour, I get the startscene as wanted, with only one hotspot meant to reveal all other hotspots shown. Upon clicking it, nothing changes, only that if I ,after clicking it, change scene through loadscene(), hotspots in the next scene will be showing, which will not be the case if I directly switch scenes, without first clicking the hotspot meant to set the variable to false. This leads me to believe: The variable was set to true globally and then set to false globally, with exception for the current scene.

    I wonder if anyone can see, where my mistake is or what I got wrong. Also which way is the way to go ?

    [color=#000000]In the meantime I will work around it by trying to employ a seperate, locally defined function that only affects the hotspots in question.

    [color=#000000]Thank you very much for any help.

    Update:
    I have made an additional discovery:
    I can make it work in the opposite sense. By switching the condition in the if statement to the opposite I can have animated hotspots on xmlloaded and hide them using the respective hotspot. This leads me to believe that for some reason the hotspot animation is not getting kicked off, while the setting of variables does work within the correct scope.

    Meanwhile I was also able to narrow down at least one flaw in my thoughts. I can not simply kick off the haltet animation again through calling hotspot_animate() from anywhere without further argument, because even tho all hotspots are the same, it is not one single loop serving all hotspots, it runs per hotspot, when it is called from skin_hotspotstyle.

    Later I found this statement by Klaus:

    Quote

    when it should be started again - from an action from another hotspot or plugin element, then the 'hotspot_animate' needs first to be rewritten to use 'absolute variable paths


    This does not seem to be the reason for it not working, as I want to control all hotspots with the style argument at once. Since the crop is defined in style I dont see any reason for it not to work. In my mind, variable frame should have the value where the loop was stopped at, so when it is called again, it takes that value, works of it, and returns crop which sets the next frame.
    This could be the culprit tho:

    Quote

    When the xml element will be first created, all attributes defined at the <style> element will be copied to the element itself. This will be done before the attributes that are defined at xml element itself will be applied.

    Then again ive tried bypassing the style already, without success.

    Edited 9 times, last by _Matthias_: additional discovery 3 (December 20, 2019 at 10:09 AM).

Participate now!

Don’t have an account yet? Register yourself now and be a part of our community!