AAAAAAAAAAAAAAAAAAAAAAAAH

This commit is contained in:
Kbz-8
2024-02-10 19:38:56 +01:00
parent f9e9538159
commit 54c4ae77f2
8 changed files with 134 additions and 93 deletions

View File

@ -0,0 +1,44 @@
import { shaderInfos } from "../3D/shaders.js"
function renderCube(ctx, x, y, z, angle = 0, sx = 1, sy = 1, sz = 1)
{
const modelMatrix = mat4.create();
mat4.translate(
modelMatrix,
modelMatrix,
[x, y, z]
);
mat4.rotate(
modelMatrix,
modelMatrix,
angle,
[0, 1, 1],
);
mat4.scale(
modelMatrix,
modelMatrix,
[sx, sy, sz]
);
const normalMatrix = mat4.create();
mat4.invert(normalMatrix, modelMatrix);
mat4.transpose(normalMatrix, normalMatrix);
ctx.uniformMatrix4fv(
shaderInfos.uniformLocations.modelMatrix,
false,
modelMatrix
);
ctx.uniformMatrix4fv(
shaderInfos.uniformLocations.normalMatrix,
false,
normalMatrix,
);
ctx.drawElements(ctx.TRIANGLES, 36, ctx.UNSIGNED_SHORT, 0);
}
export { renderCube };