I am trying ThreeJS ray caster to get the object intersection color.
There are examples on finding the face color but my problem is to get the texture color of the point of intersection but outside the shader code. Object has a texture applied to it and color varies from pixel to pixel on the face of object.
Please suggest a way to get the point color.
thanks in advance
I don't know if it works with a 3D-Canvas, but you can get the image data of a canvas and determine the pixel color. Have a look at those questions:
getPixel from HTML canvas
How to get a pixel's x,y coordinate color from an image?
How to use JavaScript or jQuery to read a pixel of an image?
With this method you don't need to use the raycaster, only the mouse coordinates of the click event, assuming that you want to get the color at the point where you click.
Of course, if there is lighting in your scene, the color you'll get is the texture color affected by lighting.
Let me know, if it works.
I solved my current problem by using
- raycaster and finding the face color
- and then check for the range of color like
>Xval && <Yval
As in may case I need to just check for the color change and flag the user accordingly. Thank for the response @Brakebein