UNPKG

760 BJavaScriptView Raw
1import { defaultValue } from './defaultValue.mjs';
2import { mapType } from './mapType.mjs';
3
4function getUniformData(program, gl) {
5 const uniforms = {};
6 const totalUniforms = gl.getProgramParameter(program, gl.ACTIVE_UNIFORMS);
7 for (let i = 0; i < totalUniforms; i++) {
8 const uniformData = gl.getActiveUniform(program, i);
9 const name = uniformData.name.replace(/\[.*?\]$/, "");
10 const isArray = !!uniformData.name.match(/\[.*?\]$/);
11 const type = mapType(gl, uniformData.type);
12 uniforms[name] = {
13 name,
14 index: i,
15 type,
16 size: uniformData.size,
17 isArray,
18 value: defaultValue(type, uniformData.size)
19 };
20 }
21 return uniforms;
22}
23
24export { getUniformData };
25//# sourceMappingURL=getUniformData.mjs.map