This commit is contained in:
Kbz-8
2024-02-12 18:34:01 +01:00
parent 54c4ae77f2
commit 7f26b839c3
3 changed files with 28 additions and 55 deletions

View File

@ -17,7 +17,7 @@ export default class extends AbstractView
this.gl = null;
this.shader_prog = null;
this.buffers = null;
this.cam_pos = [0, 10, 0];
this.cam_pos = [0, 1, 0];
this.cam_target = [0, 0, 0];
}
@ -68,16 +68,14 @@ export default class extends AbstractView
this.gl.depthFunc(this.gl.LEQUAL);
this.gl.clear(this.gl.COLOR_BUFFER_BIT | this.gl.DEPTH_BUFFER_BIT);
const fieldOfView = (90 * Math.PI) / 180;
const aspect = this.gl.canvas.clientWidth / this.gl.canvas.clientHeight;
const zNear = 0.1;
const zFar = 100.0;
const projectionMatrix = mat4.create();
const viewMatrix = mat4.create();
mat4.perspective(projectionMatrix, fieldOfView, aspect, zNear, zFar);
mat4.perspective(projectionMatrix, (90 * Math.PI) / 180, this.gl.canvas.clientWidth / this.gl.canvas.clientHeight, 0.1, 1000.0);
mat4.lookAt(viewMatrix, this.cam_pos, this.cam_target, [0, 1, 0]);
mat4.invert(viewMatrix, viewMatrix);
this.setPositionAttribute();
this.setNormalAttribute();
@ -95,8 +93,8 @@ export default class extends AbstractView
viewMatrix
);
this.game.draw(this.gl);
renderCube(this.gl, 0, 0, 0);
renderCube(this.gl, -2, -3, -10, 0, 5);
//this.game.draw(this.gl);
}
setNormalAttribute()
@ -147,7 +145,6 @@ export default class extends AbstractView
this.my_player.update_paddle(this.keys_pressed);
this.draw();
this.game?.time.new_frame();
// 1 sec fps
}, 1000 / 60);
}