vendor: 11,502 bytes, lines 1-58
1import{K as L,af as ye,ag as f,ah as W,O as le,ai as we,aj as J,I as M,ak as Y,J as v,al as R,am as S,an as he,E as xe,ao as B,ap as _e,aq as b,L as y,S as de,Z as j,P as q,Y as A,ar as H,W as ue,X as Me,as as X,H as D,at as Pe,au as be,av as Te,aw as Ce,ax as N,ay as Q,az as Se,aA as De,aB as $,a1 as V,aC as ee,aD as Re,aE as Le,aF as Be,aG as te,j as _,aH as Ae,a0 as ie,aI as se,s as ae,aJ as re}from"#entry";import{m as Ue}from"./B1QDJ5b3.js";class Ee extends L{constructor(e,t,s,i=128){if(t<=0||s<=0||i<=0)throw new Error("GroundedSkybox height, radius, and resolution must be positive.");const a=new ye(s,2*i,i);a.scale(1,1,-1);const r=a.getAttribute("position"),o=new f;for(let n=0;n<r.count;++n)if(o.fromBufferAttribute(r,n),o.y<0){const c=-t*3/2,l=o.y<c?-t/o.y:1-o.y*o.y/(3*c*c);o.multiplyScalar(l),o.toArray(r.array,3*n)}r.needsUpdate=!0,super(a,new W({map:e,depthWrite:!1}))}}const ce={name:"CopyShader",uniforms:{tDiffuse:{value:null},opacity:{value:1}},vertexShader:` 2 3 varying vec2 vUv; 4 5 void main() { 6 7 vUv = uv; 8 gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 ); 9 10 }`,fragmentShader:` 11 12 uniform float opacity; 13 14 uniform sampler2D tDiffuse; 15 16 varying vec2 vUv; 17 18 void main() { 19 20 vec4 texel = texture2D( tDiffuse, vUv ); 21 gl_FragColor = opacity * texel; 22 23 24 }`};class k{constructor(){this.isPass=!0,this.enabled=!0,this.needsSwap=!0,this.clear=!1,this.renderToScreen=!1}setSize(){}render(){console.error("THREE.Pass: .render() must be implemented in derived pass.")}dispose(){}}const ze=new le(-1,1,1,-1,0,1);class ke extends we{constructor(){super(),this.setAttribute("position",new J([-1,3,0,-1,-1,0,3,-1,0],3)),this.setAttribute("uv",new J([0,2,0,0,2,0],2))}}const Fe=new ke;class me{constructor(e){this._mesh=new L(Fe,e)}dispose(){this._mesh.geometry.dispose()}render(e){e.render(this._mesh,ze)}get material(){return this._mesh.material}set material(e){this._mesh.material=e}}class fe extends k{constructor(e,t){super(),this.textureID=t!==void 0?t:"tDiffuse",e instanceof M?(this.uniforms=e.uniforms,this.material=e):e&&(this.uniforms=Y.clone(e.uniforms),this.material=new M({name:e.name!==void 0?e.name:"unspecified",defines:Object.assign({},e.defines),uniforms:this.uniforms,vertexShader:e.vertexShader,fragmentShader:e.fragmentShader})),this.fsQuad=new me(this.material)}render(e,t,s){this.uniforms[this.textureID]&&(this.uniforms[this.textureID].value=s.texture),this.fsQuad.material=this.material,this.renderToScreen?(e.setRenderTarget(null),this.fsQuad.render(e)):(e.setRenderTarget(t),this.clear&&e.clear(e.autoClearColor,e.autoClearDepth,e.autoClearStencil),this.fsQuad.render(e))}dispose(){this.material.dispose(),this.fsQuad.dispose()}}class oe extends k{constructor(e,t){super(),this.scene=e,this.camera=t,this.clear=!0,this.needsSwap=!1,this.inverse=!1}render(e,t,s){const i=e.getContext(),a=e.state;a.buffers.color.setMask(!1),a.buffers.depth.setMask(!1),a.buffers.color.setLocked(!0),a.buffers.depth.setLocked(!0);let r,o;this.inverse?(r=0,o=1):(r=1,o=0),a.buffers.stencil.setTest(!0),a.buffers.stencil.setOp(i.REPLACE,i.REPLACE,i.REPLACE),a.buffers.stencil.setFunc(i.ALWAYS,r,4294967295),a.buffers.stencil.setClear(o),a.buffers.stencil.setLocked(!0),e.setRenderTarget(s),this.clear&&e.clear(),e.render(this.scene,this.camera),e.setRenderTarget(t),this.clear&&e.clear(),e.render(this.scene,this.camera),a.buffers.color.setLocked(!1),a.buffers.depth.setLocked(!1),a.buffers.color.setMask(!0),a.buffers.depth.setMask(!0),a.buffers.stencil.setLocked(!1),a.buffers.stencil.setFunc(i.EQUAL,1,4294967295),a.buffers.stencil.setOp(i.KEEP,i.KEEP,i.KEEP),a.buffers.stencil.setLocked(!0)}}class Ie extends k{constructor(){super(),this.needsSwap=!1}render(e){e.state.buffers.stencil.setLocked(!1),e.state.buffers.stencil.setTest(!1)}}class Oe{constructor(e,t){if(this.renderer=e,this._pixelRatio=e.getPixelRatio(),t===void 0){const s=e.getSize(new v);this._width=s.width,this._height=s.height,t=new R(this._width*this._pixelRatio,this._height*this._pixelRatio,{type:S}),t.texture.name="EffectComposer.rt1"}else this._width=t.width,this._height=t.height;this.renderTarget1=t,this.renderTarget2=t.clone(),this.renderTarget2.texture.name="EffectComposer.rt2",this.writeBuffer=this.renderTarget1,this.readBuffer=this.renderTarget2,this.renderToScreen=!0,this.passes=[],this.copyPass=new fe(ce),this.copyPass.material.blending=he,this.clock=new xe}swapBuffers(){const e=this.readBuffer;this.readBuffer=this.writeBuffer,this.writeBuffer=e}addPass(e){this.passes.push(e),e.setSize(this._width*this._pixelRatio,this._height*this._pixelRatio)}insertPass(e,t){this.passes.splice(t,0,e),e.setSize(this._width*this._pixelRatio,this._height*this._pixelRatio)}removePass(e){const t=this.passes.indexOf(e);t!==-1&&this.passes.splice(t,1)}isLastEnabledPass(e){for(let t=e+1;t<this.passes.length;t++)if(this.passes[t].enabled)return!1;return!0}render(e){e===void 0&&(e=this.clock.getDelta());const t=this.renderer.getRenderTarget();let s=!1;for(let i=0,a=this.passes.length;i<a;i++){const r=this.passes[i];if(r.enabled!==!1){if(r.renderToScreen=this.renderToScreen&&this.isLastEnabledPass(i),r.render(this.renderer,this.writeBuffer,this.readBuffer,e,s),r.needsSwap){if(s){const o=this.renderer.getContext(),n=this.renderer.state.buffers.stencil;n.setFunc(o.NOTEQUAL,1,4294967295),this.copyPass.render(this.renderer,this.writeBuffer,this.readBuffer,e),n.setFunc(o.EQUAL,1,4294967295)}this.swapBuffers()}oe!==void 0&&(r instanceof oe?s=!0:r instanceof Ie&&(s=!1))}}this.renderer.setRenderTarget(t)}reset(e){if(e===void 0){const t=this.renderer.getSize(new v);this._pixelRatio=this.renderer.getPixelRatio(),this._width=t.width,this._height=t.height,e=this.renderTarget1.clone(),e.setSize(this._width*this._pixelRatio,this._height*this._pixelRatio)}this.renderTarget1.dispose(),this.renderTarget2.dispose(),this.renderTarget1=e,this.renderTarget2=e.clone(),this.writeBuffer=this.renderTarget1,this.readBuffer=this.renderTarget2}setSize(e,t){this._width=e,this._height=t;const s=this._width*this._pixelRatio,i=this._height*this._pixelRatio;this.renderTarget1.setSize(s,i),this.renderTarget2.setSize(s,i);for(let a=0;a<this.passes.length;a++)this.passes[a].setSize(s,i)}setPixelRatio(e){this._pixelRatio=e,this.setSize(this._width,this._height)}dispose(){this.renderTarget1.dispose(),this.renderTarget2.dispose(),this.copyPass.dispose()}}class Ve extends k{constructor(e,t,s=null,i=null,a=null){super(),this.scene=e,this.camera=t,this.overrideMaterial=s,this.clearColor=i,this.clearAlpha=a,this.clear=!0,this.clearDepth=!1,this.needsSwap=!1,this._oldClearColor=new B}render(e,t,s){const i=e.autoClear;e.autoClear=!1;let a,r;this.overrideMaterial!==null&&(r=this.scene.overrideMaterial,this.scene.overrideMaterial=this.overrideMaterial),this.clearColor!==null&&(e.getClearColor(this._oldClearColor),e.setClearColor(this.clearColor)),this.clearAlpha!==null&&(a=e.getClearAlpha(),e.setClearAlpha(this.clearAlpha)),this.clearDepth==!0&&e.clearDepth(),e.setRenderTarget(this.renderToScreen?null:s),this.clear===!0&&e.clear(e.autoClearColor,e.autoClearDepth,e.autoClearStencil),e.render(this.scene,this.camera),this.clearColor!==null&&e.setClearColor(this._oldClearColor),this.clearAlpha!==null&&e.setClearAlpha(a),this.overrideMaterial!==null&&(this.scene.overrideMaterial=r),e.autoClear=i}}const He={uniforms:{tDiffuse:{value:null},luminosityThreshold:{value:1},smoothWidth:{value:1},defaultColor:{value:new B(0)},defaultOpacity:{value:0}},vertexShader:` 25 26 varying vec2 vUv; 27 28 void main() { 29 30 vUv = uv; 31 32 gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 ); 33 34 }`,fragmentShader:` 35 36 uniform sampler2D tDiffuse; 37 uniform vec3 defaultColor; 38 uniform float defaultOpacity; 39 uniform float luminosityThreshold; 40 uniform float smoothWidth; 41 42 varying vec2 vUv; 43 44 void main() { 45 46 vec4 texel = texture2D( tDiffuse, vUv ); 47 48 vec3 luma = vec3( 0.299, 0.587, 0.114 ); 49 50 float v = dot( texel.xyz, luma ); 51 52 vec4 outputColor = vec4( defaultColor.rgb, defaultOpacity ); 53 54 float alpha = smoothstep( luminosityThreshold, luminosityThreshold + smoothWidth, v ); 55 56 gl_FragColor = mix( outputColor, texel, alpha ); 57 58 }`};class U extends k{constructor(e,t,s,i){super(),this.strength=t!==void 0?t:1,this.radius=s,this.threshold=i,this.resolution=e!==void 0?new v(e.x,e.y):new v(256,256),this.clearColor=new B(0,0,0),this.renderTargetsHorizontal=[],this.renderTargetsVertical=[],this.nMips=5;let a=Math.round(this.resolution.x/2),r=Math.round(this.resolution.y/2);this.renderTargetBright=new R(a,r,{type:S}),this.renderTargetBright.texture.name="UnrealBloomPass.bright",this.renderTargetBright.texture.generateMipmaps=!1;for(let h=0;h<this.nMips;h++){const u=new R(a,r,{type:S});u.texture.name="UnrealBloomPass.h"+h,u.texture.generateMipmaps=!1,this.renderTargetsHorizontal.push(u);const p=new R(a,r,{type:S});p.texture.name="UnrealBloomPass.v"+h,p.texture.generateMipmaps=!1,this.renderTargetsVertical.push(p),a=Math.round(a/2),r=Math.round(r/2)}const o=He;this.highPassUniforms=Y.clone(o.uniforms),this.highPassUniforms.luminosityThreshold.value=i,this.highPassUniforms.smoothWidth.value=.01,this.materialHighPassFilter=new M({uniforms:this.highPassUniforms,vertexShader:o.vertexShader,fragmentShader:o.fragmentShader}),this.separableBlurMaterials=[];const n=[3,5,7,9,11];a=Math.round(this.resolution.x/2),r=Math.round(this.resolution.y/2);for(let h=0;h<this.nMips;h++)this.separableBlurMaterials.push(this.getSeperableBlurMaterial(n[h])),this.separableBlurMaterials[h].uniforms.invSize.value=new v(1/a,1/r),a=Math.round(a/2),r=Math.round(r/2);this.compositeMaterial=this.getCompositeMaterial(this.nMips),this.compositeMaterial.uniforms.blurTexture1.value=this.renderTargetsVertical[0].texture,this.compositeMaterial.uniforms.blurTexture2.value=this.renderTargetsVertical[1].texture,this.compositeMaterial.uniforms.blurTexture3.value=this.renderTargetsVertical[2].texture,this.compositeMaterial.uniforms.blurTexture4.value=this.renderTargetsVertical[3].texture,this.compositeMaterial.uniforms.blurTexture5.value=this.renderTargetsVertical[4].texture,this.compositeMaterial.uniforms.bloomStrength.value=t,this.compositeMaterial.uniforms.bloomRadius.value=.1;const c=[1,.8,.6,.4,.2];this.compositeMaterial.uniforms.bloomFactors.value=c,this.bloomTintColors=[new f(1,1,1),new f(1,1,1),new f(1,1,1),new f(1,1,1),new f(1,1,1)],this.compositeMaterial.uniforms.bloomTintColors.value=this.bloomTintColors;const l=ce;this.copyUniforms=Y.clone(l.uniforms),this.blendMaterial=new M({uniforms:this.copyUniforms,vertexShader:l.vertexShader,fragmentShader:l.fragmentShader,blending:_e,depthTest:!1,depthWrite:!1,transparent:!0}),this.enabled=!0,this.needsSwap=!1,this._oldClearColor=new B,this.oldClearAlpha=1,this.basic=new W,this.fsQuad=new me(null)}dispose(){for(let e=0;e<this.renderTargetsHorizontal.length;e++)this.renderTargetsHorizontal[e].dispose();for(let e=0;e<this.renderTargetsVertical.length;e++)this.renderTargetsVertical[e].dispose();this.renderTargetBright.dispose();for(let e=0;e<this.separableBlurMaterials.length;e++)this.separableBlurMaterials[e].dispose();this.compositeMaterial.dispose(),this.blendMaterial.dispose(),this.basic.dispose(),this.fsQuad.dispose()}setSize(e,t){let s=Math.round(e/2),i=Math.round(t/2);this.renderTargetBright.setSize(s,i);for(let a=0;a<this.nMips;a++)this.renderTargetsHorizontal[a].setSize(s,i),this.renderTargetsVertical[a].setSize(s,i),this.separableBlurMaterials[a].uniforms.invSize.value=new v(1/s,1
vendor: 4,598 bytes, lines 58-107
58/i),s=Math.round(s/2),i=Math.round(i/2)}render(e,t,s,i,a){e.getClearColor(this._oldClearColor),this.oldClearAlpha=e.getClearAlpha();const r=e.autoClear;e.autoClear=!1,e.setClearColor(this.clearColor,0),a&&e.state.buffers.stencil.setTest(!1),this.renderToScreen&&(this.fsQuad.material=this.basic,this.basic.map=s.texture,e.setRenderTarget(null),e.clear(),this.fsQuad.render(e)),this.highPassUniforms.tDiffuse.value=s.texture,this.highPassUniforms.luminosityThreshold.value=this.threshold,this.fsQuad.material=this.materialHighPassFilter,e.setRenderTarget(this.renderTargetBright),e.clear(),this.fsQuad.render(e);let o=this.renderTargetBright;for(let n=0;n<this.nMips;n++)this.fsQuad.material=this.separableBlurMaterials[n],this.separableBlurMaterials[n].uniforms.colorTexture.value=o.texture,this.separableBlurMaterials[n].uniforms.direction.value=U.BlurDirectionX,e.setRenderTarget(this.renderTargetsHorizontal[n]),e.clear(),this.fsQuad.render(e),this.separableBlurMaterials[n].uniforms.colorTexture.value=this.renderTargetsHorizontal[n].texture,this.separableBlurMaterials[n].uniforms.direction.value=U.BlurDirectionY,e.setRenderTarget(this.renderTargetsVertical[n]),e.clear(),this.fsQuad.render(e),o=this.renderTargetsVertical[n];this.fsQuad.material=this.compositeMaterial,this.compositeMaterial.uniforms.bloomStrength.value=this.strength,this.compositeMaterial.uniforms.bloomRadius.value=this.radius,this.compositeMaterial.uniforms.bloomTintColors.value=this.bloomTintColors,e.setRenderTarget(this.renderTargetsHorizontal[0]),e.clear(),this.fsQuad.render(e),this.fsQuad.material=this.blendMaterial,this.copyUniforms.tDiffuse.value=this.renderTargetsHorizontal[0].texture,a&&e.state.buffers.stencil.setTest(!0),this.renderToScreen?(e.setRenderTarget(null),this.fsQuad.render(e)):(e.setRenderTarget(s),this.fsQuad.render(e)),e.setClearColor(this._oldClearColor,this.oldClearAlpha),e.autoClear=r}getSeperableBlurMaterial(e){const t=[];for(let s=0;s<e;s++)t.push(.39894*Math.exp(-.5*s*s/(e*e))/e);return new M({defines:{KERNEL_RADIUS:e},uniforms:{colorTexture:{value:null},invSize:{value:new v(.5,.5)},direction:{value:new v(.5,.5)},gaussianCoefficients:{value:t}},vertexShader:`varying vec2 vUv; 59 void main() { 60 vUv = uv; 61 gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 ); 62 }`,fragmentShader:`#include <common> 63 varying vec2 vUv; 64 uniform sampler2D colorTexture; 65 uniform vec2 invSize; 66 uniform vec2 direction; 67 uniform float gaussianCoefficients[KERNEL_RADIUS]; 68 69 void main() { 70 float weightSum = gaussianCoefficients[0]; 71 vec3 diffuseSum = texture2D( colorTexture, vUv ).rgb * weightSum; 72 for( int i = 1; i < KERNEL_RADIUS; i ++ ) { 73 float x = float(i); 74 float w = gaussianCoefficients[i]; 75 vec2 uvOffset = direction * invSize * x; 76 vec3 sample1 = texture2D( colorTexture, vUv + uvOffset ).rgb; 77 vec3 sample2 = texture2D( colorTexture, vUv - uvOffset ).rgb; 78 diffuseSum += (sample1 + sample2) * w; 79 weightSum += 2.0 * w; 80 } 81 gl_FragColor = vec4(diffuseSum/weightSum, 1.0); 82 }`})}getCompositeMaterial(e){return new M({defines:{NUM_MIPS:e},uniforms:{blurTexture1:{value:null},blurTexture2:{value:null},blurTexture3:{value:null},blurTexture4:{value:null},blurTexture5:{value:null},bloomStrength:{value:1},bloomFactors:{value:null},bloomTintColors:{value:null},bloomRadius:{value:0}},vertexShader:`varying vec2 vUv; 83 void main() { 84 vUv = uv; 85 gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 ); 86 }`,fragmentShader:`varying vec2 vUv; 87 uniform sampler2D blurTexture1; 88 uniform sampler2D blurTexture2; 89 uniform sampler2D blurTexture3; 90 uniform sampler2D blurTexture4; 91 uniform sampler2D blurTexture5; 92 uniform float bloomStrength; 93 uniform float bloomRadius; 94 uniform float bloomFactors[NUM_MIPS]; 95 uniform vec3 bloomTintColors[NUM_MIPS]; 96 97 float lerpBloomFactor(const in float factor) { 98 float mirrorFactor = 1.2 - factor; 99 return mix(factor, mirrorFactor, bloomRadius); 100 } 101 102 void main() { 103 gl_FragColor = bloomStrength * ( lerpBloomFactor(bloomFactors[0]) * vec4(bloomTintColors[0], 1.0) * texture2D(blurTexture1, vUv) + 104 lerpBloomFactor(bloomFactors[1]) * vec4(bloomTintColors[1], 1.0) * texture2D(blurTexture2, vUv) + 105 lerpBloomFactor(bloomFactors[2]) * vec4(bloomTintColors[2], 1.0) * texture2D(blurTexture3, vUv) + 106 lerpBloomFactor(bloomFactors[3]) * vec4(bloomTintColors[3], 1.0) * texture2D(blurTexture4, vUv) + 107 lerpBloomFactor(bloomFactors[4]) * vec4(bloomTintColors[4], 1.0
107) * texture2D(blurTexture5, vUv) ); 108 }`})}}U.BlurDirectionX=new v(1,0);U.BlurDirectionY=new v(0,1);const We={name:"GammaCorrectionShader",uniforms:{tDiffuse:{value:null}},vertexShader:` 109 110 varying vec2 vUv; 111 112 void main() { 113 114 vUv = uv; 115 gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 ); 116 117 }`,fragmentShader:` 118 119 uniform sampler2D tDiffuse; 120 121 varying vec2 vUv; 122 123 void main() { 124 125 vec4 tex = texture2D( tDiffuse, vUv ); 126 127 gl_FragColor = sRGBTransferOETF( tex ); 128 129 }`},pe=(m,e,t)=>{let s;switch(m){case N:s=new Uint8ClampedArray(e*t*4);break;case S:s=new Uint16Array(e*t*4);break;case Ce:s=new Uint32Array(e*t*4);break;case Te:s=new Int8Array(e*t*4);break;case be:s=new Int16Array(e*t*4);break;case Pe:s=new Int32Array(e*t*4);break;case j:s=new Float32Array(e*t*4);break;default:throw new Error("Unsupported data type")}return s};let I;const Ge=(m,e,t,s)=>{if(I!==void 0)return I;const i=new R(1,1,s);e.setRenderTarget(i);const a=new L(new q,new W({color:16777215}));e.render(a,t),e.setRenderTarget(null);const r=pe(m,i.width,i.height);return e.readRenderTargetPixels(i,0,0,i.width,i.height,r),i.dispose(),a.geometry.dispose(),a.material.dispose(),I=r[0]!==0,I};class K{constructor(e){var t,s,i,a,r,o,n,c,l,h,u,p,g,T,w,x;this._rendererIsDisposable=!1,this._supportsReadPixels=!0,this.render=()=>{this._renderer.setRenderTarget(this._renderTarget);try{this._renderer.render(this._scene,this._camera)}catch(P){throw this._renderer.setRenderTarget(null),P}this._renderer.setRenderTarget(null)},this._width=e.width,this._height=e.height,this._type=e.type,this._colorSpace
vendor: 6,858 bytes, lines 129-162
129=e.colorSpace;const C={format:A,depthBuffer:!1,stencilBuffer:!1,type:this._type,colorSpace:this._colorSpace,anisotropy:((t=e.renderTargetOptions)===null||t===void 0?void 0:t.anisotropy)!==void 0?(s=e.renderTargetOptions)===null||s===void 0?void 0:s.anisotropy:1,generateMipmaps:((i=e.renderTargetOptions)===null||i===void 0?void 0:i.generateMipmaps)!==void 0?(a=e.renderTargetOptions)===null||a===void 0?void 0:a.generateMipmaps:!1,magFilter:((r=e.renderTargetOptions)===null||r===void 0?void 0:r.magFilter)!==void 0?(o=e.renderTargetOptions)===null||o===void 0?void 0:o.magFilter:y,minFilter:((n=e.renderTargetOptions)===null||n===void 0?void 0:n.minFilter)!==void 0?(c=e.renderTargetOptions)===null||c===void 0?void 0:c.minFilter:y,samples:((l=e.renderTargetOptions)===null||l===void 0?void 0:l.samples)!==void 0?(h=e.renderTargetOptions)===null||h===void 0?void 0:h.samples:void 0,wrapS:((u=e.renderTargetOptions)===null||u===void 0?void 0:u.wrapS)!==void 0?(p=e.renderTargetOptions)===null||p===void 0?void 0:p.wrapS:b,wrapT:((g=e.renderTargetOptions)===null||g===void 0?void 0:g.wrapT)!==void 0?(T=e.renderTargetOptions)===null||T===void 0?void 0:T.wrapT:b};if(this._material=e.material,e.renderer?this._renderer=e.renderer:(this._renderer=K.instantiateRenderer(),this._rendererIsDisposable=!0),this._scene=new de,this._camera=new le,this._camera.position.set(0,0,10),this._camera.left=-.5,this._camera.right=.5,this._camera.top=.5,this._camera.bottom=-.5,this._camera.updateProjectionMatrix(),!Ge(this._type,this._renderer,this._camera,C)){let P;switch(this._type){case S:P=this._renderer.extensions.has("EXT_color_buffer_float")?j:void 0;break}P!==void 0?(console.warn(`This browser does not support reading pixels from ${this._type} RenderTargets, switching to ${j}`),this._type=P):(this._supportsReadPixels=!1,console.warn("This browser dos not support toArray or toDataTexture, calls to those methods will result in an error thrown"))}this._quad=new L(new q,this._material),this._quad.geometry.computeBoundingBox(),this._scene.add(this._quad),this._renderTarget=new R(this.width,this.height,C),this._renderTarget.texture.mapping=((w=e.renderTargetOptions)===null||w===void 0?void 0:w.mapping)!==void 0?(x=e.renderTargetOptions)===null||x===void 0?void 0:x.mapping:H}static instantiateRenderer(){const e=new ue;return e.setSize(128,128),e}toArray(){if(!this._supportsReadPixels)throw new Error("Can't read pixels in this browser");const e=pe(this._type,this._width,this._height);return this._renderer.readRenderTargetPixels(this._renderTarget,0,0,this._width,this._height,e),e}toDataTexture(e){const t=new Me(this.toArray(),this.width,this.height,A,this._type,e?.mapping||H,e?.wrapS||b,e?.wrapT||b,e?.magFilter||y,e?.minFilter||y,e?.anisotropy||1,X);return t.generateMipmaps=e?.generateMipmaps!==void 0?e?.generateMipmaps:!1,t}disposeOnDemandRenderer(){this._renderer.setRenderTarget(null),this._rendererIsDisposable&&(this._renderer.dispose(),this._renderer.forceContextLoss())}dispose(e){this.disposeOnDemandRenderer(),e&&this.renderTarget.dispose(),this.material instanceof M&&Object.values(this.material.uniforms).forEach(t=>{t.value instanceof D&&t.value.dispose()}),Object.values(this.material).forEach(t=>{t instanceof D&&t.dispose()}),this.material.dispose(),this._quad.geometry.dispose()}get width(){return this._width}set width(e){this._width=e,this._renderTarget.setSize(this._width,this._height)}get height(){return this._height}set height(e){this._height=e,this._renderTarget.setSize(this._width,this._height)}get renderer(){return this._renderer}get renderTarget(){return this._renderTarget}set renderTarget(e){this._renderTarget=e,this._width=e.width,this._height=e.height}get material(){return this._material}get type(){return this._type}get colorSpace(){return this._colorSpace}}const Qe=` 130varying vec2 vUv; 131 132void main() { 133 vUv = uv; 134 gl_Position = projectionMatrix * modelViewMatrix * vec4(position, 1.0); 135} 136`,Ye=` 137// min half float value 138#define HALF_FLOAT_MIN vec3( -65504, -65504, -65504 ) 139// max half float value 140#define HALF_FLOAT_MAX vec3( 65504, 65504, 65504 ) 141 142uniform sampler2D sdr; 143uniform sampler2D gainMap; 144uniform vec3 gamma; 145uniform vec3 offsetHdr; 146uniform vec3 offsetSdr; 147uniform vec3 gainMapMin; 148uniform vec3 gainMapMax; 149uniform float weightFactor; 150 151varying vec2 vUv; 152 153void main() { 154 vec3 rgb = texture2D( sdr, vUv ).rgb; 155 vec3 recovery = texture2D( gainMap, vUv ).rgb; 156 vec3 logRecovery = pow( recovery, gamma ); 157 vec3 logBoost = gainMapMin * ( 1.0 - logRecovery ) + gainMapMax * logRecovery; 158 vec3 hdrColor = (rgb + offsetSdr) * exp2( logBoost * weightFactor ) - offsetHdr; 159 vec3 clampedHdrColor = max( HALF_FLOAT_MIN, min( HALF_FLOAT_MAX, hdrColor )); 160 gl_FragColor = vec4( clampedHdrColor , 1.0 ); 161} 162`;class je extends M{constructor({gamma:e,offsetHdr:t,offsetSdr:s,gainMapMin:i,gainMapMax:a,maxDisplayBoost:r,hdrCapacityMin:o,hdrCapacityMax:n,sdr:c,gainMap:l}){super({name:"GainMapDecoderMaterial",vertexShader:Qe,fragmentShader:Ye,uniforms:{sdr:{value:c},gainMap:{value:l},gamma:{value:new f(1/e[0],1/e[1],1/e[2])},offsetHdr:{value:new f().fromArray(t)},offsetSdr:{value:new f().fromArray(s)},gainMapMin:{value:new f().fromArray(i)},gainMapMax:{value:new f().fromArray(a)},weightFactor:{value:(Math.log2(r)-o)/(n-o)}},blending:he,depthTest:!1,depthWrite:!1}),this._maxDisplayBoost=r,this._hdrCapacityMin=o,this._hdrCapacityMax=n,this.needsUpdate=!0,this.uniformsNeedUpdate=!0}get sdr(){return this.uniforms.sdr.value}set sdr(e){this.uniforms.sdr.value=e}get gainMap(){return this.uniforms.gainMap.value}set gainMap(e){this.uniforms.gainMap.value=e}get offsetHdr(){return this.uniforms.offsetHdr.value.toArray()}set offsetHdr(e){this.uniforms.offsetHdr.value.fromArray(e)}get offsetSdr(){return this.uniforms.offsetSdr.value.toArray()}set offsetSdr(e){this.uniforms.offsetSdr.value.fromArray(e)}get gainMapMin(){return this.uniforms.gainMapMin.value.toArray()}set gainMapMin(e){this.uniforms.gainMapMin.value.fromArray(e)}get gainMapMax(){return this.uniforms.gainMapMax.value.toArray()}set gainMapMax(e){this.uniforms.gainMapMax.value.fromArray(e)}get gamma(){const e=this.uniforms.gamma.value;return[1/e.x,1/e.y,1/e.z]}set gamma(e){const t=this.uniforms.gamma.value;t.x=1/e[0],t.y=1/e[1],t.z=1/e[2]}get hdrCapacityMin(){return this._hdrCapacityMin}set hdrCapacityMin(e){this._hdrCapacityMin=e,this.calculateWeight()}get hdrCapacityMax(){return this._hdrCapacityMax}set hdrCapacityMax(e){this._hdrCapacityMax=e,this.calculateWeight()}get maxDisplayBoost(){return this._maxDisplayBoost}set maxDisplayBoost(e){this._maxDisplayBoost=Math.max(1,Math.min(65504,e)),this.calculateWeight()}calculateWeight(){const e=(Math.log2(this._maxDisplayBoost)-this._hdrCapacityMin)/(this._hdrCapacityMax-this._hdrCapacityMin);this.uniforms.weightFactor.value=Math.max(0,Math.min(1,e))}}const ne=m=>new Promise((e,t)=>
162{const s=document.createElement("img");s.onload=()=>{e(s)},s.onerror=i=>{t(i)},s.src=URL.createObjectURL(m)});class Xe extends Se{constructor(e,t){super(t),e&&(this._renderer=e),this._internalLoadingManager=new De}setRenderer(e){return this._renderer=e,this}setRenderTargetOptions(e){return this._renderTargetOptions=e,this}prepareQuadRenderer(){this._renderer||console.warn("WARNING: An existing WebGL Renderer was not passed to this Loader constructor or in setRenderer, the result of this Loader will need to be converted to a Data Texture with toDataTexture() before you can use it in your renderer.");const e=new je({gainMapMax:[1,1,1],gainMapMin:[0,0,0],gamma:[1,1,1],offsetHdr:[1,1,1],offsetSdr:[1,1,1],hdrCapacityMax:1,hdrCapacityMin:0,maxDisplayBoost:1,gainMap:new D,sdr:new D});return new K({width:16,height:16,type:S,colorSpace:X,material:e,renderer:this._renderer,renderTargetOptions:this._renderTargetOptions})}async render(e,t,s,i){const a=i?new Blob([i],{type:"image/jpeg"}):void 0,r=new Blob([s],{type:"image/jpeg"});let o,n,c=!1;if(typeof createImageBitmap>"u"){const u=await Promise.all([a?ne(a):Promise.resolve(void 0),ne(r)]);n=u[0],o=u[1],c=!0}else{const u=await Promise.all([a?createImageBitmap(a,{imageOrientation:"flipY"}):Promise.resolve(void 0),createImageBitmap(r,{imageOrientation:"flipY"})]);n=u[0],o=u[1]}const l=new D(n||new ImageData(2,2),H,b,b,y,$,A,N,1,X);l.flipY=c,l.needsUpdate=!0;const h=new D(o,H,b,b,y,$,A,N,1,V);h.flipY=c,h.needsUpdate=!0,e.width=o.width,e.height=o.height,e.material.gainMap=l,e.material.sdr=h,e.material.gainMapMin=t.gainMapMin,e.material.gainMapMax=t.gainMapMax,e.material.offsetHdr=t.offsetHdr,e.material.offsetSdr=t.offsetSdr,e.material.gamma=t.gamma,e.material.hdrCapacityMin=t.hdrCapacityMin,e.material.hdrCapacityMax=t.hdrCapacityMax,e.material.maxDisplayBoost=Math.pow(2,t.hdrCapacityMax),e.material.needsUpdate=!0,e.render()}}class Ne extends Xe{load([e,t,s],i,a,r){const o=this.prepareQuadRenderer();let n,c,l;const h=async()=>{if(n&&c&&l){try{await this.render(o,l,n,c)}catch(d){this.manager.itemError(e),this.manager.itemError(t),this.manager.itemError(s),typeof r=="function"&&r(d),o.disposeOnDemandRenderer();return}typeof i=="function"&&i(o),this.manager.itemEnd(e),this.manager.itemEnd(t),this.manager.itemEnd(s),o.disposeOnDemandRenderer()}};let u=!0,p=0,g=0,T=!0,w=0,x=0,C=!0,P=0,Z=0;const G=()=>{if(typeof a=="function"){const d=p+w+P,ge=g+x+Z,ve=u&&T&&C;a(new ProgressEvent("progress",{lengthComputable:ve,loaded:ge,total:d}))}};this.manager.itemStart(e),this.manager.itemStart(t),this.manager.itemStart(s);const E=new Q(this._internalLoadingManager);E.setResponseType("arraybuffer"),E.setRequestHeader(this.requestHeader),E.setPath(this.path),E.setWithCredentials(this.withCredentials),E.load(e,async d=>{if(typeof d=="string")throw new Error("Invalid sdr buffer");n=d,await h()},d=>{u=d.lengthComputable,g=d.loaded,p=d.total,G()},d=>{this.manager.itemError(e),typeof r=="function"&&r(d)});const z=new Q(this._internalLoadingManager);z.setResponseType("arraybuffer"),z.setRequestHeader(this.requestHeader),z.setPath(this.path),z.setWithCredentials(this.withCredentials),z.load(t,async d=>{if(typeof d=="string")throw new Error("Invalid gainmap buffer");c=d,await h()},d=>{T=d.lengthComputable,x=d.loaded,w=d.total,G()},d=>{this.manager.itemError(t),typeof r=="function"&&r(d)});const F=new Q(this._internalLoadingManager);return F.setRequestHeader(this.requestHeader),F.setPath(this.path),F.setWithCredentials(this.withCredentials),F.load(s,async d=>{if(typeof d!="string")throw new Error("Invalid metadata string");l=JSON.parse(d),await h()},d=>{C=d.lengthComputable,Z=d.loaded,P=d.total,G()},d=>{this.manager.itemError(s),typeof r=="function"&&r(d)}),o}}const O=16/9,qe=` 163 varying vec2 vUv; 164 void main() { 165 vUv = uv; 166 gl_Position = projectionMatrix * modelViewMatrix * vec4(position, 1.0); 167 } 168`,Ke=` 169 uniform sampler2D map; 170 uniform vec2 videoRatio; // vec2(videoAspect, planeAspect) 171 varying vec2 vUv; 172 void main() { 173 vec2 uv = vUv; 174 float videoAspect = videoRatio.x; 175 float planeAspect = videoRatio.y; 176 if (videoAspect > planeAspect) { 177 float scale = planeAspect / videoAspect; 178 uv.x = uv.x * scale + (1.0 - scale) * 0.5; 179 } else { 180 float scale = videoAspect / planeAspect; 181 uv.y = uv.y * scale + (1.0 - scale) * 0.5; 182 } 183 gl_FragColor = texture2D(map, uv); 184 } 185`;class $e{constructor(e,t=[],s={}){this.canvas=e,this.videoDataFromSanity=Array.isArray(t)&&t.length>0?typeof t[0]=="string"?t.map(i=>({videoUrl:i,fullVersionUrl:null})):t:[],this.callbacks=s,this._rafId=null,this._isDisposed=!1,this.isAnimating=!1,this.isTransitionning=!1,this.hoveredPlane=null,this.activePlane=null,this.sizes={width:window.innerWidth,height:window.innerHeight},this.mouse={x:0,y:0},this.targetRotation={x:0,y:0},this.initialCameraPosition=new f,this.initialCameraRotation=new ee(0,0,0),this.scene=new de,this.renderer=null,this.camera=null,this.composer=null,this.planes=[],this.planeItems=[],this.planeRotationValues=[1,.5,0,-.5,-1],this.planePositionValues=[10,15,12,20,14],this.videos=[],this.skybox=null,this.mobileEnvTexture=null,this.videoPool=[],this._raycaster=new Re,this._ndc=new v,this._tempVec3=new f,this._tempVec3_2=new f,this._sharedPlaneGeometry=new q(1,1),this._sharedTubeGeometry=new Le(.025,.025,1,16),this.loaders=this.initLoaders(),this.coarsePointer=window.matchMedia?.("(pointer: coarse)")?.matches??!1,this.activePointerId=null,this.pointerState={isDown:!1,start:{x:0,y:0},last:{x:0,y:0},type:this.coarsePointer?"touch":"mouse"},this.tapThreshold=8,this.lastPointerUp={time:0,type:null},this.shouldUseBloom=!1,this.renderPass=null,this.unrealBloomPass=null,this.gammaCorrectionPass=null,this.isMobileLike=this.coarsePointer||this.sizes.width<768,this.applyCameraBaseline(),this.initRenderer(),this.initCamera(),this.updateDeviceProfile({manageEnvironment:!1}),this.addPostProcessing(),this.initEnvironment(),this.addPlanes(),this.animate(),this._pointerMoveOptions={passive:!0},this._onResize=this.onResize.bind(this),this._onPointerMove=this.onPointerMove.bind(this),this._onPointerDown=this.onPointerDown.bind(this),this._onPointerUp=this.onPointerUp.bind(this),this._onPointerCancel=this.onPointerCancel.bind(this),window.addEventListener("resize",this._onResize),window.addEventListener("pointermove",this._onPointerMove,this._pointerMoveOptions),window.addEventListener("pointerdown",this._onPointerDown),window.addEventListener("pointerup",this._onPointerUp),window.addEventListener("pointercancel",this._onPointerCancel)}initLoaders(){return{textureLoader:new Be,gainMapLoader:null}}async initEnvironment(){try{if(this.isMobileLike){await this.loadMobileEnv
185ironment();return}this.loaders.gainMapLoader=new Ne(this.renderer);const e=await this.loaders.gainMapLoader.loadAsync(["/images/env/sdr.webp","/images/env/gainmap.webp","/images/env/metadata.json"]);if(this._isDisposed){e?.dispose?.();return}const t=e.toDataTexture();t.mapping=te,this.scene.environment=t,this.scene.background=e.toDataTexture();const s=new Ee(t,15,70);s.position.y=15,this.skybox=s,this.scene.add(s),t.needsUpdate=!0,e.dispose(),this.onIntro()}catch(e){console.error("[initEnvironment] error:",e),this._isDisposed||(this.scene.background=new B(328965),this.scene.environment=null,this.onIntro())}}async loadMobileEnvironment(){this.disposeMobileEnvironmentTexture();try{const e=await this.loaders.textureLoader.loadAsync("/images/env/sdr.webp");if(this._isDisposed||!this.isMobileLike){e?.dispose?.();return}e.mapping=te,e.colorSpace!==void 0&&(e.colorSpace=V),e.needsUpdate=!0,this.mobileEnvTexture=e,this.scene.background=e,this.scene.environment=e}catch(e){console.error("[loadMobileEnvironment] error:",e),this._isDisposed||(this.scene.background=new B(328965),this.scene.environment=null)}this._isDisposed||this.onIntro()}onIntro(){if(this._isDisposed)return;const e=this.getCameraBaseline();if(this.isMobileLike){this.camera.position.copy(e.position),this.camera.rotation.copy(e.rotation),this.initialCameraPosition.copy(this.camera.position),this.initialCameraRotation.copy(this.camera.rotation);return}const t=e.position.y+8,s=e.position.z+10;_.fromTo(this.camera.position,{y:t,z:s},{y:e.position.y,z:e.position.z,duration:2,ease:"quart.inOut",onComplete:()=>{this._isDisposed||(this.initialCameraPosition.copy(this.camera.position),this.initialCameraRotation.copy(this.camera.rotation))}})}initCamera(){this.camera=new Ae(75,this.sizes.width/this.sizes.height,.1,100),this.camera.position.set(0,500,100),this.scene.add(this.camera)}initRenderer(){this.renderer=new ue({canvas:this.canvas,antialias:!this.coarsePointer,powerPreference:this.coarsePointer?"low-power":"high-performance",stencil:!1,depth:!0}),this.renderer.setSize(this.sizes.width,this.sizes.height);const e=this.coarsePointer?1.5:2;this.renderer.setPixelRatio(Math.min(window.devicePixelRatio,e)),this.renderer.sortObjects=!1}updateDeviceProfile({manageEnvironment:e=!0}={}){const t=this.isMobileLike,s=window.matchMedia?.("(pointer: coarse)")?.matches;return typeof s=="boolean"&&(this.coarsePointer=s),this.isMobileLike=this.coarsePointer||this.sizes.width<768,this.shouldUseBloom=!this.isMobileLike,this.pointerState.isDown||(this.pointerState.type=this.coarsePointer?"touch":"mouse"),t!==this.isMobileLike&&(this.isMobileLike?(this.disposePostProcessing(),this.disposeMobileEnvironmentTexture(),this.scene.environment=null,this.scene.background=null,this.skybox&&(this.scene.remove(this.skybox),this.skybox.geometry?.dispose?.(),Array.isArray(this.skybox.material)?this.skybox.material.forEach(i=>i.dispose?.()):this.skybox.material?.dispose?.(),this.skybox=null),e&&this.initEnvironment()):(this.disposeMobileEnvironmentTexture(),this.scene.background=null,this.scene.environment=null,this.addPostProcessing(),this.updatePostProcessing(),e&&this.initEnvironment())),t!==this.isMobileLike}getCameraBaseline(){return{position:new f(0,this.isMobileLike?14:12,this.isMobileLike?24:20),rotation:new ee(0,0,0)}}applyCameraBaseline({syncCamera:e=!1}={}){const t=this.getCameraBaseline();this.initialCameraPosition.copy(t.position),this.initialCameraRotation.copy(t.rotation),e&&this.camera&&!this.isAnimating&&typeof document<"u"&&!document.body.classList.contains("highlight-video")&&(this.camera.position.copy(this.initialCameraPosition),this.camera.rotation.copy(this.initialCameraRotation))}getLayoutConfig(e){return this.isMobileLike?{maxColumns:Math.min(3,e),spacingX:12,baseZ:-12,depthStep:-10,planeHeight:6.5,rotationScale:.65,heightScale:.85,tubeHeight:30}:{maxColumns:Math.min(5,e),spacingX:18,baseZ:-10,depthStep:-12,planeHeight:9,rotationScale:1,heightScale:1,tubeHeight:40}}refreshLayout(){if(this._isDisposed||!this.planeItems.length)return;const e=this.planeItems.filter(i=>i&&i.mesh);e.sort((i,a)=>i.index-a.index);const t=this.getLayoutConfig(e.length),s=Math.max(1,t.maxColumns);for(let i=0;i<e.length;i++){const a=e[i];if(!a||!a.mesh)continue;const r=a.mesh,o=r.userData.aspectRatio||16/9,n=t.planeHeight,c=n*o;r.scale.set(c,n,1);const l=Math.floor(i/s),h=i%s,p=(Math.min(s,e.length-l*s)-1)*t.spacingX/2,g=h*t.spacingX-p,w=(this.planePositionValues[i%this.planePositionValues.length]||12)*t.heightScale,x=t.baseZ+l*t.depthStep;r.position.set(g,w,x);const C=this.planeRotationValues[i%this.planeRotationValues.length]||0;r.rotation.y=C*t.rotationScale,a.tube&&(a.tube.scale.set(1,t.tubeHeight,1),a.tube.position.set(g,w+t.tubeHeight/2+2,x-1))}this.planeItems=e}addPlanes(){this.videoPool=this.videoDataFromSanity.length>0?this.videoDataFromSanity:Array.from({length:17},(t,s)=>({videoUrl:`/videos/setlife/${s+1}.mp4`,fullVersionUrl:"https://vimeo.com/chrismacarifilms"}));const e=this.getRandomVideos(5);this._initialLoadCount=0,this._totalVideosToLoad=e.length,e.forEach((t,s)=>{this.createPlaneWithVideo(t.videoUrl,s,t.fullVersionUrl)})}getRandomVideos(e){const t=[...this.videoPool].sort(()=>Math.random()-.5);return t.slice(0,Math.min(e,t.length))}createPlaneWithVideo(e,t,s=null){const i=document.createElement("video");
185i.src=e,i._fullVersionUrl=s,i.loop=!0,i.muted=!0,i.playsInline=!0,i.crossOrigin="anonymous",i.preload="auto",this.videos[t]=i;let a=!1;const r=()=>{if(this._isDisposed||a)return;a=!0;const o=i.videoWidth||1920,n=i.videoHeight||1080,c=o/n,l=new ie(i);if(l.minFilter=y,l.magFilter=y,l.format=A,l.generateMipmaps=!1,l.colorSpace!==void 0&&(l.colorSpace=V),this.planes[t]){const h=this.planes[t],u=h.material.uniforms.map.value;h.material.uniforms.map.value=l,h.material.uniforms.videoRatio.value.set(c,O),h.material.needsUpdate=!0,u?.dispose()}else{const h=new M({uniforms:{map:{value:l},videoRatio:{value:new v(c,O)}},vertexShader:qe,fragmentShader:Ke,side:re}),u=new L(this._sharedPlaneGeometry,h);u.userData.aspectRatio=O,u.userData.index=t,u.userData.fullVersionUrl=i._fullVersionUrl,u.frustumCulled=!0,this.scene.add(u),this.planes[t]=u;const p=new W({color:5200742,side:re}),g=new L(this._sharedTubeGeometry,p);g.userData.index=t,g.frustumCulled=!0,this.scene.add(g),this.planeItems[t]={mesh:u,tube:g,index:t}}typeof this._initialLoadCount<"u"&&(this._initialLoadCount++,this._initialLoadCount===this._totalVideosToLoad&&(this.refreshLayout(),delete this._initialLoadCount,delete this._totalVideosToLoad)),i.play().catch(()=>{}),i.removeEventListener("loadedmetadata",r)};i.addEventListener("loadedmetadata",r,{once:!0}),setTimeout(()=>{!this._isDisposed&&i.readyState>=1&&r()},1500)}async shuffleVideos(){if(this._isDisposed||this.planes.length===0)return;const t=this.getRandomVideos(5).map(i=>{const a=document.createElement("video");return a.src=i.videoUrl,a._fullVersionUrl=i.fullVersionUrl,a.loop=!0,a.muted=!0,a.playsInline=!0,a.crossOrigin="anonymous",a.preload="auto",a}),s=t.map(i=>new Promise(a=>{const r=()=>{i.removeEventListener("loadedmetadata",r),i.play().catch(()=>{}),a()};i.addEventListener("loadedmetadata",r,{once:!0}),setTimeout(()=>{i.readyState>=1&&r()},500)}));await Promise.all(s),this.planes.forEach((i,a)=>{if(!i||this._isDisposed)return;const r=i.material.uniforms.map.value,o=t[a];if(!o)return;const n=new ie(o);n.minFilter=y,n.magFilter=y,n.format=A,n.generateMipmaps=!1,n.colorSpace!==void 0&&(n.colorSpace=V);const c=o.videoWidth||1920,l=o.videoHeight||1080,h=c/l;i.material.uniforms.map.value=n,i.material.uniforms.videoRatio.value.set(h,O),i.material.needsUpdate=!0,i.userData.fullVersionUrl=o._fullVersionUrl||null,r?.dispose(),this.videos[a]&&(this.videos[a].pause(),this.videos[a].currentTime=0),this.videos[a]=o}),this.refreshLayout()}addPostProcessing(){if(this.isMobileLike){this.composer=null,this.renderPass=null,this.unrealBloomPass=null,this.gammaCorrectionPass=null;return}this.composer=new Oe(this.renderer),this.renderPass=new Ve(this.scene,this.camera),this.composer.addPass(this.renderPass),this.unrealBloomPass=new U(new v(this.sizes.width,this.sizes.height),.25,.2,0),this.gammaCorrectionPass=new fe(We),this.shouldUseBloom&&this.composer.addPass(this.unrealBloomPass),this.composer.addPass(this.gammaCorrectionPass),this.updateBloomIntensity()}updateBloomIntensity(){if(!this.unrealBloomPass)return;const e=this.coarsePointer||this.sizes.width<768;this.unrealBloomPass.strength=e?.18:.25,this.unrealBloomPass.radius=e?.16:.2,this.unrealBloomPass.threshold=e?.1:0}updatePostProcessing(){if(!this.composer||!this.gammaCorrectionPass)return;const e=!this.coarsePointer&&this.sizes.width>=768;if(this.unrealBloomPass){const t=this.composer.passes.includes(this.unrealBloomPass);if(e&&!t){const s=this.composer.passes.indexOf(this.gammaCorrectionPass);s!==-1?this.composer.passes.splice(s,0,this.unrealBloomPass):this.composer.addPass(this.unrealBloomPass)}else if(!e&&t){const s=this.composer.passes.indexOf(this.unrealBloomPass);s!==-1&&this.composer.passes.splice(s,1)}}this.shouldUseBloom=e,this.updateBloomIntensity()}disposePostProcessing(){this.composer&&(this.composer.passes.length=0,this.composer=null),this.renderPass=null,this.unrealBloomPass=null,this.gammaCorrectionPass=null}disposeMobileEnvironmentTexture(){this.mobileEnvTexture&&(this.mobileEnvTexture.dispose?.(),this.mobileEnvTexture=null),this.skybox&&(this.scene.remove(this.skybox),this.skybox.geometry?.dispose?.(),Array.isArray(this.skybox.material)?this.skybox.material.forEach(e
185=>e.dispose?.()):this.skybox.material?.dispose?.(),this.skybox=null)}isInteractionLocked(){return Ue?.open===!0}getRotationFactors(e){const t=e||this.coarsePointer;return{x:t?.18:.15,y:t?.5:.25}}updateCursor(e){if(!this.canvas)return;const t=!this.isTouchPointer(this.pointerState.type);this.canvas.style.cursor=t&&e?"pointer":"default"}isTouchPointer(e){return e?e==="touch"||e==="pen":this.coarsePointer}onPointerMove(e){if(this._isDisposed||!this.camera||this.isInteractionLocked()||this.activePointerId!==null&&e.pointerId!==this.activePointerId)return;const{clientX:t,clientY:s}=e;this.pointerState.last.x=t,this.pointerState.last.y=s;const i=this.sizes.width,a=this.sizes.height;this.mouse.x=-(t/i)*2+1,this.mouse.y=-(s/a)*2+1;const r=this.isTouchPointer(e.pointerType),o=this.getRotationFactors(r);this.targetRotation.x=this.mouse.y*o.x*-1,this.targetRotation.y=this.mouse.x*o.y,r||this.checkPlaneHover(t,s)}checkPlaneHover(e,t){if(this._isDisposed||!this.camera||!this.planes?.length)return;this._ndc.x=e/this.sizes.width*2-1,this._ndc.y=-(t/this.sizes.height)*2+1,this._raycaster.setFromCamera(this._ndc,this.camera);const s=this._raycaster.intersectObjects(this.planes,!1);if(s.length>0){const i=s[0].object;this.hoveredPlane!==i&&(this.hoveredPlane&&this.onPlaneMouseLeave(this.hoveredPlane),this.onPlaneMouseEnter(i),this.hoveredPlane=i)}else this.hoveredPlane&&(this.onPlaneMouseLeave(this.hoveredPlane),this.hoveredPlane=null)}onPlaneMouseEnter(e){if(this._isDisposed||this.isAnimating||this.activePlane){this.updateCursor(!1);return}this.updateCursor(!0),e.userData.originalScale||(e.userData.originalScale=e.scale.clone()),_.killTweensOf(e.scale),_.to(e.scale,{x:e.userData.originalScale.x*1.05,y:e.userData.originalScale.y*1.05,duration:.4,ease:"power2.out"})}onPlaneMouseLeave(e){this._isDisposed||(this.updateCursor(!1),e&&(_.killTweensOf(e.scale),e.userData.originalScale&&_.to(e.scale,{x:e.userData.originalScale.x,y:e.userData.originalScale.y,duration:.3,ease:"power2.inOut"})))}onResize(){if(this._isDisposed||!this.camera||!this.renderer)return;this.sizes.width=window.innerWidth,this.sizes.height=window.innerHeight,this.updateDeviceProfile(),this.camera.aspect=this.sizes.width/this.sizes.height,this.camera.updateProjectionMatrix(),this.renderer.setSize(this.sizes.width,this.sizes.height);const e=this.coarsePointer?1.5:2;this.renderer.setPixelRatio(Math.min(window.devicePixelRatio,e)),this.composer&&(this.composer.setSize(this.sizes.width,this.sizes.height),this.composer.setPixelRatio(Math.min(window.devicePixelRatio,e)),this.updatePostProcessing()),this.applyCameraBaseline({syncCamera:!0}),this.refreshLayout()}onPointerDown(e){if(!(this._isDisposed||this.isInteractionLocked())){if(this.activePointerId=e.pointerId,this.pointerState.type=e.pointerType||"mouse",this.pointerState.isDown=!0,this.pointerState.start.x=e.clientX,this.pointerState.start.y=e.clientY,this.pointerState.last.x=e.clientX,this.pointerState.last.y=e.clientY,e.target?.setPointerCapture)try{e.target.setPointerCapture(e.pointerId)}catch{}this.isTouchPointer(this.pointerState.type)&&(this.updateCursor(!1),this.hoveredPlane&&(this.onPlaneMouseLeave(this.hoveredPlane),this.hoveredPlane=null))}}onPointerUp(e){if(this._isDisposed)return;if(this.isInteractionLocked()){this.pointerState.isDown=!1,this.activePointerId=null,this.pointerState.type=this.coarsePointer?"touch":"mouse";return}if(this.activePointerId!==null&&e.pointerId!==this.activePointerId)return;const t=e.clientX-this.pointerState.start.x,s=e.clientY-this.pointerState.start.y,i=Math.sqrt(t*t+s*s),a=e.target;if(this.pointerState.isDown=!1,this.activePointerId=null,this.pointerState.type=this.coarsePointer?"touch":"mouse",a?.releasePointerCapture)try{a.releasePointerCapture(e.pointerId)}catch{}i<=this.tapThreshold&&(this.handleSelection({clientX:e.clientX,clientY:e.clientY,target:a}),this.lastPointerUp.time=performance.now(),this.lastPointerUp.type=e.pointerType||this.pointerState.type)}onPointerCancel(e){if(!(this._isDisposed||this.isInteractionLocked())){if(e?.target?.releasePointerCapture)try{e.target.releasePointerCapture(e.pointerId)}catch{}this.pointerState.isDown=!1,this.activePointerId=null,this.pointerState.type=this.coarsePointer?"touch":"mouse"}}handleSelection({clientX:e,clientY:t}){if(this._isDisposed||this.isInteractionLocked()||!this.camera||!this.planes?.length||e==null||t==null)return;this._ndc.x=e/this.sizes.width*2-1,this._ndc.y=-(t/this.sizes.height)*2+1,this._raycaster.setFromCamera(this._ndc,this.camera);const s=this._raycaster.intersectObjects(this.planes,!1);if(!this.activePlane){if(s.length>0){const i=s[0].object;this.moveToPlane(i)}return}if(s.length>0){const i=s[0].object;i===this.activePlane?this.onClose():this.moveToPlane(i)}else this.onClose()}
185onClose=()=>{if(this._isDisposed||!this.camera||this.isTransitionning)return;this.isTransitionning=!0,this.isAnimating=!1,this.activePlane=null,document.body.classList.remove("highlight-video","cursor-active"),this.updateCursor(!1),se(!1),ae("default"),this.callbacks.onPlaneClose&&this.callbacks.onPlaneClose();const e=this.camera.rotation.y,t=this.initialCameraRotation.y;let s=t;const i=t-e;Math.abs(i)>Math.PI&&(s=i>0?t-Math.PI*2:t+Math.PI*2),_.to(this.camera.position,{x:this.initialCameraPosition.x,y:this.initialCameraPosition.y,z:this.initialCameraPosition.z,duration:1.25,ease:"quart.inOut"}),_.to(this.camera.rotation,{x:this.initialCameraRotation.x,y:s,z:this.initialCameraRotation.z,duration:1.25,ease:"quart.inOut",onComplete:()=>{this._isDisposed||(this.camera.rotation.y=this.initialCameraRotation.y,this.targetRotation.x=this.initialCameraRotation.x,this.targetRotation.y=this.initialCameraRotation.y,this.isTransitionning=!1)}})};moveToPlane(e){if(this._isDisposed||!this.camera||this.isTransitionning)return;this.isTransitionning=!0;const t=this.coarsePointer?7.5:9;e.getWorldDirection(this._tempVec3),this._tempVec3_2.copy(e.position).add(this._tempVec3.multiplyScalar(t)),this.isAnimating=!0,this.activePlane=e,this.updateCursor(!1),document.body.classList.add("highlight-video","cursor-active"),se(!0),ae("close"),this.callbacks.onPlaneZoom&&this.callbacks.onPlaneZoom(e.userData.fullVersionUrl||null);const s=this.camera.clone();s.position.copy(this._tempVec3_2),s.lookAt(e.position);const i=this.camera.rotation.y;let a=s.rotation.y;const r=a-i;Math.abs(r)>Math.PI&&(a=r>0?a-Math.PI*2:a+Math.PI*2),_.to(this.camera.position,{duration:1.25,x:this._tempVec3_2.x,y:this._tempVec3_2.y,z:this._tempVec3_2.z,ease:"quart.inOut"}),_.to(this.camera.rotation,{duration:1.25,x:s.rotation.x,y:a,z:s.rotation.z,ease:"quart.inOut",onComplete:()=>{this._isDisposed||(this.isAnimating=!1,this.isTransitionning=!1)}})}animate(){const e=()=>{this._isDisposed||(!this.isAnimating&&!this.activePlane&&this.camera&&this.targetRotation&&(this.camera.rotation.x+=(this.targetRotation.x-this.camera.rotation.x)*.04,this.camera.rotation.y+=(this.targetRotation.y-this.camera.rotation.y)*.04),this.composer?this.composer.render():this.renderer&&this.scene&&this.camera&&this.renderer.render(this.scene,this.camera),this._rafId=requestAnimationFrame(e))};e()}dispose(){if(!this._isDisposed){if(this._isDisposed=!0,window.removeEventListener("resize",this._onResize),window.removeEventListener("pointermove",this._onPointerMove,this._pointerMoveOptions),window.removeEventListener("pointerdown",this._onPointerDown),window.removeEventListener("pointerup",this._onPointerUp),window.removeEventListener("pointercancel",this._onPointerCancel),this._rafId&&(cancelAnimationFrame(this._rafId),this._rafId=null),this.updateCursor(!1),this.videos){for(const e of this.videos)try{e.pause(),e.src="",e.load()}catch{}this.videos=[]}if(this.planes){for(const e of this.planes)e.material?.uniforms?.map?.value?.dispose&&e.material.uniforms.map.value.dispose(),e.material?.dispose&&e.material.dispose(),e.parent&&this.scene.remove(e);this.planes=[]}this.planeItems=[],this._sharedPlaneGeometry&&(this._sharedPlaneGeometry.dispose(),this._sharedPlaneGeometry=null),this._sharedTubeGeometry&&(this._sharedTubeGeometry.dispose(),this._sharedTubeGeometry=null),this.scene&&(this.scene.traverse(e=>{e.isMesh&&(e.geometry?.dispose?.(),e.material&&(Array.isArray(e.material)?e.material.forEach(t=>{t.map?.dispose?.(),t.dispose?.()}):(e.material.map?.dispose?.(),e.material.dispose?.())))}),this.scene.clear(),this.scene.background=null,this.scene.environment=null),this.disposePostProcessing(),this.disposeMobileEnvironmentTexture(),this.renderer&&(this.renderer.dispose(),this.renderer.forceContextLoss?.(),this.renderer=null),this.camera=null,this.scene=null,this.canvas=null,this.skybox=null}}}export{$e as default};
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.