import { exportsOnResize , stepSVGParticles } from './exports' ; import { fluidOnResize , stepFluid , } from './fluid' ; import './interactions' ; import MicroModal from 'micromodal' ; import { particlesOnResize , stepParticles , } from './particles' ; import { stepInteraction } from './interactions' ; import { guiOnResize , hideGUI , showGUI } from './gui' ; import { canvas } from './gl' ; MicroModal . init ( ) ; let paused = false ; window . addEventListener ( 'keydown' , ( e ) => { if ( e . code === 'Space' ) { paused = ! paused ; paused ? showGUI ( ) : hideGUI ( ) ; } } ) ; onResize ( ) ; window . addEventListener ( 'resize' , onResize ) ; let needsResize = false ; function onResize ( ) { if ( paused ) { needsResize = true ; return ; } const width = canvas . clientWidth ; const height = canvas . clientHeight ; particlesOnResize ( width , height ) ; fluidOnResize ( width , height ) ; guiOnResize ( width , height ) ; exportsOnResize ( width , height ) ; needsResize = false ; } window . requestAnimationFrame ( step ) ; function step ( ) { window . requestAnimationFrame ( step ) ; if ( paused ) { stepSVGParticles ( ) ; return ; } if ( needsResize ) { onResize ( ) ; } stepInteraction ( ) ; stepFluid ( ) ; stepParticles ( ) ; }