Skip to content

Commit

Permalink
Cooler transition
Browse files Browse the repository at this point in the history
  • Loading branch information
jkcuk authored Mar 11, 2024
1 parent 06c866d commit 9c25e30
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions main.js
Original file line number Diff line number Diff line change
Expand Up @@ -124,16 +124,19 @@ function init() {
addOrbitControls(); // add to outside camera

// remove the splash
for(let i=0; i<100; i++) {
setTimeout(() => {
document.getElementById('splash').style.opacity = (100-i)/100;
}, 1000+10*i);
let duration=4000; // duration of transition, in ms
for(let ms=0; ms<duration; ms+=20) {
let opacity = 0.5+0.5*Math.cos(Math.PI*ms/duration);
setTimeout(() => {
document.getElementById('splash').style.opacity = opacity;
renderer.domElement.style.opacity = 1-opacity;
}, ms);
}
setTimeout(() => {
document.getElementById('splash').style.visibility = "hidden";
// the controls menu
createGUI();
}, 2100);
}, duration+100);

}

Expand Down

0 comments on commit 9c25e30

Please sign in to comment.