text: !function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports._vantaEffect=t():e._vantaEffect=t()}("undefined"!=typeof self?self:this,function(){return function(e){var t={};function i(n){if(t[n])return t[n].exports;var o=t[n]={i:n,l:!1,exports:{}};return e[n].call(o.exports,o,o.exports,i),o.l=!0,o.exports}return i.m=e,i.c=t,i.d=function(e,t,n){i.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:n})},i.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},i.t=function(e,t){if(1&t&&(e=i(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var n=Object.create(null);if(i.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var o in e)i.d(n,o,function(t){return e[t]}.bind(null,o));return n},i.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return i.d(t,"a",t),t},i.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},i.p="",i(i.s=17)}({0:function(e,t,i){"use strict";function n(e,t){for(let i in t)t.hasOwnProperty(i)&&(e[i]=t[i]);return e}function o(){return"undefined"!=typeof navigator?/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent)||window.innerWidth<600:null}i.d(t,"c",function(){return n}),i.d(t,"e",function(){return o}),i.d(t,"i",function(){return r}),i.d(t,"h",function(){return s}),i.d(t,"g",function(){return a}),i.d(t,"f",function(){return l}),i.d(t,"a",function(){return h}),i.d(t,"b",function(){return c}),i.d(t,"d",function(){return u}),Number.prototype.clamp=function(e,t){return Math.min(Math.max(this,e),t)};const r=e=>e[Math.floor(Math.random()*e.length)];function s(e,t){return null==e&&(e=0),null==t&&(t=1),e+Math.random()*(t-e)}function a(e,t){return null==e&&(e=0),null==t&&(t=1),Math.floor(e+Math.random()*(t-e+1))}const l=e=>document.querySelector(e),h=e=>"number"==typeof e?"#"+("00000"+e.toString(16)).slice(-6):e,c=(e,t=1)=>{const i=h(e),n=/^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(i),o=n?{r:parseInt(n[1],16),g:parseInt(n[2],16),b:parseInt(n[3],16)}:null;return"rgba("+o.r+","+o.g+","+o.b+","+t+")"},u=e=>.299*e.r+.587*e.g+.114*e.b},1:function(e,t,i){"use strict";i.d(t,"a",function(){return s});var n=i(0);const o="object"==typeof window;let r=o&&window.THREE||{};o&&!window.VANTA&&(window.VANTA={});const s=o&&window.VANTA||{};s.register=(e,t)=>s[e]=e=>new t(e),s.version="0.5.11";const a=function(){return Array.prototype.unshift.call(arguments,"[VANTA]"),console.error.apply(this,arguments)};s.VantaBase=class{constructor(e={}){if(!o)return!1;s.current=this,this.windowMouseMoveWrapper=this.windowMouseMoveWrapper.bind(this),this.windowTouchWrapper=this.windowTouchWrapper.bind(this),this.resize=this.resize.bind(this),this.animationLoop=this.animationLoop.bind(this),this.restart=this.restart.bind(this);const t="function"==typeof this.getDefaultOptions?this.getDefaultOptions():this.defaultOptions;if(this.options=Object(n.c)({mouseControls:!0,touchControls:!0,minHeight:200,minWidth:200,scale:1,scaleMobile:1},t),(e instanceof HTMLElement||"string"==typeof e)&&(e={el:e}),Object(n.c)(this.options,e),this.options.THREE&&(r=this.options.THREE),this.el=this.options.el,null==this.el)a('Instance needs "el" param!');else if(!(this.options.el instanceof HTMLElement)){const e=this.el;if(this.el=Object(n.f)(e),!this.el)return void a("Cannot find element",e)}this.prepareEl(),this.initThree(),this.setSize();try{this.init()}catch(e){return a("Init error",e),this.renderer&&this.renderer.domElement&&this.el.removeChild(this.renderer.domElement),void(this.options.backgroundColor&&(console.log("[VANTA] Falling back to backgroundColor"),this.el.style.background=Object(n.a)(this.options.backgroundColor)))}const i=window.addEventListener;i("resize",this.resize),window.requestAnimationFrame(this.resize),this.resize(),this.animationLoop(),this.options.mouseControls&&(i("scroll",this.windowMouseMoveWrapper),i("mousemove",this.windowMouseMoveWrapper)),this.options.touchControls&&(i("touchstart",this.windowTouchWrapper),i("touchmove",this.windowTouchWrapper))}setOptions(e={}){Object(n.c)(this.options,e)}prepareEl(){let e,t;if("undefined"!=typeof Node&&Node.TEXT_NODE)for(e=0;e<this.el.childNodes.length;e++){const t=this.el.childNodes[e];if(t.nodeType===Node.TEXT_NODE){const e=document.createElement("span");e.textContent=t.textContent,t.parentElement.insertBefore(e,t),t.remove()}}for(e=0;e<this.el.children.length;e++)t=this.el.children[e],"static"===getComputedStyle(t).position&&(t.style.position="relative"),"auto"===getComputedStyle(t).zIndex&&(t.style.zIndex=1);"static"===getComputedStyle(this.el).position&&(this.el.style.position="relative")}applyCanvasStyles(e,t={}){Object(n.c)(e.style,{position:"absolute",zIndex:0,top:0,left:0,background:""}),Object(n.c)(e.style,t),e.classList.add("vanta-canvas")}initThree(){r.WebGLRenderer?(this.renderer=new r.WebGLRenderer({alpha:!0,antialias:!0}),this.el.appendChild(this.renderer.domElement),this.applyCanvasStyles(this.renderer.domElement),isNaN(this.options.backgroundAlpha)&&(this.options.backgroundAlpha=1),this.scene=new r.Scene):console.warn("[VANTA] No THREE defined on window")}getCanvasElement(){return this.renderer?this.renderer.domElement:this.p5renderer?this.p5renderer.canvas:void 0}windowMouseMoveWrapper(e){const t=this.getCanvasElement();if(!t)return!1;const i=t.getBoundingClientRect(),n=e.clientX-i.left,o=e.clientY-i.top;n>=0&&o>=0&&n<=i.width&&o<=i.height&&(this.mouseX=n,this.mouseY=o,this.options.mouseEase||this.triggerMouseMove(n,o))}windowTouchWrapper(e){if(1===e.touches.length){const t=this.getCanvasElement();if(!t)return!1;const i=t.getBoundingClientRect(),n=e.touches[0].clientX-i.left,o=e.touches[0].clientY-i.top;n>=0&&o>=0&&n<=i.width&&o<=i.height&&(this.mouseX=n,this.mouseY=o,this.options.mouseEase||this.triggerMouseMove(n,o))}}triggerMouseMove(e,t){this.uniforms&&(this.uniforms.iMouse.value.x=e/this.scale,this.uniforms.iMouse.value.y=t/this.scale);const i=e/this.width,n=t/this.height;"function"==typeof this.onMouseMove&&this.onMouseMove(i,n)}setSize(){this.scale||(this.scale=1),Object(n.e)()&&this.options.scaleMobile?this.scale=this.options.scaleMobile:this.options.scale&&(this.scale=this.options.scale),this.width=Math.max(this.el.offsetWidth,this.options.minWidth),this.height=Math.max(this.el.offsetHeight,this.options.minHeight)}resize(){this.setSize(),this.camera&&(this.camera.aspect=this.width/this.height,"function"==typeof this.camera.updateProjectionMatrix&&this.camera.updateProjectionMatrix()),this.renderer&&(this.renderer.setSize(this.width,this.height),this.renderer.setPixelRatio(window.devicePixelRatio/this.scale)),"function"==typeof this.onResize&&this.onResize()}isOnScreen(){const e=this.el.offsetHeight,t=this.el.getBoundingClientRect(),i=window.pageYOffset||(document.documentElement||document.body.parentNode||document.body).scrollTop,n=t.top+i;return n-window.innerHeight<=i&&i<=n+e}animationLoop(){return this.t||(this.t=0),this.t+=1,this.t2||(this.t2=0),this.t2+=this.options.speed||1,this.uniforms&&(this.uniforms.iTime.value=.016667*this.t2),this.options.mouseEase&&(this.mouseEaseX=this.mouseEaseX||this.mouseX||0,this.mouseEaseY=this.mouseEaseY||this.mouseY||0,Math.abs(this.mouseEaseX-this.mouseX)+Math.abs(this.mouseEaseY-this.mouseY)>.1&&(this.mouseEaseX=this.mouseEaseX+.05*(this.mouseX-this.mouseEaseX),this.mouseEaseY=this.mouseEaseY+.05*(this.mouseY-this.mouseEaseY),this.triggerMouseMove(this.mouseEaseX,this.mouseEaseY))),(this.isOnScreen()||this.options.forceAnimate)&&("function"==typeof this.onUpdate&&this.onUpdate(),this.scene&&this.camera&&(this.renderer.render(this.scene,this.camera),this.renderer.setClearColor(this.options.backgroundColor,this.options.backgroundAlpha))),this.req=window.requestAnimationFrame(this.animationLoop)}restart(){if(this.scene)for(;this.scene.children.length;)this.scene.remove(this.scene.children[0]);"function"==typeof this.onRestart&&this.onRestart(),this.init()}init(){"function"==typeof this.onInit&&this.onInit()}destroy(){"function"==typeof this.onDestroy&&this.onDestroy();const e=window.removeEventListener;e("touchstart",this.windowTouchWrapper),e("touchmove",this.windowTouchWrapper),e("scroll",this.windowMouseMoveWrapper),e("mousemove",this.windowMouseMoveWrapper),e("resize",this.resize),window.cancelAnimationFrame(this.req),this.renderer&&(this.renderer.domElement&&this.el.removeChild(this.renderer.domElement),this.renderer=null,this.scene=null)}},t.b=s.VantaBase},17:function(e,t,i){"use strict";i.r(t);var n=i(1),o=i(0);function r(e,t,i){this.variables=[],this.currentTextureIndex=0;var n=new THREE.Scene,o=new THREE.Camera;o.position.z=1;var r={texture:{value:null}},s=h("uniform sampler2D texture;\n\nvoid main() {\n\n\tvec2 uv = gl_FragCoord.xy / resolution.xy;\n\n\tgl_FragColor = texture2D( texture, uv );\n\n}\n",r),a=new THREE.Mesh(new THREE.PlaneBufferGeometry(2,2),s);function l(i){i.defines.resolution="vec2( "+e.toFixed(1)+", "+t.toFixed(1)+" )"}function h(e,t){t=t||{};var i=new THREE.ShaderMaterial({uniforms:t,vertexShader:"void main()\t{\n\n\tgl_Position = vec4( position, 1.0 );\n\n}\n",fragmentShader:e});return l(i),i}n.add(a),this.addVariable=function(e,t,i){var n={name:e,initialValueTexture:i,material:this.createShaderMaterial(t),dependencies:null,renderTargets:[],wrapS:null,wrapT:null,minFilter:THREE.NearestFilter,magFilter:THREE.NearestFilter};return this.variables.push(n),n},this.setVariableDependencies=function(e,t){e.dependencies=t},this.init=function(){if(!i.extensions.get("OES_texture_float"))return"No OES_texture_float support for float textures.";if(0===i.capabilities.maxVertexTextures)return"No support for vertex shader textures.";for(var n=0;n<this.variables.length;n++){var o=this.variables[n];o.renderTargets[0]=this.createRenderTarget(e,t,o.wrapS,o.wrapT,o.minFilter,o.magFilter),o.renderTargets[1]=this.createRenderTarget(e,t,o.wrapS,o.wrapT,o.minFilter,o.magFilter),this.renderTexture(o.initialValueTexture,o.renderTargets[0]),this.renderTexture(o.initialValueTexture,o.renderTargets[1]);var r=o.material,s=r.uniforms;if(null!==o.dependencies)for(var a=0;a<o.dependencies.length;a++){var l=o.dependencies[a];if(l.name!==o.name){for(var h=!1,c=0;c<this.variables.length;c++)if(l.name===this.variables[c].name){h=!0;break}if(!h)return"Variable dependency not found. Variable="+o.name+", dependency="+l.name}s[l.name]={value:null},r.fragmentShader="\nuniform sampler2D "+l.name+";\n"+r.fragmentShader}}return this.currentTextureIndex=0,null},this.compute=function(){for(var e=this.currentTextureIndex,t=0===this.currentTextureIndex?1:0,i=0,n=this.variables.length;i<n;i++){var o=this.variables[i];if(null!==o.dependencies)for(var r=o.material.uniforms,s=0,a=o.dependencies.length;s<a;s++){var l=o.dependencies[s];r[l.name].value=l.renderTargets[e].texture}this.doRenderTarget(o.material,o.renderTargets[t])}this.currentTextureIndex=t},this.getCurrentRenderTarget=function(e){return e.renderTargets[this.currentTextureIndex]},this.getAlternateRenderTarget=function(e){return e.renderTargets[0===this.currentTextureIndex?1:0]},this.addResolutionDefine=l,this.createShaderMaterial=h,this.createRenderTarget=function(i,n,o,r,s,a){i=i||e,n=n||t,o=o||THREE.ClampToEdgeWrapping,r=r||THREE.ClampToEdgeWrapping,s=s||THREE.NearestFilter,a=a||THREE.NearestFilter;var l="undefined"!=typeof navigator?navigator.userAgent:"";return new THREE.WebGLRenderTarget(i,n,{wrapS:o,wrapT:r,minFilter:s,magFilter:a,format:THREE.RGBAFormat,type:/(iPad|iPhone|iPod)/g.test(l)?THREE.HalfFloatType:THREE.FloatType,stencilBuffer:!1})},this.createTexture=function(i,n){i=i||e,n=n||t;var o=new Float32Array(i*n*4),r=new THREE.DataTexture(o,e,t,THREE.RGBAFormat,THREE.FloatType);return r.needsUpdate=!0,r},this.renderTexture=function(e,t){r.texture.value=e,this.doRenderTarget(s,t),r.texture.value=null},this.doRenderTarget=function(e,t){a.material=e,i.render(n,o,t),a.material=s}}let s="object"==typeof window&&window.THREE;const a=!Object(o.e)();let l=32,h=l*l;const c=800,u=c/2;let d,p;const f=function(e){(d=function(t={}){var i=this;function n(n,o,r){const s=1.5*(t.birdSize||1);i.vertices.push(new e.Vector3(n*s,o*s,r*s))}function o(t,n,o){i.faces.push(new e.Face3(t,n,o))}e.Geometry.call(this),n(5,0,0),n(-5,-1,1),n(-5,0,0),n(-5,-2,-1),n(0,2,-6),n(0,2,6),n(2,0,0),n(-3,0,0),o(0,2,1),o(4,7,6),o(5,6,7),this.computeFaceNormals()}).prototype=Object.create(e.Geometry.prototype),p=function(t){var i,n,o=new e.Vector3,r=500,s=500,a=200,l=t;this.position=new e.Vector3,this.velocity=new e.Vector3,i=new e.Vector3,this.setGoal=function(e){n=e},this.setWorldSize=function(e,t,i){r=e,s=t,a=i},this.run=function(e){o.set(-r,this.position.y,this.position.z),(o=this.avoid(o)).multiplyScalar(5),i.add(o),o.set(r,this.position.y,this.position.z),(o=this.avoid(o)).multiplyScalar(5),i.add(o),o.set(this.position.x,-s,this.position.z),(o=this.avoid(o)).multiplyScalar(5),i.add(o),o.set(this.position.x,s,this.position.z),(o=this.avoid(o)).multiplyScalar(5),i.add(o),o.set(this.position.x,this.position.y,-a),(o=this.avoid(o)).multiplyScalar(5),i.add(o),o.set(this.position.x,this.position.y,a),(o=this.avoid(o)).multiplyScalar(5),i.add(o),Math.random()>.5&&this.flock(e),this.move()},this.flock=function(e){n&&i.add(this.reach(n,.005)),i.add(this.alignment(e)),i.add(this.cohesion(e)),i.add(this.separation(e))},this.move=function(){this.velocity.add(i);var e=this.velocity.length();e>2.5&&this.velocity.divideScalar(e/2.5),this.position.add(this.velocity),i.set(0,0,0)},this.checkBounds=function(){this.position.x>r&&(this.position.x=-r),this.position.x<-r&&(this.position.x=r),this.position.y>s&&(this.position.y=-s),this.position.y<-s&&(this.position.y=s),this.position.z>a&&(this.position.z=-a),this.position.z<-a&&(this.position.z=a)},this.avoid=function(t){var i=new e.Vector3;return i.copy(this.position),i.sub(t),i.multiplyScalar(1/this.position.distanceToSquared(t)),i},this.repulse=function(t){var n=this.position.distanceTo(t);if(n<150){var o=new e.Vector3;o.subVectors(this.position,t),o.multiplyScalar(.5/n),i.add(o)}},this.reach=function(t,i){var n=new e.Vector3;return n.subVectors(t,this.position),n.multiplyScalar(i),n},this.alignment=function(t){var i,n,o=new e.Vector3,r=0;const s=100*l.alignment/20;for(var a=0,h=t.length;a<h;a++)Math.random()>.6||(n=(i=t[a]).position.distanceTo(this.position))>0&&n<=s&&(o.add(i.velocity),r++);if(r>0){o.divideScalar(r);var c=o.length();c>.1&&o.divideScalar(c/.1)}return o},this.cohesion=function(t){var i,n,o=new e.Vector3,r=new e.Vector3,s=0;const a=100*l.cohesion/20;for(var h=0,c=t.length;h<c;h++)Math.random()>.6||(n=(i=t[h]).position.distanceTo(this.position))>0&&n<=a&&(o.add(i.position),s++);s>0&&o.divideScalar(s),r.subVectors(o,this.position);var u=r.length();return u>.1&&r.divideScalar(u/.1),r},this.separation=function(t){var i,n,o=new e.Vector3,r=new e.Vector3;const s=100*l.separation/20;for(var a=0,h=t.length;a<h;a++)Math.random()>.6||(n=(i=t[a]).position.distanceTo(this.position))>0&&n<=s&&(r.subVectors(this.position,i.position),r.normalize(),r.divideScalar(n),o.add(r));return o}},e.BirdGeometry=function(t){t.quantity&&(l=Math.pow(2,t.quantity),h=l*l);const i=3*h,n=3*i;e.BufferGeometry.call(this);const o=new e.BufferAttribute(new Float32Array(3*n),3),r=new e.BufferAttribute(new Float32Array(3*n),3),s=new e.BufferAttribute(new Float32Array(2*n),2),a=new e.BufferAttribute(new Float32Array(n),1);this.addAttribute("position",o),this.addAttribute("birdColor",r),this.addAttribute("reference",s),this.addAttribute("birdVertex",a);let c=0;const u=function(){for(let e=0;e<arguments.length;e++)o.array[c++]=arguments[e]},d=t.wingSpan||20,p=t.birdSize||1;for(let e=0;e<h;e++)u(0,-0,-20*p,0,4*p,-20*p,0,0,30*p),u(0,0,-15*p,-d*p,0,0,0,0,15*p),u(0,0,15*p,d*p,0,0,0,0,-15*p);const f={};for(c=0;c<3*i;c++){const e=~~(c/3),i=e%l/l,n=~~(e/l)/l,o=~~(c/9)/h,u=o.toString(),d=-1!=t.colorMode.indexOf("Gradient");let p;p=!d&&f[u]?f[u]:t.effect.getNewCol(o),d||f[u]||(f[u]=p),r.array[3*c+0]=p.r,r.array[3*c+1]=p.g,r.array[3*c+2]=p.b,s.array[2*c]=i,s.array[2*c+1]=n,a.array[c]=c%9}return this.scale(.2,.2,.2)},e.BirdGeometry.prototype=Object.create(e.BufferGeometry.prototype)},m="uniform float time;\nuniform float delta;\n\nvoid main() {\n\n  vec2 uv = gl_FragCoord.xy / resolution.xy;\n  vec4 tmpPos = texture2D( texturePosition, uv );\n  vec3 position = tmpPos.xyz;\n  vec3 velocity = texture2D( textureVelocity, uv ).xyz;\n\n  float phase = tmpPos.w;\n\n  phase = mod( ( phase + delta +\n    length( velocity.xz ) * delta * 3. +\n    max( velocity.y, 0.0 ) * delta * 6. ), 62.83 );\n\n  gl_FragColor = vec4( position + velocity * delta * 15. , phase );\n\n}",v="uniform float time;\nuniform float testing;\nuniform float delta; // about 0.016\nuniform float separationDistance; // 20\nuniform float alignmentDistance; // 40\nuniform float cohesionDistance;\nuniform float speedLimit;\nuniform float freedomFactor;\nuniform vec3 predator;\n\nconst float width = resolution.x;\nconst float height = resolution.y;\n\nconst float PI = 3.141592653589793;\nconst float PI_2 = PI * 2.0;\n// const float VISION = PI * 0.55;\n\nfloat zoneRadius = 40.0;\nfloat zoneRadiusSquared = 1600.0;\n\nfloat separationThresh = 0.45;\nfloat alignmentThresh = 0.65;\n\nconst float UPPER_BOUNDS = BOUNDS;\nconst float LOWER_BOUNDS = -UPPER_BOUNDS;\n\nfloat rand(vec2 co){\n  return fract(sin(dot(co.xy ,vec2(12.9898,78.233))) * 43758.5453);\n}\n\nvoid main() {\n\n  zoneRadius = separationDistance + alignmentDistance + cohesionDistance;\n  separationThresh = separationDistance / zoneRadius;\n  alignmentThresh = ( separationDistance + alignmentDistance ) / zoneRadius;\n  zoneRadiusSquared = zoneRadius * zoneRadius;\n\n\n  vec2 uv = gl_FragCoord.xy / resolution.xy;\n  vec3 birdPosition, birdVelocity;\n\n  vec3 selfPosition = texture2D( texturePosition, uv ).xyz;\n  vec3 selfVelocity = texture2D( textureVelocity, uv ).xyz;\n\n  float dist;\n  vec3 dir; // direction\n  float distSquared;\n\n  float separationSquared = separationDistance * separationDistance;\n  float cohesionSquared = cohesionDistance * cohesionDistance;\n\n  float f;\n  float percent;\n\n  vec3 velocity = selfVelocity;\n\n  float limit = speedLimit;\n\n  dir = predator * UPPER_BOUNDS - selfPosition;\n  dir.z = 0.;\n  // dir.z *= 0.6;\n  dist = length( dir );\n  distSquared = dist * dist;\n\n  float preyRadius = 150.0;\n  float preyRadiusSq = preyRadius * preyRadius;\n\n  // move birds away from predator\n  if (dist < preyRadius) {\n\n    f = ( distSquared / preyRadiusSq - 1.0 ) * delta * 100.;\n    velocity += normalize( dir ) * f;\n    limit += 5.0;\n  }\n\n  // if (testing == 0.0) {}\n  // if ( rand( uv + time ) < freedomFactor ) {}\n\n  // Attract flocks to the center\n  vec3 central = vec3( 0., 0., 0. );\n  dir = selfPosition - central;\n  dist = length( dir );\n\n  dir.y *= 2.5;\n  velocity -= normalize( dir ) * delta * 5.;\n\n  for (float y=0.0;y<height;y++) {\n    for (float x=0.0;x<width;x++) {\n\n      vec2 ref = vec2( x + 0.5, y + 0.5 ) / resolution.xy;\n      birdPosition = texture2D( texturePosition, ref ).xyz;\n\n      dir = birdPosition - selfPosition;\n      dist = length(dir);\n\n      if (dist < 0.0001) continue;\n\n      distSquared = dist * dist;\n\n      if (distSquared > zoneRadiusSquared ) continue;\n\n      percent = distSquared / zoneRadiusSquared;\n\n      if ( percent < separationThresh ) { // low\n\n        // Separation - Move apart for comfort\n        f = (separationThresh / percent - 1.0) * delta;\n        velocity -= normalize(dir) * f;\n\n      } else if ( percent < alignmentThresh ) { // high\n\n        // Alignment - fly the same direction\n        float threshDelta = alignmentThresh - separationThresh;\n        float adjustedPercent = ( percent - separationThresh ) / threshDelta;\n\n        birdVelocity = texture2D( textureVelocity, ref ).xyz;\n\n        f = ( 0.5 - cos( adjustedPercent * PI_2 ) * 0.5 + 0.5 ) * delta;\n        velocity += normalize(birdVelocity) * f;\n\n      } else {\n\n        // Attraction / Cohesion - move closer\n        float threshDelta = 1.0 - alignmentThresh;\n        float adjustedPercent = ( percent - alignmentThresh ) / threshDelta;\n\n        f = ( 0.5 - ( cos( adjustedPercent * PI_2 ) * -0.5 + 0.5 ) ) * delta;\n\n        velocity += normalize(dir) * f;\n\n      }\n    }\n  }\n\n  // this make tends to fly around than down or up\n  // if (velocity.y > 0.) velocity.y *= (1. - 0.2 * delta);\n\n  // Speed Limits\n  if ( length( velocity ) > limit ) {\n    velocity = normalize( velocity ) * limit;\n  }\n\n  gl_FragColor = vec4( velocity, 1.0 );\n\n}",y="attribute vec2 reference;\nattribute float birdVertex;\n\nattribute vec3 birdColor;\n\nuniform sampler2D texturePosition;\nuniform sampler2D textureVelocity;\n\nvarying vec4 vColor;\nvarying float z;\n\nuniform float time;\nuniform float birdSize;\n\nvoid main() {\n\n  vec4 tmpPos = texture2D( texturePosition, reference );\n  vec3 pos = tmpPos.xyz;\n  vec3 velocity = normalize(texture2D( textureVelocity, reference ).xyz);\n\n  vec3 newPosition = position;\n\n  if ( birdVertex == 4.0 || birdVertex == 7.0 ) {\n    // flap wings\n    newPosition.y = sin( tmpPos.w ) * 5. * birdSize;\n  }\n\n  newPosition = mat3( modelMatrix ) * newPosition;\n\n  velocity.z *= -1.;\n  float xz = length( velocity.xz );\n  float xyz = 1.;\n  float x = sqrt( 1. - velocity.y * velocity.y );\n\n  float cosry = velocity.x / xz;\n  float sinry = velocity.z / xz;\n\n  float cosrz = x / xyz;\n  float sinrz = velocity.y / xyz;\n\n  mat3 maty =  mat3(\n    cosry, 0, -sinry,\n    0    , 1, 0     ,\n    sinry, 0, cosry\n  );\n\n  mat3 matz =  mat3(\n    cosrz , sinrz, 0,\n    -sinrz, cosrz, 0,\n    0     , 0    , 1\n  );\n  newPosition =  maty * matz * newPosition;\n  newPosition += pos;\n  z = newPosition.z;\n\n  vColor = vec4( birdColor, 1.0 );\n  gl_Position = projectionMatrix *  viewMatrix  * vec4( newPosition, 1.0 );\n}",g="varying vec4 vColor;\nvarying float z;\nuniform vec3 color;\nvoid main() {\n  // Fake colors for now\n  float rr = 0.2 + ( 1000. - z ) / 1000. * vColor.x;\n  float gg = 0.2 + ( 1000. - z ) / 1000. * vColor.y;\n  float bb = 0.2 + ( 1000. - z ) / 1000. * vColor.z;\n  gl_FragColor = vec4( rr, gg, bb, 1. );\n}",w=function(e){const t=e.image.data;let i=0;const n=t.length;return(()=>{const e=[];for(;i<n;){const n=Math.random()*c-u,o=Math.random()*c-u,r=Math.random()*c-u;t[i+0]=n,t[i+1]=o,t[i+2]=r,t[i+3]=1,e.push(i+=4)}return e})()},x=function(e){const t=e.image.data;let i=0;const n=t.length;return(()=>{const e=[];for(;i<n;){const n=Math.random()-.5,o=Math.random()-.5,r=Math.random()-.5;t[i+0]=10*n,t[i+1]=10*o,t[i+2]=10*r,t[i+3]=1,e.push(i+=4)}return e})()};class b extends n.b{static initClass(){this.prototype.defaultOptions={backgroundColor:465199,color1:16711680,color2:53759,colorMode:"varianceGradient",birdSize:1,wingSpan:30,speedLimit:5,separation:20,alignment:20,cohesion:20,quantity:5}}constructor(e){s=e.THREE||s,f(s),super(e)}initComputeRenderer(){this.gpuCompute=new r(l,l,this.renderer);const e=this.gpuCompute.createTexture(),t=this.gpuCompute.createTexture();w(e),x(t),this.velocityVariable=this.gpuCompute.addVariable("textureVelocity",v,t),this.positionVariable=this.gpuCompute.addVariable("texturePosition",m,e),this.gpuCompute.setVariableDependencies(this.velocityVariable,[this.positionVariable,this.velocityVariable]),this.gpuCompute.setVariableDependencies(this.positionVariable,[this.positionVariable,this.velocityVariable]),this.positionUniforms=this.positionVariable.material.uniforms,this.velocityUniforms=this.velocityVariable.material.uniforms,this.positionUniforms.time={value:0},this.positionUniforms.delta={value:0},this.velocityUniforms.time={value:1},this.velocityUniforms.delta={value:0},this.velocityUniforms.testing={value:1},this.velocityUniforms.separationDistance={value:1},this.velocityUniforms.alignmentDistance={value:1},this.velocityUniforms.cohesionDistance={value:1},this.velocityUniforms.speedLimit={value:1},this.velocityUniforms.freedomFactor={value:1},this.velocityUniforms.predator={value:new s.Vector3},this.velocityVariable.material.defines.BOUNDS=c.toFixed(2),this.velocityVariable.wrapS=s.RepeatWrapping,this.velocityVariable.wrapT=s.RepeatWrapping,this.positionVariable.wrapS=s.RepeatWrapping,this.positionVariable.wrapT=s.RepeatWrapping;const i=this.gpuCompute.init();null!==i&&console.error(i)}initGpgpuBirds(){const e=Object.assign({},this.options,{effect:this}),t=new s.BirdGeometry(e);this.birdUniforms={color:{value:new s.Color(16720384)},texturePosition:{value:null},textureVelocity:{value:null},time:{value:1},delta:{value:0},birdSize:{value:this.options.birdSize}};const i=new s.ShaderMaterial({uniforms:this.birdUniforms,vertexShader:y,fragmentShader:g,side:s.DoubleSide}),n=new s.Mesh(t,i);return n.rotation.y=Math.PI/2,n.matrixAutoUpdate=!1,n.updateMatrix(),this.scene.add(n)}getNewCol(e){const t=this.options,i=null!=t.color1?t.color1:4456448,n=null!=t.color2?t.color2:6684672,o=new s.Color(i),r=new s.Color(n);let a,l;if(l=-1!=t.colorMode.indexOf("Gradient")?Math.random():e,0==t.colorMode.indexOf("variance")){const e=(o.r+Math.random()*r.r).clamp(0,1),t=(o.g+Math.random()*r.g).clamp(0,1),i=(o.b+Math.random()*r.b).clamp(0,1);a=new s.Color(e,t,i)}else a=0==t.colorMode.indexOf("mix")?new s.Color(i+l*n):o.lerp(r,l);return a}onInit(){this.camera=new s.PerspectiveCamera(75,this.width/this.height,1,3e3),this.camera.position.z=350,this.fog=new s.Fog(16777215,100,1e3),this.mouseX=this.mouseY=0;const e=this.birds=[],t=this.boids=[],i=this.options;let n,o;if(a)try{this.initComputeRenderer(),this.valuesChanger=this.valuesChanger.bind(this),this.valuesChanger(),this.initGpgpuBirds()}catch(e){console.error("[vanta.js] birds init error: ",e)}else{const a=6*Math.pow(2,i.quantity);for(var r=0;r<a;r++){(n=t[r]=new p(i)).position.x=400*Math.random()-200,n.position.y=400*Math.random()-200,n.position.z=400*Math.random()-200,n.velocity.x=2*Math.random()-1,n.velocity.y=2*Math.random()-1,n.velocity.z=2*Math.random()-1,n.setWorldSize(500,500,300);const c=-1!=i.colorMode.indexOf("Gradient"),u=new d(i);for(var l=0;l<u.faces.length;l++)if(c)for(var h=0;h<3;h++){const e=this.getNewCol();u.faces[l].vertexColors[h]=e}else{const e=this.getNewCol(r/a);u.faces[l].vertexColors[0]=e,u.faces[l].vertexColors[1]=e,u.faces[l].vertexColors[2]=e}(o=e[r]=new s.Mesh(u,new s.MeshBasicMaterial({color:16777215,side:s.DoubleSide,vertexColors:s.VertexColors}))).phase=Math.floor(62.83*Math.random()),o.position.x=t[r].position.x,o.position.y=t[r].position.y,o.position.z=t[r].position.z,this.scene.add(o)}}}valuesChanger(){this.velocityUniforms&&(this.velocityUniforms.separationDistance.value=this.options.separation,this.velocityUniforms.alignmentDistance.value=this.options.alignment,this.velocityUniforms.speedLimit.value=this.options.speedLimit,this.velocityUniforms.cohesionDistance.value=this.options.cohesion)}onUpdate(){this.now=performance.now(),this.last||(this.last=this.now);let e=(this.now-this.last)/1e3;if(e>1&&(e=1),this.last=this.now,a)this.positionUniforms.time.value=this.now,this.positionUniforms.delta.value=e,this.velocityUniforms.time.value=this.now,this.velocityUniforms.delta.value=e,this.birdUniforms.time.value=this.now,this.birdUniforms.delta.value=e,this.velocityUniforms.predator.value.set(this.mouseX,-this.mouseY,0),this.mouseX=1e4,this.mouseY=1e4,this.gpuCompute.compute(),this.birdUniforms.texturePosition.value=this.gpuCompute.getCurrentRenderTarget(this.positionVariable).texture,this.birdUniforms.textureVelocity.value=this.gpuCompute.getCurrentRenderTarget(this.velocityVariable).texture;else{const e=this.birds,n=this.boids;let o,r;for(var t=0,i=e.length;t<i;t++)(o=n[t]).run(n),(r=e[t]).rotation.y=Math.atan2(-o.velocity.z,o.velocity.x),r.rotation.z=Math.asin(o.velocity.y/o.velocity.length()),r.phase=(r.phase+(Math.max(0,r.rotation.z)+.1))%62.83,r.geometry.vertices[5].y=r.geometry.vertices[4].y=5*Math.sin(r.phase)*this.options.birdSize,r.geometry.verticesNeedUpdate=!0,r.position.x=n[t].position.x,r.position.y=n[t].position.y,r.position.z=n[t].position.z}}onMouseMove(e,t){if(this.mouseX=e-.5,this.mouseY=t-.5,!a){const e=this.boids;let t;for(var i=new s.Vector3(this.mouseX*this.width,-this.mouseY*this.height,0),n=0,o=e.length;n<o;n++)t=e[n],i.z=t.position.z,t.repulse(i)}}onDestroy(){}onResize(){}}b.initClass();t.default=n.a.register("BIRDS",b)}})});
  