Jump to content

Determine objects at pixel coordinates


mtycholaz
 Share

Recommended Posts

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?

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...