• Hi!
    one more code for extend krpano functionality, you can start any count of timers.

    The "Timer" :)

    usage:
    include timer.xml to your tour
    start timer - timer.start(name,delay,actions);
    Where
    name - is the custom timer name any you want, "mytimer" for example.
    delay - timer period delay in seconds
    actions - any krpano actions,optional

    when timer starts, event with same name will be available
    for example
    <events mytimer="actions"/>
    you can use any count of event call using named events and keep = true / false

    for stop timer use timer.stop(name);
    name - is the custom started timer name

    timer_name.reset(); - reset delay of timer, for example if you need to restart timer period.
    reset() will set enabled to true also.

    you can change delay in runtime, simple set delay value
    for example set(timer_name.delay,10); will change timer delay to 10 seconds

    for pause executing timer use
    set(timer_name.enabled,false); or timer_name.pause();
    resume executing

    set(timer_name.enabled,true); or timer_name.resume();

    EXAMPLE:
    timer.start(mytimer1,10,trace(10 seconds)); - will trace text "10 seconds" every 10 seconds.
    same but using events

    timer.start(mytimer1,10);
    <events mytimer1="trace(10 seconds)"/>

    Hope you like it *thumbup*

  • AUTOTOUR EXAMPLE: will switch scenes to next after 30 second if user not interact with tour interface and panorama and autorotate is enabled


    Have a nice day
    Andrey *thumbup*

  • Hi!
    you can change timer delay
    for example
    if you start timer
    timer.start(autotour,30); - means you set 30 seconds delay
    you can change it at any time, simple set(autotour.delay,NUMBER);
    where NUMBER is delay in seconds. set(autotour.delay,50); change delay to 50 seconds, set(autotour.delay,0.1); change delay to 100 miliseconds,
    timer continue works but with diff delay.


    Andrey *thumbup*

  • About specific vew and delay
    use tag "view" in each scene for set start view and onstart for set delay
    for example:

    Code
    <scene name="s1 onstart="set(autotour.delay,60);">
    	<view hlookat="100" vlookat="0"/>
    </scene>
    
    
    <scene name="s2" onstart="set(autotour.delay,50);">
    	<view hlookat="50" vlookat="0"/>
    </scene>


    Regards
    Andrey *thumbup*

  • I am trying to implement autotour under the START/STOP button.

    In your example I want to stop or just to pause tour for example in third scene onstart="autotour.pause();" but autotour keeps going.

    How can I stop autotour and how to reset the timer to start autotour from scene one?

    marty

  • Hi Andrey,

    I just want to check the action and used autotour.pause(); in onstart of the third pano.
    Just added to your xml this:
    <scene name="scene3" onstart="copy(layer[text].html,scene[get(xml.scene)].name);autotour.pause();">
    <view hlookat="0.0" vlookat="40.0" />

    where I want to stop or pause autotour with the scene3 but autotour keeps going.

    Is there action autotour.stop() ?

    My idea is to add start and stop button to the buttons panel.
    Autotour does not start when the rotation is OFF. I should first start rotation for starting autotour.


    What I do not know exactly is, how to start autotour if you are in the middle of the tour - start all the time from the first pano or start autotour from the current pano.
    That is a question.

  • Hiwell, this part of code is reset timer all the time.
    onxmlcomplete="autotour.reset();"
    onmouseup="autotour.reset();"

    you can call autotour.pause() with small delay
    for example
    delayedcall(0.1,autotour.pause(););
    it will pause timer after 0.1 second
    try it, hope it helps

    But you can switch off autotour by set(aytorotate.enabled,false);
    because of this
    if(autorotate.enabled, blabla
    You can add your own variable for condition of autotour work


    Andrey

  • Hi Andrey,

    I was praising your code saying to myself "it's code with taste!" based on Linus Torvlads Good Taste. But when testing your timer I found some inconsistenses:
    - the actions (arg %3) does not work;
    - the next instance of the timer overwrites the first one e.g. in my test case:

    Code
    <krpano debugmode="true" 
    onstart="showlog(true);loadscene(0);timer.start(autotour,5);timer.start(mytimer, 2, trace(%0 %1 %2 %3, ' ACTIONs' ););" 
    >


    the dealy=5 of the autotour is changed from intital value after first reset to delay=2.

    Since I wanted to use the enhanced timer for measuring of the elapsed time when loading scenes aparently I'm doing something wrong.
    Or can you, please, give me an advice how to set a breakpoint in IE/Chrome/Firefox debugger from a krpano code without a need to step-in each line of code of the embedHTML5 function?

    Thank you for inspiring ideas.
    Pavel

  • Hi Andrey
    I am reproducing the example with a tour that contains 3 scenes. scene0, scene1, scene2. Everything works fine, but when it must go from scene2 to scene0, the scene actually changes, but the text stays in scene2 and when it should change to scene1, it stays in scene0 but marked scene2, and does not return To change scene. I am using the example codes without any change. My question is if I should make any changes to the code because the number of scenes is different

  • Hi!
    sorry for such delay, better to contact me directly if you need fast answer :) too much busy these days

    well as i can see i have made mistake :) it was a bug and direct callback was not working
    so now code is fixed and works properly and it possible to use direct callback and event callback actions too
    enjoy *thumbup*
    you can download fixed version from first post, i did update, and let me know is all works fine now or not

    Also, when you start timer it starts and each time calling event with same name

    time.start(mytimer,10);

    will fire event with name mytimer each 10 sec's

    so you shold add event, like

    <events name="blabla" keep="true"
    mytimer="trace(My timer cabb back! each 10 sec's)"
    />

    that's how it is working

    Hope now all clear :)

    Best wishes
    Andrey

    And yes, you are right callback actions which is defined in start method is not fire by some reasons, hm.... strange.. i will take a look, not can not promise it will be in nearest future

  • Hi Andrey,

    I worked with your code and created an enhanced version of the timer. It works in the krpano ver. 1.19pr8 and has a new feature - it can log each action like start, pause, resume, reset, and stop. Both the timertick and elapsed time are shown in the showlog(true). The pause/resume is treated in the delayedcall, too.

    The ramirox3 issue apears in the latest krpano versions becasue the loadscene(get(sceneindex)...) does not work after one round of scenes.
    You need to use the scene.name instead:

    Code
    loadscene(get(scene[get(sceneindex)].name),null,merge,blend(0.7));


    Instead of Andrey's timer.start() I use the timer.init() action. I'm attaching the timer.xml and the example file too. Please let me know when any questions.

    Thank you,
    Pavel

Participate now!

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