Your logic never works, not in the way you think it is. The update function rotates the lens objects, copies the rotation value to LFAngle, subtracts 180 if it's over 180, then displays it. It ONLY displays it. Every time the function is called, the lens objects just keep getting their rotation incremented by a fixed amount*, then that value is used to clobber the previous value of LFAngle. So the rotation just keeps going up and up and up. Beyond 180 degrees the displayed rotation has 180 subtracted, but it's still going up.
Imagine you wrote a function like this:
function update() {
rotation = 0;
angle = rotation;
angle += 10;
console.log(angle);
}
What do you think this would display when called repeatedly? 10, 20, 30, 40, 50..., or 10, 10, 10, 10, 10...?
*I've no idea why you're incrementing the rotation by 1/pi. Rotation is specified in degrees, not radians. You could just be incrementing by 1.
... View more