@thi.ng/webgl
Version:
WebGL & GLSL abstraction layer
20 lines (19 loc) • 812 B
JavaScript
import { isNumber } from "@thi.ng/checks/is-number";
import { IDENT44 } from "@thi.ng/matrices/constants";
import { mulM44 } from "@thi.ng/matrices/mulm";
import { normal44 } from "@thi.ng/matrices/normal-mat";
import { ortho } from "@thi.ng/matrices/ortho";
const $ = (a, b, id) => a[id] || b[id]?.defaultVal || IDENT44;
const autoNormalMatrix1 = (model = "model") => (shaderU, specU) => normal44([], $(specU, shaderU, model));
const autoNormalMatrix2 = (model = "model", view = "view") => (shaderU, specU) => normal44(
null,
mulM44([], $(specU, shaderU, view), $(specU, shaderU, model))
);
function screen2d(a, b) {
return isNumber(a) ? ortho([], 0, a, b, 0, -1, 1) : ortho([], 0, a.drawingBufferWidth, a.drawingBufferHeight, 0, -1, 1);
}
export {
autoNormalMatrix1,
autoNormalMatrix2,
screen2d
};