MidnightCow Posted September 12, 2015 Share Posted September 12, 2015 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.. Quote Link to comment Share on other sites More sharing options...
GameMonetize Posted September 13, 2015 Share Posted September 13, 2015 Hello and welcome! the best option is to create a HTML IMG object to load your picture, write it into a canvas and then using texture coordinates you got from the picking read the color Quote Link to comment Share on other sites More sharing options...
Wingnut Posted September 15, 2015 Share Posted September 15, 2015 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! Quote Link to comment Share on other sites More sharing options...
MidnightCow Posted September 16, 2015 Author Share Posted September 16, 2015 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 Wingnut 1 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.