Summary Files Commits Branches @commit @diff @stats
path: root / Year 2 / Computer Graphics with WebGL / Project / Project.html
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/Project.html
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, 4 insertions, 1 deletions
-rw-r--r--Year 2/Computer Graphics with WebGL/Project/Project.html5
diff --git a/Year 2/Computer Graphics with WebGL/Project/Project.html b/Year 2/Computer Graphics with WebGL/Project/Project.html
index 202b01c..c4d090c 100644
--- a/Year 2/Computer Graphics with WebGL/Project/Project.html
+++ b/Year 2/Computer Graphics with WebGL/Project/Project.html
@@ -124,15 +124,18 @@ h2 {
window.onresize = resizeglcanvas;
var pauseAnimations = false;
+ var startT = -1;
function drawFrame()
{
+ if (startT == -1) startT = Date.now();
+ var t = Math.floor(Date.now() - startT) / 10; // tenths of a second
gl.clear(gl.COLOR_BUFFER_BIT+gl.DEPTH_BUFFER_BIT);
updateCamera();
gl.uniform3fv(uEye, pos);
skybox.draw();
- if (!pauseAnimations) animations.forEach((a) => a());
+ if (!pauseAnimations) animations.forEach((a) => a(t));
stars.forEach((s) => s.draw());
requestAnimationFrame(drawFrame);