Reputation: 21
I just started trying webgl with tQuery and well.. the simpliest code is:
var world = tQuery.createWorld().boilerplate().start();
var object = tQuery.createCube().addTo(world);
now I want to emit some data to node if there's been clicked on that cube, but it doesnt really work, I tried different versions like:
$('canvas').click(function(e){
socket.emit('foo', { msg: 'cube clicked'});
});
up to
$(tQuery('cube')).on('click', function(e){
socket.emit('foo', { msg: 'cube hovered'});
});
but it's not only triggered if I click on the cube, it's also triggered if I click beside the cube -> it's triggered if I click anywhere on the tQuery surface
how to solve that?
greets
Upvotes: 2
Views: 168
Reputation: 387
tQuery('cube').on('click', function(e){});
this should do it
Upvotes: 1