i need help with webgl.
i draw a simple cube and apply texture on each face of cube,and i am rotating the texture on the each face of the cube but the problem is:
the texture does not rotate around itself it rotate's around left bottom corner of the cube:
here is my code relative to rotation :
in the vertex shader :
vTextureCoord = ((uTMatrix) * vec4(aTextureCoord, 0.0 , 1.0)).xy;
in the script:
mat4.identity(TMatrix);
mat4.rotate(TMatrix,xRot3, [0.0, 0.0, 1.0]);
See this article and maybe this one
Rotation is always around 0,0 so if you want to rotate around some other point you need to move stuff to 0,0 first then in your case you need to move it back
Note, I always look at matrix backward. I start with the vertices of the cube and then consider applying each matrix. But, most matrix math libraries are such that the last matrix applied is the first one applied to the vertices.
On other words to me these 3 lines
mean
Note how that's the opposite order of the code but it's effectively what happens.
Other people look at the matrices as "transforming the space" in which case it can be interpreted in order