mtycholaz Posted March 19, 2014 Share Posted March 19, 2014 So this is a long shot, but I wanted to ask anyway. When a user moves the mouse cursor in the browser, the "mousemove" event. What I would like to do is pick a random x,y coordinate and determine what objects are "on/within" the given coordinate. Not sure if webgl has some tricks up it's sleeve to do this, or maybe I could create a mousemove event in javascript for a given coordinate, fire the event and see what bubbles. Looking for ideas. What I'm trying to shortcut is looping through world entities to find any close to the given coordinates. Thoughts? Quote Link to comment Share on other sites More sharing options...
mattdesl Posted March 20, 2014 Share Posted March 20, 2014 Take a look at the mouseDown method in interaction manager (dev branch, as it's changed). It just loops through display objects and hit-tests them (in reverse due to the way they get painted). Your method could use the same hitTest. There isn't really any fancier "trick". mattdesl 1 Quote Link to comment Share on other sites More sharing options...
mattdesl Posted March 20, 2014 Share Posted March 20, 2014 P.s. Pixi supports mousemove and touch move events, so you may be able to just listen to those. Quote Link to comment Share on other sites More sharing options...
mtycholaz Posted March 26, 2014 Author Share Posted March 26, 2014 Take a look at the mouseDown method in interaction manager (dev branch, as it's changed). It just loops through display objects and hit-tests them (in reverse due to the way they get painted). Your method could use the same hitTest.There isn't really any fancier "trick". This was going to be my fallback, but I wanted to see if there was a different solution. Quote Link to comment Share on other sites More sharing options...
xerver Posted March 27, 2014 Share Posted March 27, 2014 We don't use any kind of spatial partitioning in pixi.js, so there isn't any faster way besides brute forcing it. When the interaction manager rewrite comes around, maybe we will look into using something more efficient. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.