Sign in to follow this  
MidnightCow

Find meshs texture rgb value via PickingInfo?

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

 

 

 

 

Share this post


Link to post
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!

Share this post


Link to post
Share on other sites

Hi guys,

 

I think i replied to this in my head without actually replying!

 

Thanks for the suggestion Deltakosh, Wingnut that looks like a good start, i'm going to have a good at what you've did there and play around with it, will post here if i have any luck :)

Share this post


Link to post
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...
Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.