I'm new to Three.js, and to graphics generally, and I have been looking for a way to find the topmost and bottommost visible points in a PNG with a transparent background. I know in a vague sense that much of graphics manipulation is done by understanding the image as an array of pixels, so I picture this to essentially be iterating through the array for non-transparent pixels with the largest and smallest y-axis values. What feature in Three.js - or perhaps straight Javascript - will give me access to this data (this array?), or is there an even more direct way to achieve my goal already built into the library?
My goal is to vertically center the image according to its visible contents.
Thanks!
- UPDATE -
Taking a leaf from @Paul Green, I did a search for Three.js content related to getImageData
(a function used to get a pixel array from a canvas context), hoping there was some equivalent function in Three.js. I'm looking for something that stays out of the canvas and in the Three.js (webGL) realm as I'm not using the canvas in my script. I'm also looking for something that can get the info before the image is rendered. So far, a Three.js dataTexture
looks related but I still don't exactly understand it or how to use it. Any guidance would be appreciated!