From 4043cfb4eeed59aaf177bdfb6fa47aa5a6e7eb17 Mon Sep 17 00:00:00 2001 From: jkcuk <44874423+jkcuk@users.noreply.github.com> Date: Mon, 4 Mar 2024 12:42:06 +0000 Subject: [PATCH] Minor performance improvements --- main.js | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/main.js b/main.js index 194033e..598664b 100644 --- a/main.js +++ b/main.js @@ -109,6 +109,7 @@ function createInfo() { function setInfo(text) { // infotext = text; info.innerHTML = text; // infotext; + console.log(text); infotime = new Date().getTime(); setTimeout( () => { if(new Date().getTime() - infotime > 2999) info.innerHTML = `Relativistic Distortionist, University of Glasgow` }, 3000); } @@ -136,6 +137,9 @@ function animate() { // calculate the matrix that describes the correct distortion of the lookalike sphere updateTransformationMatrix(); + + // update uniforms related to FOV etc. + // updateUniforms(); // set the camera, either to the inside camera or the outside camera switch(camera) @@ -472,16 +476,16 @@ function updateTransformationMatrix() { let beta, gamma, theta, phi; if (beta2 >=1 ){ /* + // this approach doesn't work because of the way that the components of beta are set let beta0 = Math.sqrt(beta2); beta = 0.99; betaX *= beta/beta0; betaY *= beta/beta0; betaZ *= beta/beta0; - console.log(`Beta >= 1, scaling it to 0.99 (beta = (${betaX}, ${betaY}, ${betaZ}))`); + // console.log(`Beta >= 1, scaling it to 0.99 (beta = (${betaX}, ${betaY}, ${betaZ}))`); */ setWarning(true); - setInfo(`Warning: β (=${Math.sqrt(beta2)}) > 1; using previous value`); - console.log(`Warning: beta (=${Math.sqrt(beta2)}) > 1; using previous value`); + setInfo(`Warning: β (=${Math.sqrt(beta2).toFixed(2)}) > 1; using last value of β with |β| < 1`); } else { beta = Math.sqrt(beta2); gamma = 1/Math.sqrt(1-beta2); @@ -514,11 +518,10 @@ function updateTransformationMatrix() { lookalikeSphere.matrix.copy(transformationMatrix); if(shaderMaterial.uniforms.warning.value) { - setInfo(`β (=${Math.sqrt(beta2)}) < 1; all good!`); - console.log(`β (=${Math.sqrt(beta2)}) < 1; all good!`); + setWarning(false); + setInfo(`β < 1; all good!`); } - setWarning(false); - updateUniforms(); + // updateUniforms(); } }