From 50c88908b6ce38fd689360718e0a4f4307096d71 Mon Sep 17 00:00:00 2001 From: Tyler Murphy Date: Thu, 19 Jan 2023 14:58:43 -0500 Subject: [PATCH] fix projection --- public/cube.js | 6 ++++-- public/gl/core/Renderer.js | 2 +- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/public/cube.js b/public/cube.js index 631591d..0f25fb6 100644 --- a/public/cube.js +++ b/public/cube.js @@ -14,10 +14,12 @@ const main = () => { var Mesh = GL.Cube() var Cube = new GL.Entity(Mesh) - Cube.position.z = 3; + Cube.position.z = 10 Scene.add(Material, Cube) - + + Renderer.FOV = 70 + GL.Loop(() => { Renderer.draw(Scene, Camera) Cube.rotation.add(new GL.Vec3(1,1,1)) diff --git a/public/gl/core/Renderer.js b/public/gl/core/Renderer.js index 7c96379..38a7974 100644 --- a/public/gl/core/Renderer.js +++ b/public/gl/core/Renderer.js @@ -67,7 +67,7 @@ export class Renderer { const tanHalfFovy = Math.tan((this.FOV * (Math.PI/180))/ 2.0); const aspect = canvas.width / canvas.height - d[0] = 1.0 / (aspect / tanHalfFovy) + d[0] = 1.0 / (aspect * tanHalfFovy) d[5] = 1.0 / tanHalfFovy d[10] = this.FAR / (this.FAR - this.NEAR) d[11] = 1.0