From ad2776375379600364882b9515d049509509903b Mon Sep 17 00:00:00 2001 From: Syndamia Date: Mon, 28 Aug 2023 10:08:33 +0300 Subject: [WGL/P] Minor style changes and fixed level loading --- Year 2/Computer Graphics with WebGL/Project/Project.html | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) (limited to 'Year 2/Computer Graphics with WebGL/Project/Project.html') diff --git a/Year 2/Computer Graphics with WebGL/Project/Project.html b/Year 2/Computer Graphics with WebGL/Project/Project.html index 5708803..5379b6d 100644 --- a/Year 2/Computer Graphics with WebGL/Project/Project.html +++ b/Year 2/Computer Graphics with WebGL/Project/Project.html @@ -57,7 +57,8 @@ h2 { top: 0; padding: 0.5em; max-width: 24em; - max-height: calc(100vh - 0.5em); + max-height: calc(100vh - 2em); + overflow: auto; } #coordinates { left: 0; @@ -130,18 +131,21 @@ h2 { window.onresize = resizeglcanvas; var pauseAnimations = false; - var startT = -1; + var t = 0; function drawFrame() { - if (startT == -1) startT = Date.now(); - var t = Math.floor(Date.now() - startT) / 10; // tenths of a second + if (startT == -1) { startT = Date.now(); t = 0; } + var candidat = Math.floor(Date.now() - startT) / 10; // tenths of a second + if (pauseAnimations) startT += (candidat - t)*10; + else t = candidat; + gl.clear(gl.COLOR_BUFFER_BIT+gl.DEPTH_BUFFER_BIT); updateCamera(); gl.uniform3fv(uEye, pos); skybox.draw(); - if (!pauseAnimations) animations.forEach((a) => a(t)); + if (!pauseAnimations || t == 0) animations.forEach((a) => a(t)); stars.forEach((s) => s.draw()); requestAnimationFrame(drawFrame); -- cgit v1.3.1-26-gb76a