Summary Files Commits Branches @commit @diff @stats
diff options
context:
space:
mode:
Commite30cf6167ef469413055075d8413e33c75714f08 (patch)
Author
 Syndamia <kamen@syndamia.com>
2023-08-28 15:12:42 +0300
Committer
 Syndamia <kamen@syndamia.com>
2023-08-28 15:12:42 +0300
Files709aaaab077c37bb64c80b614383f6a9cf7473f4
uni-projects-e30cf6167ef469413055075d8413e33c75714f08.tar
uni-projects-e30cf6167ef469413055075d8413e33c75714f08.tar.gz
uni-projects-e30cf6167ef469413055075d8413e33c75714f08.zip
Parentc73c206450d22c9ada83b8026588c1bdf0a7e10f (diff)
[WGL/P/level] Added three more levels
diff --git a/Year 2/Computer Graphics with WebGL/Project/level.js b/Year 2/Computer Graphics with WebGL/Project/level.js
index 83311c0..ffba652 100644
--- a/Year 2/Computer Graphics with WebGL/Project/level.js
+++ b/Year 2/Computer Graphics with WebGL/Project/level.js
@@ -113,4 +113,37 @@ function createLevels() {
[1014,0,892]);
l2.addStar([1070,0,1000], 10, (t, star) => vecSum(star.center, [-t,0,0]));
l2.addBlackHole([1000,0,900], 30, undefined);
+
+ var l3 = new Level(
+ "Star behind black hole",
+ "The star is behind the black hole and it's going fruther away from the camera and then closer. The star itself is always much smaller than the center of the black hole (that swallows all light), but we can still see parts of it thanks to the gravitational lensing.",
+ [1000,0,650]);
+ l3.addStar([1000,0,1000], 10, (t, star) => vecSum(star.center, [0,0,-36 * (1 + Math.sin(t/10 + 1.5 * Math.PI))]));
+ l3.addBlackHole([1000,0,900], 30, undefined);
+
+ var l4 = new Level(
+ "Star, orbiting a black hole",
+ "We can see how if we look at a star, orbiting the black hole, from an angle, we'll see the bottom and top part of the distorted light be disjoint and how the bottom part moves in the opposite direction to the orbit.",
+ [1000,0,650]);
+ var speed = Math.PI / 20, rad = 40;
+ l4.addStar([1000+rad,0,900], 3,
+ (t, star) => vecSum([1000,0,900], [Math.cos(t*speed) * rad,
+ Math.sin(t*speed) * 5,
+ Math.sin(t*speed) * rad]));
+ l4.addBlackHole([1000,0,900], 35, undefined);
+
+ var l5 = new Level(
+ "Star ring orbiting around the black hole",
+ "Similarly to a black hole with an accretion disk, like the one in the movie Interstellar, we can see how it looks as if the stars in the back warp and hop over the black hole, and how there is something of a half-circle on the bottom of the black hole, that starts from behind it.",
+ [1000,0,650]);
+ speed = Math.PI / 10;
+ for (var i = 0; i < 2 * Math.PI; i += Math.PI / 7) {
+ // I'm kinda cheating here, since I use the star's coordinates to store i
+ // but passing i to the lambda function always passes by refrence, no matter what I do
+ l5.addStar([1000,i,900], 3,
+ (t, star) => vecSum([1000,0,900], [Math.cos(star.center[1] + t*speed) * rad,
+ Math.sin(star.center[1] + t*speed) * 5,
+ Math.sin(star.center[1] + t*speed) * rad]));
+ }
+ l5.addBlackHole([1000,0,900], 35, undefined);
}
diff --git a/Year 2/Computer Graphics with WebGL/Project/shaders.js b/Year 2/Computer Graphics with WebGL/Project/shaders.js
index 5dcc2ae..b6bdb19 100644
--- a/Year 2/Computer Graphics with WebGL/Project/shaders.js
+++ b/Year 2/Computer Graphics with WebGL/Project/shaders.js
@@ -1,4 +1,4 @@
-const STAR_MAX_COUNT = 5;
+const STAR_MAX_COUNT = 16;
const BLACKHOLE_MAX_COUNT = 5;
const STAR_COLOR = [0.956,0.5,0.215];