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

Function updateForTextures

docs/app/js/sanddance-app.js:77859–77908  ·  view source on GitHub ↗
(_ref)

Source from the content-addressed store, hash-verified

77857var SIZE_UNIFORM_PREFIX = "transform_uSize_";
77858var VS_POS_VARIABLE = "transform_position";
77859function updateForTextures(_ref) {
77860 var vs = _ref.vs, sourceTextureMap = _ref.sourceTextureMap, targetTextureVarying = _ref.targetTextureVarying, targetTexture = _ref.targetTexture;
77861 var texAttributeNames = Object.keys(sourceTextureMap);
77862 var sourceCount = texAttributeNames.length;
77863 var targetTextureType = null;
77864 var samplerTextureMap = {};
77865 var updatedVs = vs;
77866 var finalInject = {};
77867 if (sourceCount > 0 || targetTextureVarying) {
77868 var vsLines = updatedVs.split("\n");
77869 var updateVsLines = vsLines.slice();
77870 vsLines.forEach(function(line, index, lines) {
77871 if (sourceCount > 0) {
77872 var updated = processAttributeDefinition(line, sourceTextureMap);
77873 if (updated) {
77874 var updatedLine = updated.updatedLine, inject = updated.inject;
77875 updateVsLines[index] = updatedLine;
77876 finalInject = (0, _shadertools.combineInjects)([
77877 finalInject,
77878 inject
77879 ]);
77880 Object.assign(samplerTextureMap, updated.samplerTextureMap);
77881 sourceCount--;
77882 }
77883 }
77884 if (targetTextureVarying && !targetTextureType) targetTextureType = getVaryingType(line, targetTextureVarying);
77885 });
77886 if (targetTextureVarying) {
77887 (0, _webgl.assert)(targetTexture);
77888 var sizeName = "".concat(SIZE_UNIFORM_PREFIX).concat(targetTextureVarying);
77889 var uniformDeclaration = "uniform vec2 ".concat(sizeName, ";\n");
77890 var posInstructions = " vec2 ".concat(VS_POS_VARIABLE, " = transform_getPos(").concat(sizeName, ");\n gl_Position = vec4(").concat(VS_POS_VARIABLE, ", 0, 1.);\n");
77891 var inject1 = {
77892 "vs:#decl": uniformDeclaration,
77893 "vs:#main-start": posInstructions
77894 };
77895 finalInject = (0, _shadertools.combineInjects)([
77896 finalInject,
77897 inject1
77898 ]);
77899 }
77900 updatedVs = updateVsLines.join("\n");
77901 }
77902 return {
77903 vs: updatedVs,
77904 targetTextureType: targetTextureType,
77905 inject: finalInject,
77906 samplerTextureMap: samplerTextureMap
77907 };
77908}
77909function getSizeUniforms(_ref2) {
77910 var sourceTextureMap = _ref2.sourceTextureMap, targetTextureVarying = _ref2.targetTextureVarying, targetTexture = _ref2.targetTexture;
77911 var uniforms = {};

Callers

nothing calls this directly

Calls 3

getVaryingTypeFunction · 0.70
forEachMethod · 0.45

Tested by

no test coverage detected