Pixel perfect touch or how to determine if a pixel of a sprite is transparent

Thanks again @stevetranby, you have been very helpful.

I have already seen the Synchronous glReadPixel in cocos2d-x-v3 discussion but I do not quite understand it. I am not sure how this code could be converted to JavaScript.

As for the Alexander’s Wong implementation, it is very interesting but again it is written in C++. From what I understand, draw() creates a custom command that executes a callback function, that executes the glReadPixels() function, which in turn stores the bytes in the _pixelBuffer, when the command is executed. Then we need getPixelValue() to get the actual value of the pixel. When is the correct time to execute getPixelValue(), or how do we know that the command has finished executing ?

Is there any implementation for JavaScript that uses this custom command callback ?

It would be perfect if there was a JavaScript solution that could then work through JSB…