MCPcopy Create free account
hub / github.com/microsoft/SandDance / getArraySetter

Function getArraySetter

docs/app/js/sanddance-app.js:64917–64941  ·  view source on GitHub ↗
(functionName, toArray, size, uniformSetter)

Source from the content-addressed store, hash-verified

64915 };
64916}
64917function 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}
64942function setVectorUniform(gl, functionName, location, value) {
64943 gl[functionName](location, value);
64944}

Callers

nothing calls this directly

Calls 2

toArrayFunction · 0.70
setMethod · 0.45

Tested by

no test coverage detected