@@ -44,7 +44,7 @@ let shaders = [
4444 u_depth : { value : 1.0 , type : "f" } ,
4545 u_width : { value : 0.3 , type : "f" } ,
4646 u_speed : { value : 0.6 , type : "f" } ,
47- u_layers : { value : 25 , type : "i" } ,
47+ u_layers : { value : 32 , type : "i" } ,
4848 u_blur : { value : false , type : "b" } ,
4949 u_brightness : { value : 0.75 , type : "f" } ,
5050 u_post_processing : { value : true , type : "b" } ,
@@ -414,7 +414,7 @@ function setMouse() {
414414// this.onmousedown = this.onmousemove = this.onmouseup = null;
415415// }
416416
417- async function showTransition ( ) {
417+ function showTransition ( ) {
418418 if ( material == null ) return ;
419419
420420 renderer . render ( scene , camera ) ; //WebGLRenderer.preserveDrawingBuffer is false.
@@ -424,14 +424,27 @@ async function showTransition() {
424424 quad . material = new THREE . MeshBasicMaterial ( { map : texture , transparent : true , opacity : 1.0 } ) ;
425425 scene . add ( quad ) ;
426426
427- for ( let val = 1 ; val >= 0 ; val -= 0.1 ) {
427+ let duration = 1000 ;
428+ let startTime = null ;
429+
430+ function animate ( timestamp ) {
431+ if ( ! startTime ) startTime = timestamp ;
432+ const progress = timestamp - startTime ;
433+ const val = 1 - Math . min ( progress / duration , 1 ) ;
434+
428435 quad . material . opacity = val ;
429- await new Promise ( ( r ) => setTimeout ( r , 75 ) ) ;
436+ renderer . render ( scene , camera ) ;
437+
438+ if ( progress < duration ) {
439+ requestAnimationFrame ( animate ) ;
440+ } else {
441+ texture . dispose ( ) ;
442+ scene . remove ( quad ) ;
443+ URL . revokeObjectURL ( screenShot ) ;
444+ }
430445 }
431446
432- texture . dispose ( ) ;
433- scene . remove ( quad ) ;
434- URL . revokeObjectURL ( screenShot ) ;
447+ animate ( 0 ) ;
435448}
436449
437450function resize ( ) {
0 commit comments