Joe, I tried your first idea and do not see a slowdown, and do not see lines drawn. The version using heavy_process does not work: when the app is initialized, no starting canvas appears. The version with a new drawlines() does not show any lines nor turtles.
I've got my fingers crossed something easy-ish works. Thanks, again, (Sent you files separately.) On Tue, Apr 29, 2014 at 3:57 PM, Joe Bogner <[email protected]> wrote: > > function drawLines(linecolors,moves) { > gl.lineWidth(2); > gl.uniform1i( uLit, 0 ); > for(var i=0;i<linecolors.length;i++) > { > var drawFrame = function() { drawPrimitive( gl.LINES, > linecolors[i], moves[i]); } > requestAnimationFrame(drawFrame); > } > gl.lineWidth(1); > } > > Fun other links: > > http://jsfiddle.net/calpo/H7EEE/ > > http://jsfiddle.net/ondras/xmCSY/ > > If you wanted to "slow down" the animation, you could probably steal this > function: > > function heavy_process(){ > var stoptime = 8; > var start = (new Date()).getTime(); > while((new Date()).getTime() - start < stoptime){ > // sleep > } > > > and then do: > > var drawFrame = function() { heavy_process(); drawPrimitive( gl.LINES, > linecolors[i], moves[i]); } > > instead of what was above > > I can try it if I had a running version > > I can't recall if requestAnimationFrame blocks or not. If it doesn't block, > then you'll need to restructure your code or just pass a callback in > > This could be as simple as: > > function > > drawTurtles(linecolors,moves,leftColor,rightColor,backColor,bottom,left,right,back,bottomNs,leftNs,rightNs,backNs){ > gl.uniform1i( uLit, 0 ); > > var after = function() { > bottomColor = [ 1,1,1,0]; > gl.uniform1i( uLit, 1 ); > for(var i=0;i<leftColor.length;i++) > { > gl.uniform3f( uNormal, leftNs[i][0],leftNs[i][1],leftNs[i][2]); > drawPrimitive( gl.TRIANGLES, leftColor[i], left[i]); > gl.uniform3f( uNormal, rightNs[i][0],rightNs[i][1],rightNs[i][2]); > drawPrimitive( gl.TRIANGLES, rightColor[i], right[i]); > gl.uniform3f( uNormal, backNs[i][0],backNs[i][1],backNs[i][2]); > drawPrimitive( gl.TRIANGLES, backColor[i], back[i]); > gl.uniform3f( uNormal, > -bottomNs[i][0],-bottomNs[i][1],-bottomNs[i][2]); > drawPrimitive( gl.TRIANGLES, bottomColor, bottom[i]); > } > > } > drawLines(linecolors,moves, after) > } > > Then your drawLines becomes: > > function drawLines(linecolors,moves, callback) { > gl.lineWidth(2); > gl.uniform1i( uLit, 0 ); > for(var i=0;i<linecolors.length;i++) > { > var drawFrame = function() { > heavy_process(); > drawPrimitive( gl.LINES, linecolors[i], moves[i]); > > //resume the rest of the drawing after the last frame is > drawn > if (i == linecolors.length-1) { callback(); } > } > requestAnimationFrame(drawFrame); > > } > gl.lineWidth(1); > } > > haven't tested > > > -- (B=) ---------------------------------------------------------------------- For information about J forums see http://www.jsoftware.com/forums.htm
