Why is the onviewchange event disabled ?

  • Hi,

    I've implemented a compas on my VT ; the code is inspired from the "compass" included in the KRPano examples.

    I use the "onviewchange" event to update the compass heading,

    It works fine in most cases, except during "moveto" and "movetohotspot" actions ;

    I've tried setting "nonblocking" to true in the moveto actions, but it didn't change anything...

    Any suggestions ?

    Thanks for your help

    Philippe

  • oops, in my initial post I mentionned "moveto" and "movetohotspot" actions. Its a misprint *sad* , I meant "lookto" and "looktohotspot" instead ; and the only one of these with a non blocking parameter is "lookto".

    But anyway, the problem is still there, and I have no explanation yet...

  • try downloading the newest krpano.swf and/or try an older version. Make an example with just the onviewchange event

    Code
    <krpano onstart="showlog(); moveto(90,0);" >
    <events onviewchange="trace(view.hlookat)" />
    <preview type="grid()" />
    </krpano>
  • I think I'm slowly going somewhere :

    Code
    lookto(x,y,field,smooth(100,100,100))

    is blocking so that view.hlookat is not updated until lookto is done

    Code
    lookto(x,y,field,smooth(100,100,100),true,true);
    nextaction();

    is nonblocking : view.hlookat is updated while lookto is running.

    However, in this case, since it is nonblocking, nextaction() is executed while the lookto is running, so that it's a mess. I've tried :

    Code
    lookto(x,y,field,smooth(100,100,100),true,true,WAIT)

    to wait for the end of the lookto action but it doesn't work.

    right now the only solution I have is :

    Code
    lookto(x,y,field,smooth(100,100,100),true,true); 
    delayedcall(2.0,nextaction());


    but that's really not satisfying, because I don't know what the delay must be : it depends on how long the lookto action could last, and that is unknown.

    What I nead is some way to wait until the lookto action is ended.

    Right now I've no idea how to do this *confused*

  • I've found the answer ; its so simple I feel stupid about it *cry* :

    Of course, the "donecall" of the nonblocking lookto is called when the action is .... done !

    So that the answer is

    Code
    lookto(x,y,field,smooth(100,100,100),true,true,nextaction());


    and this works perfectly : nextaction() is run only when lookto is finished, and view.hlookat is updated since lookto is now nonblocking.

    Now I whish there was a nonblocking looktohotspot ; well I'll have to rewrite the code anyway, so...

    Thanks for your stimulating help, Zephyr

    Philippe

  • I sometime throw in a delayedcall(0, doaction()); when actions start to soon.

    about the looktohotspot:

    %1 = hotspot name
    %2 = field of view

    Code
    <action name="lookto_hotspot">
    lookto(get(hotspot[%1].ath),get(hotspot[%1].atv), %2,smooth(100,100,100),true,true,nextaction());
    </action>

    or differently you add a third parameter with the nextaction() in it or have the nextaction as property in the hotspot.

Jetzt mitmachen!

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