In reading through this, in your second Update 0, I noticed that you had a
youtube link that looked like
https://www.youtube.com/edit?o=U&video_id=YeLNbD0BpqA but this is an "edit"
link so only works for you. For other people to use it you should probably
instead use something like
http://www.youtube.com/watch?v=YeLNbD0BpqA&t=1m34s
I then entered your function definitions from the big quoted block (and I
had to skip the first line, which read
"drawTurtles(linecolors,moves,leftColors,rightColors,backColors,bottoms,lefts,rights,backs,bottomNs,leftNs,rightNs,backNs);").
And I then I put a <canvas id="glcanvas" width="640" height="480"></canvas>
onto the page and entered your first setInterval command
(setInterval(drawPrimitive, 1000/2);). This resulted in a stream of 'gl is
not defined' errors.
So I fixed that, by running
gl= document.getElementById('glcanvas').getContext('webgl');
and then running init();
But then I ran into: getTextContent is not defined
followed by a stream of aCoords is not defined errors.
So... then I went to a copy of tgjhs.ijs that I had downloaded earlier and
extracted your shaders from there, and added them to the page:
<script type="x-shader/x-vertex" id="vshader"> attribute vec3 coords;
uniform mat4 modelview; uniform mat4 projection; uniform bool lit; uniform
vec3 normal; uniform mat3 normalMatrix; uniform vec4 color; uniform vec4
linecolor; varying vec4 vColor; void main() { vec4 coords =
vec4(coords,1.0); vec4 transformedVertex = modelview * coords; gl_Position
= projection * transformedVertex; if (lit) { vec3 unitNormal =
normalize(normalMatrix*normal); float multiplier = abs(unitNormal.z);
vColor = vec4( multiplier*color.r, multiplier*color.g, multiplier*color.b,
color.a ); } else { vColor = color; } } </script> <script
type="x-shader/x-fragment" id="fshader"> precision mediump float; varying
vec4 vColor; void main() { gl_FragColor = vColor; } </script>
and, while I was at it, I brought over your definition of getTextContent
and defined that, and re-ran init. Still no good, so I brought over
createProgram, defined that and re-ran init.
That leaves me with:
Failed to execute 'uniform4fv' on 'WebGLRenderingContext': The 2nd argument
is not an Array.
Um... ok, no data.
Ok, time for another approach.
The copy I have of tgsjhs is from over a week ago (April 20). Can you tell
me if that matches the content of the stack overflow question?
I know how I think I would solve the question which I think you are asking
(I'd use setInterval just like you specified in your stack overflow
question), but I think I need to have a complete example of your code in
front of me to make progress (and I will probably have. I would not use
6!:3 in J (that could be made to work but the underlying changes on the
client side would be radical).
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
On Tue, Apr 29, 2014 at 12:14 PM, Brian Schott <[email protected]>wrote:
> In my turtle graphics app "tgsjhs" I am currently unable to achieve any
> smooth animation of turtle moves. I have had and extensive conversation on
> stackoverflow.com at the following link, and it looks as if I am incapable
> of using the javascript/jquery side to accomplish the desired animation, so
> I am looking for ideas here for accomplishing the desired animation in J
> and its interaction via JS scripts.
>
>
> http://stackoverflow.com/questions/23313863/apply-setinterval-to-what-function/23326041#23326041
>
> At present, the relevant j code is as follows. NUMBER contains the number
> of (animation) steps that turtle(s) have already undertaken from the
> beginning of the simulation. Each time a "command" is "entered" in the
> system, NUMBER is incremented as many times as needed according to the
> various turtle movements, and each such movement is added to the list named
> PENDING. So PENDING is a list containing NUMBER number of items which at
> present are all processed without delay by the webgl code each time a
> "command" is entered. My goal is to force a short delay between each of
> those items being processed by inserting a delay using 6!:3.
>
> I may not have provide enough information, but can I get some help in how
> to accomplish this? I especially don't know how to write more javascript
> and maybe more j to break this process up into more steps.
>
> (Actually it would be better still if a hybrid of this definition were
> possible: if the *existing* list items were executed at once as they
> currently are, and only the newest additions to NUMBER in the list group
> were animated. But that is extra credit. You see, each "command" may
> increment NUMBER and PENDING more than once.)
>
> ev_command_enter=: 3 : 0
> PENDING=: ''
> NUMBER=: 0
> ". getv 'command'
> jhrajax (":NUMBER),JASEP,viewXYZ,JASEP,viewUP,JASEP,}.PENDING
> )
>
> And at present the pieces of JS in the app are as follows.
>
> function ev_command_enter(){jdoajax(["command"],"");}
>
> function ev_command_enter_ajax(elements)
> {
> var number = elements[0];
> viewXYZ = elements[1];
> viewUP = elements[2];
> for(var r = 0; r < number; r++) {
> var ts = [];
> for(var i = 0; i < 13; i++) {
> element = r*13+i+3;
> ts.push(elements[element]);
> }
> linecolor=eval(ts[0]);
> linecolors = linecolors.concat(linecolor);
> move=eval(ts[1]);
> moves = moves.concat(move);
> leftColors=eval(ts[2]);
> rightColors=eval(ts[3]);
> backColors=eval(ts[4]);
> bottoms=eval(ts[5]);
> lefts=eval(ts[6]);
> rights=eval(ts[7]);
> backs=eval(ts[8]);
> bottomNs=eval(ts[9]);
> leftNs=eval(ts[10]);
> rightNs=eval(ts[11]);
> backNs=eval(ts[12]);
> draw();
> }
> }
>
> Thanks,
>
> --
> (B=)
> ----------------------------------------------------------------------
> For information about J forums see http://www.jsoftware.com/forums.htm
>
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm