Forums > Javascript

jit.gl.text2d created with javascript not working ?

August 30, 2010 | 3:13 pm

please help,
i have a simple stripped down javascript, that should write some text in a window with jit.gl.text2d.
i can see the axes of jit.gl.text2d, but not the text.
in the example below i include a jit.gl.gridshape just to show, that this one works fine.
any ideas?
thanks
klaus

autowatch = 1;
var window = new JitterObject("jit.window","thewin");
window.depthbuffer = 1;
window.idlemouse = 1;
var render = new JitterObject("jit.gl.render","thewin");
render.ortho = 2;
var tt,ss;

tt = new JitterObject("jit.gl.gridshape","thewin");
tt.scale = [0.1,0.1,0.1];
tt.position = [Math.random()-0.5,Math.random()-0.5,0];
tt.shape = "plane";
tt.lighting_enable = 1;
tt.smooth_shading = 1;

ss = new JitterObject("jit.gl.text2d","thewin");
ss.text = "ertz";
ss.size = 78;
ss.axes = 1;
ss.position = [Math.random()-0.5,Math.random()-0.5,0];

function bang()
{

render.erase();
render.drawclients();
render.swap();
}


August 30, 2010 | 8:31 pm

Sounds like a depth buffering issue. You may way to disable depth buffeting for your text object and explicitly render after the gridshape.

-Joshua


August 30, 2010 | 9:19 pm

i try ..
and turn off depth buffering here with depth_enable = 0
but the following still does not show my text:

autowatch = 1;
var window = new JitterObject("jit.window","thewin");
window.depthbuffer = 0;
window.idlemouse = 1;
var render = new JitterObject("jit.gl.render","thewin");
render.ortho = 2;
var ss;

ss = new JitterObject("jit.gl.text2d","thewin");
ss.text = "ertz";
ss.size = 78;
ss.axes = 1;
ss.depth_enable = 0;

function bang()
{

render.erase();
render.drawclients();
render.swap();
}


August 29, 2012 | 5:34 am

you can use ss.text("ertz"); syntax instead of ss.text = "ertz".
i had a same problem. i wish Max has more detail reference about javascript :)


August 30, 2012 | 3:56 pm

The difference between ss.text("foobar") and (say) ss.depth_enable=0 is that text is a message to jit.gl.text2d while depth_enable is an attribute.

This is actually all documented fairly clearly in the Max reference.

Javascript will, of course happily allow you to shoot yourself in the kneecap as much as you want, but that’s another story.

BTW, size is another message that you’re treating as an attribute in the posted code.

Always remember:

- Max messages are functions in Javascript
- Max attributes are attributes in Javascript (you can set and get using simple assignment)

Ignore those two rules at your own peril


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