UNPKG

rabbit-ear

Version:
53 lines (49 loc) 1.18 kB
/* Rabbit Ear 0.9.4 alpha 2024-04-20 (c) Kraft, GNU GPLv3 License */ import { multiplyMatrices4, identity4x4 } from '../../math/matrix4.js'; import { parseColorToWebGLColor } from '../general/colors.js'; const makeUniforms = ({ projectionMatrix, modelViewMatrix, frontColor, backColor, outlineColor, strokeWidth, opacity, }) => ({ u_matrix: { func: "uniformMatrix4fv", value: multiplyMatrices4( projectionMatrix || identity4x4, modelViewMatrix || identity4x4, ), }, u_projection: { func: "uniformMatrix4fv", value: projectionMatrix || identity4x4, }, u_modelView: { func: "uniformMatrix4fv", value: modelViewMatrix || identity4x4, }, u_frontColor: { func: "uniform3fv", value: parseColorToWebGLColor(frontColor || "gray"), }, u_backColor: { func: "uniform3fv", value: parseColorToWebGLColor(backColor || "white"), }, u_outlineColor: { func: "uniform3fv", value: parseColorToWebGLColor(outlineColor || "black"), }, u_strokeWidth: { func: "uniform1f", value: strokeWidth !== undefined ? strokeWidth : 0.05, }, u_opacity: { func: "uniform1f", value: opacity !== undefined ? opacity : 1, }, }); export { makeUniforms };