From 19ac1aee5d8fecb6d55d333dc5b209413e6d962c Mon Sep 17 00:00:00 2001 From: Tyler Murphy Date: Wed, 18 Jan 2023 23:44:45 -0500 Subject: small changes --- public/gl/core/Entity.js | 3 +++ public/gl/core/Renderer.js | 15 ++++++++------- 2 files changed, 11 insertions(+), 7 deletions(-) (limited to 'public/gl/core') diff --git a/public/gl/core/Entity.js b/public/gl/core/Entity.js index d0d6e4a..43ea87d 100644 --- a/public/gl/core/Entity.js +++ b/public/gl/core/Entity.js @@ -15,6 +15,9 @@ export class Entity { } tran() { + this.rotation.x %= 360; + this.rotation.y %= 360; + this.rotation.z %= 360; return new Mat4() .identity() .pos(this.position) diff --git a/public/gl/core/Renderer.js b/public/gl/core/Renderer.js index 32f5e9c..b3b2121 100644 --- a/public/gl/core/Renderer.js +++ b/public/gl/core/Renderer.js @@ -32,6 +32,10 @@ export class Renderer { canvas.height = window.innerHeight gl.viewport(0, 0, canvas.width, canvas.height) } + + this.FOV = 90 + this.FAR = 1000 + this.NEAR = .1 } draw(scene, camera) { @@ -57,17 +61,14 @@ export class Renderer { } proj() { - const fov = 90 - const far = 100 - const near = 0.1 const aspect = canvas.width / canvas.height - const f = 1.0 / Math.tan((fov * (Math.PI/180)) / 2) + const f = 1.0 / Math.tan((this.FOV * (Math.PI/180)) / 2) const fa = f / aspect - const nf = 1.0 / (near - far) + const nf = 1.0 / (this.NEAR - this.FAR) - const c1 = (near + far) * nf - const c2 = near * far * nf * 2 + const c1 = (this.NEAR + this.FAR) * nf + const c2 = this.NEAR * this.FAR * nf * 2 return new Mat4().set( fa, 0, 0, 0, -- cgit v1.2.3-freya