UNPKG

2.11 kBSource Map (JSON)View Raw
1{"version":3,"file":"getUniformData.js","sources":["../../../src/shader/utils/getUniformData.ts"],"sourcesContent":["import { defaultValue } from './defaultValue';\nimport { mapType } from './mapType';\n\nimport type { IUniformData } from '../Program';\n\n/**\n * returns the uniform data from the program\n * @private\n * @param program - the webgl program\n * @param gl - the WebGL context\n * @returns {object} the uniform data for this program\n */\nexport function getUniformData(program: WebGLProgram, gl: WebGLRenderingContextBase): {[key: string]: IUniformData}\n{\n const uniforms: {[key: string]: IUniformData} = {};\n\n const totalUniforms = gl.getProgramParameter(program, gl.ACTIVE_UNIFORMS);\n\n for (let i = 0; i < totalUniforms; i++)\n {\n const uniformData = gl.getActiveUniform(program, i);\n const name = uniformData.name.replace(/\\[.*?\\]$/, '');\n\n const isArray = !!(uniformData.name.match(/\\[.*?\\]$/));\n\n const type = mapType(gl, uniformData.type);\n\n uniforms[name] = {\n name,\n index: i,\n type,\n size: uniformData.size,\n isArray,\n value: defaultValue(type, uniformData.size),\n };\n }\n\n return uniforms;\n}\n"],"names":["mapType","defaultValue"],"mappings":";;;;;;;AAYO,SAAA,cAAA,CAAwB,SAAuB,EACtD,EAAA;AACI,EAAA,MAAM,WAA0C,EAAC,CAAA;AAEjD,EAAA,MAAM,aAAgB,GAAA,EAAA,CAAG,mBAAoB,CAAA,OAAA,EAAS,GAAG,eAAe,CAAA,CAAA;AAExE,EAAA,KAAA,IAAS,CAAI,GAAA,CAAA,EAAG,CAAI,GAAA,aAAA,EAAe,CACnC,EAAA,EAAA;AACI,IAAA,MAAM,WAAc,GAAA,EAAA,CAAG,gBAAiB,CAAA,OAAA,EAAS,CAAC,CAAA,CAAA;AAClD,IAAA,MAAM,IAAO,GAAA,WAAA,CAAY,IAAK,CAAA,OAAA,CAAQ,YAAY,EAAE,CAAA,CAAA;AAEpD,IAAA,MAAM,UAAU,CAAC,CAAE,WAAY,CAAA,IAAA,CAAK,MAAM,UAAU,CAAA,CAAA;AAEpD,IAAA,MAAM,IAAO,GAAAA,eAAA,CAAQ,EAAI,EAAA,WAAA,CAAY,IAAI,CAAA,CAAA;AAEzC,IAAA,QAAA,CAAS,IAAQ,CAAA,GAAA;AAAA,MACb,IAAA;AAAA,MACA,KAAO,EAAA,CAAA;AAAA,MACP,IAAA;AAAA,MACA,MAAM,WAAY,CAAA,IAAA;AAAA,MAClB,OAAA;AAAA,MACA,KAAO,EAAAC,yBAAA,CAAa,IAAM,EAAA,WAAA,CAAY,IAAI,CAAA;AAAA,KAC9C,CAAA;AAAA,GACJ;AAEA,EAAO,OAAA,QAAA,CAAA;AACX;;;;"}
\No newline at end of file