Forums > Javascript

newbie – need basic help to start.

July 29, 2009 | 10:05 am

Hello,

Could anyone show me how to retrieve screentoworld coordinates out of JS , pleeeease.

Thank you.

outlets = 2;

//GL
var win = new JitterObject("jit.window","coordinate");
win.idlemouse = 1;

var rend = new JitterObject("jit.gl.render","coordinate");
rend.erase_color = [0., 0., 0. ,1.];

/***********
var coords = rend.screentoworld();
outlet (0, coords)
**********/

//LISTENER
var listen = new JitterListener("coordinate", callbk);
function callbk(event)
{
var x,y;

if (event.eventname=="mouseidle")
{
x = event.args[0];
y = event.args[1];
outlet (1, x, y)
}
}

callbk.local = 1;

function bang()
{
rend.erase();
rend.drawclients();
rend.swap();
}


July 29, 2009 | 10:47 am

Yes, of course, the community is here for those kind of help.
It is really easy, just look:

outlets = 2;

//GL
var win = new JitterObject("jit.window","coordinate");
win.idlemouse = 1;

var rend = new JitterObject("jit.gl.render","coordinate");
rend.erase_color = [0., 0., 0. ,1.];

function bang()
{
rend.erase();
rend.drawclients();
rend.swap();
}

//LISTENER
var listen = new JitterListener("coordinate", callbk);
function callbk(event)
{
var x,y;
var getpos;

if (event.eventname=="mouseidle")
{
x = event.args[0];
y = event.args[1];
outlet (0, x, y)

getpos = rend.screentoworld(x,y);
outlet (1, getpos);
}

}

callbk.local = 1;


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