user1672022
user1672022

Reputation: 21

tQuery event handler on cube

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

Answers (1)

Jerome Etienne
Jerome Etienne

Reputation: 387

tQuery('cube').on('click', function(e){});

this should do it

Upvotes: 1

Related Questions