OutputMatrix in Javascript (jit.gl.text)
Hi !
Is it possible to "OutputMatrix" of Jit.gl.text inside Javascript ?
I saw "matrixCalc" but I don't know if it's the right thing and I don't understand the syntax...
well, I post a patch with what I try to achieve in javascript...
Overall, I just want the OutputMatrix of jit.gl.text out of the outlet of the js object...
Thank's !
it's a little tricky, but possible. you have to create a JitterListener object to listen for the matrixoutput events.
for your case, i would modify the script to create a single jit.gl.text object, and instead store an array of matrices when you receive them in the callback function.
autowatch = 1
//create arrays for text
add_letters=[]
add_graph=[]
//erase all text
function clear() {
add_letters=[]
add_graph=[]
}
var letters = new JitterObject("jit.gl.text","ctx");
var lstnr = new JitterListener(letters.name, callbackfun);
letters.position=[0.,0.,0.]
letters.mode=("3d")
letters.matrixoutput=(1)
letters.automatic = 0;
//insert text
function letter(l) {
add_letters.push(String.fromCharCode(l));
letters.text(String.fromCharCode(l))
letters.drawraw();
}
function callbackfun(event)
{
if (event.eventname == "matrixoutput") {
// create javascript matrix from matrixoutput event arg
var lmat = new JitterMatrix(event.args[0]);
add_graph.push(lmat);
post(event.args[0]+"\n");
outlet(0, "jit_matrix", event.args[0]);
}
}
callbackfun.local = 1;
Thank's a lot Rob !
I'll study this...