Skip to content

Commit

Permalink
Minor performance improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
jkcuk authored Mar 4, 2024
1 parent cddedee commit 4043cfb
Showing 1 changed file with 10 additions and 7 deletions.
17 changes: 10 additions & 7 deletions main.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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: &beta; (=${Math.sqrt(beta2).toFixed(2)}) > 1; using last value of <b>&beta;</b> with |&beta;| < 1`);
} else {
beta = Math.sqrt(beta2);
gamma = 1/Math.sqrt(1-beta2);
Expand Down Expand Up @@ -514,11 +518,10 @@ function updateTransformationMatrix() {
lookalikeSphere.matrix.copy(transformationMatrix);

if(shaderMaterial.uniforms.warning.value) {
setInfo(`&beta; (=${Math.sqrt(beta2)}) < 1; all good!`);
console.log(`&beta; (=${Math.sqrt(beta2)}) < 1; all good!`);
setWarning(false);
setInfo(`&beta; < 1; all good!`);
}
setWarning(false);
updateUniforms();
// updateUniforms();
}
}

Expand Down

0 comments on commit 4043cfb

Please sign in to comment.