As a newcomer to Three.js and graphics in general, I've been on the lookout for a method to identify the highest and lowest visible points in a PNG image with transparency. I understand that graphics manipulation involves manipulating an array of pixels, so my approach would be to iterate through this array to find non-transparent pixels with the maximum and minimum y-axis values. Is there a specific feature in Three.js or perhaps even pure Javascript that can grant me access to this data (pixel array)? Alternatively, does the library offer a more direct way to achieve my objective?
The ultimate goal here is to vertically align the image based on its visible content.
Thank you!
- UPDATE -
Following @Paul Green's advice, I searched for material related to getImageData
in Three.js, which is used to extract a pixel array from a canvas context. My intention was to find a similar function within Three.js without involving the canvas element since my script doesn't utilize it. I'm seeking a solution that allows me to gather information before rendering the image. The idea of a Three.js dataTexture
seems promising, but I still need more clarity on how to implement it. Any guidance on this matter would be greatly appreciated!