Summary Files Commits Branches @commit @diff @stats
path: root / Year 2 / Computer Graphics with WebGL / Project / spaceship.js
diff options
context:
space:
mode:
Commit46ee648fff31004221d307d0af9cabc0c4250a4c (patch)
Author
 Syndamia <kamen@syndamia.com>
2023-08-27 12:01:37 +0300
Committer
 Syndamia <kamen@syndamia.com>
2023-08-27 12:01:37 +0300
Files5c2041dec852318c1ba7ddb16f43abbeb942b53d /Year 2/Computer Graphics with WebGL/Project/spaceship.js
uni-projects-46ee648fff31004221d307d0af9cabc0c4250a4c.tar
uni-projects-46ee648fff31004221d307d0af9cabc0c4250a4c.tar.gz
uni-projects-46ee648fff31004221d307d0af9cabc0c4250a4c.zip
Parent87e9c9fa25b21bec3a658dcebc6c765a511d838e (diff)
[WGL/P] Minor formatting and naming changes
1 files changed, 4 insertions, 4 deletions
-rw-r--r--Year 2/Computer Graphics with WebGL/Project/spaceship.js8
diff --git a/Year 2/Computer Graphics with WebGL/Project/spaceship.js b/Year 2/Computer Graphics with WebGL/Project/spaceship.js
index 3f88b69..cb3b548 100644
--- a/Year 2/Computer Graphics with WebGL/Project/spaceship.js
+++ b/Year 2/Computer Graphics with WebGL/Project/spaceship.js
@@ -15,6 +15,7 @@ SphericalCoord.prototype.recalculateCartesian = function() {
Math.sin(this.theta) * Math.cos(this.phi)];
}
SphericalCoord.prototype.addAngles = function(theta, phi) {
+ // I figured this out on my own :)
// Theta is in the range [0, pi), however in a sphere we have 2pi degrees.
// We keep a "full" theta, which is in the range [0, 2pi), and then adjust normal theta
// accordingly. With just normal theta, after a positive value is passed (for example)
@@ -25,7 +26,6 @@ SphericalCoord.prototype.addAngles = function(theta, phi) {
// pi and 2pi, you need to rotate phi by 180 degrees (2pi), so theta is acting on the other
// hemisphere, and then we need to remove from 2pi the "leftover" amount, since our theta
// would signify the "reverse" angle than the one we want.
- // Special thanks for interactive applet: https://mathinsight.org/spherical_coordinates
var before = this.fulltheta <= Math.PI;
this.fulltheta = (this.fulltheta + theta) % (2 * Math.PI);
@@ -84,7 +84,7 @@ var keyAction = [
() => { pos = vecSum(pos, left.toCartesian()); }, // 'a'
() => { pos = vecSub(pos, left.toCartesian()); }, // 'd'
];
-document.addEventListener("keydown", (event) => {
+document.addEventListener('keydown', (event) => {
if (isPaused) return;
switch (event.key) {
@@ -96,7 +96,7 @@ document.addEventListener("keydown", (event) => {
case 'd' : pressedKeys[5] = true; break;
}
});
-document.addEventListener("keyup", (event) => {
+document.addEventListener('keyup', (event) => {
if (isPaused) return;
switch (event.key) {
@@ -144,7 +144,7 @@ function mouseInit() {
/*
* On every draw
*/
-function lookUpdate() {
+function updateCamera() {
for (var i = 0; i < pressedKeys.length; i++)
if (pressedKeys[i]) keyAction[i]();
lookAt(pos, vecSum(pos, forward.toCartesian()), up.toCartesian());