From e30cf6167ef469413055075d8413e33c75714f08 Mon Sep 17 00:00:00 2001 From: Syndamia Date: Mon, 28 Aug 2023 15:12:42 +0300 Subject: [WGL/P/level] Added three more levels --- .../Computer Graphics with WebGL/Project/level.js | 33 ++++++++++++++++++++++ 1 file changed, 33 insertions(+) (limited to 'Year 2/Computer Graphics with WebGL/Project/level.js') 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); } -- cgit v1.3.1-26-gb76a