import{a as pn}from"./chunk-1vb38x2b.js";import{$d as c,Ad as p,Dd as M,Qd as b,Sd as j,_d as tn,_f as xn,fd as K,hd as en,ih as gn,lf as d,m as cn,n as an,pa as J,pd as fn,sa as X,xa as l,xd as z,xe as D}from"./chunk-nw9je8wy.js";import"./chunk-rrt78xph.js";var g=new j;g.setAttribute("position",new b([-1,-1,0,1,-1,0,1,1,0,-1,1,0],3));g.setAttribute("uv",new b([0,0,1,0,1,1,0,1],2));g.setIndex([0,1,2,0,2,3]);class y extends M{app;model;backgroundPlane;useRenderTarget=!1;glassObjects=[];mount(n,r){this.app=n,this.model=r,this._build()}unmount(){this.app=null}destroy(){this._dispose(),this.app=null}_build(){}_dispose(){this.glassObjects=[],g.dispose()}onActivate(){}tick(n,r){}progress(n){}onResize(n,r){}}var Cn={shader:`precision highp float; uniform vec3 uBlue1; uniform vec3 uBlue2; uniform vec3 uWhiteColor; uniform vec2 uLerpedMouse; uniform float uProgress, uBackRender, uActiveScene; varying vec2 vUv; #define PI 3.141592653589793 highp float rand( const in vec2 uv ) { const highp float a = 12.9898, b = 78.233, c = 43758.5453; highp float dt = dot( uv.xy, vec2( a,b ) ), sn = mod( dt, PI ); return fract( sin( sn ) * c ); } void main() { if(uBackRender < .5) discard; vec2 ditheredUv = vUv; ditheredUv += (rand(gl_FragCoord.xy) - .5) * .2; vec3 color; if (uActiveScene == 0.) { float gradient = smoothstep(1.0, 0.0, length(ditheredUv - vec2(0.3, 0.9))); color = mix(uBlue1, uBlue2, gradient); float ellYPos = -.99 * smoothstep(1., 0.0, uProgress); vec2 ellUv = vUv; ellUv -= vec2(.5); ellUv -= vec2(0., ellYPos); float ellipser = length(ellUv); float blur = .02 * uBackRender; float ellipse = smoothstep(0.602 + blur, 0.6 - blur, ellipser); ellipse = mix(1., ellipse, step(0., ellUv.y)); color = mix(color, uWhiteColor * .85, ellipse); if(uBackRender > .5){ color = mix(color, uWhiteColor * .85, .4); } } else if (uActiveScene == 1.) { color = vec3(0.894,0.973,0.988); } else if (uActiveScene == 2.) { float gradient = smoothstep(1.0, 0.0, length(ditheredUv - vec2(0.3, 0.9) - .2 * uLerpedMouse)); color = mix(uBlue1, uBlue2, gradient); if(uBackRender > .5){ color = mix(color, uWhiteColor, .4); } } gl_FragColor = vec4(color, 1.0); gl_FragColor = linearToOutputTexel(gl_FragColor); }`,use:(n)=>{let r=n.material||n;return r.fragmentShader=`precision highp float; uniform vec3 uBlue1; uniform vec3 uBlue2; uniform vec3 uWhiteColor; uniform vec2 uLerpedMouse; uniform float uProgress, uBackRender, uActiveScene; varying vec2 vUv; #define PI 3.141592653589793 highp float rand( const in vec2 uv ) { const highp float a = 12.9898, b = 78.233, c = 43758.5453; highp float dt = dot( uv.xy, vec2( a,b ) ), sn = mod( dt, PI ); return fract( sin( sn ) * c ); } void main() { if(uBackRender < .5) discard; vec2 ditheredUv = vUv; ditheredUv += (rand(gl_FragCoord.xy) - .5) * .2; vec3 color; if (uActiveScene == 0.) { float gradient = smoothstep(1.0, 0.0, length(ditheredUv - vec2(0.3, 0.9))); color = mix(uBlue1, uBlue2, gradient); float ellYPos = -.99 * smoothstep(1., 0.0, uProgress); vec2 ellUv = vUv; ellUv -= vec2(.5); ellUv -= vec2(0., ellYPos); float ellipser = length(ellUv); float blur = .02 * uBackRender; float ellipse = smoothstep(0.602 + blur, 0.6 - blur, ellipser); ellipse = mix(1., ellipse, step(0., ellUv.y)); color = mix(color, uWhiteColor * .85, ellipse); if(uBackRender > .5){ color = mix(color, uWhiteColor * .85, .4); } } else if (uActiveScene == 1.) { color = vec3(0.894,0.973,0.988); } else if (uActiveScene == 2.) { float gradient = smoothstep(1.0, 0.0, length(ditheredUv - vec2(0.3, 0.9) - .2 * uLerpedMouse)); color = mix(uBlue1, uBlue2, gradient); if(uBackRender > .5){ color = mix(color, uWhiteColor, .4); } } gl_FragColor = vec4(color, 1.0); gl_FragColor = linearToOutputTexel(gl_FragColor); }`,r.needsUpdate=!0,n},unuse:()=>{},clear:()=>{},update:()=>{}},I=Cn;var ln={shader:`varying vec2 vUv; void main() { gl_Position = vec4(position.xy, 1.0, 1.0); vUv = uv; }`,use:(n)=>{let r=n.material||n;return r.vertexShader=`varying vec2 vUv; void main() { gl_Position = vec4(position.xy, 1.0, 1.0); vUv = uv; }`,r.needsUpdate=!0,n},unuse:()=>{},clear:()=>{},update:()=>{}},k=ln;class B extends d{constructor(){super();this.uniforms={uBlue1:{value:new p(8512760)},uBlue2:{value:new p(52991)},uWhiteColor:{value:new p(14544885)},uProgress:e.uProgress,uResolution:e.uResolution,uBackRender:e.uBackRender,uActiveScene:e.uActiveScene,uLerpedMouse:e.uLerpedMouse},I.use(this),k.use(this)}}var yn={shader:`precision highp float; uniform bool uBackRender; uniform bool uMobile; uniform float uProgress; uniform float uActiveScene; uniform vec3 uColor; uniform vec2 uResolution; uniform sampler2D tBackground; uniform sampler2D tMatcap; uniform sampler2D tNoise; varying vec2 vUv; varying vec3 vNormal; varying vec3 vWorldPosition; varying vec3 vViewPosition; const int samples = 12, LOD = 2, sLOD = 1 << LOD; const float sigma = float(samples) * .8; float gaussian(vec2 i) { return exp( -.5* dot(i/=sigma,i) ) / ( 6.28 * sigma*sigma ); } vec4 blur(sampler2D sp, vec2 U, vec2 scale) { vec4 O = vec4(0); int s = samples/sLOD; for ( int i = 0; i < s*s; i++ ) { vec2 d = vec2(i%s, i/s)*float(sLOD) - float(samples)/2.; O += gaussian(d) * textureLod( sp, U + scale * d , float(LOD) ); } return O / O.a; } void main() { float progress = uProgress * float(uActiveScene == 0.); vec3 noise = texture2D(tNoise, vUv * 7.).rgb; vec3 normal = vNormal; normal = normalize(normal + (noise - .5) * .01); vec3 dNormal = normalize(vNormal + (noise - .5) * .15); vec3 viewDir = normalize( vViewPosition ); vec3 x = normalize( vec3( viewDir.z, 0.0, - viewDir.x ) ); vec3 y = cross( viewDir, x ); vec2 uv = vec2( dot( x, normal ), dot( y, normal ) ) * 0.495 + 0.5; vec3 color = vec3(.95); vec3 matcapColor = texture2D(tMatcap, uv ).rgb; float alpha = 1.; if (!uBackRender) { vec2 sUv = gl_FragCoord.xy / uResolution; vec2 dsUv = sUv + dNormal.rg * .01; vec4 bgColor; if(!uMobile) { bgColor = blur(tBackground, dsUv, 1./uResolution); } else { bgColor = texture2D(tBackground, dsUv); } bgColor.rgb *= .9 + .1 * color; color = mix(color, bgColor.rgb, smoothstep(1., .0, length(matcapColor))); } else { alpha = 0.5 * smoothstep(.0, 1., length(matcapColor)); } gl_FragColor = vec4(color, alpha); gl_FragColor = linearToOutputTexel(gl_FragColor); }`,use:(n)=>{let r=n.material||n;return r.fragmentShader=`precision highp float; uniform bool uBackRender; uniform bool uMobile; uniform float uProgress; uniform float uActiveScene; uniform vec3 uColor; uniform vec2 uResolution; uniform sampler2D tBackground; uniform sampler2D tMatcap; uniform sampler2D tNoise; varying vec2 vUv; varying vec3 vNormal; varying vec3 vWorldPosition; varying vec3 vViewPosition; const int samples = 12, LOD = 2, sLOD = 1 << LOD; const float sigma = float(samples) * .8; float gaussian(vec2 i) { return exp( -.5* dot(i/=sigma,i) ) / ( 6.28 * sigma*sigma ); } vec4 blur(sampler2D sp, vec2 U, vec2 scale) { vec4 O = vec4(0); int s = samples/sLOD; for ( int i = 0; i < s*s; i++ ) { vec2 d = vec2(i%s, i/s)*float(sLOD) - float(samples)/2.; O += gaussian(d) * textureLod( sp, U + scale * d , float(LOD) ); } return O / O.a; } void main() { float progress = uProgress * float(uActiveScene == 0.); vec3 noise = texture2D(tNoise, vUv * 7.).rgb; vec3 normal = vNormal; normal = normalize(normal + (noise - .5) * .01); vec3 dNormal = normalize(vNormal + (noise - .5) * .15); vec3 viewDir = normalize( vViewPosition ); vec3 x = normalize( vec3( viewDir.z, 0.0, - viewDir.x ) ); vec3 y = cross( viewDir, x ); vec2 uv = vec2( dot( x, normal ), dot( y, normal ) ) * 0.495 + 0.5; vec3 color = vec3(.95); vec3 matcapColor = texture2D(tMatcap, uv ).rgb; float alpha = 1.; if (!uBackRender) { vec2 sUv = gl_FragCoord.xy / uResolution; vec2 dsUv = sUv + dNormal.rg * .01; vec4 bgColor; if(!uMobile) { bgColor = blur(tBackground, dsUv, 1./uResolution); } else { bgColor = texture2D(tBackground, dsUv); } bgColor.rgb *= .9 + .1 * color; color = mix(color, bgColor.rgb, smoothstep(1., .0, length(matcapColor))); } else { alpha = 0.5 * smoothstep(.0, 1., length(matcapColor)); } gl_FragColor = vec4(color, alpha); gl_FragColor = linearToOutputTexel(gl_FragColor); }`,r.needsUpdate=!0,n},unuse:()=>{},clear:()=>{},update:()=>{}},q=yn;var dn={shader:`varying vec2 vUv; varying vec3 vNormal; varying vec3 vWorldPosition; varying vec3 vViewPosition; void main() { vec4 mvPosition = modelMatrix * vec4(position, 1.); vWorldPosition = mvPosition.xyz; mvPosition = viewMatrix * mvPosition; vViewPosition = mvPosition.xyz; gl_Position = projectionMatrix * mvPosition; vUv = uv; vNormal = normalMatrix * normal; }`,use:(n)=>{let r=n.material||n;return r.vertexShader=`varying vec2 vUv; varying vec3 vNormal; varying vec3 vWorldPosition; varying vec3 vViewPosition; void main() { vec4 mvPosition = modelMatrix * vec4(position, 1.); vWorldPosition = mvPosition.xyz; mvPosition = viewMatrix * mvPosition; vViewPosition = mvPosition.xyz; gl_Position = projectionMatrix * mvPosition; vUv = uv; vNormal = normalMatrix * normal; }`,r.needsUpdate=!0,n},unuse:()=>{},clear:()=>{},update:()=>{}},E=dn;var T,F,P=document.createElement("canvas");P.width=P.height=256;var G=P.getContext("2d"),Z=G.getImageData(0,0,P.width,P.height);Z.data.forEach((n,r)=>{Z.data[r]=Math.round(Math.random()*255)});G.putImageData(Z,0,0);var w={get texture(){if(!T)T=new D(P),T.wrapS=T.wrapT=J,T.minFilter=l,T.magFilter=l;return T},get nearestTexture(){if(!F)F=new D(P),F.wrapS=F.wrapT=J,F.minFilter=X,F.magFilter=X;return F}};class h extends d{constructor(){super();this.uniforms={uColor:{value:new p(16777215)},tMatcap:{value:null},tBackground:e.tBackground,uResolution:e.uResolution,uBackRender:e.uBackRender,tNoise:{value:w.texture},uMobile:e.uMobile,uProgress:e.uProgress,uActiveScene:e.uActiveScene},this.transparent=!0,q.use(this),E.use(this)}}var Bn={shader:`precision highp float; uniform float uProgress, uActiveScene; uniform sampler2D tMap, tBlured; uniform bool uBackRender; varying vec2 vUv; void main() { if(uBackRender) { gl_FragColor = texture2D(tBlured, vec2(vUv.x , 1. - vUv.y)); } else { gl_FragColor = texture2D(tMap, vUv); } if(uActiveScene == 0.) { gl_FragColor.a *= smoothstep(1., 0.95, uProgress); } gl_FragColor = linearToOutputTexel(gl_FragColor); }`,use:(n)=>{let r=n.material||n;return r.fragmentShader=`precision highp float; uniform float uProgress, uActiveScene; uniform sampler2D tMap, tBlured; uniform bool uBackRender; varying vec2 vUv; void main() { if(uBackRender) { gl_FragColor = texture2D(tBlured, vec2(vUv.x , 1. - vUv.y)); } else { gl_FragColor = texture2D(tMap, vUv); } if(uActiveScene == 0.) { gl_FragColor.a *= smoothstep(1., 0.95, uProgress); } gl_FragColor = linearToOutputTexel(gl_FragColor); }`,r.needsUpdate=!0,n},unuse:()=>{},clear:()=>{},update:()=>{}},_=Bn;var Un={shader:`varying vec2 vUv; uniform vec2 uLerpedMouse; uniform float uActiveScene; mat4 rotationMatrix(vec3 axis, float angle) { axis = normalize(axis); float s = sin(angle); float c = cos(angle); float oc = 1.0 - c; return mat4(oc * axis.x * axis.x + c, oc * axis.x * axis.y - axis.z * s, oc * axis.z * axis.x + axis.y * s, 0.0, oc * axis.x * axis.y + axis.z * s, oc * axis.y * axis.y + c, oc * axis.y * axis.z - axis.x * s, 0.0, oc * axis.z * axis.x - axis.y * s, oc * axis.y * axis.z + axis.x * s, oc * axis.z * axis.z + c, 0.0, 0.0, 0.0, 0.0, 1.0); } void main() { vec3 transformed = position; float mouseIntensity = mix(0.05, 0.0, step(0.5, uActiveScene)); transformed.y -= uLerpedMouse.y * mouseIntensity; vec4 mvPosition = modelMatrix * vec4(transformed, 1.); mat4 rotMat = rotationMatrix(vec3(0.0, 1.0, 0.0), mouseIntensity * 2.0 * uLerpedMouse.x); mvPosition = rotMat * mvPosition; gl_Position = projectionMatrix * viewMatrix * mvPosition; vUv = uv; }`,use:(n)=>{let r=n.material||n;return r.vertexShader=`varying vec2 vUv; uniform vec2 uLerpedMouse; uniform float uActiveScene; mat4 rotationMatrix(vec3 axis, float angle) { axis = normalize(axis); float s = sin(angle); float c = cos(angle); float oc = 1.0 - c; return mat4(oc * axis.x * axis.x + c, oc * axis.x * axis.y - axis.z * s, oc * axis.z * axis.x + axis.y * s, 0.0, oc * axis.x * axis.y + axis.z * s, oc * axis.y * axis.y + c, oc * axis.y * axis.z - axis.x * s, 0.0, oc * axis.z * axis.x - axis.y * s, oc * axis.y * axis.z + axis.x * s, oc * axis.z * axis.z + c, 0.0, 0.0, 0.0, 0.0, 1.0); } void main() { vec3 transformed = position; float mouseIntensity = mix(0.05, 0.0, step(0.5, uActiveScene)); transformed.y -= uLerpedMouse.y * mouseIntensity; vec4 mvPosition = modelMatrix * vec4(transformed, 1.); mat4 rotMat = rotationMatrix(vec3(0.0, 1.0, 0.0), mouseIntensity * 2.0 * uLerpedMouse.x); mvPosition = rotMat * mvPosition; gl_Position = projectionMatrix * viewMatrix * mvPosition; vUv = uv; }`,r.needsUpdate=!0,n},unuse:()=>{},clear:()=>{},update:()=>{}},nn=Un;class N extends d{constructor(n=1){super();this.uniforms={tMap:{value:null},tBlured:n===2?e.tBluredTexture2:e.tBluredTexture,uBackRender:e.uBackRender,uLerpedMouse:e.uLerpedMouse,uActiveScene:e.uActiveScene,uProgress:e.uProgress},this.transparent=!0,_.use(this),nn.use(this)}}var Tn=0.55,Fn=0.1;class O extends y{logo;images;imagesPos=[];_apparitionTime=0;_apparitionActive=!1;_build(){this.useRenderTarget=!0;let n=this.model;this.setupBackground();let r=n.getObjectByName("Logo");if(!(r instanceof c))throw Error("Logo mesh not found in SceneA model");r.material=new h,r.layers.enable(x.BACKGROUND),r.rotation.order="YZX",this.logo=r.clone(),this.add(this.logo),this.glassObjects.push(this.logo),this.images=new z;let o=new N,t=null,i=[];n.traverse((s)=>{if(s.name.slice(0,4)==="Img_"&&s instanceof c){let m=Array.isArray(s.material)?s.material[0]:s.material;if(!t&&m&&"map"in m)t=m.map??null;let a=parseInt(s.name.slice(4),10),U=s.clone();U.material=o,i.push({index:a,mesh:U})}}),i.sort((s,m)=>s.index-m.index);for(let{mesh:s}of i){if(this.imagesPos.push(s.position.clone()),s.position.z<0)s.layers.enable(x.BACKGROUND);this.images.add(s)}o.uniforms.tMap.value=t;let u=n.getObjectByName("MATCAP");if(!(u instanceof c))throw Error("MATCAP mesh not found in SceneA model");let v=Array.isArray(u.material)?u.material[0]:u.material;if(v&&"map"in v)this.logo.material.uniforms.tMatcap.value=v.map??null;this.add(this.images)}_dispose(){super._dispose(),this.backgroundPlane.material.dispose(),this.logo.geometry.dispose(),this.logo.material.dispose(),this.images.traverse((n)=>{if(n instanceof c)if(n.geometry.dispose(),Array.isArray(n.material))n.material.forEach((r)=>r.dispose());else n.material.dispose()}),this.imagesPos=[]}onActivate(){this._apparitionTime=0,this._apparitionActive=!0,this.logo.scale.setScalar(0),this.images.children.forEach((n)=>n.scale.setScalar(0))}tick(n,r){if(this.logo.rotation.y+=0.2*e.uLerpedMouse.value.x,this.logo.rotation.x+=0.2*e.uLerpedMouse.value.y,this._apparitionActive){this._apparitionTime+=n;let o=!0,t=(i,u)=>{let v=(this._apparitionTime-u*Fn)/Tn,s=Math.min(1,Math.max(0,v));if(s<1)o=!1;i.scale.setScalar(1-Math.pow(1-s,3))};if(t(this.logo,0),this.images.children.forEach((i,u)=>t(i,u+1)),o)this._apparitionActive=!1}}progress(n){e.uProgress.value=n,this.logo.rotation.x=n*0.67,this.logo.rotation.y=n*0.67,this.images.children[0].position.y=this.imagesPos[0].y-0.2*n,this.images.children[0].position.x=this.imagesPos[0].x+1.8*n,this.images.children[1].position.x=this.imagesPos[1].x-0.15*n,this.images.children[1].position.y=this.imagesPos[1].y-1*n,this.images.children[2].position.x=this.imagesPos[2].x+0.3*n,this.images.children[2].position.y=this.imagesPos[2].y+1.2*n,this.images.children[3].position.y=this.imagesPos[3].y+0.1*n,this.images.children[3].position.x=this.imagesPos[3].x-2*n}setupBackground(){this.backgroundPlane=new c(g,new B),this.backgroundPlane.frustumCulled=!1,this.backgroundPlane.renderOrder=-1,this.backgroundPlane.layers.set(x.BACKGROUND),this.add(this.backgroundPlane)}}var Cr=Math.PI/180,lr=180/Math.PI;function Q(n,r,o){return(1-o)*n+o*r}function f(n,r,o){if(n<=r)return 0;if(n>=o)return 1;return n=(n-r)/(o-r),n*n*(3-2*n)}function S(n,r,o){if(n<=r)return 0;if(n>=o)return 1;return n=(n-r)/(o-r),n*n*n*(n*(n*6-15)+10)}var Pn={shader:`precision highp float; uniform bool uBackRender; uniform bool uMobile; uniform float uProgress; uniform float uActiveScene; uniform vec3 uColor; uniform float uOpacity; uniform vec2 uResolution; uniform sampler2D tBackground; uniform sampler2D tMatcap; uniform sampler2D tNoise; varying vec2 vUv; varying vec3 vNormal; varying vec3 vWorldPosition; varying vec3 vViewPosition; const int samples = 12, LOD = 2, sLOD = 1 << LOD; const float sigma = float(samples) * .8; float gaussian(vec2 i) { return exp( -.5* dot(i/=sigma,i) ) / ( 6.28 * sigma*sigma ); } vec4 blur(sampler2D sp, vec2 U, vec2 scale) { vec4 O = vec4(0); int s = samples/sLOD; for ( int i = 0; i < s*s; i++ ) { vec2 d = vec2(i%s, i/s)*float(sLOD) - float(samples)/2.; O += gaussian(d) * textureLod( sp, U + scale * d , float(LOD) ); } return O / O.a; } vec2 rotateVec2(vec2 uv, float rotation) { vec2 mid = vec2(0.5); return vec2( cos(rotation) * (uv.x - mid.x) + sin(rotation) * (uv.y - mid.y) + mid.x, cos(rotation) * (uv.y - mid.y) - sin(rotation) * (uv.x - mid.x) + mid.y ); } void main() { vec3 lilac = vec3(0.761,0.827,1.); vec3 teal = vec3(0.506,0.894,0.973); vec3 blue = vec3(0.,0.808,1.); vec2 rUv = rotateVec2(vUv, -3.14 * 0.25); vec3 gradientColor = mix(teal, lilac, smoothstep(0.4, .8, rUv.y)); gradientColor = mix(blue, gradientColor, smoothstep(0., .5, rUv.y)); float flatTo3D = smoothstep(0.8, 1., uProgress); float progress = uProgress; vec3 noise = texture2D(tNoise, vUv * 7.).rgb; vec3 normal = vNormal; normal = normalize(normal + (noise - .5) * .01); vec3 dNormal = normalize(vNormal + (noise - .5) * .15); vec3 viewDir = normalize( vViewPosition ); vec3 x = normalize( vec3( viewDir.z, 0.0, - viewDir.x ) ); vec3 y = cross( viewDir, x ); vec2 uv = vec2( dot( x, normal ), dot( y, normal ) ) * 0.495 + 0.5; vec3 color = mix(blue, vec3(.85), smoothstep(0.05, .45, length(vUv - .5))); vec3 matcapColor = texture2D(tMatcap, uv ).rgb; matcapColor *= (2. + float(uBackRender) * 1.); float alpha = 1.; if (!uBackRender) { vec2 sUv = gl_FragCoord.xy / uResolution; vec2 dsUv = sUv + dNormal.rg * .01; vec4 bgColor; if(!uMobile) { bgColor = blur(tBackground, dsUv, 1./uResolution); } else { bgColor = texture2D(tBackground, dsUv); } bgColor.rgb *= .3 + .7 * color; color = mix(color, bgColor.rgb, .1 + 0.9 * smoothstep(1.7, .2, length(matcapColor))); } else { alpha = .7 *smoothstep(.2, .3, length(matcapColor)); } gl_FragColor = vec4(color, alpha); gl_FragColor = linearToOutputTexel(gl_FragColor); gl_FragColor = mix(vec4(gradientColor, smoothstep(0.6, .7, uProgress)), gl_FragColor, flatTo3D); }`,use:(n)=>{let r=n.material||n;return r.fragmentShader=`precision highp float; uniform bool uBackRender; uniform bool uMobile; uniform float uProgress; uniform float uActiveScene; uniform vec3 uColor; uniform float uOpacity; uniform vec2 uResolution; uniform sampler2D tBackground; uniform sampler2D tMatcap; uniform sampler2D tNoise; varying vec2 vUv; varying vec3 vNormal; varying vec3 vWorldPosition; varying vec3 vViewPosition; const int samples = 12, LOD = 2, sLOD = 1 << LOD; const float sigma = float(samples) * .8; float gaussian(vec2 i) { return exp( -.5* dot(i/=sigma,i) ) / ( 6.28 * sigma*sigma ); } vec4 blur(sampler2D sp, vec2 U, vec2 scale) { vec4 O = vec4(0); int s = samples/sLOD; for ( int i = 0; i < s*s; i++ ) { vec2 d = vec2(i%s, i/s)*float(sLOD) - float(samples)/2.; O += gaussian(d) * textureLod( sp, U + scale * d , float(LOD) ); } return O / O.a; } vec2 rotateVec2(vec2 uv, float rotation) { vec2 mid = vec2(0.5); return vec2( cos(rotation) * (uv.x - mid.x) + sin(rotation) * (uv.y - mid.y) + mid.x, cos(rotation) * (uv.y - mid.y) - sin(rotation) * (uv.x - mid.x) + mid.y ); } void main() { vec3 lilac = vec3(0.761,0.827,1.); vec3 teal = vec3(0.506,0.894,0.973); vec3 blue = vec3(0.,0.808,1.); vec2 rUv = rotateVec2(vUv, -3.14 * 0.25); vec3 gradientColor = mix(teal, lilac, smoothstep(0.4, .8, rUv.y)); gradientColor = mix(blue, gradientColor, smoothstep(0., .5, rUv.y)); float flatTo3D = smoothstep(0.8, 1., uProgress); float progress = uProgress; vec3 noise = texture2D(tNoise, vUv * 7.).rgb; vec3 normal = vNormal; normal = normalize(normal + (noise - .5) * .01); vec3 dNormal = normalize(vNormal + (noise - .5) * .15); vec3 viewDir = normalize( vViewPosition ); vec3 x = normalize( vec3( viewDir.z, 0.0, - viewDir.x ) ); vec3 y = cross( viewDir, x ); vec2 uv = vec2( dot( x, normal ), dot( y, normal ) ) * 0.495 + 0.5; vec3 color = mix(blue, vec3(.85), smoothstep(0.05, .45, length(vUv - .5))); vec3 matcapColor = texture2D(tMatcap, uv ).rgb; matcapColor *= (2. + float(uBackRender) * 1.); float alpha = 1.; if (!uBackRender) { vec2 sUv = gl_FragCoord.xy / uResolution; vec2 dsUv = sUv + dNormal.rg * .01; vec4 bgColor; if(!uMobile) { bgColor = blur(tBackground, dsUv, 1./uResolution); } else { bgColor = texture2D(tBackground, dsUv); } bgColor.rgb *= .3 + .7 * color; color = mix(color, bgColor.rgb, .1 + 0.9 * smoothstep(1.7, .2, length(matcapColor))); } else { alpha = .7 *smoothstep(.2, .3, length(matcapColor)); } gl_FragColor = vec4(color, alpha); gl_FragColor = linearToOutputTexel(gl_FragColor); gl_FragColor = mix(vec4(gradientColor, smoothstep(0.6, .7, uProgress)), gl_FragColor, flatTo3D); }`,r.needsUpdate=!0,n},unuse:()=>{},clear:()=>{},update:()=>{}},rn=Pn;var Nn={shader:`varying vec2 vUv; varying vec3 vNormal; varying vec3 vWorldPosition; varying vec3 vViewPosition; void main() { vec4 mvPosition = modelMatrix * vec4(position, 1.); vWorldPosition = mvPosition.xyz; mvPosition = viewMatrix * mvPosition; vViewPosition = mvPosition.xyz; gl_Position = projectionMatrix * mvPosition; vUv = uv; vNormal = normalMatrix * normal; }`,use:(n)=>{let r=n.material||n;return r.vertexShader=`varying vec2 vUv; varying vec3 vNormal; varying vec3 vWorldPosition; varying vec3 vViewPosition; void main() { vec4 mvPosition = modelMatrix * vec4(position, 1.); vWorldPosition = mvPosition.xyz; mvPosition = viewMatrix * mvPosition; vViewPosition = mvPosition.xyz; gl_Position = projectionMatrix * mvPosition; vUv = uv; vNormal = normalMatrix * normal; }`,r.needsUpdate=!0,n},unuse:()=>{},clear:()=>{},update:()=>{}},on=Nn;class H extends d{constructor(){super();this.uniforms={uColor:{value:new p(52991)},tMatcap:{value:null},tBackground:e.tBackground,uResolution:e.uResolution,uBackRender:e.uBackRender,tNoise:{value:w.texture},uMobile:e.uMobile,uProgress:e.uProgress,uActiveScene:e.uActiveScene},this.transparent=!0,rn.use(this),on.use(this)}}var R=new en(-0.4,-0.8,0),zn=0.45,Dn=1.6,Sn=(n)=>n<0.5?2*n*n:1-(-2*n+2)**2/2;class L extends y{_introSpeed;_tabSpeed;constructor(n={}){super();this._introSpeed=n.introSpeed??zn,this._tabSpeed=n.tabSpeed??Dn}squircles;parallaxGroup=new z;sparkleGroup=new z;sparkle;smallSparkle;squirclesMaterial;animationProgress=0;introPlaying=!1;tabProgress=0;tabPlaying=!1;_activeTabIndex=0;_previousTabIndex=0;tabImages=[];imageMaterial1;imageMaterial2;_build(){this.useRenderTarget=!0;let n=this.model;this.setupBackground();let r=n.getObjectByName("Squircles");if(!(r instanceof z))throw Error("Squircles object not found in SceneB model");this.squircles=r,this.add(this.squircles),this.squirclesMaterial=new tn({color:new p(52991),transparent:!0,opacity:1}),this.squircles.children.forEach((a)=>{if(a instanceof c)a.material=this.squirclesMaterial});let o=new H,t=n.getObjectByName("MATCAP");if(!(t instanceof c))throw Error("MATCAP mesh not found in SceneA model");let i=Array.isArray(t.material)?t.material[0]:t.material;if(i&&"map"in i)o.uniforms.tMatcap.value=i.map??null;let u=n.getObjectByName("Sparkle"),v=n.getObjectByName("SparkleS");if(!(u instanceof c)||!(v instanceof c))throw Error("Sparkle object not found in SceneB model");else u.material=o,this.sparkle=u,v.material=o,this.smallSparkle=v,this.glassObjects.push(this.sparkle,this.smallSparkle),u.layers.enable(x.BACKGROUND),v.layers.enable(x.BACKGROUND),this.sparkleGroup.add(this.sparkle,this.smallSparkle),this.parallaxGroup.add(this.sparkleGroup);this.sparkleGroup.rotation.order="YXZ",this.add(this.parallaxGroup),this.scale.setScalar(1.3),this.imageMaterial1=new N(1),this.imageMaterial2=new N(2);for(let a=0;a<4;a++)this.tabImages[a]=new z;let s=null,m=null;n.traverse((a)=>{let U=a.name.match(/^T(\d)_Image_/);if(!U||!(a instanceof c))return;let Y=parseInt(U[1]);if(Y>3)return;let C=Array.isArray(a.material)?a.material[0]:a.material,$=C&&"name"in C&&C.name==="Image2",mn=$?this.imageMaterial2:this.imageMaterial1;if(!$&&!s&&C&&"map"in C)s=C.map??null;if($&&!m&&C&&"map"in C)m=C.map??null;let W=a.clone();if(W.position.z<2)W.layers.enable(x.BACKGROUND);W.material=mn,this.tabImages[Y].add(W)}),this.imageMaterial1.uniforms.tMap.value=s,this.imageMaterial2.uniforms.tMap.value=m;for(let a of this.tabImages)a.children.forEach((U)=>U.scale.setScalar(0)),this.parallaxGroup.add(a)}_dispose(){super._dispose(),this.backgroundPlane.material.dispose(),this.squirclesMaterial.dispose(),this.sparkle.material.dispose(),this.imageMaterial1.dispose(),this.imageMaterial2.dispose();for(let n of this.tabImages)n.traverse((r)=>{if(r instanceof c)r.geometry.dispose()});this.tabImages=[]}onActivate(){if(this.introPlaying)this.animationProgress=1,this.introPlaying=!1;this.tabPlaying=!1,this._playIntro(this.animationProgress),e.uProgress.value=this.animationProgress}startIntro(){this.animationProgress=0,this.introPlaying=!0;for(let n of this.tabImages)n.children.forEach((r)=>r.scale.setScalar(0))}tick(n,r){if(this.introPlaying){if(this.animationProgress=Math.min(this.animationProgress+n*this._introSpeed,1),this.animationProgress>=1)this.introPlaying=!1;this._playIntro(this.animationProgress),e.uProgress.value=this.animationProgress}if(this.tabPlaying){if(this.tabProgress=Math.min(this.tabProgress+n*this._tabSpeed,1),this.tabProgress>=1)this.tabPlaying=!1;this._playAnimation(Sn(this.tabProgress))}this.parallaxGroup.rotation.y=-0.1*e.uLerpedMouse.value.x,this.parallaxGroup.rotation.x=-0.1*e.uLerpedMouse.value.y}animate(n){if(n===this._activeTabIndex)return;if(this.introPlaying)this.animationProgress=1,e.uProgress.value=18,this._playIntro(1),this.introPlaying=!1;this._previousTabIndex=this._activeTabIndex,this._activeTabIndex=n,this.tabProgress=0,this.tabPlaying=!0}_playAnimation(n){if(this._activeTabIndex>=4)return;let r=1-f(n,0,0.4)+f(n,0.6,1);this.sparkleGroup.rotation.y=R.y+n*Math.PI*2,this.sparkleGroup.rotation.x=R.x*r,this.tabImages.forEach((o,t)=>{o.children.forEach((i,u)=>{let v=u*0.05;if(t===this._previousTabIndex)i.scale.setScalar(1-f(n,0,0.4+v));else if(t===this._activeTabIndex)i.scale.setScalar(f(n,0.6+v,1));else i.scale.setScalar(0)})})}_playIntro(n){let r=f(n,0,0.5);this.squircles.children.forEach((i,u)=>{let v=u*0.1,s=S(r-v,0,0.4);i.rotation.z=1*(1-s),i.scale.setScalar(s)});let o=S(n,0.3,0.6);this.squircles.rotation.z=-o*Math.PI,this.squircles.scale.setScalar(1-0.2*S(n,0.6,0.7)),this.squirclesMaterial.opacity=1-S(n,0.65,0.7);let t=f(n,0.6,1);if(t<=0)this.sparkle.visible=!1;else this.sparkle.visible=!0,this.parallaxGroup.position.z=f(t,0,0.1)*2;if(t<=0.3)this.smallSparkle.visible=!1;else this.smallSparkle.visible=!0,this.smallSparkle.position.z=Q(-0.1,0,f(t,0.3,0.5)),this.smallSparkle.position.x=Q(0.04,0.25,f(t,0.3,0.4)),this.smallSparkle.position.y=0.2+0.05*f(t,0.3,0.35)*(1-f(t,0.35,0.4)),this.smallSparkle.rotation.z=(1-f(t,0.3,0.4))*0.5;this.sparkleGroup.rotation.y=R.y*f(t,0.1,1),this.sparkleGroup.rotation.x=R.x*f(t,0.2,1),this.tabImages[0].children[0]?.scale.setScalar(f(t,0.85,0.95)),this.tabImages[0].children[1]?.scale.setScalar(f(t,0.9,1))}setupBackground(){this.backgroundPlane=new c(g,new B),this.backgroundPlane.frustumCulled=!1,this.backgroundPlane.renderOrder=-1,this.backgroundPlane.layers.set(x.BACKGROUND),this.add(this.backgroundPlane)}}class V extends y{logo;_build(){this.useRenderTarget=!0;let n=this.model;this.setupBackground();let r=n.getObjectByName("Logo");if(!(r instanceof c))throw Error("Logo mesh not found in SceneA model");this.logo=r.clone(),this.add(this.logo),this.glassObjects.push(this.logo),this.logo.scale.setScalar(1.7),this.logo.position.x=0.1,this.logo.rotation.x=0.7,this.logo.rotation.y=0.7}_dispose(){super._dispose(),this.backgroundPlane.material.dispose(),this.logo.geometry.dispose(),this.logo.material.dispose()}tick(n,r){this.logo.rotation.y=0.7-0.1*e.uLerpedMouse.value.x,this.logo.rotation.x=0.7-0.1*e.uLerpedMouse.value.y}setupBackground(){this.backgroundPlane=new c(g,new B),this.backgroundPlane.frustumCulled=!1,this.backgroundPlane.renderOrder=-1,this.backgroundPlane.layers.set(x.BACKGROUND),this.add(this.backgroundPlane)}}function un(n,r,o=12){let t=null;if(n.traverse((i)=>{if(t||!(i instanceof c))return;let u=Array.isArray(i.material)?i.material[0]:i.material;if(u&&"name"in u&&u.name===r&&"map"in u)t=u.map??null}),!t)return null;return vn(t,o)}function sn(n,r=12){let o=Wn(n);if(!o)return null;return vn(o,r)}function vn(n,r){let o=n.source.data??n.image;if(!wn(o))return null;let t=hn(o);if(!t)return null;let i=document.createElement("canvas");i.width=t.width,i.height=t.height;let u=i.getContext("2d");if(!u)return null;u.filter=`blur(${r}px)`,u.drawImage(o,0,0,t.width,t.height);let v=new D(i);return v.colorSpace=n.colorSpace,v.minFilter=l,v.magFilter=l,v.needsUpdate=!0,v}function Wn(n){let r=null;return n.traverse((o)=>{if(r||!o.name.startsWith("Img_")||!(o instanceof c))return;let t=Array.isArray(o.material)?o.material[0]:o.material;if(t&&"map"in t)r=t.map??null}),r}function wn(n){if(!n||typeof n!=="object")return!1;let r=n;return Boolean(r.naturalWidth||r.videoWidth||r.width)&&Boolean(r.naturalHeight||r.videoHeight||r.height)}function hn(n){let r=n,o=r.naturalWidth??r.videoWidth??r.width,t=r.naturalHeight??r.videoHeight??r.height;if(!o||!t)return null;return{width:o,height:t}}class A{ready;camera;renderer;renderTarget;model=null;_blurredTexture=null;_blurredTexture2=null;_mouseTarget=new K;_progress=0;_targetProgress=0;_isTickerRunning=!1;_activeScene=null;_scenes={};_lastTime;_modelUrl;_onPointerMove;_resizeObserver=null;_tabsOptions;constructor(n={}){this._modelUrl=n.modelUrl??"/halo.glb",this._tabsOptions=n.tabsOptions,this._initCore(),this._bindEvents(),this.ready=this._loadAssets()}_initCore(){let{innerWidth:n,innerHeight:r}=window,o=Math.max(n,1),t=Math.max(r,1),i=Math.min(window.devicePixelRatio,2);this.camera=new xn(25,o/t,0.1,100),this.camera.position.set(0,0,6),this.renderer=new gn({antialias:!0,alpha:!0}),this.renderer.setClearColor(0,0),this.renderer.setPixelRatio(i),this.renderer.setSize(o,t,!1),this.renderTarget=new fn(o*i,t*i,{minFilter:l,magFilter:l}),e.uResolution.value.set(o*i,t*i),e.uMobile.value=n<=400}async _loadAssets(){let r=await new pn().loadAsync(this._modelUrl);this.model=r.scene,this.blurTexture(this.model),this._scenes={hero:new O,tabs:new L(this._tabsOptions),banner:new V},Object.values(this._scenes).forEach((o)=>{o.mount(this,this.model)})}setScene(n,r){let o=this._scenes[n];if(!o)throw Error(`Scene with key "${n}" does not exist`);if(r.appendChild(this.renderer.domElement),this.renderer.domElement.style.position="absolute",this.renderer.domElement.style.inset="0",this.renderer.domElement.style.width="100%",this.renderer.domElement.style.height="100%",this.renderer.domElement.style.background="transparent",!this._resizeObserver)this._resizeObserver=new ResizeObserver(()=>{this._handleCanvasResize()});this._resizeObserver.disconnect(),this._resizeObserver.observe(this.renderer.domElement),this._handleCanvasResize(),this._activeScene=o,this._activeScene.onActivate(),this._activeScene.progress(this._progress),e.uActiveScene.value=Object.keys(this._scenes).indexOf(n)}progress(n){let r=Math.min(Math.max(n,0),1);this._targetProgress=r,this._progress=r,this._activeScene?.progress(r)}startTabsIntro(){this._scenes.tabs.startIntro()}animateTabs(n){this._scenes.tabs.animate(n)}startTicker(){if(this._isTickerRunning)return;this._isTickerRunning=!0,this._lastTime=void 0}stopTicker(){if(!this._isTickerRunning)return;this._lastTime=void 0,this._isTickerRunning=!1}tick(n=0){if(!this._isTickerRunning)return;let r=Math.min((n-(this._lastTime??n))/1000,0.1),o=n/1000;this._progress=this._targetProgress,e.uTime.value=o,e.uLerpedMouse.value.lerp(this._mouseTarget,0.02),this._lastTime=n,this._activeScene?.progress(this._progress),this._activeScene?.tick(r,o),this.render()}render(){if(this._activeScene){if(this._activeScene.useRenderTarget)this._activeScene.glassObjects.forEach((n)=>{this.setMeshMaterialSide(n.material,an)}),this.camera.layers.disableAll(),this.camera.layers.enable(x.BACKGROUND),this.renderer.setRenderTarget(this.renderTarget),e.uBackRender.value=!0,e.tBackground.value=null,this.renderer.render(this._activeScene,this.camera),e.tBackground.value=this.renderTarget.texture,this.renderer.setRenderTarget(null),this.camera.layers.enableAll(),this._activeScene.glassObjects.forEach((n)=>{this.setMeshMaterialSide(n.material,cn)}),e.uBackRender.value=!1;this.renderer.render(this._activeScene,this.camera)}}blurTexture(n){this._blurredTexture?.dispose(),this._blurredTexture=sn(n),e.tBluredTexture.value=this._blurredTexture,this._blurredTexture2?.dispose(),this._blurredTexture2=un(n,"Image2"),e.tBluredTexture2.value=this._blurredTexture2}_handleCanvasResize(){let{width:n,height:r}=this.renderer.domElement.getBoundingClientRect();if(n<=0||r<=0)return;let o=Math.min(window.devicePixelRatio,2);this.camera.aspect=n/r,this.camera.updateProjectionMatrix(),this.renderer.setPixelRatio(o),this.renderer.setSize(n,r,!1),this.renderTarget.setSize(n*o,r*o),e.uResolution.value.set(n*o,r*o),Object.values(this._scenes).forEach((t)=>{t.onResize(n,r)}),this.render()}setMeshMaterialSide(n,r){if(Array.isArray(n)){n.forEach((o)=>{o.side=r});return}n.side=r}_bindEvents(){this._onPointerMove=(n)=>{let r=window.innerWidth||1,o=window.innerHeight||1;this._mouseTarget.set(n.clientX/r*2-1,-(n.clientY/o)*2+1)},window.addEventListener("pointermove",this._onPointerMove)}destroy(){this.stopTicker(),window.removeEventListener("pointermove",this._onPointerMove),this._resizeObserver?.disconnect(),this._resizeObserver=null,Object.values(this._scenes).forEach((n)=>n.destroy()),this._scenes={},this._activeScene=null,this._blurredTexture?.dispose(),e.tBluredTexture.value=null,this._blurredTexture2?.dispose(),e.tBluredTexture2.value=null,this.renderTarget.dispose(),this.renderer.dispose(),this.renderer.domElement.remove()}}var e={uTime:{value:0},uProgress:{value:0},uMobile:{value:!1},uLerpedMouse:{value:new K},tBackground:{value:null},tBluredTexture:{value:null},tBluredTexture2:{value:null},uResolution:{value:new K},uBackRender:{value:!1},uActiveScene:{value:0}},x={ALL:0,BACKGROUND:1};export{e as globalUniforms,A as WebglApp,x as LAYERS};