{
const uniforms = {
modelMatrix: modelMatrix,
viewMatrix: viewMatrix,
projMatrix: projMatrix,
offsets: offsetArray,
lightPosOrDir: lightParameters.lightType == "point"? [...lightPosition, 1] : [...lightDirection, 0],
eyePosition: m4.inverse(viewMatrix).slice(12, 15),
materialColor: hex2rgb(misc.materialColor),
ambientIntensity: misc.ambient / 100,
specularColor: hex2rgb(specularProperty.specularColor),
shininess: specularProperty.shininess,
K_s: specularProperty.K_s,
};
const bufferInfoArray = vertexAttributes.map((d)=>twgl.createBufferInfoFromArrays(gl, d));
gl.useProgram(programInfo.program);
gl.enable(gl.DEPTH_TEST);
gl.clear(gl.COLOR_BUFFER_BIT);
gl.clearColor(...hex2rgb(sceneParameters.color),1.0);
twgl.setUniforms(programInfo, uniforms);
bufferInfoArray.forEach((bufferInfo)=> {
twgl.setBuffersAndAttributes(gl, programInfo, bufferInfo);
twgl.drawBufferInfo(gl, bufferInfo, gl.TRIANGLES, bufferInfo.numElements, 0, 3);
}
);
return gl.canvas;
}