Cache custom uniforms values to avoid setting them redundantly

Optimization is applied only to uniforms whose value is of type number in JS. Extending this to vector and matrix uniforms would be possible, but the returns are smaller.