Picking causes a not working mouse and camera interaction

36 views
Skip to first unread message

Dominik Garrecht

unread,
Jun 25, 2012, 2:27:36 AM6/25/12
to phi...@googlegroups.com
Dear group users,

If I am going to activate picking in my scene, my user interaction (camera will be updated when the user changes his mouse position) will not work anymore. Everything works fine until I add the picking event (picking: true) to my event list. After adding it, picking works (it is combined with an onClick event. The objects in my scene are all "pickable: true". I tried to use "pick: true" in my event list, then my mouse camera interaction works, but picking doesn't work.

You can find my setup here: http://nopaste.piranho.de/1033.ac5.html

I need information about the model which was clicked. It's not important to get the exact pixel color.

Hopefully someone can help me!

Thanks,
Dominik

Nicolas Garcia Belmonte

unread,
Jun 26, 2012, 11:27:40 AM6/26/12
to phi...@googlegroups.com
Hi Dominik,

Thanks for your email. I think this happens because when enabling picking some events will only be triggered when they're applied to the pickable objects. So click mousemove mouseenter mouseleave will all be only triggered when this happens on top of a sphere for example. I think this is the issue.

A way to workaround this issue would be to add an event to the canvas element itself when the onLoad to update the mouse coordinates. So you could remove the onMouseMove handler and add:

onLoad: function(app) {
  //right before the basic gl setup
  canvas.addEventListener('mousemove', function(e) {
    //use e.clientX and e.clientY to update mouse coords
  }, false);
}

I hope this helps.
--
Nicolas Garcia Belmonte - http://philogb.github.com/
Reply all
Reply to author
Forward
0 new messages