|
Javascript Shift or Splice QuestionThis js works fine as is, just continues to fill the queue until potential fps death.... I am trying to insert a shift (or splice) so I can limit the queue size for the "points" array. I am having trouble and now my brain stopped working.... Help? { if(reset || result.points == undefined) result.points = new Array; if(draw) { var point = new Array; point[0] = inputX; point[1] = inputY; point[2] = inputZ; point[3] = lineWidth; transformPoint(point, xTheta*Math.PI/180, yTheta*Math.PI/180, zTheta*Math.PI/180); result.points.push(point); }
|
something like this?
Thanks very much, fsk.
Instead of:
if(result.points.length>lengthLimit)result.points.shift();
I had:
if(points.length>lengthLimit)result.points.shift();
sigh...
I think you might ALSO be able to do something like:
To get the count to back down after it's increased... I don't know, I didn't test it, because it's just a snippet.
Uhh, somewhere around here I have tons of compositions that do a queue with a splice function, that smokris introduced me to, which is basically:
Hey, thanks, George. Yeah, that splice method Smokris added to the dev js queue example -- I yanked it out of one of your comps along the way and have it on hand. Now that the syntax is in order with this one it's easy to swap out shift, splice, etc.