Brian - can you send me the latest version or can you confirm the latest
version is on the wiki? I'm getting an error about viewUP missing I think.

In terms of the solution, I think you might be able to surgically add some
code that doesn't require a complete rewrite:

Conceptually, I think this would work:

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


On Tue, Apr 29, 2014 at 2:41 PM, Brian Schott <[email protected]>wrote:

> I am sending you directly the more up to date files in a separate email.
>
> I am doubtful about fixing the javascript code alone because of the very
> convincing and long answer given by @gman.
>
> Thanks for the heads up regarding the bad link. I have fixed that.
>
> My imagination of a solution to this problem via J is to have function
> ev_command_enter_ajax(elements) send a fake event back to j. That fake
> event would contain a revised version of its argument "elements" that could
> be sent right back to javascript after the desired delay. The revision
> would behead the list of movement items and decrease the value of NUMBER
> embedded in it, before sending off the fake event. But the problem with
> that approach may be exactly what you are warning me about regarding
> browser security issues? I had not known about that.
>
>
> On Tue, Apr 29, 2014 at 1:56 PM, Raul Miller <[email protected]>
> wrote:
>
> >
> > A big issue with jhs is browser security. The browser has to deal with
> > every advertiser in the world wanting to get control of it. So web
> browsers
> > are somewhat selective about what they will retrieve. More specifically:
> it
> > will not accept anything from the web server except in response to a
> > request to that server. And that's something you are going to need to be
> > conscious of here.
> >
> > Thanks,
> >
> > --
> > Raul
> >
> >
> >
> >
>
> --
> (B=) <-----my sig
> Brian Schott
> ----------------------------------------------------------------------
> For information about J forums see http://www.jsoftware.com/forums.htm
>
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

Reply via email to