| 64915 | }; |
| 64916 | } |
| 64917 | function getArraySetter(functionName, toArray, size, uniformSetter) { |
| 64918 | var cache = null; |
| 64919 | var cacheLength = null; |
| 64920 | return function(gl, location, value) { |
| 64921 | var arrayValue = toArray(value, size); |
| 64922 | var length = arrayValue.length; |
| 64923 | var update = false; |
| 64924 | if (cache === null) { |
| 64925 | cache = new Float32Array(length); |
| 64926 | cacheLength = length; |
| 64927 | update = true; |
| 64928 | } else { |
| 64929 | (0, _utils.assert)(cacheLength === length, "Uniform length cannot change."); |
| 64930 | for(var i = 0; i < length; ++i)if (arrayValue[i] !== cache[i]) { |
| 64931 | update = true; |
| 64932 | break; |
| 64933 | } |
| 64934 | } |
| 64935 | if (update) { |
| 64936 | uniformSetter(gl, functionName, location, arrayValue); |
| 64937 | cache.set(arrayValue); |
| 64938 | } |
| 64939 | return update; |
| 64940 | }; |
| 64941 | } |
| 64942 | function setVectorUniform(gl, functionName, location, value) { |
| 64943 | gl[functionName](location, value); |
| 64944 | } |