BufferedGeometry UV calculation and texture assignment

Hello,
I’m trying to assign texture to 2D shaped BufferedGeometry.
But texture won’t show please refer to this fiddle https://jsfiddle.net/likwifi/dpvrbo6x/2/
My UV calculation code is basically x and y coordinate divided by shapes min and max values.

Thanks in advance.

Updated fiddle: https://jsfiddle.net/w6egporb/

Your function setUV() was slightly wrong. When you open the browser’s dev console, you can actually see WebGL warnings produces by your incorrectly generate uv buffer.

BTW: It’s not recommended to access the array property of BufferAttribute. Instead, use methods like getX() or getY() since these methods properly compute the stride/offset values for the buffer access.

4 Likes