KRPano actions and javascript actions calls

  • Hello all!
    I'm playing with KRPano and for some technical and performances reasons, I decided to work in XML file with both Javascript and Native actions.
    Today, I'm struggling hard to get the things work together! :)
    Calling is an javascript-type action from a standard KRPano native-action is straight forward:

    Code
    <action name="caller">
       callee();
    </action>
    
    
    <action name="callee" type="javascript">
       console.debug("yeepee");
    </action>


    But for some technical reasons, it's more complicated the other way:

    Code
    <action name="caller" type="javascript">
       krpano.call("callee()");
    </action>
    
    
    <action name="callee">
       trace("yeepee");
    </action>


    When the Big Deal comes, it is when we start talking about parameters... Once again, Native-to-JS is trivial, but the other way is not.
    I ended to this point: because I must give my actions arrays, I instanciate arrays in calls before to call the expected actions:


    Code
    <action name="caller" type="javascript">
       var val1 = "plouf";
       var val2 = 4*6;
       krpano.call("def(my_array, array);set(my_array[0], "+val1+");set(my_array[1], "+val2+");callee()");
    </action>
    <action name="callee">
       trace("Provided values are:", get(my_array[0]), " / ", get(my_array[1]));
    </action>


    I'm not sure this is very optimal ;) and it looks very.very ugly :D
    Do you know a better way?
    Image I work with very long arrays I have to declare in loops and construct a call-string before to launch the action... This is very poor in performance. :/
    Best regards and thanks for your enlightened help!

    « Quidquid latine dictum sit, altum sonatur »
    Pentax stuff.

  • you could pass the args like this
    krpano.call( 'callee('+val1+','+val2+');' );
    or better
    kprano.action.callee(val1,val2);

    krpano.call cant be avoided in every case, but it should be an exception

    here is some info on how to use the js api:
    https://krpano.com/docu/plugininterface/#top

  • Hi indexofrefraction!
    Thanks for the answer. My point is that I should pass an array.
    I read Action are limited to 99 params, that is a first limitation, and the second is that I don't know how to access params in a form of an array (like in JS: "args[idx]").
    Today, I have about 50 params (items in my array) but in production, it might go up to 10 000 000 items :P
    Regards

    « Quidquid latine dictum sit, altum sonatur »
    Pentax stuff.

Participate now!

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