MCPcopy Index your code
hub / github.com/microsoft/SandDance / toTypedArray

Function toTypedArray

docs/app/js/sanddance-app.js:64823–64839  ·  view source on GitHub ↗
(value, uniformLength, Type, cache)

Source from the content-addressed store, hash-verified

64821 0
64822];
64823function toTypedArray(value, uniformLength, Type, cache) {
64824 if (uniformLength === 1 && typeof value === "boolean") value = value ? 1 : 0;
64825 if (Number.isFinite(value)) {
64826 array1[0] = value;
64827 value = array1;
64828 }
64829 var length = value.length;
64830 if (length % uniformLength) (0, _gltools.log).warn("Uniform size should be multiples of ".concat(uniformLength), value)();
64831 if (value instanceof Type) return value;
64832 var result = cache[length];
64833 if (!result) {
64834 result = new Type(length);
64835 cache[length] = result;
64836 }
64837 for(var i = 0; i < length; i++)result[i] = value[i];
64838 return result;
64839}
64840function toFloatArray(value, uniformLength) {
64841 return toTypedArray(value, uniformLength, Float32Array, FLOAT_ARRAY);
64842}

Callers 3

toFloatArrayFunction · 0.70
toIntArrayFunction · 0.70
toUIntArrayFunction · 0.70

Calls 1

warnMethod · 0.45

Tested by

no test coverage detected