Summary Files Commits Branches @commit @diff @stats
path: root / Year 2 / Computer Graphics with WebGL / Project / level.js
diff options
context:
space:
mode:
Commit034d9301fdd5cc70648e2cd9a6ae202b89eebe39 (patch)
Author
 Syndamia <kamen@syndamia.com>
2023-08-27 16:03:21 +0300
Committer
 Syndamia <kamen@syndamia.com>
2023-08-27 16:03:21 +0300
Files79e6b8a1434e5e515f056072bced53de6aea02e7 /Year 2/Computer Graphics with WebGL/Project/level.js
uni-projects-034d9301fdd5cc70648e2cd9a6ae202b89eebe39.tar
uni-projects-034d9301fdd5cc70648e2cd9a6ae202b89eebe39.tar.gz
uni-projects-034d9301fdd5cc70648e2cd9a6ae202b89eebe39.zip
Parentd8015a3653bb820f7df93660fe7dfa2368690312 (diff)
[WGL/P] Animation can now depend on time and changed first level so sun moves back and forth
1 files changed, 3 insertions, 3 deletions
-rw-r--r--Year 2/Computer Graphics with WebGL/Project/level.js6
diff --git a/Year 2/Computer Graphics with WebGL/Project/level.js b/Year 2/Computer Graphics with WebGL/Project/level.js
index 68eed7a..7f4120a 100644
--- a/Year 2/Computer Graphics with WebGL/Project/level.js
+++ b/Year 2/Computer Graphics with WebGL/Project/level.js
@@ -16,12 +16,12 @@ Level = function(name, description, cameraCoords) {
Level.prototype.addStar = function(center, size, animation) {
var star = new Star(center, size);
this.stars.push(star);
- if (animation) this.animations.push(() => star.moveTo(animation(star)));
+ if (animation) this.animations.push((t) => star.moveTo(animation(t, star)));
}
Level.prototype.addBlackHole = function(center, size, animation) {
var bh = new BlackHole(center, size);
this.blackHoles.push(bh);
- if (animation) this.animations.push(() => bh.moveTo(animation(bh)));
+ if (animation) this.animations.push((t) => bh.moveTo(animation(t, bh)));
}
Level.prototype.load = function() {
stars = this.stars;
@@ -35,6 +35,6 @@ function createLevels() {
"Star passing behind black hole",
"You can see how the black hole (correctly) warps the light of the star behind it when it passes",
[1000,0,650]);
- l1.addStar([1100,0,1000], 10, (star) => (vecSum(star.sphere.center, [-0.5,0,0])));
+ l1.addStar([1100,0,1000], 10, (t, star) => [1100 -100 * (1 + Math.sin(t/300 + 1.5 * Math.PI)),0,1000]);
l1.addBlackHole([1000,0,900], 30, undefined);
}