Jump to content

Find meshs texture rgb value via PickingInfo?


MidnightCow
 Share

Recommended Posts

Hi there,

 

I'm literally brand new to WebGL and BabylonJS ( although already a programmer and 3d artist ), but having a lot of fun learning it, great job on the engine/api so far guys.

 

What i'm trying to figure out, is if there is a way to discover the rgb texture value where the mouse has been clicked..

 

Having a look at PickingInfo, it looks as though getTextureCoordinates() might be used to read the position on a bitmap texture for example ( just wild theories at this point of course ), although i can see no way to access the rgb data of a bitmap or texture object anywhere in the Babylon API.  Any idea if this might be possible?

 

Basically what i'm trying to achieve is - i have an object, with a texture on it, and i would like the user to be able to click on different parts of the object to make stuff happen.  So i was thinking, if the texture had say a blue area, the user clicks on the blue, it does something, they click on a red part, it does something else..

 

The other more obvious way i think to achieve this would be to either break the object up into separate clickable meshes and go from there, or have invisible hotspot meshes that detected clicks in specific areas..  But i just wanted to try and figure out if this would be possible.  Texture hotspots based on colour would be a handy thing to have for general interactivity..

 

 

 

 

Link to comment
Share on other sites

Hi guys.  I was goofing around with this a bit...  http://playground.babylonjs.com/#2KUCI

ref:  https://developer.mozilla.org/en-US/docs/Web/API/Canvas_API/Tutorial/Pixel_manipulation_with_canvas

I have a colorful diffuseTexture on the ground, and that same image is used in a memory-only canvas... but I just can't get the data members to show anything but 0 0 0 0 for a picked color.  This is my first time trying this, so mistakes are almost certain.  Help/discoveries welcome.  Thanks!

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...