summaryrefslogtreecommitdiff
path: root/public/gl/core
diff options
context:
space:
mode:
authorTyler Murphy <tylermurphy534@gmail.com>2023-01-18 23:44:45 -0500
committerTyler Murphy <tylermurphy534@gmail.com>2023-01-18 23:44:45 -0500
commit19ac1aee5d8fecb6d55d333dc5b209413e6d962c (patch)
tree8f59b02debd0995bfb204a9908987eaf95ba79e9 /public/gl/core
parentcube (diff)
downloadwebgl-19ac1aee5d8fecb6d55d333dc5b209413e6d962c.tar.gz
webgl-19ac1aee5d8fecb6d55d333dc5b209413e6d962c.tar.bz2
webgl-19ac1aee5d8fecb6d55d333dc5b209413e6d962c.zip
small changes
Diffstat (limited to 'public/gl/core')
-rw-r--r--public/gl/core/Entity.js3
-rw-r--r--public/gl/core/Renderer.js15
2 files changed, 11 insertions, 7 deletions
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,