I have created a simple robot in webgl with cubes and now i want to rotate one "leg" around a point. But the leg is rotating around its origin. I want to rotate it around the point that connects with the body. I dont understand how to do it. How i am supposed to use translations and rotations outside of a push/pop when these translations will change the center of the world for the cubes i want to draw later on?? A little help would be appreciated. Thanks.
One way is using a matrIx stack
Basically you need to translate the object so it's center point is at the origin, rotate, then translate it back
push(); rotateY(frameCount*0.01); translate(-100, 0, 0); sphere(10); pop();
This is literally your entire code, this is literally ALL you need, that link in the other answer is almost entirely useless. This code will do the job.