Forums > Javascript

sending messages to jit.gl.sketch from javascript


Oct 24 2008 | 12:16 am

hello, isn’t it always the simple things that take the most time?

i have a simple patch that has a sketch object that i want to send opengl messages from inside a javascript object.

the problem i am having is such.

if i send the message "circle" it works fine however if i send the message "circle 2.0" the quotation marks are sent as well

jit.gl.sketch doesnt understand the quotes.

attached is the patch and the .js file any help would be most appreciated.

— Pasted Max Patch, click to expand. —

banger.js

inlets= 1;
outlets = 2;

function bang(){

outlet(0, "circle");
outlet(1, "circle 2.0");
}

Oct 24 2008 | 12:40 am

ive found a work around but its not an optimal solution any help would still be most welcome

check it out!

— Pasted Max Patch, click to expand. —

banger.js

inlets= 1;
outlets = 2;

function bang(){

outlet(0, "circle 0.2");
outlet(1, "bang");
}

Oct 24 2008 | 3:00 am

On Oct 23, 2008, at 5:16 PM, Aran wrote:

> outlet(1, "circle 2.0");

You want this to be:

outlet(1, "circle", 2.0);

Quotes make one big symbol containing all the text. Lists are
delimited with commas, rather than spaces in this setting. YOu can
also use jit.gl.sketch directly within JS if that’s easier for your
purposes.

-Joshua


dtr
Nov 01 2008 | 2:06 pm

tanx guys, had the exact same issue today…


dtr
Nov 05 2008 | 4:43 pm

Quote: jkc wrote on Thu, 23 October 2008 21:00
—————————————————-
>
>. YOu can also use jit.gl.sketch directly within JS if that’s easier for your
> purposes.
>
> -Joshua
>
—————————————————-

hey is there a sample/tutorial of that somewhere around? i’m making my first steps with GL in JS and it’s rather daunting…

Nov 10 2008 | 12:17 am

the jsui object has a built in sketch object (to draw your ui elements)
in the Max5.0examplesjavascript folder there is an example jsui_3dballs which uses the built in sketch object.

otherwise using the js object

you can get a reference to a sketch object that already exists in the patcher (or any object for that matter),
if you have set the scripting name of the object

in the inspector i have set the scripting name of a sketch object in my patch to "blipsketch"

then i can get it like this
// get the patcher object
p = this.patcher;

// get the sketch object
var mysketch = p.getnamed("blipSketch");
if (mysketch == null){
post("couldnt find sketch objectn");
}

//print out its properties

for(i in mysketch)
{
post("property: " + i + " = " + mysketch[i] + "n");
}

you can do this in a loadbang method or just chuck it in the file outside a method and it will get executed first.

once you have the sketch object you can draw into it as in this code snipet

with (mysketch) {
glpushmatrix();
glcolor (1.0, 0.0, 0.0);
torus (1.0, 0.1);
glpopmatrix();
}

ill post an example of creating a sketch object later.


dtr
Nov 12 2008 | 10:26 am

tanx! will dig into it

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

Forums > Javascript