Reputation: 6394
I have a Pjs sketch, which looks as follows:
void setup(){
//setup stuff among all, setup:
Graph graph = new Graph;
}
void update(String [] input){
//loop through the input update the Graph class
}
void draw(){
graph.display();
}
class Graph{
//setup graph
void update(String word){
//update graph with info
}
}
void display() {
// draw graph;
}
}
In javascript part I have the following (at some point):
processingjs.update(String);
So what's happening is that I sometimes the draw() loop does not get called and nothing shows up. However if I put graph.display(); into to the update() function the graph gets drawn consistently, however I loose certain flexibility that comes with running it in draw().
I wonder it an expected behavior and I should rewrite as if I am just using update to draw or should I try to move the update functionality into the draw loop (and call it from javascript)?
If I can provide extra info, please let me know. Any input greatly appreciated,
Thanks!
Upvotes: 1
Views: 258
Reputation: 6394
Actually solved this.
What I was doing is passing an array to processingjs.update() and then looping through it and updating my graph from within Processing.
The solution is to loop on Javascript side and send to Processing results one by one..
I think I kind of understand why that is so, but if I am wrong, please correct me.
Upvotes: 1