Forums > Jitter

"draw" message to jit.gl.text3d via JS?


zlp
July 17, 2008 | 7:52 pm

Hi. I’m working on an iterative text thing in javascript, and I would like to use a single jit.gl.text3d object @automatic 0 to draw hundreds of words to a texture and then pass it to the renderer when I’m done.

Before I get to all of the texture business, I can’t seem to pass a "draw" message to my text3d object via javascript. (works fine in the MAX GUI)

Here is a simplified js and patch to demonstrate (max 4.6):

———————
SAVE AS testscript.js
———————

outlets = 1;

var mycontext = jsarguments[1]; // the render context

function bang() {
outlet (0, "erase") // to renderer

// our humble object
text3dInstance = new JitterObject("jit.gl.text3d",mycontext);
text3dInstance.automatic = 0;
text3dInstance.align = 1;
text3dInstance.depth = 0;
text3dInstance.scale = [.2, .2, 1];

text3dInstance.position = [0, 0, 1];
text3dInstance.text("Where");
text3dInstance.draw(); // doesn’t seem to be drawing?

text3dInstance.position = [0, -0.2, 1];
text3dInstance.text("Am I?");
text3dInstance.draw(); // doesn’t seem to be drawing?

outlet (0, "bang") // to renderer
killme();
}

function killme() {
if (text3dInstance) {
text3dInstance.freepeer();
}
}

———————
The patch
———————

max v2;
#N vpatcher 436 83 1229 486;
#P window setfont "Sans Serif" 18.;
#P comment 498 104 212 196626 the (broken) JS way?;
#P button 451 155 15 0;
#P window setfont "Sans Serif" 9.;
#P message 31 157 35 196617 erase;
#P comment 107 133 262 196617 (Press from left to right to demonstrate message order);
#P message 413 156 33 196617 draw;
#P message 212 157 33 196617 draw;
#P message 321 157 86 196617 position 0 -0.2 1;
#P message 70 157 72 196617 position 0 0 1;
#P message 251 157 59 196617 text Am I?;
#P message 146 157 60 196617 text Where;
#P newex 85 192 314 196617 jit.gl.text3d test @align 1 @depth 0 @scale 0.2 0.2 1 @automatic 0;
#P newex 172 322 79 196617 jit.window test;
#P newex 173 296 187 196617 jit.gl.render test @erase_color 0 0 0 1;
#P button 542 153 15 0;
#P newex 542 179 100 196617 js testscript.js test;
#P window setfont "Sans Serif" 18.;
#P comment 172 100 142 196626 the MAX way…;
#P window setfont "Sans Serif" 9.;
#P comment 558 198 113 196617 "js testscript.js test";
#P fasten 8 0 6 0 256 182 90 182;
#P fasten 9 0 6 0 75 182 90 182;
#P fasten 7 0 6 0 151 182 90 182;
#P fasten 11 0 6 0 217 182 90 182;
#P fasten 10 0 6 0 326 182 90 182;
#P fasten 12 0 6 0 418 182 90 182;
#P fasten 2 0 4 0 547 265 178 265;
#P fasten 14 0 4 0 36 265 178 265;
#P fasten 15 0 4 0 456 265 178 265;
#P connect 3 0 2 0;
#P pop;


July 19, 2008 | 6:57 pm

Interesting, you should probably post that on the javascript forum?



zlp
July 20, 2008 | 1:15 am

Great idea. Now it’s here:
[URL]http://www.cycling74.com/forums/index.php?t=rview&th=34803&rid=4723[/URL]


Viewing 3 posts - 1 through 3 (of 3 total)