Sie sind nicht angemeldet.

Anoril

Schüler

  • »Anoril« ist der Autor dieses Themas

Beiträge: 69

Wohnort: Paris, France

Beruf: Game Developer and Photographer

  • Nachricht senden

1

Donnerstag, 31. Januar 2019, 11:09

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:

Quellcode

1
2
3
4
5
6
7
<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:

Quellcode

1
2
3
4
5
6
7
<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:


Quellcode

1
2
3
4
5
6
7
8
<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.

2

Donnerstag, 31. Januar 2019, 12:05

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

Dieser Beitrag wurde bereits 4 mal editiert, zuletzt von »indexofrefraction« (31. Januar 2019, 12:23)


Anoril

Schüler

  • »Anoril« ist der Autor dieses Themas

Beiträge: 69

Wohnort: Paris, France

Beruf: Game Developer and Photographer

  • Nachricht senden

3

Donnerstag, 31. Januar 2019, 18:54

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.