3D working
This commit is contained in:
@ -14,7 +14,7 @@ function renderCube(ctx, x, y, z, angle = 0, sx = 1, sy = 1, sz = 1)
|
||||
modelMatrix,
|
||||
modelMatrix,
|
||||
angle,
|
||||
[0, 1, 1],
|
||||
[0, 1, 0],
|
||||
);
|
||||
|
||||
mat4.scale(
|
||||
@ -23,6 +23,12 @@ function renderCube(ctx, x, y, z, angle = 0, sx = 1, sy = 1, sz = 1)
|
||||
[sx, sy, sz]
|
||||
);
|
||||
|
||||
mat4.translate(
|
||||
modelMatrix,
|
||||
modelMatrix,
|
||||
[-1, 0, 0] // wtf, this works ?
|
||||
);
|
||||
|
||||
const normalMatrix = mat4.create();
|
||||
mat4.invert(normalMatrix, modelMatrix);
|
||||
mat4.transpose(normalMatrix, normalMatrix);
|
||||
|
@ -15,7 +15,7 @@ const vertex_shader_source = `
|
||||
|
||||
highp vec3 ambientLight = vec3(0.3, 0.3, 0.3);
|
||||
highp vec3 directionalLightColor = vec3(1, 1, 1);
|
||||
highp vec3 directionalVector = normalize(vec3(1, 15, -1.75));
|
||||
highp vec3 directionalVector = vec3(-10, 2, -10);
|
||||
|
||||
highp vec4 transformedNormal = uNormalMat * vec4(aNormal, 1.0);
|
||||
|
||||
|
Reference in New Issue
Block a user