hi i want to create a js which creates an sketch object with drawing triangels by hand. my problem is, i couldn’t figure out how to create them in js. with jit tutorial 40 an 47. but there are no sketch objects. thanks
mysketch.shape = ["tri",x....z] doesent work
thanks for your help
At work at mo, so can’t try it, but here’s some example code using gridshape that might help you:
obj = new JitterObject( "jit.gl.gridshape", dest );
obj.shape = "plane";
obj.scale = [ 0.095, 0.040, 1 ];
obj.color = [ 0.3, 0.3, 0.3, 1 ];
obj.position = render.screentoworld( x, y );
i think if you add:
obj.gridmode = 1;
it will output triangles, but not sure as I’ve only used this for drawing quads.
not sure what the performance is either using sketch against shape, would be interested to know.
anyway, hope this helps you figure out what you need
This is the same construct i am using for creating spheres and cubes. The problem is, i know how to create the jitter sketch object
sketch = new JitterObject("jit.gl.sketch",dest);
but i didnt know how to access it to draw an triangle. this doesnt work.
sketch.shape = ["tri",x....z];
and i didnt find anything to this at the help
and jit tutorial 40
try this (off my head)
sketch.glbegin( "triangles" );
sketch.glcolor( … );
sketch.glvertex( v1 );
sketch.glvertex( v2 );
sketch.glvertex( v3 );
yeah leehu, many thanks it is working now.
also, make sure you understand the difference between calling messages and setting attributes on Jitter objects in js.
"position" is an attribute of gl.sketch, so you set it like this:
sketch.position = [0, 0, 0];
"gltranslate" is a message to gl.sketch, which means it’s an object method in js, and called like this:
sketch.gltranslate(0, 1, 0);
thanks for this explanation.