From bc6ae7c52adb2608ad112d37baa1253a07dff19c Mon Sep 17 00:00:00 2001 From: Rabbid76 <11585504+Rabbid76@users.noreply.github.com> Date: Fri, 6 Dec 2024 01:33:58 +0000 Subject: [PATCH] build(deps): upgrade NPM packages (automated) --- deploy/bundle.js | 2 +- package-lock.json | 388 +++++++++++++++++++++++++--------------------- package.json | 24 +-- 3 files changed, 220 insertions(+), 194 deletions(-) diff --git a/deploy/bundle.js b/deploy/bundle.js index f8dd8f4..3f0add8 100644 --- a/deploy/bundle.js +++ b/deploy/bundle.js @@ -1,2 +1,2 @@ /*! For license information please see bundle.js.LICENSE.txt */ -(()=>{"use strict";var e={};e.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(e){if("object"==typeof window)return window}}(),(()=>{var t;e.g.importScripts&&(t=e.g.location+"");var n=e.g.document;if(!t&&n&&(n.currentScript&&"SCRIPT"===n.currentScript.tagName.toUpperCase()&&(t=n.currentScript.src),!t)){var i=n.getElementsByTagName("script");if(i.length)for(var r=i.length-1;r>-1&&(!t||!/^http(s?):/.test(t));)t=i[r--].src}if(!t)throw new Error("Automatic publicPath is not supported in this browser");t=t.replace(/#.*$/,"").replace(/\?.*$/,"").replace(/\/[^\/]+$/,"/"),e.p=t})();const t=[{name:"BrainStem",url:"./BrainStem.glb"},{name:"DamagedHelmet",url:"./DamagedHelmet.glb"}],n="170",i=0,r=1,a=2,s=100,o=101,l=102,c=200,h=201,d=202,u=203,p=204,f=205,m=206,g=207,v=208,_=209,x=210,y=211,S=212,w=213,b=214,M=0,T=1,E=2,A=3,P=4,R=5,C=6,D=7,L="attached",I=301,U=302,O=306,N=1e3,F=1001,B=1002,z=1003,k=1004,H=1005,V=1006,G=1007,W=1008,j=1009,X=1012,Y=1013,q=1014,Z=1015,K=1016,J=1017,Q=1018,$=1020,ee=1023,te=1026,ne=1027,ie=1028,re=1029,ae=1030,se=1031,oe=1033,le=33776,ce=33777,he=33778,de=33779,ue=35840,pe=35841,fe=35842,me=35843,ge=36196,ve=37492,_e=37496,xe=37808,ye=37809,Se=37810,we=37811,be=37812,Me=37813,Te=37814,Ee=37815,Ae=37816,Pe=37817,Re=37818,Ce=37819,De=37820,Le=37821,Ie=36492,Ue=36494,Oe=36495,Ne=36284,Fe=36285,Be=36286,ze=2300,ke=2301,He=2302,Ve="",Ge="srgb",We="srgb-linear",je="linear",Xe="srgb",Ye=7680,qe=512,Ze=513,Ke=514,Je=515,Qe=516,$e=517,et=518,tt=519,nt=35044,it="300 es",rt=2e3,at=2001;class st{addEventListener(e,t){void 0===this._listeners&&(this._listeners={});const n=this._listeners;void 0===n[e]&&(n[e]=[]),-1===n[e].indexOf(t)&&n[e].push(t)}hasEventListener(e,t){if(void 0===this._listeners)return!1;const n=this._listeners;return void 0!==n[e]&&-1!==n[e].indexOf(t)}removeEventListener(e,t){if(void 0===this._listeners)return;const n=this._listeners[e];if(void 0!==n){const e=n.indexOf(t);-1!==e&&n.splice(e,1)}}dispatchEvent(e){if(void 0===this._listeners)return;const t=this._listeners[e.type];if(void 0!==t){e.target=this;const n=t.slice(0);for(let t=0,i=n.length;t>8&255]+ot[e>>16&255]+ot[e>>24&255]+"-"+ot[255&t]+ot[t>>8&255]+"-"+ot[t>>16&15|64]+ot[t>>24&255]+"-"+ot[63&n|128]+ot[n>>8&255]+"-"+ot[n>>16&255]+ot[n>>24&255]+ot[255&i]+ot[i>>8&255]+ot[i>>16&255]+ot[i>>24&255]).toLowerCase()}function dt(e,t,n){return Math.max(t,Math.min(n,e))}function ut(e,t){return(e%t+t)%t}function pt(e,t,n){return(1-n)*e+n*t}function ft(e,t){switch(t.constructor){case Float32Array:return e;case Uint32Array:return e/4294967295;case Uint16Array:return e/65535;case Uint8Array:return e/255;case Int32Array:return Math.max(e/2147483647,-1);case Int16Array:return Math.max(e/32767,-1);case Int8Array:return Math.max(e/127,-1);default:throw new Error("Invalid component type.")}}function mt(e,t){switch(t.constructor){case Float32Array:return e;case Uint32Array:return Math.round(4294967295*e);case Uint16Array:return Math.round(65535*e);case Uint8Array:return Math.round(255*e);case Int32Array:return Math.round(2147483647*e);case Int16Array:return Math.round(32767*e);case Int8Array:return Math.round(127*e);default:throw new Error("Invalid component type.")}}const gt=lt,vt=function(e){return e*ct};class _t{constructor(e=0,t=0){_t.prototype.isVector2=!0,this.x=e,this.y=t}get width(){return this.x}set width(e){this.x=e}get height(){return this.y}set height(e){this.y=e}set(e,t){return this.x=e,this.y=t,this}setScalar(e){return this.x=e,this.y=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setComponent(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;default:throw new Error("index is out of range: "+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;default:throw new Error("index is out of range: "+e)}}clone(){return new this.constructor(this.x,this.y)}copy(e){return this.x=e.x,this.y=e.y,this}add(e){return this.x+=e.x,this.y+=e.y,this}addScalar(e){return this.x+=e,this.y+=e,this}addVectors(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this}addScaledVector(e,t){return this.x+=e.x*t,this.y+=e.y*t,this}sub(e){return this.x-=e.x,this.y-=e.y,this}subScalar(e){return this.x-=e,this.y-=e,this}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this}multiply(e){return this.x*=e.x,this.y*=e.y,this}multiplyScalar(e){return this.x*=e,this.y*=e,this}divide(e){return this.x/=e.x,this.y/=e.y,this}divideScalar(e){return this.multiplyScalar(1/e)}applyMatrix3(e){const t=this.x,n=this.y,i=e.elements;return this.x=i[0]*t+i[3]*n+i[6],this.y=i[1]*t+i[4]*n+i[7],this}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this}clamp(e,t){return this.x=Math.max(e.x,Math.min(t.x,this.x)),this.y=Math.max(e.y,Math.min(t.y,this.y)),this}clampScalar(e,t){return this.x=Math.max(e,Math.min(t,this.x)),this.y=Math.max(e,Math.min(t,this.y)),this}clampLength(e,t){const n=this.length();return this.divideScalar(n||1).multiplyScalar(Math.max(e,Math.min(t,n)))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this}negate(){return this.x=-this.x,this.y=-this.y,this}dot(e){return this.x*e.x+this.y*e.y}cross(e){return this.x*e.y-this.y*e.x}lengthSq(){return this.x*this.x+this.y*this.y}length(){return Math.sqrt(this.x*this.x+this.y*this.y)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)}normalize(){return this.divideScalar(this.length()||1)}angle(){return Math.atan2(-this.y,-this.x)+Math.PI}angleTo(e){const t=Math.sqrt(this.lengthSq()*e.lengthSq());if(0===t)return Math.PI/2;const n=this.dot(e)/t;return Math.acos(dt(n,-1,1))}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){const t=this.x-e.x,n=this.y-e.y;return t*t+n*n}manhattanDistanceTo(e){return Math.abs(this.x-e.x)+Math.abs(this.y-e.y)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this}lerpVectors(e,t,n){return this.x=e.x+(t.x-e.x)*n,this.y=e.y+(t.y-e.y)*n,this}equals(e){return e.x===this.x&&e.y===this.y}fromArray(e,t=0){return this.x=e[t],this.y=e[t+1],this}toArray(e=[],t=0){return e[t]=this.x,e[t+1]=this.y,e}fromBufferAttribute(e,t){return this.x=e.getX(t),this.y=e.getY(t),this}rotateAround(e,t){const n=Math.cos(t),i=Math.sin(t),r=this.x-e.x,a=this.y-e.y;return this.x=r*n-a*i+e.x,this.y=r*i+a*n+e.y,this}random(){return this.x=Math.random(),this.y=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y}}class xt{constructor(e,t,n,i,r,a,s,o,l){xt.prototype.isMatrix3=!0,this.elements=[1,0,0,0,1,0,0,0,1],void 0!==e&&this.set(e,t,n,i,r,a,s,o,l)}set(e,t,n,i,r,a,s,o,l){const c=this.elements;return c[0]=e,c[1]=i,c[2]=s,c[3]=t,c[4]=r,c[5]=o,c[6]=n,c[7]=a,c[8]=l,this}identity(){return this.set(1,0,0,0,1,0,0,0,1),this}copy(e){const t=this.elements,n=e.elements;return t[0]=n[0],t[1]=n[1],t[2]=n[2],t[3]=n[3],t[4]=n[4],t[5]=n[5],t[6]=n[6],t[7]=n[7],t[8]=n[8],this}extractBasis(e,t,n){return e.setFromMatrix3Column(this,0),t.setFromMatrix3Column(this,1),n.setFromMatrix3Column(this,2),this}setFromMatrix4(e){const t=e.elements;return this.set(t[0],t[4],t[8],t[1],t[5],t[9],t[2],t[6],t[10]),this}multiply(e){return this.multiplyMatrices(this,e)}premultiply(e){return this.multiplyMatrices(e,this)}multiplyMatrices(e,t){const n=e.elements,i=t.elements,r=this.elements,a=n[0],s=n[3],o=n[6],l=n[1],c=n[4],h=n[7],d=n[2],u=n[5],p=n[8],f=i[0],m=i[3],g=i[6],v=i[1],_=i[4],x=i[7],y=i[2],S=i[5],w=i[8];return r[0]=a*f+s*v+o*y,r[3]=a*m+s*_+o*S,r[6]=a*g+s*x+o*w,r[1]=l*f+c*v+h*y,r[4]=l*m+c*_+h*S,r[7]=l*g+c*x+h*w,r[2]=d*f+u*v+p*y,r[5]=d*m+u*_+p*S,r[8]=d*g+u*x+p*w,this}multiplyScalar(e){const t=this.elements;return t[0]*=e,t[3]*=e,t[6]*=e,t[1]*=e,t[4]*=e,t[7]*=e,t[2]*=e,t[5]*=e,t[8]*=e,this}determinant(){const e=this.elements,t=e[0],n=e[1],i=e[2],r=e[3],a=e[4],s=e[5],o=e[6],l=e[7],c=e[8];return t*a*c-t*s*l-n*r*c+n*s*o+i*r*l-i*a*o}invert(){const e=this.elements,t=e[0],n=e[1],i=e[2],r=e[3],a=e[4],s=e[5],o=e[6],l=e[7],c=e[8],h=c*a-s*l,d=s*o-c*r,u=l*r-a*o,p=t*h+n*d+i*u;if(0===p)return this.set(0,0,0,0,0,0,0,0,0);const f=1/p;return e[0]=h*f,e[1]=(i*l-c*n)*f,e[2]=(s*n-i*a)*f,e[3]=d*f,e[4]=(c*t-i*o)*f,e[5]=(i*r-s*t)*f,e[6]=u*f,e[7]=(n*o-l*t)*f,e[8]=(a*t-n*r)*f,this}transpose(){let e;const t=this.elements;return e=t[1],t[1]=t[3],t[3]=e,e=t[2],t[2]=t[6],t[6]=e,e=t[5],t[5]=t[7],t[7]=e,this}getNormalMatrix(e){return this.setFromMatrix4(e).invert().transpose()}transposeIntoArray(e){const t=this.elements;return e[0]=t[0],e[1]=t[3],e[2]=t[6],e[3]=t[1],e[4]=t[4],e[5]=t[7],e[6]=t[2],e[7]=t[5],e[8]=t[8],this}setUvTransform(e,t,n,i,r,a,s){const o=Math.cos(r),l=Math.sin(r);return this.set(n*o,n*l,-n*(o*a+l*s)+a+e,-i*l,i*o,-i*(-l*a+o*s)+s+t,0,0,1),this}scale(e,t){return this.premultiply(yt.makeScale(e,t)),this}rotate(e){return this.premultiply(yt.makeRotation(-e)),this}translate(e,t){return this.premultiply(yt.makeTranslation(e,t)),this}makeTranslation(e,t){return e.isVector2?this.set(1,0,e.x,0,1,e.y,0,0,1):this.set(1,0,e,0,1,t,0,0,1),this}makeRotation(e){const t=Math.cos(e),n=Math.sin(e);return this.set(t,-n,0,n,t,0,0,0,1),this}makeScale(e,t){return this.set(e,0,0,0,t,0,0,0,1),this}equals(e){const t=this.elements,n=e.elements;for(let e=0;e<9;e++)if(t[e]!==n[e])return!1;return!0}fromArray(e,t=0){for(let n=0;n<9;n++)this.elements[n]=e[n+t];return this}toArray(e=[],t=0){const n=this.elements;return e[t]=n[0],e[t+1]=n[1],e[t+2]=n[2],e[t+3]=n[3],e[t+4]=n[4],e[t+5]=n[5],e[t+6]=n[6],e[t+7]=n[7],e[t+8]=n[8],e}clone(){return(new this.constructor).fromArray(this.elements)}}const yt=new xt;function St(e){for(let t=e.length-1;t>=0;--t)if(e[t]>=65535)return!0;return!1}function wt(e){return document.createElementNS("http://www.w3.org/1999/xhtml",e)}function bt(){const e=wt("canvas");return e.style.display="block",e}Int8Array,Uint8Array,Uint8ClampedArray,Int16Array,Uint16Array,Int32Array,Uint32Array,Float32Array,Float64Array;const Mt={};function Tt(e){e in Mt||(Mt[e]=!0,console.warn(e))}const Et={enabled:!0,workingColorSpace:We,spaces:{},convert:function(e,t,n){return!1!==this.enabled&&t!==n&&t&&n?(this.spaces[t].transfer===Xe&&(e.r=At(e.r),e.g=At(e.g),e.b=At(e.b)),this.spaces[t].primaries!==this.spaces[n].primaries&&(e.applyMatrix3(this.spaces[t].toXYZ),e.applyMatrix3(this.spaces[n].fromXYZ)),this.spaces[n].transfer===Xe&&(e.r=Pt(e.r),e.g=Pt(e.g),e.b=Pt(e.b)),e):e},fromWorkingColorSpace:function(e,t){return this.convert(e,this.workingColorSpace,t)},toWorkingColorSpace:function(e,t){return this.convert(e,t,this.workingColorSpace)},getPrimaries:function(e){return this.spaces[e].primaries},getTransfer:function(e){return e===Ve?je:this.spaces[e].transfer},getLuminanceCoefficients:function(e,t=this.workingColorSpace){return e.fromArray(this.spaces[t].luminanceCoefficients)},define:function(e){Object.assign(this.spaces,e)},_getMatrix:function(e,t,n){return e.copy(this.spaces[t].toXYZ).multiply(this.spaces[n].fromXYZ)},_getDrawingBufferColorSpace:function(e){return this.spaces[e].outputColorSpaceConfig.drawingBufferColorSpace},_getUnpackColorSpace:function(e=this.workingColorSpace){return this.spaces[e].workingColorSpaceConfig.unpackColorSpace}};function At(e){return e<.04045?.0773993808*e:Math.pow(.9478672986*e+.0521327014,2.4)}function Pt(e){return e<.0031308?12.92*e:1.055*Math.pow(e,.41666)-.055}const Rt=[.64,.33,.3,.6,.15,.06],Ct=[.2126,.7152,.0722],Dt=[.3127,.329],Lt=(new xt).set(.4123908,.3575843,.1804808,.212639,.7151687,.0721923,.0193308,.1191948,.9505322),It=(new xt).set(3.2409699,-1.5373832,-.4986108,-.9692436,1.8759675,.0415551,.0556301,-.203977,1.0569715);let Ut;Et.define({[We]:{primaries:Rt,whitePoint:Dt,transfer:je,toXYZ:Lt,fromXYZ:It,luminanceCoefficients:Ct,workingColorSpaceConfig:{unpackColorSpace:Ge},outputColorSpaceConfig:{drawingBufferColorSpace:Ge}},[Ge]:{primaries:Rt,whitePoint:Dt,transfer:Xe,toXYZ:Lt,fromXYZ:It,luminanceCoefficients:Ct,outputColorSpaceConfig:{drawingBufferColorSpace:Ge}}});class Ot{static getDataURL(e){if(/^data:/i.test(e.src))return e.src;if("undefined"==typeof HTMLCanvasElement)return e.src;let t;if(e instanceof HTMLCanvasElement)t=e;else{void 0===Ut&&(Ut=wt("canvas")),Ut.width=e.width,Ut.height=e.height;const n=Ut.getContext("2d");e instanceof ImageData?n.putImageData(e,0,0):n.drawImage(e,0,0,e.width,e.height),t=Ut}return t.width>2048||t.height>2048?(console.warn("THREE.ImageUtils.getDataURL: Image converted to jpg for performance reasons",e),t.toDataURL("image/jpeg",.6)):t.toDataURL("image/png")}static sRGBToLinear(e){if("undefined"!=typeof HTMLImageElement&&e instanceof HTMLImageElement||"undefined"!=typeof HTMLCanvasElement&&e instanceof HTMLCanvasElement||"undefined"!=typeof ImageBitmap&&e instanceof ImageBitmap){const t=wt("canvas");t.width=e.width,t.height=e.height;const n=t.getContext("2d");n.drawImage(e,0,0,e.width,e.height);const i=n.getImageData(0,0,e.width,e.height),r=i.data;for(let e=0;e0&&(n.userData=this.userData),t||(e.textures[this.uuid]=n),n}dispose(){this.dispatchEvent({type:"dispose"})}transformUv(e){if(300!==this.mapping)return e;if(e.applyMatrix3(this.matrix),e.x<0||e.x>1)switch(this.wrapS){case N:e.x=e.x-Math.floor(e.x);break;case F:e.x=e.x<0?0:1;break;case B:1===Math.abs(Math.floor(e.x)%2)?e.x=Math.ceil(e.x)-e.x:e.x=e.x-Math.floor(e.x)}if(e.y<0||e.y>1)switch(this.wrapT){case N:e.y=e.y-Math.floor(e.y);break;case F:e.y=e.y<0?0:1;break;case B:1===Math.abs(Math.floor(e.y)%2)?e.y=Math.ceil(e.y)-e.y:e.y=e.y-Math.floor(e.y)}return this.flipY&&(e.y=1-e.y),e}set needsUpdate(e){!0===e&&(this.version++,this.source.needsUpdate=!0)}set needsPMREMUpdate(e){!0===e&&this.pmremVersion++}}kt.DEFAULT_IMAGE=null,kt.DEFAULT_MAPPING=300,kt.DEFAULT_ANISOTROPY=1;class Ht{constructor(e=0,t=0,n=0,i=1){Ht.prototype.isVector4=!0,this.x=e,this.y=t,this.z=n,this.w=i}get width(){return this.z}set width(e){this.z=e}get height(){return this.w}set height(e){this.w=e}set(e,t,n,i){return this.x=e,this.y=t,this.z=n,this.w=i,this}setScalar(e){return this.x=e,this.y=e,this.z=e,this.w=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setZ(e){return this.z=e,this}setW(e){return this.w=e,this}setComponent(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;case 2:this.z=t;break;case 3:this.w=t;break;default:throw new Error("index is out of range: "+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;case 2:return this.z;case 3:return this.w;default:throw new Error("index is out of range: "+e)}}clone(){return new this.constructor(this.x,this.y,this.z,this.w)}copy(e){return this.x=e.x,this.y=e.y,this.z=e.z,this.w=void 0!==e.w?e.w:1,this}add(e){return this.x+=e.x,this.y+=e.y,this.z+=e.z,this.w+=e.w,this}addScalar(e){return this.x+=e,this.y+=e,this.z+=e,this.w+=e,this}addVectors(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this.z=e.z+t.z,this.w=e.w+t.w,this}addScaledVector(e,t){return this.x+=e.x*t,this.y+=e.y*t,this.z+=e.z*t,this.w+=e.w*t,this}sub(e){return this.x-=e.x,this.y-=e.y,this.z-=e.z,this.w-=e.w,this}subScalar(e){return this.x-=e,this.y-=e,this.z-=e,this.w-=e,this}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this.z=e.z-t.z,this.w=e.w-t.w,this}multiply(e){return this.x*=e.x,this.y*=e.y,this.z*=e.z,this.w*=e.w,this}multiplyScalar(e){return this.x*=e,this.y*=e,this.z*=e,this.w*=e,this}applyMatrix4(e){const t=this.x,n=this.y,i=this.z,r=this.w,a=e.elements;return this.x=a[0]*t+a[4]*n+a[8]*i+a[12]*r,this.y=a[1]*t+a[5]*n+a[9]*i+a[13]*r,this.z=a[2]*t+a[6]*n+a[10]*i+a[14]*r,this.w=a[3]*t+a[7]*n+a[11]*i+a[15]*r,this}divide(e){return this.x/=e.x,this.y/=e.y,this.z/=e.z,this.w/=e.w,this}divideScalar(e){return this.multiplyScalar(1/e)}setAxisAngleFromQuaternion(e){this.w=2*Math.acos(e.w);const t=Math.sqrt(1-e.w*e.w);return t<1e-4?(this.x=1,this.y=0,this.z=0):(this.x=e.x/t,this.y=e.y/t,this.z=e.z/t),this}setAxisAngleFromRotationMatrix(e){let t,n,i,r;const a=.01,s=.1,o=e.elements,l=o[0],c=o[4],h=o[8],d=o[1],u=o[5],p=o[9],f=o[2],m=o[6],g=o[10];if(Math.abs(c-d)o&&e>v?ev?o=0?1:-1,i=1-t*t;if(i>Number.EPSILON){const r=Math.sqrt(i),a=Math.atan2(r,t*n);e=Math.sin(e*a)/r,s=Math.sin(s*a)/r}const r=s*n;if(o=o*e+d*r,l=l*e+u*r,c=c*e+p*r,h=h*e+f*r,e===1-s){const e=1/Math.sqrt(o*o+l*l+c*c+h*h);o*=e,l*=e,c*=e,h*=e}}e[t]=o,e[t+1]=l,e[t+2]=c,e[t+3]=h}static multiplyQuaternionsFlat(e,t,n,i,r,a){const s=n[i],o=n[i+1],l=n[i+2],c=n[i+3],h=r[a],d=r[a+1],u=r[a+2],p=r[a+3];return e[t]=s*p+c*h+o*u-l*d,e[t+1]=o*p+c*d+l*h-s*u,e[t+2]=l*p+c*u+s*d-o*h,e[t+3]=c*p-s*h-o*d-l*u,e}get x(){return this._x}set x(e){this._x=e,this._onChangeCallback()}get y(){return this._y}set y(e){this._y=e,this._onChangeCallback()}get z(){return this._z}set z(e){this._z=e,this._onChangeCallback()}get w(){return this._w}set w(e){this._w=e,this._onChangeCallback()}set(e,t,n,i){return this._x=e,this._y=t,this._z=n,this._w=i,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._w)}copy(e){return this._x=e.x,this._y=e.y,this._z=e.z,this._w=e.w,this._onChangeCallback(),this}setFromEuler(e,t=!0){const n=e._x,i=e._y,r=e._z,a=e._order,s=Math.cos,o=Math.sin,l=s(n/2),c=s(i/2),h=s(r/2),d=o(n/2),u=o(i/2),p=o(r/2);switch(a){case"XYZ":this._x=d*c*h+l*u*p,this._y=l*u*h-d*c*p,this._z=l*c*p+d*u*h,this._w=l*c*h-d*u*p;break;case"YXZ":this._x=d*c*h+l*u*p,this._y=l*u*h-d*c*p,this._z=l*c*p-d*u*h,this._w=l*c*h+d*u*p;break;case"ZXY":this._x=d*c*h-l*u*p,this._y=l*u*h+d*c*p,this._z=l*c*p+d*u*h,this._w=l*c*h-d*u*p;break;case"ZYX":this._x=d*c*h-l*u*p,this._y=l*u*h+d*c*p,this._z=l*c*p-d*u*h,this._w=l*c*h+d*u*p;break;case"YZX":this._x=d*c*h+l*u*p,this._y=l*u*h+d*c*p,this._z=l*c*p-d*u*h,this._w=l*c*h-d*u*p;break;case"XZY":this._x=d*c*h-l*u*p,this._y=l*u*h-d*c*p,this._z=l*c*p+d*u*h,this._w=l*c*h+d*u*p;break;default:console.warn("THREE.Quaternion: .setFromEuler() encountered an unknown order: "+a)}return!0===t&&this._onChangeCallback(),this}setFromAxisAngle(e,t){const n=t/2,i=Math.sin(n);return this._x=e.x*i,this._y=e.y*i,this._z=e.z*i,this._w=Math.cos(n),this._onChangeCallback(),this}setFromRotationMatrix(e){const t=e.elements,n=t[0],i=t[4],r=t[8],a=t[1],s=t[5],o=t[9],l=t[2],c=t[6],h=t[10],d=n+s+h;if(d>0){const e=.5/Math.sqrt(d+1);this._w=.25/e,this._x=(c-o)*e,this._y=(r-l)*e,this._z=(a-i)*e}else if(n>s&&n>h){const e=2*Math.sqrt(1+n-s-h);this._w=(c-o)/e,this._x=.25*e,this._y=(i+a)/e,this._z=(r+l)/e}else if(s>h){const e=2*Math.sqrt(1+s-n-h);this._w=(r-l)/e,this._x=(i+a)/e,this._y=.25*e,this._z=(o+c)/e}else{const e=2*Math.sqrt(1+h-n-s);this._w=(a-i)/e,this._x=(r+l)/e,this._y=(o+c)/e,this._z=.25*e}return this._onChangeCallback(),this}setFromUnitVectors(e,t){let n=e.dot(t)+1;return nMath.abs(e.z)?(this._x=-e.y,this._y=e.x,this._z=0,this._w=n):(this._x=0,this._y=-e.z,this._z=e.y,this._w=n)):(this._x=e.y*t.z-e.z*t.y,this._y=e.z*t.x-e.x*t.z,this._z=e.x*t.y-e.y*t.x,this._w=n),this.normalize()}angleTo(e){return 2*Math.acos(Math.abs(dt(this.dot(e),-1,1)))}rotateTowards(e,t){const n=this.angleTo(e);if(0===n)return this;const i=Math.min(1,t/n);return this.slerp(e,i),this}identity(){return this.set(0,0,0,1)}invert(){return this.conjugate()}conjugate(){return this._x*=-1,this._y*=-1,this._z*=-1,this._onChangeCallback(),this}dot(e){return this._x*e._x+this._y*e._y+this._z*e._z+this._w*e._w}lengthSq(){return this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w}length(){return Math.sqrt(this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w)}normalize(){let e=this.length();return 0===e?(this._x=0,this._y=0,this._z=0,this._w=1):(e=1/e,this._x=this._x*e,this._y=this._y*e,this._z=this._z*e,this._w=this._w*e),this._onChangeCallback(),this}multiply(e){return this.multiplyQuaternions(this,e)}premultiply(e){return this.multiplyQuaternions(e,this)}multiplyQuaternions(e,t){const n=e._x,i=e._y,r=e._z,a=e._w,s=t._x,o=t._y,l=t._z,c=t._w;return this._x=n*c+a*s+i*l-r*o,this._y=i*c+a*o+r*s-n*l,this._z=r*c+a*l+n*o-i*s,this._w=a*c-n*s-i*o-r*l,this._onChangeCallback(),this}slerp(e,t){if(0===t)return this;if(1===t)return this.copy(e);const n=this._x,i=this._y,r=this._z,a=this._w;let s=a*e._w+n*e._x+i*e._y+r*e._z;if(s<0?(this._w=-e._w,this._x=-e._x,this._y=-e._y,this._z=-e._z,s=-s):this.copy(e),s>=1)return this._w=a,this._x=n,this._y=i,this._z=r,this;const o=1-s*s;if(o<=Number.EPSILON){const e=1-t;return this._w=e*a+t*this._w,this._x=e*n+t*this._x,this._y=e*i+t*this._y,this._z=e*r+t*this._z,this.normalize(),this}const l=Math.sqrt(o),c=Math.atan2(l,s),h=Math.sin((1-t)*c)/l,d=Math.sin(t*c)/l;return this._w=a*h+this._w*d,this._x=n*h+this._x*d,this._y=i*h+this._y*d,this._z=r*h+this._z*d,this._onChangeCallback(),this}slerpQuaternions(e,t,n){return this.copy(e).slerp(t,n)}random(){const e=2*Math.PI*Math.random(),t=2*Math.PI*Math.random(),n=Math.random(),i=Math.sqrt(1-n),r=Math.sqrt(n);return this.set(i*Math.sin(e),i*Math.cos(e),r*Math.sin(t),r*Math.cos(t))}equals(e){return e._x===this._x&&e._y===this._y&&e._z===this._z&&e._w===this._w}fromArray(e,t=0){return this._x=e[t],this._y=e[t+1],this._z=e[t+2],this._w=e[t+3],this._onChangeCallback(),this}toArray(e=[],t=0){return e[t]=this._x,e[t+1]=this._y,e[t+2]=this._z,e[t+3]=this._w,e}fromBufferAttribute(e,t){return this._x=e.getX(t),this._y=e.getY(t),this._z=e.getZ(t),this._w=e.getW(t),this._onChangeCallback(),this}toJSON(){return this.toArray()}_onChange(e){return this._onChangeCallback=e,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._w}}class Yt{constructor(e=0,t=0,n=0){Yt.prototype.isVector3=!0,this.x=e,this.y=t,this.z=n}set(e,t,n){return void 0===n&&(n=this.z),this.x=e,this.y=t,this.z=n,this}setScalar(e){return this.x=e,this.y=e,this.z=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setZ(e){return this.z=e,this}setComponent(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;case 2:this.z=t;break;default:throw new Error("index is out of range: "+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;case 2:return this.z;default:throw new Error("index is out of range: "+e)}}clone(){return new this.constructor(this.x,this.y,this.z)}copy(e){return this.x=e.x,this.y=e.y,this.z=e.z,this}add(e){return this.x+=e.x,this.y+=e.y,this.z+=e.z,this}addScalar(e){return this.x+=e,this.y+=e,this.z+=e,this}addVectors(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this.z=e.z+t.z,this}addScaledVector(e,t){return this.x+=e.x*t,this.y+=e.y*t,this.z+=e.z*t,this}sub(e){return this.x-=e.x,this.y-=e.y,this.z-=e.z,this}subScalar(e){return this.x-=e,this.y-=e,this.z-=e,this}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this.z=e.z-t.z,this}multiply(e){return this.x*=e.x,this.y*=e.y,this.z*=e.z,this}multiplyScalar(e){return this.x*=e,this.y*=e,this.z*=e,this}multiplyVectors(e,t){return this.x=e.x*t.x,this.y=e.y*t.y,this.z=e.z*t.z,this}applyEuler(e){return this.applyQuaternion(Zt.setFromEuler(e))}applyAxisAngle(e,t){return this.applyQuaternion(Zt.setFromAxisAngle(e,t))}applyMatrix3(e){const t=this.x,n=this.y,i=this.z,r=e.elements;return this.x=r[0]*t+r[3]*n+r[6]*i,this.y=r[1]*t+r[4]*n+r[7]*i,this.z=r[2]*t+r[5]*n+r[8]*i,this}applyNormalMatrix(e){return this.applyMatrix3(e).normalize()}applyMatrix4(e){const t=this.x,n=this.y,i=this.z,r=e.elements,a=1/(r[3]*t+r[7]*n+r[11]*i+r[15]);return this.x=(r[0]*t+r[4]*n+r[8]*i+r[12])*a,this.y=(r[1]*t+r[5]*n+r[9]*i+r[13])*a,this.z=(r[2]*t+r[6]*n+r[10]*i+r[14])*a,this}applyQuaternion(e){const t=this.x,n=this.y,i=this.z,r=e.x,a=e.y,s=e.z,o=e.w,l=2*(a*i-s*n),c=2*(s*t-r*i),h=2*(r*n-a*t);return this.x=t+o*l+a*h-s*c,this.y=n+o*c+s*l-r*h,this.z=i+o*h+r*c-a*l,this}project(e){return this.applyMatrix4(e.matrixWorldInverse).applyMatrix4(e.projectionMatrix)}unproject(e){return this.applyMatrix4(e.projectionMatrixInverse).applyMatrix4(e.matrixWorld)}transformDirection(e){const t=this.x,n=this.y,i=this.z,r=e.elements;return this.x=r[0]*t+r[4]*n+r[8]*i,this.y=r[1]*t+r[5]*n+r[9]*i,this.z=r[2]*t+r[6]*n+r[10]*i,this.normalize()}divide(e){return this.x/=e.x,this.y/=e.y,this.z/=e.z,this}divideScalar(e){return this.multiplyScalar(1/e)}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this.z=Math.min(this.z,e.z),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this.z=Math.max(this.z,e.z),this}clamp(e,t){return this.x=Math.max(e.x,Math.min(t.x,this.x)),this.y=Math.max(e.y,Math.min(t.y,this.y)),this.z=Math.max(e.z,Math.min(t.z,this.z)),this}clampScalar(e,t){return this.x=Math.max(e,Math.min(t,this.x)),this.y=Math.max(e,Math.min(t,this.y)),this.z=Math.max(e,Math.min(t,this.z)),this}clampLength(e,t){const n=this.length();return this.divideScalar(n||1).multiplyScalar(Math.max(e,Math.min(t,n)))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this.z=Math.trunc(this.z),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this}dot(e){return this.x*e.x+this.y*e.y+this.z*e.z}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)}normalize(){return this.divideScalar(this.length()||1)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this.z+=(e.z-this.z)*t,this}lerpVectors(e,t,n){return this.x=e.x+(t.x-e.x)*n,this.y=e.y+(t.y-e.y)*n,this.z=e.z+(t.z-e.z)*n,this}cross(e){return this.crossVectors(this,e)}crossVectors(e,t){const n=e.x,i=e.y,r=e.z,a=t.x,s=t.y,o=t.z;return this.x=i*o-r*s,this.y=r*a-n*o,this.z=n*s-i*a,this}projectOnVector(e){const t=e.lengthSq();if(0===t)return this.set(0,0,0);const n=e.dot(this)/t;return this.copy(e).multiplyScalar(n)}projectOnPlane(e){return qt.copy(this).projectOnVector(e),this.sub(qt)}reflect(e){return this.sub(qt.copy(e).multiplyScalar(2*this.dot(e)))}angleTo(e){const t=Math.sqrt(this.lengthSq()*e.lengthSq());if(0===t)return Math.PI/2;const n=this.dot(e)/t;return Math.acos(dt(n,-1,1))}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){const t=this.x-e.x,n=this.y-e.y,i=this.z-e.z;return t*t+n*n+i*i}manhattanDistanceTo(e){return Math.abs(this.x-e.x)+Math.abs(this.y-e.y)+Math.abs(this.z-e.z)}setFromSpherical(e){return this.setFromSphericalCoords(e.radius,e.phi,e.theta)}setFromSphericalCoords(e,t,n){const i=Math.sin(t)*e;return this.x=i*Math.sin(n),this.y=Math.cos(t)*e,this.z=i*Math.cos(n),this}setFromCylindrical(e){return this.setFromCylindricalCoords(e.radius,e.theta,e.y)}setFromCylindricalCoords(e,t,n){return this.x=e*Math.sin(t),this.y=n,this.z=e*Math.cos(t),this}setFromMatrixPosition(e){const t=e.elements;return this.x=t[12],this.y=t[13],this.z=t[14],this}setFromMatrixScale(e){const t=this.setFromMatrixColumn(e,0).length(),n=this.setFromMatrixColumn(e,1).length(),i=this.setFromMatrixColumn(e,2).length();return this.x=t,this.y=n,this.z=i,this}setFromMatrixColumn(e,t){return this.fromArray(e.elements,4*t)}setFromMatrix3Column(e,t){return this.fromArray(e.elements,3*t)}setFromEuler(e){return this.x=e._x,this.y=e._y,this.z=e._z,this}setFromColor(e){return this.x=e.r,this.y=e.g,this.z=e.b,this}equals(e){return e.x===this.x&&e.y===this.y&&e.z===this.z}fromArray(e,t=0){return this.x=e[t],this.y=e[t+1],this.z=e[t+2],this}toArray(e=[],t=0){return e[t]=this.x,e[t+1]=this.y,e[t+2]=this.z,e}fromBufferAttribute(e,t){return this.x=e.getX(t),this.y=e.getY(t),this.z=e.getZ(t),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this}randomDirection(){const e=Math.random()*Math.PI*2,t=2*Math.random()-1,n=Math.sqrt(1-t*t);return this.x=n*Math.cos(e),this.y=t,this.z=n*Math.sin(e),this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z}}const qt=new Yt,Zt=new Xt;class Kt{constructor(e=new Yt(1/0,1/0,1/0),t=new Yt(-1/0,-1/0,-1/0)){this.isBox3=!0,this.min=e,this.max=t}set(e,t){return this.min.copy(e),this.max.copy(t),this}setFromArray(e){this.makeEmpty();for(let t=0,n=e.length;t=this.min.x&&e.x<=this.max.x&&e.y>=this.min.y&&e.y<=this.max.y&&e.z>=this.min.z&&e.z<=this.max.z}containsBox(e){return this.min.x<=e.min.x&&e.max.x<=this.max.x&&this.min.y<=e.min.y&&e.max.y<=this.max.y&&this.min.z<=e.min.z&&e.max.z<=this.max.z}getParameter(e,t){return t.set((e.x-this.min.x)/(this.max.x-this.min.x),(e.y-this.min.y)/(this.max.y-this.min.y),(e.z-this.min.z)/(this.max.z-this.min.z))}intersectsBox(e){return e.max.x>=this.min.x&&e.min.x<=this.max.x&&e.max.y>=this.min.y&&e.min.y<=this.max.y&&e.max.z>=this.min.z&&e.min.z<=this.max.z}intersectsSphere(e){return this.clampPoint(e.center,Qt),Qt.distanceToSquared(e.center)<=e.radius*e.radius}intersectsPlane(e){let t,n;return e.normal.x>0?(t=e.normal.x*this.min.x,n=e.normal.x*this.max.x):(t=e.normal.x*this.max.x,n=e.normal.x*this.min.x),e.normal.y>0?(t+=e.normal.y*this.min.y,n+=e.normal.y*this.max.y):(t+=e.normal.y*this.max.y,n+=e.normal.y*this.min.y),e.normal.z>0?(t+=e.normal.z*this.min.z,n+=e.normal.z*this.max.z):(t+=e.normal.z*this.max.z,n+=e.normal.z*this.min.z),t<=-e.constant&&n>=-e.constant}intersectsTriangle(e){if(this.isEmpty())return!1;this.getCenter(on),ln.subVectors(this.max,on),en.subVectors(e.a,on),tn.subVectors(e.b,on),nn.subVectors(e.c,on),rn.subVectors(tn,en),an.subVectors(nn,tn),sn.subVectors(en,nn);let t=[0,-rn.z,rn.y,0,-an.z,an.y,0,-sn.z,sn.y,rn.z,0,-rn.x,an.z,0,-an.x,sn.z,0,-sn.x,-rn.y,rn.x,0,-an.y,an.x,0,-sn.y,sn.x,0];return!!dn(t,en,tn,nn,ln)&&(t=[1,0,0,0,1,0,0,0,1],!!dn(t,en,tn,nn,ln)&&(cn.crossVectors(rn,an),t=[cn.x,cn.y,cn.z],dn(t,en,tn,nn,ln)))}clampPoint(e,t){return t.copy(e).clamp(this.min,this.max)}distanceToPoint(e){return this.clampPoint(e,Qt).distanceTo(e)}getBoundingSphere(e){return this.isEmpty()?e.makeEmpty():(this.getCenter(e.center),e.radius=.5*this.getSize(Qt).length()),e}intersect(e){return this.min.max(e.min),this.max.min(e.max),this.isEmpty()&&this.makeEmpty(),this}union(e){return this.min.min(e.min),this.max.max(e.max),this}applyMatrix4(e){return this.isEmpty()||(Jt[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(e),Jt[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(e),Jt[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(e),Jt[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(e),Jt[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(e),Jt[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(e),Jt[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(e),Jt[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(e),this.setFromPoints(Jt)),this}translate(e){return this.min.add(e),this.max.add(e),this}equals(e){return e.min.equals(this.min)&&e.max.equals(this.max)}}const Jt=[new Yt,new Yt,new Yt,new Yt,new Yt,new Yt,new Yt,new Yt],Qt=new Yt,$t=new Kt,en=new Yt,tn=new Yt,nn=new Yt,rn=new Yt,an=new Yt,sn=new Yt,on=new Yt,ln=new Yt,cn=new Yt,hn=new Yt;function dn(e,t,n,i,r){for(let a=0,s=e.length-3;a<=s;a+=3){hn.fromArray(e,a);const s=r.x*Math.abs(hn.x)+r.y*Math.abs(hn.y)+r.z*Math.abs(hn.z),o=t.dot(hn),l=n.dot(hn),c=i.dot(hn);if(Math.max(-Math.max(o,l,c),Math.min(o,l,c))>s)return!1}return!0}const un=new Kt,pn=new Yt,fn=new Yt;class mn{constructor(e=new Yt,t=-1){this.isSphere=!0,this.center=e,this.radius=t}set(e,t){return this.center.copy(e),this.radius=t,this}setFromPoints(e,t){const n=this.center;void 0!==t?n.copy(t):un.setFromPoints(e).getCenter(n);let i=0;for(let t=0,r=e.length;tthis.radius*this.radius&&(t.sub(this.center).normalize(),t.multiplyScalar(this.radius).add(this.center)),t}getBoundingBox(e){return this.isEmpty()?(e.makeEmpty(),e):(e.set(this.center,this.center),e.expandByScalar(this.radius),e)}applyMatrix4(e){return this.center.applyMatrix4(e),this.radius=this.radius*e.getMaxScaleOnAxis(),this}translate(e){return this.center.add(e),this}expandByPoint(e){if(this.isEmpty())return this.center.copy(e),this.radius=0,this;pn.subVectors(e,this.center);const t=pn.lengthSq();if(t>this.radius*this.radius){const e=Math.sqrt(t),n=.5*(e-this.radius);this.center.addScaledVector(pn,n/e),this.radius+=n}return this}union(e){return e.isEmpty()?this:this.isEmpty()?(this.copy(e),this):(!0===this.center.equals(e.center)?this.radius=Math.max(this.radius,e.radius):(fn.subVectors(e.center,this.center).setLength(e.radius),this.expandByPoint(pn.copy(e.center).add(fn)),this.expandByPoint(pn.copy(e.center).sub(fn))),this)}equals(e){return e.center.equals(this.center)&&e.radius===this.radius}clone(){return(new this.constructor).copy(this)}}const gn=new Yt,vn=new Yt,_n=new Yt,xn=new Yt,yn=new Yt,Sn=new Yt,wn=new Yt;class bn{constructor(e=new Yt,t=new Yt(0,0,-1)){this.origin=e,this.direction=t}set(e,t){return this.origin.copy(e),this.direction.copy(t),this}copy(e){return this.origin.copy(e.origin),this.direction.copy(e.direction),this}at(e,t){return t.copy(this.origin).addScaledVector(this.direction,e)}lookAt(e){return this.direction.copy(e).sub(this.origin).normalize(),this}recast(e){return this.origin.copy(this.at(e,gn)),this}closestPointToPoint(e,t){t.subVectors(e,this.origin);const n=t.dot(this.direction);return n<0?t.copy(this.origin):t.copy(this.origin).addScaledVector(this.direction,n)}distanceToPoint(e){return Math.sqrt(this.distanceSqToPoint(e))}distanceSqToPoint(e){const t=gn.subVectors(e,this.origin).dot(this.direction);return t<0?this.origin.distanceToSquared(e):(gn.copy(this.origin).addScaledVector(this.direction,t),gn.distanceToSquared(e))}distanceSqToSegment(e,t,n,i){vn.copy(e).add(t).multiplyScalar(.5),_n.copy(t).sub(e).normalize(),xn.copy(this.origin).sub(vn);const r=.5*e.distanceTo(t),a=-this.direction.dot(_n),s=xn.dot(this.direction),o=-xn.dot(_n),l=xn.lengthSq(),c=Math.abs(1-a*a);let h,d,u,p;if(c>0)if(h=a*o-s,d=a*s-o,p=r*c,h>=0)if(d>=-p)if(d<=p){const e=1/c;h*=e,d*=e,u=h*(h+a*d+2*s)+d*(a*h+d+2*o)+l}else d=r,h=Math.max(0,-(a*d+s)),u=-h*h+d*(d+2*o)+l;else d=-r,h=Math.max(0,-(a*d+s)),u=-h*h+d*(d+2*o)+l;else d<=-p?(h=Math.max(0,-(-a*r+s)),d=h>0?-r:Math.min(Math.max(-r,-o),r),u=-h*h+d*(d+2*o)+l):d<=p?(h=0,d=Math.min(Math.max(-r,-o),r),u=d*(d+2*o)+l):(h=Math.max(0,-(a*r+s)),d=h>0?r:Math.min(Math.max(-r,-o),r),u=-h*h+d*(d+2*o)+l);else d=a>0?-r:r,h=Math.max(0,-(a*d+s)),u=-h*h+d*(d+2*o)+l;return n&&n.copy(this.origin).addScaledVector(this.direction,h),i&&i.copy(vn).addScaledVector(_n,d),u}intersectSphere(e,t){gn.subVectors(e.center,this.origin);const n=gn.dot(this.direction),i=gn.dot(gn)-n*n,r=e.radius*e.radius;if(i>r)return null;const a=Math.sqrt(r-i),s=n-a,o=n+a;return o<0?null:s<0?this.at(o,t):this.at(s,t)}intersectsSphere(e){return this.distanceSqToPoint(e.center)<=e.radius*e.radius}distanceToPlane(e){const t=e.normal.dot(this.direction);if(0===t)return 0===e.distanceToPoint(this.origin)?0:null;const n=-(this.origin.dot(e.normal)+e.constant)/t;return n>=0?n:null}intersectPlane(e,t){const n=this.distanceToPlane(e);return null===n?null:this.at(n,t)}intersectsPlane(e){const t=e.distanceToPoint(this.origin);return 0===t||e.normal.dot(this.direction)*t<0}intersectBox(e,t){let n,i,r,a,s,o;const l=1/this.direction.x,c=1/this.direction.y,h=1/this.direction.z,d=this.origin;return l>=0?(n=(e.min.x-d.x)*l,i=(e.max.x-d.x)*l):(n=(e.max.x-d.x)*l,i=(e.min.x-d.x)*l),c>=0?(r=(e.min.y-d.y)*c,a=(e.max.y-d.y)*c):(r=(e.max.y-d.y)*c,a=(e.min.y-d.y)*c),n>a||r>i?null:((r>n||isNaN(n))&&(n=r),(a=0?(s=(e.min.z-d.z)*h,o=(e.max.z-d.z)*h):(s=(e.max.z-d.z)*h,o=(e.min.z-d.z)*h),n>o||s>i?null:((s>n||n!=n)&&(n=s),(o=0?n:i,t)))}intersectsBox(e){return null!==this.intersectBox(e,gn)}intersectTriangle(e,t,n,i,r){yn.subVectors(t,e),Sn.subVectors(n,e),wn.crossVectors(yn,Sn);let a,s=this.direction.dot(wn);if(s>0){if(i)return null;a=1}else{if(!(s<0))return null;a=-1,s=-s}xn.subVectors(this.origin,e);const o=a*this.direction.dot(Sn.crossVectors(xn,Sn));if(o<0)return null;const l=a*this.direction.dot(yn.cross(xn));if(l<0)return null;if(o+l>s)return null;const c=-a*xn.dot(wn);return c<0?null:this.at(c/s,r)}applyMatrix4(e){return this.origin.applyMatrix4(e),this.direction.transformDirection(e),this}equals(e){return e.origin.equals(this.origin)&&e.direction.equals(this.direction)}clone(){return(new this.constructor).copy(this)}}class Mn{constructor(e,t,n,i,r,a,s,o,l,c,h,d,u,p,f,m){Mn.prototype.isMatrix4=!0,this.elements=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],void 0!==e&&this.set(e,t,n,i,r,a,s,o,l,c,h,d,u,p,f,m)}set(e,t,n,i,r,a,s,o,l,c,h,d,u,p,f,m){const g=this.elements;return g[0]=e,g[4]=t,g[8]=n,g[12]=i,g[1]=r,g[5]=a,g[9]=s,g[13]=o,g[2]=l,g[6]=c,g[10]=h,g[14]=d,g[3]=u,g[7]=p,g[11]=f,g[15]=m,this}identity(){return this.set(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1),this}clone(){return(new Mn).fromArray(this.elements)}copy(e){const t=this.elements,n=e.elements;return t[0]=n[0],t[1]=n[1],t[2]=n[2],t[3]=n[3],t[4]=n[4],t[5]=n[5],t[6]=n[6],t[7]=n[7],t[8]=n[8],t[9]=n[9],t[10]=n[10],t[11]=n[11],t[12]=n[12],t[13]=n[13],t[14]=n[14],t[15]=n[15],this}copyPosition(e){const t=this.elements,n=e.elements;return t[12]=n[12],t[13]=n[13],t[14]=n[14],this}setFromMatrix3(e){const t=e.elements;return this.set(t[0],t[3],t[6],0,t[1],t[4],t[7],0,t[2],t[5],t[8],0,0,0,0,1),this}extractBasis(e,t,n){return e.setFromMatrixColumn(this,0),t.setFromMatrixColumn(this,1),n.setFromMatrixColumn(this,2),this}makeBasis(e,t,n){return this.set(e.x,t.x,n.x,0,e.y,t.y,n.y,0,e.z,t.z,n.z,0,0,0,0,1),this}extractRotation(e){const t=this.elements,n=e.elements,i=1/Tn.setFromMatrixColumn(e,0).length(),r=1/Tn.setFromMatrixColumn(e,1).length(),a=1/Tn.setFromMatrixColumn(e,2).length();return t[0]=n[0]*i,t[1]=n[1]*i,t[2]=n[2]*i,t[3]=0,t[4]=n[4]*r,t[5]=n[5]*r,t[6]=n[6]*r,t[7]=0,t[8]=n[8]*a,t[9]=n[9]*a,t[10]=n[10]*a,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,this}makeRotationFromEuler(e){const t=this.elements,n=e.x,i=e.y,r=e.z,a=Math.cos(n),s=Math.sin(n),o=Math.cos(i),l=Math.sin(i),c=Math.cos(r),h=Math.sin(r);if("XYZ"===e.order){const e=a*c,n=a*h,i=s*c,r=s*h;t[0]=o*c,t[4]=-o*h,t[8]=l,t[1]=n+i*l,t[5]=e-r*l,t[9]=-s*o,t[2]=r-e*l,t[6]=i+n*l,t[10]=a*o}else if("YXZ"===e.order){const e=o*c,n=o*h,i=l*c,r=l*h;t[0]=e+r*s,t[4]=i*s-n,t[8]=a*l,t[1]=a*h,t[5]=a*c,t[9]=-s,t[2]=n*s-i,t[6]=r+e*s,t[10]=a*o}else if("ZXY"===e.order){const e=o*c,n=o*h,i=l*c,r=l*h;t[0]=e-r*s,t[4]=-a*h,t[8]=i+n*s,t[1]=n+i*s,t[5]=a*c,t[9]=r-e*s,t[2]=-a*l,t[6]=s,t[10]=a*o}else if("ZYX"===e.order){const e=a*c,n=a*h,i=s*c,r=s*h;t[0]=o*c,t[4]=i*l-n,t[8]=e*l+r,t[1]=o*h,t[5]=r*l+e,t[9]=n*l-i,t[2]=-l,t[6]=s*o,t[10]=a*o}else if("YZX"===e.order){const e=a*o,n=a*l,i=s*o,r=s*l;t[0]=o*c,t[4]=r-e*h,t[8]=i*h+n,t[1]=h,t[5]=a*c,t[9]=-s*c,t[2]=-l*c,t[6]=n*h+i,t[10]=e-r*h}else if("XZY"===e.order){const e=a*o,n=a*l,i=s*o,r=s*l;t[0]=o*c,t[4]=-h,t[8]=l*c,t[1]=e*h+r,t[5]=a*c,t[9]=n*h-i,t[2]=i*h-n,t[6]=s*c,t[10]=r*h+e}return t[3]=0,t[7]=0,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,this}makeRotationFromQuaternion(e){return this.compose(An,e,Pn)}lookAt(e,t,n){const i=this.elements;return Dn.subVectors(e,t),0===Dn.lengthSq()&&(Dn.z=1),Dn.normalize(),Rn.crossVectors(n,Dn),0===Rn.lengthSq()&&(1===Math.abs(n.z)?Dn.x+=1e-4:Dn.z+=1e-4,Dn.normalize(),Rn.crossVectors(n,Dn)),Rn.normalize(),Cn.crossVectors(Dn,Rn),i[0]=Rn.x,i[4]=Cn.x,i[8]=Dn.x,i[1]=Rn.y,i[5]=Cn.y,i[9]=Dn.y,i[2]=Rn.z,i[6]=Cn.z,i[10]=Dn.z,this}multiply(e){return this.multiplyMatrices(this,e)}premultiply(e){return this.multiplyMatrices(e,this)}multiplyMatrices(e,t){const n=e.elements,i=t.elements,r=this.elements,a=n[0],s=n[4],o=n[8],l=n[12],c=n[1],h=n[5],d=n[9],u=n[13],p=n[2],f=n[6],m=n[10],g=n[14],v=n[3],_=n[7],x=n[11],y=n[15],S=i[0],w=i[4],b=i[8],M=i[12],T=i[1],E=i[5],A=i[9],P=i[13],R=i[2],C=i[6],D=i[10],L=i[14],I=i[3],U=i[7],O=i[11],N=i[15];return r[0]=a*S+s*T+o*R+l*I,r[4]=a*w+s*E+o*C+l*U,r[8]=a*b+s*A+o*D+l*O,r[12]=a*M+s*P+o*L+l*N,r[1]=c*S+h*T+d*R+u*I,r[5]=c*w+h*E+d*C+u*U,r[9]=c*b+h*A+d*D+u*O,r[13]=c*M+h*P+d*L+u*N,r[2]=p*S+f*T+m*R+g*I,r[6]=p*w+f*E+m*C+g*U,r[10]=p*b+f*A+m*D+g*O,r[14]=p*M+f*P+m*L+g*N,r[3]=v*S+_*T+x*R+y*I,r[7]=v*w+_*E+x*C+y*U,r[11]=v*b+_*A+x*D+y*O,r[15]=v*M+_*P+x*L+y*N,this}multiplyScalar(e){const t=this.elements;return t[0]*=e,t[4]*=e,t[8]*=e,t[12]*=e,t[1]*=e,t[5]*=e,t[9]*=e,t[13]*=e,t[2]*=e,t[6]*=e,t[10]*=e,t[14]*=e,t[3]*=e,t[7]*=e,t[11]*=e,t[15]*=e,this}determinant(){const e=this.elements,t=e[0],n=e[4],i=e[8],r=e[12],a=e[1],s=e[5],o=e[9],l=e[13],c=e[2],h=e[6],d=e[10],u=e[14];return e[3]*(+r*o*h-i*l*h-r*s*d+n*l*d+i*s*u-n*o*u)+e[7]*(+t*o*u-t*l*d+r*a*d-i*a*u+i*l*c-r*o*c)+e[11]*(+t*l*h-t*s*u-r*a*h+n*a*u+r*s*c-n*l*c)+e[15]*(-i*s*c-t*o*h+t*s*d+i*a*h-n*a*d+n*o*c)}transpose(){const e=this.elements;let t;return t=e[1],e[1]=e[4],e[4]=t,t=e[2],e[2]=e[8],e[8]=t,t=e[6],e[6]=e[9],e[9]=t,t=e[3],e[3]=e[12],e[12]=t,t=e[7],e[7]=e[13],e[13]=t,t=e[11],e[11]=e[14],e[14]=t,this}setPosition(e,t,n){const i=this.elements;return e.isVector3?(i[12]=e.x,i[13]=e.y,i[14]=e.z):(i[12]=e,i[13]=t,i[14]=n),this}invert(){const e=this.elements,t=e[0],n=e[1],i=e[2],r=e[3],a=e[4],s=e[5],o=e[6],l=e[7],c=e[8],h=e[9],d=e[10],u=e[11],p=e[12],f=e[13],m=e[14],g=e[15],v=h*m*l-f*d*l+f*o*u-s*m*u-h*o*g+s*d*g,_=p*d*l-c*m*l-p*o*u+a*m*u+c*o*g-a*d*g,x=c*f*l-p*h*l+p*s*u-a*f*u-c*s*g+a*h*g,y=p*h*o-c*f*o-p*s*d+a*f*d+c*s*m-a*h*m,S=t*v+n*_+i*x+r*y;if(0===S)return this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);const w=1/S;return e[0]=v*w,e[1]=(f*d*r-h*m*r-f*i*u+n*m*u+h*i*g-n*d*g)*w,e[2]=(s*m*r-f*o*r+f*i*l-n*m*l-s*i*g+n*o*g)*w,e[3]=(h*o*r-s*d*r-h*i*l+n*d*l+s*i*u-n*o*u)*w,e[4]=_*w,e[5]=(c*m*r-p*d*r+p*i*u-t*m*u-c*i*g+t*d*g)*w,e[6]=(p*o*r-a*m*r-p*i*l+t*m*l+a*i*g-t*o*g)*w,e[7]=(a*d*r-c*o*r+c*i*l-t*d*l-a*i*u+t*o*u)*w,e[8]=x*w,e[9]=(p*h*r-c*f*r-p*n*u+t*f*u+c*n*g-t*h*g)*w,e[10]=(a*f*r-p*s*r+p*n*l-t*f*l-a*n*g+t*s*g)*w,e[11]=(c*s*r-a*h*r-c*n*l+t*h*l+a*n*u-t*s*u)*w,e[12]=y*w,e[13]=(c*f*i-p*h*i+p*n*d-t*f*d-c*n*m+t*h*m)*w,e[14]=(p*s*i-a*f*i-p*n*o+t*f*o+a*n*m-t*s*m)*w,e[15]=(a*h*i-c*s*i+c*n*o-t*h*o-a*n*d+t*s*d)*w,this}scale(e){const t=this.elements,n=e.x,i=e.y,r=e.z;return t[0]*=n,t[4]*=i,t[8]*=r,t[1]*=n,t[5]*=i,t[9]*=r,t[2]*=n,t[6]*=i,t[10]*=r,t[3]*=n,t[7]*=i,t[11]*=r,this}getMaxScaleOnAxis(){const e=this.elements,t=e[0]*e[0]+e[1]*e[1]+e[2]*e[2],n=e[4]*e[4]+e[5]*e[5]+e[6]*e[6],i=e[8]*e[8]+e[9]*e[9]+e[10]*e[10];return Math.sqrt(Math.max(t,n,i))}makeTranslation(e,t,n){return e.isVector3?this.set(1,0,0,e.x,0,1,0,e.y,0,0,1,e.z,0,0,0,1):this.set(1,0,0,e,0,1,0,t,0,0,1,n,0,0,0,1),this}makeRotationX(e){const t=Math.cos(e),n=Math.sin(e);return this.set(1,0,0,0,0,t,-n,0,0,n,t,0,0,0,0,1),this}makeRotationY(e){const t=Math.cos(e),n=Math.sin(e);return this.set(t,0,n,0,0,1,0,0,-n,0,t,0,0,0,0,1),this}makeRotationZ(e){const t=Math.cos(e),n=Math.sin(e);return this.set(t,-n,0,0,n,t,0,0,0,0,1,0,0,0,0,1),this}makeRotationAxis(e,t){const n=Math.cos(t),i=Math.sin(t),r=1-n,a=e.x,s=e.y,o=e.z,l=r*a,c=r*s;return this.set(l*a+n,l*s-i*o,l*o+i*s,0,l*s+i*o,c*s+n,c*o-i*a,0,l*o-i*s,c*o+i*a,r*o*o+n,0,0,0,0,1),this}makeScale(e,t,n){return this.set(e,0,0,0,0,t,0,0,0,0,n,0,0,0,0,1),this}makeShear(e,t,n,i,r,a){return this.set(1,n,r,0,e,1,a,0,t,i,1,0,0,0,0,1),this}compose(e,t,n){const i=this.elements,r=t._x,a=t._y,s=t._z,o=t._w,l=r+r,c=a+a,h=s+s,d=r*l,u=r*c,p=r*h,f=a*c,m=a*h,g=s*h,v=o*l,_=o*c,x=o*h,y=n.x,S=n.y,w=n.z;return i[0]=(1-(f+g))*y,i[1]=(u+x)*y,i[2]=(p-_)*y,i[3]=0,i[4]=(u-x)*S,i[5]=(1-(d+g))*S,i[6]=(m+v)*S,i[7]=0,i[8]=(p+_)*w,i[9]=(m-v)*w,i[10]=(1-(d+f))*w,i[11]=0,i[12]=e.x,i[13]=e.y,i[14]=e.z,i[15]=1,this}decompose(e,t,n){const i=this.elements;let r=Tn.set(i[0],i[1],i[2]).length();const a=Tn.set(i[4],i[5],i[6]).length(),s=Tn.set(i[8],i[9],i[10]).length();this.determinant()<0&&(r=-r),e.x=i[12],e.y=i[13],e.z=i[14],En.copy(this);const o=1/r,l=1/a,c=1/s;return En.elements[0]*=o,En.elements[1]*=o,En.elements[2]*=o,En.elements[4]*=l,En.elements[5]*=l,En.elements[6]*=l,En.elements[8]*=c,En.elements[9]*=c,En.elements[10]*=c,t.setFromRotationMatrix(En),n.x=r,n.y=a,n.z=s,this}makePerspective(e,t,n,i,r,a,s=2e3){const o=this.elements,l=2*r/(t-e),c=2*r/(n-i),h=(t+e)/(t-e),d=(n+i)/(n-i);let u,p;if(s===rt)u=-(a+r)/(a-r),p=-2*a*r/(a-r);else{if(s!==at)throw new Error("THREE.Matrix4.makePerspective(): Invalid coordinate system: "+s);u=-a/(a-r),p=-a*r/(a-r)}return o[0]=l,o[4]=0,o[8]=h,o[12]=0,o[1]=0,o[5]=c,o[9]=d,o[13]=0,o[2]=0,o[6]=0,o[10]=u,o[14]=p,o[3]=0,o[7]=0,o[11]=-1,o[15]=0,this}makeOrthographic(e,t,n,i,r,a,s=2e3){const o=this.elements,l=1/(t-e),c=1/(n-i),h=1/(a-r),d=(t+e)*l,u=(n+i)*c;let p,f;if(s===rt)p=(a+r)*h,f=-2*h;else{if(s!==at)throw new Error("THREE.Matrix4.makeOrthographic(): Invalid coordinate system: "+s);p=r*h,f=-1*h}return o[0]=2*l,o[4]=0,o[8]=0,o[12]=-d,o[1]=0,o[5]=2*c,o[9]=0,o[13]=-u,o[2]=0,o[6]=0,o[10]=f,o[14]=-p,o[3]=0,o[7]=0,o[11]=0,o[15]=1,this}equals(e){const t=this.elements,n=e.elements;for(let e=0;e<16;e++)if(t[e]!==n[e])return!1;return!0}fromArray(e,t=0){for(let n=0;n<16;n++)this.elements[n]=e[n+t];return this}toArray(e=[],t=0){const n=this.elements;return e[t]=n[0],e[t+1]=n[1],e[t+2]=n[2],e[t+3]=n[3],e[t+4]=n[4],e[t+5]=n[5],e[t+6]=n[6],e[t+7]=n[7],e[t+8]=n[8],e[t+9]=n[9],e[t+10]=n[10],e[t+11]=n[11],e[t+12]=n[12],e[t+13]=n[13],e[t+14]=n[14],e[t+15]=n[15],e}}const Tn=new Yt,En=new Mn,An=new Yt(0,0,0),Pn=new Yt(1,1,1),Rn=new Yt,Cn=new Yt,Dn=new Yt,Ln=new Mn,In=new Xt;class Un{constructor(e=0,t=0,n=0,i=Un.DEFAULT_ORDER){this.isEuler=!0,this._x=e,this._y=t,this._z=n,this._order=i}get x(){return this._x}set x(e){this._x=e,this._onChangeCallback()}get y(){return this._y}set y(e){this._y=e,this._onChangeCallback()}get z(){return this._z}set z(e){this._z=e,this._onChangeCallback()}get order(){return this._order}set order(e){this._order=e,this._onChangeCallback()}set(e,t,n,i=this._order){return this._x=e,this._y=t,this._z=n,this._order=i,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._order)}copy(e){return this._x=e._x,this._y=e._y,this._z=e._z,this._order=e._order,this._onChangeCallback(),this}setFromRotationMatrix(e,t=this._order,n=!0){const i=e.elements,r=i[0],a=i[4],s=i[8],o=i[1],l=i[5],c=i[9],h=i[2],d=i[6],u=i[10];switch(t){case"XYZ":this._y=Math.asin(dt(s,-1,1)),Math.abs(s)<.9999999?(this._x=Math.atan2(-c,u),this._z=Math.atan2(-a,r)):(this._x=Math.atan2(d,l),this._z=0);break;case"YXZ":this._x=Math.asin(-dt(c,-1,1)),Math.abs(c)<.9999999?(this._y=Math.atan2(s,u),this._z=Math.atan2(o,l)):(this._y=Math.atan2(-h,r),this._z=0);break;case"ZXY":this._x=Math.asin(dt(d,-1,1)),Math.abs(d)<.9999999?(this._y=Math.atan2(-h,u),this._z=Math.atan2(-a,l)):(this._y=0,this._z=Math.atan2(o,r));break;case"ZYX":this._y=Math.asin(-dt(h,-1,1)),Math.abs(h)<.9999999?(this._x=Math.atan2(d,u),this._z=Math.atan2(o,r)):(this._x=0,this._z=Math.atan2(-a,l));break;case"YZX":this._z=Math.asin(dt(o,-1,1)),Math.abs(o)<.9999999?(this._x=Math.atan2(-c,l),this._y=Math.atan2(-h,r)):(this._x=0,this._y=Math.atan2(s,u));break;case"XZY":this._z=Math.asin(-dt(a,-1,1)),Math.abs(a)<.9999999?(this._x=Math.atan2(d,l),this._y=Math.atan2(s,r)):(this._x=Math.atan2(-c,u),this._y=0);break;default:console.warn("THREE.Euler: .setFromRotationMatrix() encountered an unknown order: "+t)}return this._order=t,!0===n&&this._onChangeCallback(),this}setFromQuaternion(e,t,n){return Ln.makeRotationFromQuaternion(e),this.setFromRotationMatrix(Ln,t,n)}setFromVector3(e,t=this._order){return this.set(e.x,e.y,e.z,t)}reorder(e){return In.setFromEuler(this),this.setFromQuaternion(In,e)}equals(e){return e._x===this._x&&e._y===this._y&&e._z===this._z&&e._order===this._order}fromArray(e){return this._x=e[0],this._y=e[1],this._z=e[2],void 0!==e[3]&&(this._order=e[3]),this._onChangeCallback(),this}toArray(e=[],t=0){return e[t]=this._x,e[t+1]=this._y,e[t+2]=this._z,e[t+3]=this._order,e}_onChange(e){return this._onChangeCallback=e,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._order}}Un.DEFAULT_ORDER="XYZ";class On{constructor(){this.mask=1}set(e){this.mask=1<>>0}enable(e){this.mask|=1<1){for(let e=0;e1){for(let e=0;e0&&(i.userData=this.userData),i.layers=this.layers.mask,i.matrix=this.matrix.toArray(),i.up=this.up.toArray(),!1===this.matrixAutoUpdate&&(i.matrixAutoUpdate=!1),this.isInstancedMesh&&(i.type="InstancedMesh",i.count=this.count,i.instanceMatrix=this.instanceMatrix.toJSON(),null!==this.instanceColor&&(i.instanceColor=this.instanceColor.toJSON())),this.isBatchedMesh&&(i.type="BatchedMesh",i.perObjectFrustumCulled=this.perObjectFrustumCulled,i.sortObjects=this.sortObjects,i.drawRanges=this._drawRanges,i.reservedRanges=this._reservedRanges,i.visibility=this._visibility,i.active=this._active,i.bounds=this._bounds.map((e=>({boxInitialized:e.boxInitialized,boxMin:e.box.min.toArray(),boxMax:e.box.max.toArray(),sphereInitialized:e.sphereInitialized,sphereRadius:e.sphere.radius,sphereCenter:e.sphere.center.toArray()}))),i.maxInstanceCount=this._maxInstanceCount,i.maxVertexCount=this._maxVertexCount,i.maxIndexCount=this._maxIndexCount,i.geometryInitialized=this._geometryInitialized,i.geometryCount=this._geometryCount,i.matricesTexture=this._matricesTexture.toJSON(e),null!==this._colorsTexture&&(i.colorsTexture=this._colorsTexture.toJSON(e)),null!==this.boundingSphere&&(i.boundingSphere={center:i.boundingSphere.center.toArray(),radius:i.boundingSphere.radius}),null!==this.boundingBox&&(i.boundingBox={min:i.boundingBox.min.toArray(),max:i.boundingBox.max.toArray()})),this.isScene)this.background&&(this.background.isColor?i.background=this.background.toJSON():this.background.isTexture&&(i.background=this.background.toJSON(e).uuid)),this.environment&&this.environment.isTexture&&!0!==this.environment.isRenderTargetTexture&&(i.environment=this.environment.toJSON(e).uuid);else if(this.isMesh||this.isLine||this.isPoints){i.geometry=r(e.geometries,this.geometry);const t=this.geometry.parameters;if(void 0!==t&&void 0!==t.shapes){const n=t.shapes;if(Array.isArray(n))for(let t=0,i=n.length;t0){i.children=[];for(let t=0;t0){i.animations=[];for(let t=0;t0&&(n.geometries=t),i.length>0&&(n.materials=i),r.length>0&&(n.textures=r),s.length>0&&(n.images=s),o.length>0&&(n.shapes=o),l.length>0&&(n.skeletons=l),c.length>0&&(n.animations=c),h.length>0&&(n.nodes=h)}return n.object=i,n;function a(e){const t=[];for(const n in e){const i=e[n];delete i.metadata,t.push(i)}return t}}clone(e){return(new this.constructor).copy(this,e)}copy(e,t=!0){if(this.name=e.name,this.up.copy(e.up),this.position.copy(e.position),this.rotation.order=e.rotation.order,this.quaternion.copy(e.quaternion),this.scale.copy(e.scale),this.matrix.copy(e.matrix),this.matrixWorld.copy(e.matrixWorld),this.matrixAutoUpdate=e.matrixAutoUpdate,this.matrixWorldAutoUpdate=e.matrixWorldAutoUpdate,this.matrixWorldNeedsUpdate=e.matrixWorldNeedsUpdate,this.layers.mask=e.layers.mask,this.visible=e.visible,this.castShadow=e.castShadow,this.receiveShadow=e.receiveShadow,this.frustumCulled=e.frustumCulled,this.renderOrder=e.renderOrder,this.animations=e.animations.slice(),this.userData=JSON.parse(JSON.stringify(e.userData)),!0===t)for(let t=0;t0?i.multiplyScalar(1/Math.sqrt(r)):i.set(0,0,0)}static getBarycoord(e,t,n,i,r){Qn.subVectors(i,t),$n.subVectors(n,t),ei.subVectors(e,t);const a=Qn.dot(Qn),s=Qn.dot($n),o=Qn.dot(ei),l=$n.dot($n),c=$n.dot(ei),h=a*l-s*s;if(0===h)return r.set(0,0,0),null;const d=1/h,u=(l*o-s*c)*d,p=(a*c-s*o)*d;return r.set(1-u-p,p,u)}static containsPoint(e,t,n,i){return null!==this.getBarycoord(e,t,n,i,ti)&&ti.x>=0&&ti.y>=0&&ti.x+ti.y<=1}static getInterpolation(e,t,n,i,r,a,s,o){return null===this.getBarycoord(e,t,n,i,ti)?(o.x=0,o.y=0,"z"in o&&(o.z=0),"w"in o&&(o.w=0),null):(o.setScalar(0),o.addScaledVector(r,ti.x),o.addScaledVector(a,ti.y),o.addScaledVector(s,ti.z),o)}static getInterpolatedAttribute(e,t,n,i,r,a){return li.setScalar(0),ci.setScalar(0),hi.setScalar(0),li.fromBufferAttribute(e,t),ci.fromBufferAttribute(e,n),hi.fromBufferAttribute(e,i),a.setScalar(0),a.addScaledVector(li,r.x),a.addScaledVector(ci,r.y),a.addScaledVector(hi,r.z),a}static isFrontFacing(e,t,n,i){return Qn.subVectors(n,t),$n.subVectors(e,t),Qn.cross($n).dot(i)<0}set(e,t,n){return this.a.copy(e),this.b.copy(t),this.c.copy(n),this}setFromPointsAndIndices(e,t,n,i){return this.a.copy(e[t]),this.b.copy(e[n]),this.c.copy(e[i]),this}setFromAttributeAndIndices(e,t,n,i){return this.a.fromBufferAttribute(e,t),this.b.fromBufferAttribute(e,n),this.c.fromBufferAttribute(e,i),this}clone(){return(new this.constructor).copy(this)}copy(e){return this.a.copy(e.a),this.b.copy(e.b),this.c.copy(e.c),this}getArea(){return Qn.subVectors(this.c,this.b),$n.subVectors(this.a,this.b),.5*Qn.cross($n).length()}getMidpoint(e){return e.addVectors(this.a,this.b).add(this.c).multiplyScalar(1/3)}getNormal(e){return di.getNormal(this.a,this.b,this.c,e)}getPlane(e){return e.setFromCoplanarPoints(this.a,this.b,this.c)}getBarycoord(e,t){return di.getBarycoord(e,this.a,this.b,this.c,t)}getInterpolation(e,t,n,i,r){return di.getInterpolation(e,this.a,this.b,this.c,t,n,i,r)}containsPoint(e){return di.containsPoint(e,this.a,this.b,this.c)}isFrontFacing(e){return di.isFrontFacing(this.a,this.b,this.c,e)}intersectsBox(e){return e.intersectsTriangle(this)}closestPointToPoint(e,t){const n=this.a,i=this.b,r=this.c;let a,s;ni.subVectors(i,n),ii.subVectors(r,n),ai.subVectors(e,n);const o=ni.dot(ai),l=ii.dot(ai);if(o<=0&&l<=0)return t.copy(n);si.subVectors(e,i);const c=ni.dot(si),h=ii.dot(si);if(c>=0&&h<=c)return t.copy(i);const d=o*h-c*l;if(d<=0&&o>=0&&c<=0)return a=o/(o-c),t.copy(n).addScaledVector(ni,a);oi.subVectors(e,r);const u=ni.dot(oi),p=ii.dot(oi);if(p>=0&&u<=p)return t.copy(r);const f=u*l-o*p;if(f<=0&&l>=0&&p<=0)return s=l/(l-p),t.copy(n).addScaledVector(ii,s);const m=c*p-u*h;if(m<=0&&h-c>=0&&u-p>=0)return ri.subVectors(r,i),s=(h-c)/(h-c+(u-p)),t.copy(i).addScaledVector(ri,s);const g=1/(m+f+d);return a=f*g,s=d*g,t.copy(n).addScaledVector(ni,a).addScaledVector(ii,s)}equals(e){return e.a.equals(this.a)&&e.b.equals(this.b)&&e.c.equals(this.c)}}const ui={aliceblue:15792383,antiquewhite:16444375,aqua:65535,aquamarine:8388564,azure:15794175,beige:16119260,bisque:16770244,black:0,blanchedalmond:16772045,blue:255,blueviolet:9055202,brown:10824234,burlywood:14596231,cadetblue:6266528,chartreuse:8388352,chocolate:13789470,coral:16744272,cornflowerblue:6591981,cornsilk:16775388,crimson:14423100,cyan:65535,darkblue:139,darkcyan:35723,darkgoldenrod:12092939,darkgray:11119017,darkgreen:25600,darkgrey:11119017,darkkhaki:12433259,darkmagenta:9109643,darkolivegreen:5597999,darkorange:16747520,darkorchid:10040012,darkred:9109504,darksalmon:15308410,darkseagreen:9419919,darkslateblue:4734347,darkslategray:3100495,darkslategrey:3100495,darkturquoise:52945,darkviolet:9699539,deeppink:16716947,deepskyblue:49151,dimgray:6908265,dimgrey:6908265,dodgerblue:2003199,firebrick:11674146,floralwhite:16775920,forestgreen:2263842,fuchsia:16711935,gainsboro:14474460,ghostwhite:16316671,gold:16766720,goldenrod:14329120,gray:8421504,green:32768,greenyellow:11403055,grey:8421504,honeydew:15794160,hotpink:16738740,indianred:13458524,indigo:4915330,ivory:16777200,khaki:15787660,lavender:15132410,lavenderblush:16773365,lawngreen:8190976,lemonchiffon:16775885,lightblue:11393254,lightcoral:15761536,lightcyan:14745599,lightgoldenrodyellow:16448210,lightgray:13882323,lightgreen:9498256,lightgrey:13882323,lightpink:16758465,lightsalmon:16752762,lightseagreen:2142890,lightskyblue:8900346,lightslategray:7833753,lightslategrey:7833753,lightsteelblue:11584734,lightyellow:16777184,lime:65280,limegreen:3329330,linen:16445670,magenta:16711935,maroon:8388608,mediumaquamarine:6737322,mediumblue:205,mediumorchid:12211667,mediumpurple:9662683,mediumseagreen:3978097,mediumslateblue:8087790,mediumspringgreen:64154,mediumturquoise:4772300,mediumvioletred:13047173,midnightblue:1644912,mintcream:16121850,mistyrose:16770273,moccasin:16770229,navajowhite:16768685,navy:128,oldlace:16643558,olive:8421376,olivedrab:7048739,orange:16753920,orangered:16729344,orchid:14315734,palegoldenrod:15657130,palegreen:10025880,paleturquoise:11529966,palevioletred:14381203,papayawhip:16773077,peachpuff:16767673,peru:13468991,pink:16761035,plum:14524637,powderblue:11591910,purple:8388736,rebeccapurple:6697881,red:16711680,rosybrown:12357519,royalblue:4286945,saddlebrown:9127187,salmon:16416882,sandybrown:16032864,seagreen:3050327,seashell:16774638,sienna:10506797,silver:12632256,skyblue:8900331,slateblue:6970061,slategray:7372944,slategrey:7372944,snow:16775930,springgreen:65407,steelblue:4620980,tan:13808780,teal:32896,thistle:14204888,tomato:16737095,turquoise:4251856,violet:15631086,wheat:16113331,white:16777215,whitesmoke:16119285,yellow:16776960,yellowgreen:10145074},pi={h:0,s:0,l:0},fi={h:0,s:0,l:0};function mi(e,t,n){return n<0&&(n+=1),n>1&&(n-=1),n<1/6?e+6*(t-e)*n:n<.5?t:n<2/3?e+6*(t-e)*(2/3-n):e}class gi{constructor(e,t,n){return this.isColor=!0,this.r=1,this.g=1,this.b=1,this.set(e,t,n)}set(e,t,n){if(void 0===t&&void 0===n){const t=e;t&&t.isColor?this.copy(t):"number"==typeof t?this.setHex(t):"string"==typeof t&&this.setStyle(t)}else this.setRGB(e,t,n);return this}setScalar(e){return this.r=e,this.g=e,this.b=e,this}setHex(e,t=Ge){return e=Math.floor(e),this.r=(e>>16&255)/255,this.g=(e>>8&255)/255,this.b=(255&e)/255,Et.toWorkingColorSpace(this,t),this}setRGB(e,t,n,i=Et.workingColorSpace){return this.r=e,this.g=t,this.b=n,Et.toWorkingColorSpace(this,i),this}setHSL(e,t,n,i=Et.workingColorSpace){if(e=ut(e,1),t=dt(t,0,1),n=dt(n,0,1),0===t)this.r=this.g=this.b=n;else{const i=n<=.5?n*(1+t):n+t-n*t,r=2*n-i;this.r=mi(r,i,e+1/3),this.g=mi(r,i,e),this.b=mi(r,i,e-1/3)}return Et.toWorkingColorSpace(this,i),this}setStyle(e,t=Ge){function n(t){void 0!==t&&parseFloat(t)<1&&console.warn("THREE.Color: Alpha component of "+e+" will be ignored.")}let i;if(i=/^(\w+)\(([^\)]*)\)/.exec(e)){let r;const a=i[1],s=i[2];switch(a){case"rgb":case"rgba":if(r=/^\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(s))return n(r[4]),this.setRGB(Math.min(255,parseInt(r[1],10))/255,Math.min(255,parseInt(r[2],10))/255,Math.min(255,parseInt(r[3],10))/255,t);if(r=/^\s*(\d+)\%\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(s))return n(r[4]),this.setRGB(Math.min(100,parseInt(r[1],10))/100,Math.min(100,parseInt(r[2],10))/100,Math.min(100,parseInt(r[3],10))/100,t);break;case"hsl":case"hsla":if(r=/^\s*(\d*\.?\d+)\s*,\s*(\d*\.?\d+)\%\s*,\s*(\d*\.?\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(s))return n(r[4]),this.setHSL(parseFloat(r[1])/360,parseFloat(r[2])/100,parseFloat(r[3])/100,t);break;default:console.warn("THREE.Color: Unknown color model "+e)}}else if(i=/^\#([A-Fa-f\d]+)$/.exec(e)){const n=i[1],r=n.length;if(3===r)return this.setRGB(parseInt(n.charAt(0),16)/15,parseInt(n.charAt(1),16)/15,parseInt(n.charAt(2),16)/15,t);if(6===r)return this.setHex(parseInt(n,16),t);console.warn("THREE.Color: Invalid hex color "+e)}else if(e&&e.length>0)return this.setColorName(e,t);return this}setColorName(e,t=Ge){const n=ui[e.toLowerCase()];return void 0!==n?this.setHex(n,t):console.warn("THREE.Color: Unknown color "+e),this}clone(){return new this.constructor(this.r,this.g,this.b)}copy(e){return this.r=e.r,this.g=e.g,this.b=e.b,this}copySRGBToLinear(e){return this.r=At(e.r),this.g=At(e.g),this.b=At(e.b),this}copyLinearToSRGB(e){return this.r=Pt(e.r),this.g=Pt(e.g),this.b=Pt(e.b),this}convertSRGBToLinear(){return this.copySRGBToLinear(this),this}convertLinearToSRGB(){return this.copyLinearToSRGB(this),this}getHex(e=Ge){return Et.fromWorkingColorSpace(vi.copy(this),e),65536*Math.round(dt(255*vi.r,0,255))+256*Math.round(dt(255*vi.g,0,255))+Math.round(dt(255*vi.b,0,255))}getHexString(e=Ge){return("000000"+this.getHex(e).toString(16)).slice(-6)}getHSL(e,t=Et.workingColorSpace){Et.fromWorkingColorSpace(vi.copy(this),t);const n=vi.r,i=vi.g,r=vi.b,a=Math.max(n,i,r),s=Math.min(n,i,r);let o,l;const c=(s+a)/2;if(s===a)o=0,l=0;else{const e=a-s;switch(l=c<=.5?e/(a+s):e/(2-a-s),a){case n:o=(i-r)/e+(i0!=e>0&&this.version++,this._alphaTest=e}onBeforeRender(){}onBeforeCompile(){}customProgramCacheKey(){return this.onBeforeCompile.toString()}setValues(e){if(void 0!==e)for(const t in e){const n=e[t];if(void 0===n){console.warn(`THREE.Material: parameter '${t}' has value of undefined.`);continue}const i=this[t];void 0!==i?i&&i.isColor?i.set(n):i&&i.isVector3&&n&&n.isVector3?i.copy(n):this[t]=n:console.warn(`THREE.Material: '${t}' is not a property of THREE.${this.type}.`)}}toJSON(e){const t=void 0===e||"string"==typeof e;t&&(e={textures:{},images:{}});const n={metadata:{version:4.6,type:"Material",generator:"Material.toJSON"}};function i(e){const t=[];for(const n in e){const i=e[n];delete i.metadata,t.push(i)}return t}if(n.uuid=this.uuid,n.type=this.type,""!==this.name&&(n.name=this.name),this.color&&this.color.isColor&&(n.color=this.color.getHex()),void 0!==this.roughness&&(n.roughness=this.roughness),void 0!==this.metalness&&(n.metalness=this.metalness),void 0!==this.sheen&&(n.sheen=this.sheen),this.sheenColor&&this.sheenColor.isColor&&(n.sheenColor=this.sheenColor.getHex()),void 0!==this.sheenRoughness&&(n.sheenRoughness=this.sheenRoughness),this.emissive&&this.emissive.isColor&&(n.emissive=this.emissive.getHex()),void 0!==this.emissiveIntensity&&1!==this.emissiveIntensity&&(n.emissiveIntensity=this.emissiveIntensity),this.specular&&this.specular.isColor&&(n.specular=this.specular.getHex()),void 0!==this.specularIntensity&&(n.specularIntensity=this.specularIntensity),this.specularColor&&this.specularColor.isColor&&(n.specularColor=this.specularColor.getHex()),void 0!==this.shininess&&(n.shininess=this.shininess),void 0!==this.clearcoat&&(n.clearcoat=this.clearcoat),void 0!==this.clearcoatRoughness&&(n.clearcoatRoughness=this.clearcoatRoughness),this.clearcoatMap&&this.clearcoatMap.isTexture&&(n.clearcoatMap=this.clearcoatMap.toJSON(e).uuid),this.clearcoatRoughnessMap&&this.clearcoatRoughnessMap.isTexture&&(n.clearcoatRoughnessMap=this.clearcoatRoughnessMap.toJSON(e).uuid),this.clearcoatNormalMap&&this.clearcoatNormalMap.isTexture&&(n.clearcoatNormalMap=this.clearcoatNormalMap.toJSON(e).uuid,n.clearcoatNormalScale=this.clearcoatNormalScale.toArray()),void 0!==this.dispersion&&(n.dispersion=this.dispersion),void 0!==this.iridescence&&(n.iridescence=this.iridescence),void 0!==this.iridescenceIOR&&(n.iridescenceIOR=this.iridescenceIOR),void 0!==this.iridescenceThicknessRange&&(n.iridescenceThicknessRange=this.iridescenceThicknessRange),this.iridescenceMap&&this.iridescenceMap.isTexture&&(n.iridescenceMap=this.iridescenceMap.toJSON(e).uuid),this.iridescenceThicknessMap&&this.iridescenceThicknessMap.isTexture&&(n.iridescenceThicknessMap=this.iridescenceThicknessMap.toJSON(e).uuid),void 0!==this.anisotropy&&(n.anisotropy=this.anisotropy),void 0!==this.anisotropyRotation&&(n.anisotropyRotation=this.anisotropyRotation),this.anisotropyMap&&this.anisotropyMap.isTexture&&(n.anisotropyMap=this.anisotropyMap.toJSON(e).uuid),this.map&&this.map.isTexture&&(n.map=this.map.toJSON(e).uuid),this.matcap&&this.matcap.isTexture&&(n.matcap=this.matcap.toJSON(e).uuid),this.alphaMap&&this.alphaMap.isTexture&&(n.alphaMap=this.alphaMap.toJSON(e).uuid),this.lightMap&&this.lightMap.isTexture&&(n.lightMap=this.lightMap.toJSON(e).uuid,n.lightMapIntensity=this.lightMapIntensity),this.aoMap&&this.aoMap.isTexture&&(n.aoMap=this.aoMap.toJSON(e).uuid,n.aoMapIntensity=this.aoMapIntensity),this.bumpMap&&this.bumpMap.isTexture&&(n.bumpMap=this.bumpMap.toJSON(e).uuid,n.bumpScale=this.bumpScale),this.normalMap&&this.normalMap.isTexture&&(n.normalMap=this.normalMap.toJSON(e).uuid,n.normalMapType=this.normalMapType,n.normalScale=this.normalScale.toArray()),this.displacementMap&&this.displacementMap.isTexture&&(n.displacementMap=this.displacementMap.toJSON(e).uuid,n.displacementScale=this.displacementScale,n.displacementBias=this.displacementBias),this.roughnessMap&&this.roughnessMap.isTexture&&(n.roughnessMap=this.roughnessMap.toJSON(e).uuid),this.metalnessMap&&this.metalnessMap.isTexture&&(n.metalnessMap=this.metalnessMap.toJSON(e).uuid),this.emissiveMap&&this.emissiveMap.isTexture&&(n.emissiveMap=this.emissiveMap.toJSON(e).uuid),this.specularMap&&this.specularMap.isTexture&&(n.specularMap=this.specularMap.toJSON(e).uuid),this.specularIntensityMap&&this.specularIntensityMap.isTexture&&(n.specularIntensityMap=this.specularIntensityMap.toJSON(e).uuid),this.specularColorMap&&this.specularColorMap.isTexture&&(n.specularColorMap=this.specularColorMap.toJSON(e).uuid),this.envMap&&this.envMap.isTexture&&(n.envMap=this.envMap.toJSON(e).uuid,void 0!==this.combine&&(n.combine=this.combine)),void 0!==this.envMapRotation&&(n.envMapRotation=this.envMapRotation.toArray()),void 0!==this.envMapIntensity&&(n.envMapIntensity=this.envMapIntensity),void 0!==this.reflectivity&&(n.reflectivity=this.reflectivity),void 0!==this.refractionRatio&&(n.refractionRatio=this.refractionRatio),this.gradientMap&&this.gradientMap.isTexture&&(n.gradientMap=this.gradientMap.toJSON(e).uuid),void 0!==this.transmission&&(n.transmission=this.transmission),this.transmissionMap&&this.transmissionMap.isTexture&&(n.transmissionMap=this.transmissionMap.toJSON(e).uuid),void 0!==this.thickness&&(n.thickness=this.thickness),this.thicknessMap&&this.thicknessMap.isTexture&&(n.thicknessMap=this.thicknessMap.toJSON(e).uuid),void 0!==this.attenuationDistance&&this.attenuationDistance!==1/0&&(n.attenuationDistance=this.attenuationDistance),void 0!==this.attenuationColor&&(n.attenuationColor=this.attenuationColor.getHex()),void 0!==this.size&&(n.size=this.size),null!==this.shadowSide&&(n.shadowSide=this.shadowSide),void 0!==this.sizeAttenuation&&(n.sizeAttenuation=this.sizeAttenuation),1!==this.blending&&(n.blending=this.blending),0!==this.side&&(n.side=this.side),!0===this.vertexColors&&(n.vertexColors=!0),this.opacity<1&&(n.opacity=this.opacity),!0===this.transparent&&(n.transparent=!0),204!==this.blendSrc&&(n.blendSrc=this.blendSrc),205!==this.blendDst&&(n.blendDst=this.blendDst),this.blendEquation!==s&&(n.blendEquation=this.blendEquation),null!==this.blendSrcAlpha&&(n.blendSrcAlpha=this.blendSrcAlpha),null!==this.blendDstAlpha&&(n.blendDstAlpha=this.blendDstAlpha),null!==this.blendEquationAlpha&&(n.blendEquationAlpha=this.blendEquationAlpha),this.blendColor&&this.blendColor.isColor&&(n.blendColor=this.blendColor.getHex()),0!==this.blendAlpha&&(n.blendAlpha=this.blendAlpha),3!==this.depthFunc&&(n.depthFunc=this.depthFunc),!1===this.depthTest&&(n.depthTest=this.depthTest),!1===this.depthWrite&&(n.depthWrite=this.depthWrite),!1===this.colorWrite&&(n.colorWrite=this.colorWrite),255!==this.stencilWriteMask&&(n.stencilWriteMask=this.stencilWriteMask),519!==this.stencilFunc&&(n.stencilFunc=this.stencilFunc),0!==this.stencilRef&&(n.stencilRef=this.stencilRef),255!==this.stencilFuncMask&&(n.stencilFuncMask=this.stencilFuncMask),this.stencilFail!==Ye&&(n.stencilFail=this.stencilFail),this.stencilZFail!==Ye&&(n.stencilZFail=this.stencilZFail),this.stencilZPass!==Ye&&(n.stencilZPass=this.stencilZPass),!0===this.stencilWrite&&(n.stencilWrite=this.stencilWrite),void 0!==this.rotation&&0!==this.rotation&&(n.rotation=this.rotation),!0===this.polygonOffset&&(n.polygonOffset=!0),0!==this.polygonOffsetFactor&&(n.polygonOffsetFactor=this.polygonOffsetFactor),0!==this.polygonOffsetUnits&&(n.polygonOffsetUnits=this.polygonOffsetUnits),void 0!==this.linewidth&&1!==this.linewidth&&(n.linewidth=this.linewidth),void 0!==this.dashSize&&(n.dashSize=this.dashSize),void 0!==this.gapSize&&(n.gapSize=this.gapSize),void 0!==this.scale&&(n.scale=this.scale),!0===this.dithering&&(n.dithering=!0),this.alphaTest>0&&(n.alphaTest=this.alphaTest),!0===this.alphaHash&&(n.alphaHash=!0),!0===this.alphaToCoverage&&(n.alphaToCoverage=!0),!0===this.premultipliedAlpha&&(n.premultipliedAlpha=!0),!0===this.forceSinglePass&&(n.forceSinglePass=!0),!0===this.wireframe&&(n.wireframe=!0),this.wireframeLinewidth>1&&(n.wireframeLinewidth=this.wireframeLinewidth),"round"!==this.wireframeLinecap&&(n.wireframeLinecap=this.wireframeLinecap),"round"!==this.wireframeLinejoin&&(n.wireframeLinejoin=this.wireframeLinejoin),!0===this.flatShading&&(n.flatShading=!0),!1===this.visible&&(n.visible=!1),!1===this.toneMapped&&(n.toneMapped=!1),!1===this.fog&&(n.fog=!1),Object.keys(this.userData).length>0&&(n.userData=this.userData),t){const t=i(e.textures),r=i(e.images);t.length>0&&(n.textures=t),r.length>0&&(n.images=r)}return n}clone(){return(new this.constructor).copy(this)}copy(e){this.name=e.name,this.blending=e.blending,this.side=e.side,this.vertexColors=e.vertexColors,this.opacity=e.opacity,this.transparent=e.transparent,this.blendSrc=e.blendSrc,this.blendDst=e.blendDst,this.blendEquation=e.blendEquation,this.blendSrcAlpha=e.blendSrcAlpha,this.blendDstAlpha=e.blendDstAlpha,this.blendEquationAlpha=e.blendEquationAlpha,this.blendColor.copy(e.blendColor),this.blendAlpha=e.blendAlpha,this.depthFunc=e.depthFunc,this.depthTest=e.depthTest,this.depthWrite=e.depthWrite,this.stencilWriteMask=e.stencilWriteMask,this.stencilFunc=e.stencilFunc,this.stencilRef=e.stencilRef,this.stencilFuncMask=e.stencilFuncMask,this.stencilFail=e.stencilFail,this.stencilZFail=e.stencilZFail,this.stencilZPass=e.stencilZPass,this.stencilWrite=e.stencilWrite;const t=e.clippingPlanes;let n=null;if(null!==t){const e=t.length;n=new Array(e);for(let i=0;i!==e;++i)n[i]=t[i].clone()}return this.clippingPlanes=n,this.clipIntersection=e.clipIntersection,this.clipShadows=e.clipShadows,this.shadowSide=e.shadowSide,this.colorWrite=e.colorWrite,this.precision=e.precision,this.polygonOffset=e.polygonOffset,this.polygonOffsetFactor=e.polygonOffsetFactor,this.polygonOffsetUnits=e.polygonOffsetUnits,this.dithering=e.dithering,this.alphaTest=e.alphaTest,this.alphaHash=e.alphaHash,this.alphaToCoverage=e.alphaToCoverage,this.premultipliedAlpha=e.premultipliedAlpha,this.forceSinglePass=e.forceSinglePass,this.visible=e.visible,this.toneMapped=e.toneMapped,this.userData=JSON.parse(JSON.stringify(e.userData)),this}dispose(){this.dispatchEvent({type:"dispose"})}set needsUpdate(e){!0===e&&this.version++}onBuild(){console.warn("Material: onBuild() has been removed.")}}class yi extends xi{static get type(){return"MeshBasicMaterial"}constructor(e){super(),this.isMeshBasicMaterial=!0,this.color=new gi(16777215),this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new Un,this.combine=0,this.reflectivity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.specularMap=e.specularMap,this.alphaMap=e.alphaMap,this.envMap=e.envMap,this.envMapRotation.copy(e.envMapRotation),this.combine=e.combine,this.reflectivity=e.reflectivity,this.refractionRatio=e.refractionRatio,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.fog=e.fog,this}}const Si=wi();function wi(){const e=new ArrayBuffer(4),t=new Float32Array(e),n=new Uint32Array(e),i=new Uint32Array(512),r=new Uint32Array(512);for(let e=0;e<256;++e){const t=e-127;t<-27?(i[e]=0,i[256|e]=32768,r[e]=24,r[256|e]=24):t<-14?(i[e]=1024>>-t-14,i[256|e]=1024>>-t-14|32768,r[e]=-t-1,r[256|e]=-t-1):t<=15?(i[e]=t+15<<10,i[256|e]=t+15<<10|32768,r[e]=13,r[256|e]=13):t<128?(i[e]=31744,i[256|e]=64512,r[e]=24,r[256|e]=24):(i[e]=31744,i[256|e]=64512,r[e]=13,r[256|e]=13)}const a=new Uint32Array(2048),s=new Uint32Array(64),o=new Uint32Array(64);for(let e=1;e<1024;++e){let t=e<<13,n=0;for(;!(8388608&t);)t<<=1,n-=8388608;t&=-8388609,n+=947912704,a[e]=t|n}for(let e=1024;e<2048;++e)a[e]=939524096+(e-1024<<13);for(let e=1;e<31;++e)s[e]=e<<23;s[31]=1199570944,s[32]=2147483648;for(let e=33;e<63;++e)s[e]=2147483648+(e-32<<23);s[63]=3347054592;for(let e=1;e<64;++e)32!==e&&(o[e]=1024);return{floatView:t,uint32View:n,baseTable:i,shiftTable:r,mantissaTable:a,exponentTable:s,offsetTable:o}}const bi={toHalfFloat:function(e){Math.abs(e)>65504&&console.warn("THREE.DataUtils.toHalfFloat(): Value out of range."),e=dt(e,-65504,65504),Si.floatView[0]=e;const t=Si.uint32View[0],n=t>>23&511;return Si.baseTable[n]+((8388607&t)>>Si.shiftTable[n])},fromHalfFloat:function(e){const t=e>>10;return Si.uint32View[0]=Si.mantissaTable[Si.offsetTable[t]+(1023&e)]+Si.exponentTable[t],Si.floatView[0]}},Mi=new Yt,Ti=new _t;class Ei{constructor(e,t,n=!1){if(Array.isArray(e))throw new TypeError("THREE.BufferAttribute: array should be a Typed Array.");this.isBufferAttribute=!0,this.name="",this.array=e,this.itemSize=t,this.count=void 0!==e?e.length/t:0,this.normalized=n,this.usage=nt,this.updateRanges=[],this.gpuType=Z,this.version=0}onUploadCallback(){}set needsUpdate(e){!0===e&&this.version++}setUsage(e){return this.usage=e,this}addUpdateRange(e,t){this.updateRanges.push({start:e,count:t})}clearUpdateRanges(){this.updateRanges.length=0}copy(e){return this.name=e.name,this.array=new e.array.constructor(e.array),this.itemSize=e.itemSize,this.count=e.count,this.normalized=e.normalized,this.usage=e.usage,this.gpuType=e.gpuType,this}copyAt(e,t,n){e*=this.itemSize,n*=t.itemSize;for(let i=0,r=this.itemSize;it.count&&console.warn("THREE.BufferGeometry: Buffer size too small for points data. Use .dispose() and create a new geometry."),t.needsUpdate=!0}return this}computeBoundingBox(){null===this.boundingBox&&(this.boundingBox=new Kt);const e=this.attributes.position,t=this.morphAttributes.position;if(e&&e.isGLBufferAttribute)return console.error("THREE.BufferGeometry.computeBoundingBox(): GLBufferAttribute requires a manual bounding box.",this),void this.boundingBox.set(new Yt(-1/0,-1/0,-1/0),new Yt(1/0,1/0,1/0));if(void 0!==e){if(this.boundingBox.setFromBufferAttribute(e),t)for(let e=0,n=t.length;e0&&(e.userData=this.userData),void 0!==this.parameters){const t=this.parameters;for(const n in t)void 0!==t[n]&&(e[n]=t[n]);return e}e.data={attributes:{}};const t=this.index;null!==t&&(e.data.index={type:t.array.constructor.name,array:Array.prototype.slice.call(t.array)});const n=this.attributes;for(const t in n){const i=n[t];e.data.attributes[t]=i.toJSON(e.data)}const i={};let r=!1;for(const t in this.morphAttributes){const n=this.morphAttributes[t],a=[];for(let t=0,i=n.length;t0&&(i[t]=a,r=!0)}r&&(e.data.morphAttributes=i,e.data.morphTargetsRelative=this.morphTargetsRelative);const a=this.groups;a.length>0&&(e.data.groups=JSON.parse(JSON.stringify(a)));const s=this.boundingSphere;return null!==s&&(e.data.boundingSphere={center:s.center.toArray(),radius:s.radius}),e}clone(){return(new this.constructor).copy(this)}copy(e){this.index=null,this.attributes={},this.morphAttributes={},this.groups=[],this.boundingBox=null,this.boundingSphere=null;const t={};this.name=e.name;const n=e.index;null!==n&&this.setIndex(n.clone(t));const i=e.attributes;for(const e in i){const n=i[e];this.setAttribute(e,n.clone(t))}const r=e.morphAttributes;for(const e in r){const n=[],i=r[e];for(let e=0,r=i.length;e0){const n=e[t[0]];if(void 0!==n){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let e=0,t=n.length;e(e.far-e.near)**2)return}Bi.copy(r).invert(),zi.copy(e.ray).applyMatrix4(Bi),null!==n.boundingBox&&!1===zi.intersectsBox(n.boundingBox)||this._computeIntersections(e,t,zi)}}_computeIntersections(e,t,n){let i;const r=this.geometry,a=this.material,s=r.index,o=r.attributes.position,l=r.attributes.uv,c=r.attributes.uv1,h=r.attributes.normal,d=r.groups,u=r.drawRange;if(null!==s)if(Array.isArray(a))for(let r=0,o=d.length;rn.far?null:{distance:c,point:qi.clone(),object:e}}(e,t,n,i,Vi,Gi,Wi,Yi);if(h){const e=new Yt;di.getBarycoord(Yi,Vi,Gi,Wi,e),r&&(h.uv=di.getInterpolatedAttribute(r,o,l,c,e,new _t)),a&&(h.uv1=di.getInterpolatedAttribute(a,o,l,c,e,new _t)),s&&(h.normal=di.getInterpolatedAttribute(s,o,l,c,e,new Yt),h.normal.dot(i.direction)>0&&h.normal.multiplyScalar(-1));const t={a:o,b:l,c,normal:new Yt,materialIndex:0};di.getNormal(Vi,Gi,Wi,t.normal),h.face=t,h.barycoord=e}return h}class Ji extends Fi{constructor(e=1,t=1,n=1,i=1,r=1,a=1){super(),this.type="BoxGeometry",this.parameters={width:e,height:t,depth:n,widthSegments:i,heightSegments:r,depthSegments:a};const s=this;i=Math.floor(i),r=Math.floor(r),a=Math.floor(a);const o=[],l=[],c=[],h=[];let d=0,u=0;function p(e,t,n,i,r,a,p,f,m,g,v){const _=a/m,x=p/g,y=a/2,S=p/2,w=f/2,b=m+1,M=g+1;let T=0,E=0;const A=new Yt;for(let a=0;a0?1:-1,c.push(A.x,A.y,A.z),h.push(o/m),h.push(1-a/g),T+=1}}for(let e=0;e0&&(t.defines=this.defines),t.vertexShader=this.vertexShader,t.fragmentShader=this.fragmentShader,t.lights=this.lights,t.clipping=this.clipping;const n={};for(const e in this.extensions)!0===this.extensions[e]&&(n[e]=!0);return Object.keys(n).length>0&&(t.extensions=n),t}}class ir extends Jn{constructor(){super(),this.isCamera=!0,this.type="Camera",this.matrixWorldInverse=new Mn,this.projectionMatrix=new Mn,this.projectionMatrixInverse=new Mn,this.coordinateSystem=rt}copy(e,t){return super.copy(e,t),this.matrixWorldInverse.copy(e.matrixWorldInverse),this.projectionMatrix.copy(e.projectionMatrix),this.projectionMatrixInverse.copy(e.projectionMatrixInverse),this.coordinateSystem=e.coordinateSystem,this}getWorldDirection(e){return super.getWorldDirection(e).negate()}updateMatrixWorld(e){super.updateMatrixWorld(e),this.matrixWorldInverse.copy(this.matrixWorld).invert()}updateWorldMatrix(e,t){super.updateWorldMatrix(e,t),this.matrixWorldInverse.copy(this.matrixWorld).invert()}clone(){return(new this.constructor).copy(this)}}const rr=new Yt,ar=new _t,sr=new _t;class or extends ir{constructor(e=50,t=1,n=.1,i=2e3){super(),this.isPerspectiveCamera=!0,this.type="PerspectiveCamera",this.fov=e,this.zoom=1,this.near=n,this.far=i,this.focus=10,this.aspect=t,this.view=null,this.filmGauge=35,this.filmOffset=0,this.updateProjectionMatrix()}copy(e,t){return super.copy(e,t),this.fov=e.fov,this.zoom=e.zoom,this.near=e.near,this.far=e.far,this.focus=e.focus,this.aspect=e.aspect,this.view=null===e.view?null:Object.assign({},e.view),this.filmGauge=e.filmGauge,this.filmOffset=e.filmOffset,this}setFocalLength(e){const t=.5*this.getFilmHeight()/e;this.fov=2*ct*Math.atan(t),this.updateProjectionMatrix()}getFocalLength(){const e=Math.tan(.5*lt*this.fov);return.5*this.getFilmHeight()/e}getEffectiveFOV(){return 2*ct*Math.atan(Math.tan(.5*lt*this.fov)/this.zoom)}getFilmWidth(){return this.filmGauge*Math.min(this.aspect,1)}getFilmHeight(){return this.filmGauge/Math.max(this.aspect,1)}getViewBounds(e,t,n){rr.set(-1,-1,.5).applyMatrix4(this.projectionMatrixInverse),t.set(rr.x,rr.y).multiplyScalar(-e/rr.z),rr.set(1,1,.5).applyMatrix4(this.projectionMatrixInverse),n.set(rr.x,rr.y).multiplyScalar(-e/rr.z)}getViewSize(e,t){return this.getViewBounds(e,ar,sr),t.subVectors(sr,ar)}setViewOffset(e,t,n,i,r,a){this.aspect=e/t,null===this.view&&(this.view={enabled:!0,fullWidth:1,fullHeight:1,offsetX:0,offsetY:0,width:1,height:1}),this.view.enabled=!0,this.view.fullWidth=e,this.view.fullHeight=t,this.view.offsetX=n,this.view.offsetY=i,this.view.width=r,this.view.height=a,this.updateProjectionMatrix()}clearViewOffset(){null!==this.view&&(this.view.enabled=!1),this.updateProjectionMatrix()}updateProjectionMatrix(){const e=this.near;let t=e*Math.tan(.5*lt*this.fov)/this.zoom,n=2*t,i=this.aspect*n,r=-.5*i;const a=this.view;if(null!==this.view&&this.view.enabled){const e=a.fullWidth,s=a.fullHeight;r+=a.offsetX*i/e,t-=a.offsetY*n/s,i*=a.width/e,n*=a.height/s}const s=this.filmOffset;0!==s&&(r+=e*s/this.getFilmWidth()),this.projectionMatrix.makePerspective(r,r+i,t,t-n,e,this.far,this.coordinateSystem),this.projectionMatrixInverse.copy(this.projectionMatrix).invert()}toJSON(e){const t=super.toJSON(e);return t.object.fov=this.fov,t.object.zoom=this.zoom,t.object.near=this.near,t.object.far=this.far,t.object.focus=this.focus,t.object.aspect=this.aspect,null!==this.view&&(t.object.view=Object.assign({},this.view)),t.object.filmGauge=this.filmGauge,t.object.filmOffset=this.filmOffset,t}}const lr=-90;class cr extends Jn{constructor(e,t,n){super(),this.type="CubeCamera",this.renderTarget=n,this.coordinateSystem=null,this.activeMipmapLevel=0;const i=new or(lr,1,e,t);i.layers=this.layers,this.add(i);const r=new or(lr,1,e,t);r.layers=this.layers,this.add(r);const a=new or(lr,1,e,t);a.layers=this.layers,this.add(a);const s=new or(lr,1,e,t);s.layers=this.layers,this.add(s);const o=new or(lr,1,e,t);o.layers=this.layers,this.add(o);const l=new or(lr,1,e,t);l.layers=this.layers,this.add(l)}updateCoordinateSystem(){const e=this.coordinateSystem,t=this.children.concat(),[n,i,r,a,s,o]=t;for(const e of t)this.remove(e);if(e===rt)n.up.set(0,1,0),n.lookAt(1,0,0),i.up.set(0,1,0),i.lookAt(-1,0,0),r.up.set(0,0,-1),r.lookAt(0,1,0),a.up.set(0,0,1),a.lookAt(0,-1,0),s.up.set(0,1,0),s.lookAt(0,0,1),o.up.set(0,1,0),o.lookAt(0,0,-1);else{if(e!==at)throw new Error("THREE.CubeCamera.updateCoordinateSystem(): Invalid coordinate system: "+e);n.up.set(0,-1,0),n.lookAt(-1,0,0),i.up.set(0,-1,0),i.lookAt(1,0,0),r.up.set(0,0,1),r.lookAt(0,1,0),a.up.set(0,0,-1),a.lookAt(0,-1,0),s.up.set(0,-1,0),s.lookAt(0,0,1),o.up.set(0,-1,0),o.lookAt(0,0,-1)}for(const e of t)this.add(e),e.updateMatrixWorld()}update(e,t){null===this.parent&&this.updateMatrixWorld();const{renderTarget:n,activeMipmapLevel:i}=this;this.coordinateSystem!==e.coordinateSystem&&(this.coordinateSystem=e.coordinateSystem,this.updateCoordinateSystem());const[r,a,s,o,l,c]=this.children,h=e.getRenderTarget(),d=e.getActiveCubeFace(),u=e.getActiveMipmapLevel(),p=e.xr.enabled;e.xr.enabled=!1;const f=n.texture.generateMipmaps;n.texture.generateMipmaps=!1,e.setRenderTarget(n,0,i),e.render(t,r),e.setRenderTarget(n,1,i),e.render(t,a),e.setRenderTarget(n,2,i),e.render(t,s),e.setRenderTarget(n,3,i),e.render(t,o),e.setRenderTarget(n,4,i),e.render(t,l),n.texture.generateMipmaps=f,e.setRenderTarget(n,5,i),e.render(t,c),e.setRenderTarget(h,d,u),e.xr.enabled=p,n.texture.needsPMREMUpdate=!0}}class hr extends kt{constructor(e,t,n,i,r,a,s,o,l,c){super(e=void 0!==e?e:[],t=void 0!==t?t:I,n,i,r,a,s,o,l,c),this.isCubeTexture=!0,this.flipY=!1}get images(){return this.image}set images(e){this.image=e}}class dr extends Gt{constructor(e=1,t={}){super(e,e,t),this.isWebGLCubeRenderTarget=!0;const n={width:e,height:e,depth:1},i=[n,n,n,n,n,n];this.texture=new hr(i,t.mapping,t.wrapS,t.wrapT,t.magFilter,t.minFilter,t.format,t.type,t.anisotropy,t.colorSpace),this.texture.isRenderTargetTexture=!0,this.texture.generateMipmaps=void 0!==t.generateMipmaps&&t.generateMipmaps,this.texture.minFilter=void 0!==t.minFilter?t.minFilter:V}fromEquirectangularTexture(e,t){this.texture.type=t.type,this.texture.colorSpace=t.colorSpace,this.texture.generateMipmaps=t.generateMipmaps,this.texture.minFilter=t.minFilter,this.texture.magFilter=t.magFilter;const n={tEquirect:{value:null}},i="\n\n\t\t\t\tvarying vec3 vWorldDirection;\n\n\t\t\t\tvec3 transformDirection( in vec3 dir, in mat4 matrix ) {\n\n\t\t\t\t\treturn normalize( ( matrix * vec4( dir, 0.0 ) ).xyz );\n\n\t\t\t\t}\n\n\t\t\t\tvoid main() {\n\n\t\t\t\t\tvWorldDirection = transformDirection( position, modelMatrix );\n\n\t\t\t\t\t#include \n\t\t\t\t\t#include \n\n\t\t\t\t}\n\t\t\t",r="\n\n\t\t\t\tuniform sampler2D tEquirect;\n\n\t\t\t\tvarying vec3 vWorldDirection;\n\n\t\t\t\t#include \n\n\t\t\t\tvoid main() {\n\n\t\t\t\t\tvec3 direction = normalize( vWorldDirection );\n\n\t\t\t\t\tvec2 sampleUV = equirectUv( direction );\n\n\t\t\t\t\tgl_FragColor = texture2D( tEquirect, sampleUV );\n\n\t\t\t\t}\n\t\t\t",a=new Ji(5,5,5),s=new nr({name:"CubemapFromEquirect",uniforms:Qi(n),vertexShader:i,fragmentShader:r,side:1,blending:0});s.uniforms.tEquirect.value=t;const o=new Zi(a,s),l=t.minFilter;return t.minFilter===W&&(t.minFilter=V),new cr(1,10,this).update(e,o),t.minFilter=l,o.geometry.dispose(),o.material.dispose(),this}clear(e,t,n,i){const r=e.getRenderTarget();for(let r=0;r<6;r++)e.setRenderTarget(this,r),e.clear(t,n,i);e.setRenderTarget(r)}}const ur=new Yt,pr=new Yt,fr=new xt;class mr{constructor(e=new Yt(1,0,0),t=0){this.isPlane=!0,this.normal=e,this.constant=t}set(e,t){return this.normal.copy(e),this.constant=t,this}setComponents(e,t,n,i){return this.normal.set(e,t,n),this.constant=i,this}setFromNormalAndCoplanarPoint(e,t){return this.normal.copy(e),this.constant=-t.dot(this.normal),this}setFromCoplanarPoints(e,t,n){const i=ur.subVectors(n,t).cross(pr.subVectors(e,t)).normalize();return this.setFromNormalAndCoplanarPoint(i,e),this}copy(e){return this.normal.copy(e.normal),this.constant=e.constant,this}normalize(){const e=1/this.normal.length();return this.normal.multiplyScalar(e),this.constant*=e,this}negate(){return this.constant*=-1,this.normal.negate(),this}distanceToPoint(e){return this.normal.dot(e)+this.constant}distanceToSphere(e){return this.distanceToPoint(e.center)-e.radius}projectPoint(e,t){return t.copy(e).addScaledVector(this.normal,-this.distanceToPoint(e))}intersectLine(e,t){const n=e.delta(ur),i=this.normal.dot(n);if(0===i)return 0===this.distanceToPoint(e.start)?t.copy(e.start):null;const r=-(e.start.dot(this.normal)+this.constant)/i;return r<0||r>1?null:t.copy(e.start).addScaledVector(n,r)}intersectsLine(e){const t=this.distanceToPoint(e.start),n=this.distanceToPoint(e.end);return t<0&&n>0||n<0&&t>0}intersectsBox(e){return e.intersectsPlane(this)}intersectsSphere(e){return e.intersectsPlane(this)}coplanarPoint(e){return e.copy(this.normal).multiplyScalar(-this.constant)}applyMatrix4(e,t){const n=t||fr.getNormalMatrix(e),i=this.coplanarPoint(ur).applyMatrix4(e),r=this.normal.applyMatrix3(n).normalize();return this.constant=-i.dot(r),this}translate(e){return this.constant-=e.dot(this.normal),this}equals(e){return e.normal.equals(this.normal)&&e.constant===this.constant}clone(){return(new this.constructor).copy(this)}}const gr=new mn,vr=new Yt;class _r{constructor(e=new mr,t=new mr,n=new mr,i=new mr,r=new mr,a=new mr){this.planes=[e,t,n,i,r,a]}set(e,t,n,i,r,a){const s=this.planes;return s[0].copy(e),s[1].copy(t),s[2].copy(n),s[3].copy(i),s[4].copy(r),s[5].copy(a),this}copy(e){const t=this.planes;for(let n=0;n<6;n++)t[n].copy(e.planes[n]);return this}setFromProjectionMatrix(e,t=2e3){const n=this.planes,i=e.elements,r=i[0],a=i[1],s=i[2],o=i[3],l=i[4],c=i[5],h=i[6],d=i[7],u=i[8],p=i[9],f=i[10],m=i[11],g=i[12],v=i[13],_=i[14],x=i[15];if(n[0].setComponents(o-r,d-l,m-u,x-g).normalize(),n[1].setComponents(o+r,d+l,m+u,x+g).normalize(),n[2].setComponents(o+a,d+c,m+p,x+v).normalize(),n[3].setComponents(o-a,d-c,m-p,x-v).normalize(),n[4].setComponents(o-s,d-h,m-f,x-_).normalize(),t===rt)n[5].setComponents(o+s,d+h,m+f,x+_).normalize();else{if(t!==at)throw new Error("THREE.Frustum.setFromProjectionMatrix(): Invalid coordinate system: "+t);n[5].setComponents(s,h,f,_).normalize()}return this}intersectsObject(e){if(void 0!==e.boundingSphere)null===e.boundingSphere&&e.computeBoundingSphere(),gr.copy(e.boundingSphere).applyMatrix4(e.matrixWorld);else{const t=e.geometry;null===t.boundingSphere&&t.computeBoundingSphere(),gr.copy(t.boundingSphere).applyMatrix4(e.matrixWorld)}return this.intersectsSphere(gr)}intersectsSprite(e){return gr.center.set(0,0,0),gr.radius=.7071067811865476,gr.applyMatrix4(e.matrixWorld),this.intersectsSphere(gr)}intersectsSphere(e){const t=this.planes,n=e.center,i=-e.radius;for(let e=0;e<6;e++)if(t[e].distanceToPoint(n)0?e.max.x:e.min.x,vr.y=i.normal.y>0?e.max.y:e.min.y,vr.z=i.normal.z>0?e.max.z:e.min.z,i.distanceToPoint(vr)<0)return!1}return!0}containsPoint(e){const t=this.planes;for(let n=0;n<6;n++)if(t[n].distanceToPoint(e)<0)return!1;return!0}clone(){return(new this.constructor).copy(this)}}function xr(){let e=null,t=!1,n=null,i=null;function r(t,a){n(t,a),i=e.requestAnimationFrame(r)}return{start:function(){!0!==t&&null!==n&&(i=e.requestAnimationFrame(r),t=!0)},stop:function(){e.cancelAnimationFrame(i),t=!1},setAnimationLoop:function(e){n=e},setContext:function(t){e=t}}}function yr(e){const t=new WeakMap;return{get:function(e){return e.isInterleavedBufferAttribute&&(e=e.data),t.get(e)},remove:function(n){n.isInterleavedBufferAttribute&&(n=n.data);const i=t.get(n);i&&(e.deleteBuffer(i.buffer),t.delete(n))},update:function(n,i){if(n.isInterleavedBufferAttribute&&(n=n.data),n.isGLBufferAttribute){const e=t.get(n);return void((!e||e.versione.start-t.start));let t=0;for(let e=1;e 0\n\tvec4 plane;\n\t#ifdef ALPHA_TO_COVERAGE\n\t\tfloat distanceToPlane, distanceGradient;\n\t\tfloat clipOpacity = 1.0;\n\t\t#pragma unroll_loop_start\n\t\tfor ( int i = 0; i < UNION_CLIPPING_PLANES; i ++ ) {\n\t\t\tplane = clippingPlanes[ i ];\n\t\t\tdistanceToPlane = - dot( vClipPosition, plane.xyz ) + plane.w;\n\t\t\tdistanceGradient = fwidth( distanceToPlane ) / 2.0;\n\t\t\tclipOpacity *= smoothstep( - distanceGradient, distanceGradient, distanceToPlane );\n\t\t\tif ( clipOpacity == 0.0 ) discard;\n\t\t}\n\t\t#pragma unroll_loop_end\n\t\t#if UNION_CLIPPING_PLANES < NUM_CLIPPING_PLANES\n\t\t\tfloat unionClipOpacity = 1.0;\n\t\t\t#pragma unroll_loop_start\n\t\t\tfor ( int i = UNION_CLIPPING_PLANES; i < NUM_CLIPPING_PLANES; i ++ ) {\n\t\t\t\tplane = clippingPlanes[ i ];\n\t\t\t\tdistanceToPlane = - dot( vClipPosition, plane.xyz ) + plane.w;\n\t\t\t\tdistanceGradient = fwidth( distanceToPlane ) / 2.0;\n\t\t\t\tunionClipOpacity *= 1.0 - smoothstep( - distanceGradient, distanceGradient, distanceToPlane );\n\t\t\t}\n\t\t\t#pragma unroll_loop_end\n\t\t\tclipOpacity *= 1.0 - unionClipOpacity;\n\t\t#endif\n\t\tdiffuseColor.a *= clipOpacity;\n\t\tif ( diffuseColor.a == 0.0 ) discard;\n\t#else\n\t\t#pragma unroll_loop_start\n\t\tfor ( int i = 0; i < UNION_CLIPPING_PLANES; i ++ ) {\n\t\t\tplane = clippingPlanes[ i ];\n\t\t\tif ( dot( vClipPosition, plane.xyz ) > plane.w ) discard;\n\t\t}\n\t\t#pragma unroll_loop_end\n\t\t#if UNION_CLIPPING_PLANES < NUM_CLIPPING_PLANES\n\t\t\tbool clipped = true;\n\t\t\t#pragma unroll_loop_start\n\t\t\tfor ( int i = UNION_CLIPPING_PLANES; i < NUM_CLIPPING_PLANES; i ++ ) {\n\t\t\t\tplane = clippingPlanes[ i ];\n\t\t\t\tclipped = ( dot( vClipPosition, plane.xyz ) > plane.w ) && clipped;\n\t\t\t}\n\t\t\t#pragma unroll_loop_end\n\t\t\tif ( clipped ) discard;\n\t\t#endif\n\t#endif\n#endif",clipping_planes_pars_fragment:"#if NUM_CLIPPING_PLANES > 0\n\tvarying vec3 vClipPosition;\n\tuniform vec4 clippingPlanes[ NUM_CLIPPING_PLANES ];\n#endif",clipping_planes_pars_vertex:"#if NUM_CLIPPING_PLANES > 0\n\tvarying vec3 vClipPosition;\n#endif",clipping_planes_vertex:"#if NUM_CLIPPING_PLANES > 0\n\tvClipPosition = - mvPosition.xyz;\n#endif",color_fragment:"#if defined( USE_COLOR_ALPHA )\n\tdiffuseColor *= vColor;\n#elif defined( USE_COLOR )\n\tdiffuseColor.rgb *= vColor;\n#endif",color_pars_fragment:"#if defined( USE_COLOR_ALPHA )\n\tvarying vec4 vColor;\n#elif defined( USE_COLOR )\n\tvarying vec3 vColor;\n#endif",color_pars_vertex:"#if defined( USE_COLOR_ALPHA )\n\tvarying vec4 vColor;\n#elif defined( USE_COLOR ) || defined( USE_INSTANCING_COLOR ) || defined( USE_BATCHING_COLOR )\n\tvarying vec3 vColor;\n#endif",color_vertex:"#if defined( USE_COLOR_ALPHA )\n\tvColor = vec4( 1.0 );\n#elif defined( USE_COLOR ) || defined( USE_INSTANCING_COLOR ) || defined( USE_BATCHING_COLOR )\n\tvColor = vec3( 1.0 );\n#endif\n#ifdef USE_COLOR\n\tvColor *= color;\n#endif\n#ifdef USE_INSTANCING_COLOR\n\tvColor.xyz *= instanceColor.xyz;\n#endif\n#ifdef USE_BATCHING_COLOR\n\tvec3 batchingColor = getBatchingColor( getIndirectIndex( gl_DrawID ) );\n\tvColor.xyz *= batchingColor.xyz;\n#endif",common:"#define PI 3.141592653589793\n#define PI2 6.283185307179586\n#define PI_HALF 1.5707963267948966\n#define RECIPROCAL_PI 0.3183098861837907\n#define RECIPROCAL_PI2 0.15915494309189535\n#define EPSILON 1e-6\n#ifndef saturate\n#define saturate( a ) clamp( a, 0.0, 1.0 )\n#endif\n#define whiteComplement( a ) ( 1.0 - saturate( a ) )\nfloat pow2( const in float x ) { return x*x; }\nvec3 pow2( const in vec3 x ) { return x*x; }\nfloat pow3( const in float x ) { return x*x*x; }\nfloat pow4( const in float x ) { float x2 = x*x; return x2*x2; }\nfloat max3( const in vec3 v ) { return max( max( v.x, v.y ), v.z ); }\nfloat average( const in vec3 v ) { return dot( v, vec3( 0.3333333 ) ); }\nhighp float rand( const in vec2 uv ) {\n\tconst highp float a = 12.9898, b = 78.233, c = 43758.5453;\n\thighp float dt = dot( uv.xy, vec2( a,b ) ), sn = mod( dt, PI );\n\treturn fract( sin( sn ) * c );\n}\n#ifdef HIGH_PRECISION\n\tfloat precisionSafeLength( vec3 v ) { return length( v ); }\n#else\n\tfloat precisionSafeLength( vec3 v ) {\n\t\tfloat maxComponent = max3( abs( v ) );\n\t\treturn length( v / maxComponent ) * maxComponent;\n\t}\n#endif\nstruct IncidentLight {\n\tvec3 color;\n\tvec3 direction;\n\tbool visible;\n};\nstruct ReflectedLight {\n\tvec3 directDiffuse;\n\tvec3 directSpecular;\n\tvec3 indirectDiffuse;\n\tvec3 indirectSpecular;\n};\n#ifdef USE_ALPHAHASH\n\tvarying vec3 vPosition;\n#endif\nvec3 transformDirection( in vec3 dir, in mat4 matrix ) {\n\treturn normalize( ( matrix * vec4( dir, 0.0 ) ).xyz );\n}\nvec3 inverseTransformDirection( in vec3 dir, in mat4 matrix ) {\n\treturn normalize( ( vec4( dir, 0.0 ) * matrix ).xyz );\n}\nmat3 transposeMat3( const in mat3 m ) {\n\tmat3 tmp;\n\ttmp[ 0 ] = vec3( m[ 0 ].x, m[ 1 ].x, m[ 2 ].x );\n\ttmp[ 1 ] = vec3( m[ 0 ].y, m[ 1 ].y, m[ 2 ].y );\n\ttmp[ 2 ] = vec3( m[ 0 ].z, m[ 1 ].z, m[ 2 ].z );\n\treturn tmp;\n}\nbool isPerspectiveMatrix( mat4 m ) {\n\treturn m[ 2 ][ 3 ] == - 1.0;\n}\nvec2 equirectUv( in vec3 dir ) {\n\tfloat u = atan( dir.z, dir.x ) * RECIPROCAL_PI2 + 0.5;\n\tfloat v = asin( clamp( dir.y, - 1.0, 1.0 ) ) * RECIPROCAL_PI + 0.5;\n\treturn vec2( u, v );\n}\nvec3 BRDF_Lambert( const in vec3 diffuseColor ) {\n\treturn RECIPROCAL_PI * diffuseColor;\n}\nvec3 F_Schlick( const in vec3 f0, const in float f90, const in float dotVH ) {\n\tfloat fresnel = exp2( ( - 5.55473 * dotVH - 6.98316 ) * dotVH );\n\treturn f0 * ( 1.0 - fresnel ) + ( f90 * fresnel );\n}\nfloat F_Schlick( const in float f0, const in float f90, const in float dotVH ) {\n\tfloat fresnel = exp2( ( - 5.55473 * dotVH - 6.98316 ) * dotVH );\n\treturn f0 * ( 1.0 - fresnel ) + ( f90 * fresnel );\n} // validated",cube_uv_reflection_fragment:"#ifdef ENVMAP_TYPE_CUBE_UV\n\t#define cubeUV_minMipLevel 4.0\n\t#define cubeUV_minTileSize 16.0\n\tfloat getFace( vec3 direction ) {\n\t\tvec3 absDirection = abs( direction );\n\t\tfloat face = - 1.0;\n\t\tif ( absDirection.x > absDirection.z ) {\n\t\t\tif ( absDirection.x > absDirection.y )\n\t\t\t\tface = direction.x > 0.0 ? 0.0 : 3.0;\n\t\t\telse\n\t\t\t\tface = direction.y > 0.0 ? 1.0 : 4.0;\n\t\t} else {\n\t\t\tif ( absDirection.z > absDirection.y )\n\t\t\t\tface = direction.z > 0.0 ? 2.0 : 5.0;\n\t\t\telse\n\t\t\t\tface = direction.y > 0.0 ? 1.0 : 4.0;\n\t\t}\n\t\treturn face;\n\t}\n\tvec2 getUV( vec3 direction, float face ) {\n\t\tvec2 uv;\n\t\tif ( face == 0.0 ) {\n\t\t\tuv = vec2( direction.z, direction.y ) / abs( direction.x );\n\t\t} else if ( face == 1.0 ) {\n\t\t\tuv = vec2( - direction.x, - direction.z ) / abs( direction.y );\n\t\t} else if ( face == 2.0 ) {\n\t\t\tuv = vec2( - direction.x, direction.y ) / abs( direction.z );\n\t\t} else if ( face == 3.0 ) {\n\t\t\tuv = vec2( - direction.z, direction.y ) / abs( direction.x );\n\t\t} else if ( face == 4.0 ) {\n\t\t\tuv = vec2( - direction.x, direction.z ) / abs( direction.y );\n\t\t} else {\n\t\t\tuv = vec2( direction.x, direction.y ) / abs( direction.z );\n\t\t}\n\t\treturn 0.5 * ( uv + 1.0 );\n\t}\n\tvec3 bilinearCubeUV( sampler2D envMap, vec3 direction, float mipInt ) {\n\t\tfloat face = getFace( direction );\n\t\tfloat filterInt = max( cubeUV_minMipLevel - mipInt, 0.0 );\n\t\tmipInt = max( mipInt, cubeUV_minMipLevel );\n\t\tfloat faceSize = exp2( mipInt );\n\t\thighp vec2 uv = getUV( direction, face ) * ( faceSize - 2.0 ) + 1.0;\n\t\tif ( face > 2.0 ) {\n\t\t\tuv.y += faceSize;\n\t\t\tface -= 3.0;\n\t\t}\n\t\tuv.x += face * faceSize;\n\t\tuv.x += filterInt * 3.0 * cubeUV_minTileSize;\n\t\tuv.y += 4.0 * ( exp2( CUBEUV_MAX_MIP ) - faceSize );\n\t\tuv.x *= CUBEUV_TEXEL_WIDTH;\n\t\tuv.y *= CUBEUV_TEXEL_HEIGHT;\n\t\t#ifdef texture2DGradEXT\n\t\t\treturn texture2DGradEXT( envMap, uv, vec2( 0.0 ), vec2( 0.0 ) ).rgb;\n\t\t#else\n\t\t\treturn texture2D( envMap, uv ).rgb;\n\t\t#endif\n\t}\n\t#define cubeUV_r0 1.0\n\t#define cubeUV_m0 - 2.0\n\t#define cubeUV_r1 0.8\n\t#define cubeUV_m1 - 1.0\n\t#define cubeUV_r4 0.4\n\t#define cubeUV_m4 2.0\n\t#define cubeUV_r5 0.305\n\t#define cubeUV_m5 3.0\n\t#define cubeUV_r6 0.21\n\t#define cubeUV_m6 4.0\n\tfloat roughnessToMip( float roughness ) {\n\t\tfloat mip = 0.0;\n\t\tif ( roughness >= cubeUV_r1 ) {\n\t\t\tmip = ( cubeUV_r0 - roughness ) * ( cubeUV_m1 - cubeUV_m0 ) / ( cubeUV_r0 - cubeUV_r1 ) + cubeUV_m0;\n\t\t} else if ( roughness >= cubeUV_r4 ) {\n\t\t\tmip = ( cubeUV_r1 - roughness ) * ( cubeUV_m4 - cubeUV_m1 ) / ( cubeUV_r1 - cubeUV_r4 ) + cubeUV_m1;\n\t\t} else if ( roughness >= cubeUV_r5 ) {\n\t\t\tmip = ( cubeUV_r4 - roughness ) * ( cubeUV_m5 - cubeUV_m4 ) / ( cubeUV_r4 - cubeUV_r5 ) + cubeUV_m4;\n\t\t} else if ( roughness >= cubeUV_r6 ) {\n\t\t\tmip = ( cubeUV_r5 - roughness ) * ( cubeUV_m6 - cubeUV_m5 ) / ( cubeUV_r5 - cubeUV_r6 ) + cubeUV_m5;\n\t\t} else {\n\t\t\tmip = - 2.0 * log2( 1.16 * roughness );\t\t}\n\t\treturn mip;\n\t}\n\tvec4 textureCubeUV( sampler2D envMap, vec3 sampleDir, float roughness ) {\n\t\tfloat mip = clamp( roughnessToMip( roughness ), cubeUV_m0, CUBEUV_MAX_MIP );\n\t\tfloat mipF = fract( mip );\n\t\tfloat mipInt = floor( mip );\n\t\tvec3 color0 = bilinearCubeUV( envMap, sampleDir, mipInt );\n\t\tif ( mipF == 0.0 ) {\n\t\t\treturn vec4( color0, 1.0 );\n\t\t} else {\n\t\t\tvec3 color1 = bilinearCubeUV( envMap, sampleDir, mipInt + 1.0 );\n\t\t\treturn vec4( mix( color0, color1, mipF ), 1.0 );\n\t\t}\n\t}\n#endif",defaultnormal_vertex:"vec3 transformedNormal = objectNormal;\n#ifdef USE_TANGENT\n\tvec3 transformedTangent = objectTangent;\n#endif\n#ifdef USE_BATCHING\n\tmat3 bm = mat3( batchingMatrix );\n\ttransformedNormal /= vec3( dot( bm[ 0 ], bm[ 0 ] ), dot( bm[ 1 ], bm[ 1 ] ), dot( bm[ 2 ], bm[ 2 ] ) );\n\ttransformedNormal = bm * transformedNormal;\n\t#ifdef USE_TANGENT\n\t\ttransformedTangent = bm * transformedTangent;\n\t#endif\n#endif\n#ifdef USE_INSTANCING\n\tmat3 im = mat3( instanceMatrix );\n\ttransformedNormal /= vec3( dot( im[ 0 ], im[ 0 ] ), dot( im[ 1 ], im[ 1 ] ), dot( im[ 2 ], im[ 2 ] ) );\n\ttransformedNormal = im * transformedNormal;\n\t#ifdef USE_TANGENT\n\t\ttransformedTangent = im * transformedTangent;\n\t#endif\n#endif\ntransformedNormal = normalMatrix * transformedNormal;\n#ifdef FLIP_SIDED\n\ttransformedNormal = - transformedNormal;\n#endif\n#ifdef USE_TANGENT\n\ttransformedTangent = ( modelViewMatrix * vec4( transformedTangent, 0.0 ) ).xyz;\n\t#ifdef FLIP_SIDED\n\t\ttransformedTangent = - transformedTangent;\n\t#endif\n#endif",displacementmap_pars_vertex:"#ifdef USE_DISPLACEMENTMAP\n\tuniform sampler2D displacementMap;\n\tuniform float displacementScale;\n\tuniform float displacementBias;\n#endif",displacementmap_vertex:"#ifdef USE_DISPLACEMENTMAP\n\ttransformed += normalize( objectNormal ) * ( texture2D( displacementMap, vDisplacementMapUv ).x * displacementScale + displacementBias );\n#endif",emissivemap_fragment:"#ifdef USE_EMISSIVEMAP\n\tvec4 emissiveColor = texture2D( emissiveMap, vEmissiveMapUv );\n\t#ifdef DECODE_VIDEO_TEXTURE_EMISSIVE\n\t\temissiveColor = sRGBTransferEOTF( emissiveColor );\n\t#endif\n\ttotalEmissiveRadiance *= emissiveColor.rgb;\n#endif",emissivemap_pars_fragment:"#ifdef USE_EMISSIVEMAP\n\tuniform sampler2D emissiveMap;\n#endif",colorspace_fragment:"gl_FragColor = linearToOutputTexel( gl_FragColor );",colorspace_pars_fragment:"vec4 LinearTransferOETF( in vec4 value ) {\n\treturn value;\n}\nvec4 sRGBTransferEOTF( in vec4 value ) {\n\treturn vec4( mix( pow( value.rgb * 0.9478672986 + vec3( 0.0521327014 ), vec3( 2.4 ) ), value.rgb * 0.0773993808, vec3( lessThanEqual( value.rgb, vec3( 0.04045 ) ) ) ), value.a );\n}\nvec4 sRGBTransferOETF( in vec4 value ) {\n\treturn vec4( mix( pow( value.rgb, vec3( 0.41666 ) ) * 1.055 - vec3( 0.055 ), value.rgb * 12.92, vec3( lessThanEqual( value.rgb, vec3( 0.0031308 ) ) ) ), value.a );\n}",envmap_fragment:"#ifdef USE_ENVMAP\n\t#ifdef ENV_WORLDPOS\n\t\tvec3 cameraToFrag;\n\t\tif ( isOrthographic ) {\n\t\t\tcameraToFrag = normalize( vec3( - viewMatrix[ 0 ][ 2 ], - viewMatrix[ 1 ][ 2 ], - viewMatrix[ 2 ][ 2 ] ) );\n\t\t} else {\n\t\t\tcameraToFrag = normalize( vWorldPosition - cameraPosition );\n\t\t}\n\t\tvec3 worldNormal = inverseTransformDirection( normal, viewMatrix );\n\t\t#ifdef ENVMAP_MODE_REFLECTION\n\t\t\tvec3 reflectVec = reflect( cameraToFrag, worldNormal );\n\t\t#else\n\t\t\tvec3 reflectVec = refract( cameraToFrag, worldNormal, refractionRatio );\n\t\t#endif\n\t#else\n\t\tvec3 reflectVec = vReflect;\n\t#endif\n\t#ifdef ENVMAP_TYPE_CUBE\n\t\tvec4 envColor = textureCube( envMap, envMapRotation * vec3( flipEnvMap * reflectVec.x, reflectVec.yz ) );\n\t#else\n\t\tvec4 envColor = vec4( 0.0 );\n\t#endif\n\t#ifdef ENVMAP_BLENDING_MULTIPLY\n\t\toutgoingLight = mix( outgoingLight, outgoingLight * envColor.xyz, specularStrength * reflectivity );\n\t#elif defined( ENVMAP_BLENDING_MIX )\n\t\toutgoingLight = mix( outgoingLight, envColor.xyz, specularStrength * reflectivity );\n\t#elif defined( ENVMAP_BLENDING_ADD )\n\t\toutgoingLight += envColor.xyz * specularStrength * reflectivity;\n\t#endif\n#endif",envmap_common_pars_fragment:"#ifdef USE_ENVMAP\n\tuniform float envMapIntensity;\n\tuniform float flipEnvMap;\n\tuniform mat3 envMapRotation;\n\t#ifdef ENVMAP_TYPE_CUBE\n\t\tuniform samplerCube envMap;\n\t#else\n\t\tuniform sampler2D envMap;\n\t#endif\n\t\n#endif",envmap_pars_fragment:"#ifdef USE_ENVMAP\n\tuniform float reflectivity;\n\t#if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG ) || defined( LAMBERT )\n\t\t#define ENV_WORLDPOS\n\t#endif\n\t#ifdef ENV_WORLDPOS\n\t\tvarying vec3 vWorldPosition;\n\t\tuniform float refractionRatio;\n\t#else\n\t\tvarying vec3 vReflect;\n\t#endif\n#endif",envmap_pars_vertex:"#ifdef USE_ENVMAP\n\t#if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG ) || defined( LAMBERT )\n\t\t#define ENV_WORLDPOS\n\t#endif\n\t#ifdef ENV_WORLDPOS\n\t\t\n\t\tvarying vec3 vWorldPosition;\n\t#else\n\t\tvarying vec3 vReflect;\n\t\tuniform float refractionRatio;\n\t#endif\n#endif",envmap_physical_pars_fragment:"#ifdef USE_ENVMAP\n\tvec3 getIBLIrradiance( const in vec3 normal ) {\n\t\t#ifdef ENVMAP_TYPE_CUBE_UV\n\t\t\tvec3 worldNormal = inverseTransformDirection( normal, viewMatrix );\n\t\t\tvec4 envMapColor = textureCubeUV( envMap, envMapRotation * worldNormal, 1.0 );\n\t\t\treturn PI * envMapColor.rgb * envMapIntensity;\n\t\t#else\n\t\t\treturn vec3( 0.0 );\n\t\t#endif\n\t}\n\tvec3 getIBLRadiance( const in vec3 viewDir, const in vec3 normal, const in float roughness ) {\n\t\t#ifdef ENVMAP_TYPE_CUBE_UV\n\t\t\tvec3 reflectVec = reflect( - viewDir, normal );\n\t\t\treflectVec = normalize( mix( reflectVec, normal, roughness * roughness) );\n\t\t\treflectVec = inverseTransformDirection( reflectVec, viewMatrix );\n\t\t\tvec4 envMapColor = textureCubeUV( envMap, envMapRotation * reflectVec, roughness );\n\t\t\treturn envMapColor.rgb * envMapIntensity;\n\t\t#else\n\t\t\treturn vec3( 0.0 );\n\t\t#endif\n\t}\n\t#ifdef USE_ANISOTROPY\n\t\tvec3 getIBLAnisotropyRadiance( const in vec3 viewDir, const in vec3 normal, const in float roughness, const in vec3 bitangent, const in float anisotropy ) {\n\t\t\t#ifdef ENVMAP_TYPE_CUBE_UV\n\t\t\t\tvec3 bentNormal = cross( bitangent, viewDir );\n\t\t\t\tbentNormal = normalize( cross( bentNormal, bitangent ) );\n\t\t\t\tbentNormal = normalize( mix( bentNormal, normal, pow2( pow2( 1.0 - anisotropy * ( 1.0 - roughness ) ) ) ) );\n\t\t\t\treturn getIBLRadiance( viewDir, bentNormal, roughness );\n\t\t\t#else\n\t\t\t\treturn vec3( 0.0 );\n\t\t\t#endif\n\t\t}\n\t#endif\n#endif",envmap_vertex:"#ifdef USE_ENVMAP\n\t#ifdef ENV_WORLDPOS\n\t\tvWorldPosition = worldPosition.xyz;\n\t#else\n\t\tvec3 cameraToVertex;\n\t\tif ( isOrthographic ) {\n\t\t\tcameraToVertex = normalize( vec3( - viewMatrix[ 0 ][ 2 ], - viewMatrix[ 1 ][ 2 ], - viewMatrix[ 2 ][ 2 ] ) );\n\t\t} else {\n\t\t\tcameraToVertex = normalize( worldPosition.xyz - cameraPosition );\n\t\t}\n\t\tvec3 worldNormal = inverseTransformDirection( transformedNormal, viewMatrix );\n\t\t#ifdef ENVMAP_MODE_REFLECTION\n\t\t\tvReflect = reflect( cameraToVertex, worldNormal );\n\t\t#else\n\t\t\tvReflect = refract( cameraToVertex, worldNormal, refractionRatio );\n\t\t#endif\n\t#endif\n#endif",fog_vertex:"#ifdef USE_FOG\n\tvFogDepth = - mvPosition.z;\n#endif",fog_pars_vertex:"#ifdef USE_FOG\n\tvarying float vFogDepth;\n#endif",fog_fragment:"#ifdef USE_FOG\n\t#ifdef FOG_EXP2\n\t\tfloat fogFactor = 1.0 - exp( - fogDensity * fogDensity * vFogDepth * vFogDepth );\n\t#else\n\t\tfloat fogFactor = smoothstep( fogNear, fogFar, vFogDepth );\n\t#endif\n\tgl_FragColor.rgb = mix( gl_FragColor.rgb, fogColor, fogFactor );\n#endif",fog_pars_fragment:"#ifdef USE_FOG\n\tuniform vec3 fogColor;\n\tvarying float vFogDepth;\n\t#ifdef FOG_EXP2\n\t\tuniform float fogDensity;\n\t#else\n\t\tuniform float fogNear;\n\t\tuniform float fogFar;\n\t#endif\n#endif",gradientmap_pars_fragment:"#ifdef USE_GRADIENTMAP\n\tuniform sampler2D gradientMap;\n#endif\nvec3 getGradientIrradiance( vec3 normal, vec3 lightDirection ) {\n\tfloat dotNL = dot( normal, lightDirection );\n\tvec2 coord = vec2( dotNL * 0.5 + 0.5, 0.0 );\n\t#ifdef USE_GRADIENTMAP\n\t\treturn vec3( texture2D( gradientMap, coord ).r );\n\t#else\n\t\tvec2 fw = fwidth( coord ) * 0.5;\n\t\treturn mix( vec3( 0.7 ), vec3( 1.0 ), smoothstep( 0.7 - fw.x, 0.7 + fw.x, coord.x ) );\n\t#endif\n}",lightmap_pars_fragment:"#ifdef USE_LIGHTMAP\n\tuniform sampler2D lightMap;\n\tuniform float lightMapIntensity;\n#endif",lights_lambert_fragment:"LambertMaterial material;\nmaterial.diffuseColor = diffuseColor.rgb;\nmaterial.specularStrength = specularStrength;",lights_lambert_pars_fragment:"varying vec3 vViewPosition;\nstruct LambertMaterial {\n\tvec3 diffuseColor;\n\tfloat specularStrength;\n};\nvoid RE_Direct_Lambert( const in IncidentLight directLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in LambertMaterial material, inout ReflectedLight reflectedLight ) {\n\tfloat dotNL = saturate( dot( geometryNormal, directLight.direction ) );\n\tvec3 irradiance = dotNL * directLight.color;\n\treflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );\n}\nvoid RE_IndirectDiffuse_Lambert( const in vec3 irradiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in LambertMaterial material, inout ReflectedLight reflectedLight ) {\n\treflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );\n}\n#define RE_Direct\t\t\t\tRE_Direct_Lambert\n#define RE_IndirectDiffuse\t\tRE_IndirectDiffuse_Lambert",lights_pars_begin:"uniform bool receiveShadow;\nuniform vec3 ambientLightColor;\n#if defined( USE_LIGHT_PROBES )\n\tuniform vec3 lightProbe[ 9 ];\n#endif\nvec3 shGetIrradianceAt( in vec3 normal, in vec3 shCoefficients[ 9 ] ) {\n\tfloat x = normal.x, y = normal.y, z = normal.z;\n\tvec3 result = shCoefficients[ 0 ] * 0.886227;\n\tresult += shCoefficients[ 1 ] * 2.0 * 0.511664 * y;\n\tresult += shCoefficients[ 2 ] * 2.0 * 0.511664 * z;\n\tresult += shCoefficients[ 3 ] * 2.0 * 0.511664 * x;\n\tresult += shCoefficients[ 4 ] * 2.0 * 0.429043 * x * y;\n\tresult += shCoefficients[ 5 ] * 2.0 * 0.429043 * y * z;\n\tresult += shCoefficients[ 6 ] * ( 0.743125 * z * z - 0.247708 );\n\tresult += shCoefficients[ 7 ] * 2.0 * 0.429043 * x * z;\n\tresult += shCoefficients[ 8 ] * 0.429043 * ( x * x - y * y );\n\treturn result;\n}\nvec3 getLightProbeIrradiance( const in vec3 lightProbe[ 9 ], const in vec3 normal ) {\n\tvec3 worldNormal = inverseTransformDirection( normal, viewMatrix );\n\tvec3 irradiance = shGetIrradianceAt( worldNormal, lightProbe );\n\treturn irradiance;\n}\nvec3 getAmbientLightIrradiance( const in vec3 ambientLightColor ) {\n\tvec3 irradiance = ambientLightColor;\n\treturn irradiance;\n}\nfloat getDistanceAttenuation( const in float lightDistance, const in float cutoffDistance, const in float decayExponent ) {\n\tfloat distanceFalloff = 1.0 / max( pow( lightDistance, decayExponent ), 0.01 );\n\tif ( cutoffDistance > 0.0 ) {\n\t\tdistanceFalloff *= pow2( saturate( 1.0 - pow4( lightDistance / cutoffDistance ) ) );\n\t}\n\treturn distanceFalloff;\n}\nfloat getSpotAttenuation( const in float coneCosine, const in float penumbraCosine, const in float angleCosine ) {\n\treturn smoothstep( coneCosine, penumbraCosine, angleCosine );\n}\n#if NUM_DIR_LIGHTS > 0\n\tstruct DirectionalLight {\n\t\tvec3 direction;\n\t\tvec3 color;\n\t};\n\tuniform DirectionalLight directionalLights[ NUM_DIR_LIGHTS ];\n\tvoid getDirectionalLightInfo( const in DirectionalLight directionalLight, out IncidentLight light ) {\n\t\tlight.color = directionalLight.color;\n\t\tlight.direction = directionalLight.direction;\n\t\tlight.visible = true;\n\t}\n#endif\n#if NUM_POINT_LIGHTS > 0\n\tstruct PointLight {\n\t\tvec3 position;\n\t\tvec3 color;\n\t\tfloat distance;\n\t\tfloat decay;\n\t};\n\tuniform PointLight pointLights[ NUM_POINT_LIGHTS ];\n\tvoid getPointLightInfo( const in PointLight pointLight, const in vec3 geometryPosition, out IncidentLight light ) {\n\t\tvec3 lVector = pointLight.position - geometryPosition;\n\t\tlight.direction = normalize( lVector );\n\t\tfloat lightDistance = length( lVector );\n\t\tlight.color = pointLight.color;\n\t\tlight.color *= getDistanceAttenuation( lightDistance, pointLight.distance, pointLight.decay );\n\t\tlight.visible = ( light.color != vec3( 0.0 ) );\n\t}\n#endif\n#if NUM_SPOT_LIGHTS > 0\n\tstruct SpotLight {\n\t\tvec3 position;\n\t\tvec3 direction;\n\t\tvec3 color;\n\t\tfloat distance;\n\t\tfloat decay;\n\t\tfloat coneCos;\n\t\tfloat penumbraCos;\n\t};\n\tuniform SpotLight spotLights[ NUM_SPOT_LIGHTS ];\n\tvoid getSpotLightInfo( const in SpotLight spotLight, const in vec3 geometryPosition, out IncidentLight light ) {\n\t\tvec3 lVector = spotLight.position - geometryPosition;\n\t\tlight.direction = normalize( lVector );\n\t\tfloat angleCos = dot( light.direction, spotLight.direction );\n\t\tfloat spotAttenuation = getSpotAttenuation( spotLight.coneCos, spotLight.penumbraCos, angleCos );\n\t\tif ( spotAttenuation > 0.0 ) {\n\t\t\tfloat lightDistance = length( lVector );\n\t\t\tlight.color = spotLight.color * spotAttenuation;\n\t\t\tlight.color *= getDistanceAttenuation( lightDistance, spotLight.distance, spotLight.decay );\n\t\t\tlight.visible = ( light.color != vec3( 0.0 ) );\n\t\t} else {\n\t\t\tlight.color = vec3( 0.0 );\n\t\t\tlight.visible = false;\n\t\t}\n\t}\n#endif\n#if NUM_RECT_AREA_LIGHTS > 0\n\tstruct RectAreaLight {\n\t\tvec3 color;\n\t\tvec3 position;\n\t\tvec3 halfWidth;\n\t\tvec3 halfHeight;\n\t};\n\tuniform sampler2D ltc_1;\tuniform sampler2D ltc_2;\n\tuniform RectAreaLight rectAreaLights[ NUM_RECT_AREA_LIGHTS ];\n#endif\n#if NUM_HEMI_LIGHTS > 0\n\tstruct HemisphereLight {\n\t\tvec3 direction;\n\t\tvec3 skyColor;\n\t\tvec3 groundColor;\n\t};\n\tuniform HemisphereLight hemisphereLights[ NUM_HEMI_LIGHTS ];\n\tvec3 getHemisphereLightIrradiance( const in HemisphereLight hemiLight, const in vec3 normal ) {\n\t\tfloat dotNL = dot( normal, hemiLight.direction );\n\t\tfloat hemiDiffuseWeight = 0.5 * dotNL + 0.5;\n\t\tvec3 irradiance = mix( hemiLight.groundColor, hemiLight.skyColor, hemiDiffuseWeight );\n\t\treturn irradiance;\n\t}\n#endif",lights_toon_fragment:"ToonMaterial material;\nmaterial.diffuseColor = diffuseColor.rgb;",lights_toon_pars_fragment:"varying vec3 vViewPosition;\nstruct ToonMaterial {\n\tvec3 diffuseColor;\n};\nvoid RE_Direct_Toon( const in IncidentLight directLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in ToonMaterial material, inout ReflectedLight reflectedLight ) {\n\tvec3 irradiance = getGradientIrradiance( geometryNormal, directLight.direction ) * directLight.color;\n\treflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );\n}\nvoid RE_IndirectDiffuse_Toon( const in vec3 irradiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in ToonMaterial material, inout ReflectedLight reflectedLight ) {\n\treflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );\n}\n#define RE_Direct\t\t\t\tRE_Direct_Toon\n#define RE_IndirectDiffuse\t\tRE_IndirectDiffuse_Toon",lights_phong_fragment:"BlinnPhongMaterial material;\nmaterial.diffuseColor = diffuseColor.rgb;\nmaterial.specularColor = specular;\nmaterial.specularShininess = shininess;\nmaterial.specularStrength = specularStrength;",lights_phong_pars_fragment:"varying vec3 vViewPosition;\nstruct BlinnPhongMaterial {\n\tvec3 diffuseColor;\n\tvec3 specularColor;\n\tfloat specularShininess;\n\tfloat specularStrength;\n};\nvoid RE_Direct_BlinnPhong( const in IncidentLight directLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in BlinnPhongMaterial material, inout ReflectedLight reflectedLight ) {\n\tfloat dotNL = saturate( dot( geometryNormal, directLight.direction ) );\n\tvec3 irradiance = dotNL * directLight.color;\n\treflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );\n\treflectedLight.directSpecular += irradiance * BRDF_BlinnPhong( directLight.direction, geometryViewDir, geometryNormal, material.specularColor, material.specularShininess ) * material.specularStrength;\n}\nvoid RE_IndirectDiffuse_BlinnPhong( const in vec3 irradiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in BlinnPhongMaterial material, inout ReflectedLight reflectedLight ) {\n\treflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );\n}\n#define RE_Direct\t\t\t\tRE_Direct_BlinnPhong\n#define RE_IndirectDiffuse\t\tRE_IndirectDiffuse_BlinnPhong",lights_physical_fragment:"PhysicalMaterial material;\nmaterial.diffuseColor = diffuseColor.rgb * ( 1.0 - metalnessFactor );\nvec3 dxy = max( abs( dFdx( nonPerturbedNormal ) ), abs( dFdy( nonPerturbedNormal ) ) );\nfloat geometryRoughness = max( max( dxy.x, dxy.y ), dxy.z );\nmaterial.roughness = max( roughnessFactor, 0.0525 );material.roughness += geometryRoughness;\nmaterial.roughness = min( material.roughness, 1.0 );\n#ifdef IOR\n\tmaterial.ior = ior;\n\t#ifdef USE_SPECULAR\n\t\tfloat specularIntensityFactor = specularIntensity;\n\t\tvec3 specularColorFactor = specularColor;\n\t\t#ifdef USE_SPECULAR_COLORMAP\n\t\t\tspecularColorFactor *= texture2D( specularColorMap, vSpecularColorMapUv ).rgb;\n\t\t#endif\n\t\t#ifdef USE_SPECULAR_INTENSITYMAP\n\t\t\tspecularIntensityFactor *= texture2D( specularIntensityMap, vSpecularIntensityMapUv ).a;\n\t\t#endif\n\t\tmaterial.specularF90 = mix( specularIntensityFactor, 1.0, metalnessFactor );\n\t#else\n\t\tfloat specularIntensityFactor = 1.0;\n\t\tvec3 specularColorFactor = vec3( 1.0 );\n\t\tmaterial.specularF90 = 1.0;\n\t#endif\n\tmaterial.specularColor = mix( min( pow2( ( material.ior - 1.0 ) / ( material.ior + 1.0 ) ) * specularColorFactor, vec3( 1.0 ) ) * specularIntensityFactor, diffuseColor.rgb, metalnessFactor );\n#else\n\tmaterial.specularColor = mix( vec3( 0.04 ), diffuseColor.rgb, metalnessFactor );\n\tmaterial.specularF90 = 1.0;\n#endif\n#ifdef USE_CLEARCOAT\n\tmaterial.clearcoat = clearcoat;\n\tmaterial.clearcoatRoughness = clearcoatRoughness;\n\tmaterial.clearcoatF0 = vec3( 0.04 );\n\tmaterial.clearcoatF90 = 1.0;\n\t#ifdef USE_CLEARCOATMAP\n\t\tmaterial.clearcoat *= texture2D( clearcoatMap, vClearcoatMapUv ).x;\n\t#endif\n\t#ifdef USE_CLEARCOAT_ROUGHNESSMAP\n\t\tmaterial.clearcoatRoughness *= texture2D( clearcoatRoughnessMap, vClearcoatRoughnessMapUv ).y;\n\t#endif\n\tmaterial.clearcoat = saturate( material.clearcoat );\tmaterial.clearcoatRoughness = max( material.clearcoatRoughness, 0.0525 );\n\tmaterial.clearcoatRoughness += geometryRoughness;\n\tmaterial.clearcoatRoughness = min( material.clearcoatRoughness, 1.0 );\n#endif\n#ifdef USE_DISPERSION\n\tmaterial.dispersion = dispersion;\n#endif\n#ifdef USE_IRIDESCENCE\n\tmaterial.iridescence = iridescence;\n\tmaterial.iridescenceIOR = iridescenceIOR;\n\t#ifdef USE_IRIDESCENCEMAP\n\t\tmaterial.iridescence *= texture2D( iridescenceMap, vIridescenceMapUv ).r;\n\t#endif\n\t#ifdef USE_IRIDESCENCE_THICKNESSMAP\n\t\tmaterial.iridescenceThickness = (iridescenceThicknessMaximum - iridescenceThicknessMinimum) * texture2D( iridescenceThicknessMap, vIridescenceThicknessMapUv ).g + iridescenceThicknessMinimum;\n\t#else\n\t\tmaterial.iridescenceThickness = iridescenceThicknessMaximum;\n\t#endif\n#endif\n#ifdef USE_SHEEN\n\tmaterial.sheenColor = sheenColor;\n\t#ifdef USE_SHEEN_COLORMAP\n\t\tmaterial.sheenColor *= texture2D( sheenColorMap, vSheenColorMapUv ).rgb;\n\t#endif\n\tmaterial.sheenRoughness = clamp( sheenRoughness, 0.07, 1.0 );\n\t#ifdef USE_SHEEN_ROUGHNESSMAP\n\t\tmaterial.sheenRoughness *= texture2D( sheenRoughnessMap, vSheenRoughnessMapUv ).a;\n\t#endif\n#endif\n#ifdef USE_ANISOTROPY\n\t#ifdef USE_ANISOTROPYMAP\n\t\tmat2 anisotropyMat = mat2( anisotropyVector.x, anisotropyVector.y, - anisotropyVector.y, anisotropyVector.x );\n\t\tvec3 anisotropyPolar = texture2D( anisotropyMap, vAnisotropyMapUv ).rgb;\n\t\tvec2 anisotropyV = anisotropyMat * normalize( 2.0 * anisotropyPolar.rg - vec2( 1.0 ) ) * anisotropyPolar.b;\n\t#else\n\t\tvec2 anisotropyV = anisotropyVector;\n\t#endif\n\tmaterial.anisotropy = length( anisotropyV );\n\tif( material.anisotropy == 0.0 ) {\n\t\tanisotropyV = vec2( 1.0, 0.0 );\n\t} else {\n\t\tanisotropyV /= material.anisotropy;\n\t\tmaterial.anisotropy = saturate( material.anisotropy );\n\t}\n\tmaterial.alphaT = mix( pow2( material.roughness ), 1.0, pow2( material.anisotropy ) );\n\tmaterial.anisotropyT = tbn[ 0 ] * anisotropyV.x + tbn[ 1 ] * anisotropyV.y;\n\tmaterial.anisotropyB = tbn[ 1 ] * anisotropyV.x - tbn[ 0 ] * anisotropyV.y;\n#endif",lights_physical_pars_fragment:"struct PhysicalMaterial {\n\tvec3 diffuseColor;\n\tfloat roughness;\n\tvec3 specularColor;\n\tfloat specularF90;\n\tfloat dispersion;\n\t#ifdef USE_CLEARCOAT\n\t\tfloat clearcoat;\n\t\tfloat clearcoatRoughness;\n\t\tvec3 clearcoatF0;\n\t\tfloat clearcoatF90;\n\t#endif\n\t#ifdef USE_IRIDESCENCE\n\t\tfloat iridescence;\n\t\tfloat iridescenceIOR;\n\t\tfloat iridescenceThickness;\n\t\tvec3 iridescenceFresnel;\n\t\tvec3 iridescenceF0;\n\t#endif\n\t#ifdef USE_SHEEN\n\t\tvec3 sheenColor;\n\t\tfloat sheenRoughness;\n\t#endif\n\t#ifdef IOR\n\t\tfloat ior;\n\t#endif\n\t#ifdef USE_TRANSMISSION\n\t\tfloat transmission;\n\t\tfloat transmissionAlpha;\n\t\tfloat thickness;\n\t\tfloat attenuationDistance;\n\t\tvec3 attenuationColor;\n\t#endif\n\t#ifdef USE_ANISOTROPY\n\t\tfloat anisotropy;\n\t\tfloat alphaT;\n\t\tvec3 anisotropyT;\n\t\tvec3 anisotropyB;\n\t#endif\n};\nvec3 clearcoatSpecularDirect = vec3( 0.0 );\nvec3 clearcoatSpecularIndirect = vec3( 0.0 );\nvec3 sheenSpecularDirect = vec3( 0.0 );\nvec3 sheenSpecularIndirect = vec3(0.0 );\nvec3 Schlick_to_F0( const in vec3 f, const in float f90, const in float dotVH ) {\n float x = clamp( 1.0 - dotVH, 0.0, 1.0 );\n float x2 = x * x;\n float x5 = clamp( x * x2 * x2, 0.0, 0.9999 );\n return ( f - vec3( f90 ) * x5 ) / ( 1.0 - x5 );\n}\nfloat V_GGX_SmithCorrelated( const in float alpha, const in float dotNL, const in float dotNV ) {\n\tfloat a2 = pow2( alpha );\n\tfloat gv = dotNL * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNV ) );\n\tfloat gl = dotNV * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNL ) );\n\treturn 0.5 / max( gv + gl, EPSILON );\n}\nfloat D_GGX( const in float alpha, const in float dotNH ) {\n\tfloat a2 = pow2( alpha );\n\tfloat denom = pow2( dotNH ) * ( a2 - 1.0 ) + 1.0;\n\treturn RECIPROCAL_PI * a2 / pow2( denom );\n}\n#ifdef USE_ANISOTROPY\n\tfloat V_GGX_SmithCorrelated_Anisotropic( const in float alphaT, const in float alphaB, const in float dotTV, const in float dotBV, const in float dotTL, const in float dotBL, const in float dotNV, const in float dotNL ) {\n\t\tfloat gv = dotNL * length( vec3( alphaT * dotTV, alphaB * dotBV, dotNV ) );\n\t\tfloat gl = dotNV * length( vec3( alphaT * dotTL, alphaB * dotBL, dotNL ) );\n\t\tfloat v = 0.5 / ( gv + gl );\n\t\treturn saturate(v);\n\t}\n\tfloat D_GGX_Anisotropic( const in float alphaT, const in float alphaB, const in float dotNH, const in float dotTH, const in float dotBH ) {\n\t\tfloat a2 = alphaT * alphaB;\n\t\thighp vec3 v = vec3( alphaB * dotTH, alphaT * dotBH, a2 * dotNH );\n\t\thighp float v2 = dot( v, v );\n\t\tfloat w2 = a2 / v2;\n\t\treturn RECIPROCAL_PI * a2 * pow2 ( w2 );\n\t}\n#endif\n#ifdef USE_CLEARCOAT\n\tvec3 BRDF_GGX_Clearcoat( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in PhysicalMaterial material) {\n\t\tvec3 f0 = material.clearcoatF0;\n\t\tfloat f90 = material.clearcoatF90;\n\t\tfloat roughness = material.clearcoatRoughness;\n\t\tfloat alpha = pow2( roughness );\n\t\tvec3 halfDir = normalize( lightDir + viewDir );\n\t\tfloat dotNL = saturate( dot( normal, lightDir ) );\n\t\tfloat dotNV = saturate( dot( normal, viewDir ) );\n\t\tfloat dotNH = saturate( dot( normal, halfDir ) );\n\t\tfloat dotVH = saturate( dot( viewDir, halfDir ) );\n\t\tvec3 F = F_Schlick( f0, f90, dotVH );\n\t\tfloat V = V_GGX_SmithCorrelated( alpha, dotNL, dotNV );\n\t\tfloat D = D_GGX( alpha, dotNH );\n\t\treturn F * ( V * D );\n\t}\n#endif\nvec3 BRDF_GGX( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in PhysicalMaterial material ) {\n\tvec3 f0 = material.specularColor;\n\tfloat f90 = material.specularF90;\n\tfloat roughness = material.roughness;\n\tfloat alpha = pow2( roughness );\n\tvec3 halfDir = normalize( lightDir + viewDir );\n\tfloat dotNL = saturate( dot( normal, lightDir ) );\n\tfloat dotNV = saturate( dot( normal, viewDir ) );\n\tfloat dotNH = saturate( dot( normal, halfDir ) );\n\tfloat dotVH = saturate( dot( viewDir, halfDir ) );\n\tvec3 F = F_Schlick( f0, f90, dotVH );\n\t#ifdef USE_IRIDESCENCE\n\t\tF = mix( F, material.iridescenceFresnel, material.iridescence );\n\t#endif\n\t#ifdef USE_ANISOTROPY\n\t\tfloat dotTL = dot( material.anisotropyT, lightDir );\n\t\tfloat dotTV = dot( material.anisotropyT, viewDir );\n\t\tfloat dotTH = dot( material.anisotropyT, halfDir );\n\t\tfloat dotBL = dot( material.anisotropyB, lightDir );\n\t\tfloat dotBV = dot( material.anisotropyB, viewDir );\n\t\tfloat dotBH = dot( material.anisotropyB, halfDir );\n\t\tfloat V = V_GGX_SmithCorrelated_Anisotropic( material.alphaT, alpha, dotTV, dotBV, dotTL, dotBL, dotNV, dotNL );\n\t\tfloat D = D_GGX_Anisotropic( material.alphaT, alpha, dotNH, dotTH, dotBH );\n\t#else\n\t\tfloat V = V_GGX_SmithCorrelated( alpha, dotNL, dotNV );\n\t\tfloat D = D_GGX( alpha, dotNH );\n\t#endif\n\treturn F * ( V * D );\n}\nvec2 LTC_Uv( const in vec3 N, const in vec3 V, const in float roughness ) {\n\tconst float LUT_SIZE = 64.0;\n\tconst float LUT_SCALE = ( LUT_SIZE - 1.0 ) / LUT_SIZE;\n\tconst float LUT_BIAS = 0.5 / LUT_SIZE;\n\tfloat dotNV = saturate( dot( N, V ) );\n\tvec2 uv = vec2( roughness, sqrt( 1.0 - dotNV ) );\n\tuv = uv * LUT_SCALE + LUT_BIAS;\n\treturn uv;\n}\nfloat LTC_ClippedSphereFormFactor( const in vec3 f ) {\n\tfloat l = length( f );\n\treturn max( ( l * l + f.z ) / ( l + 1.0 ), 0.0 );\n}\nvec3 LTC_EdgeVectorFormFactor( const in vec3 v1, const in vec3 v2 ) {\n\tfloat x = dot( v1, v2 );\n\tfloat y = abs( x );\n\tfloat a = 0.8543985 + ( 0.4965155 + 0.0145206 * y ) * y;\n\tfloat b = 3.4175940 + ( 4.1616724 + y ) * y;\n\tfloat v = a / b;\n\tfloat theta_sintheta = ( x > 0.0 ) ? v : 0.5 * inversesqrt( max( 1.0 - x * x, 1e-7 ) ) - v;\n\treturn cross( v1, v2 ) * theta_sintheta;\n}\nvec3 LTC_Evaluate( const in vec3 N, const in vec3 V, const in vec3 P, const in mat3 mInv, const in vec3 rectCoords[ 4 ] ) {\n\tvec3 v1 = rectCoords[ 1 ] - rectCoords[ 0 ];\n\tvec3 v2 = rectCoords[ 3 ] - rectCoords[ 0 ];\n\tvec3 lightNormal = cross( v1, v2 );\n\tif( dot( lightNormal, P - rectCoords[ 0 ] ) < 0.0 ) return vec3( 0.0 );\n\tvec3 T1, T2;\n\tT1 = normalize( V - N * dot( V, N ) );\n\tT2 = - cross( N, T1 );\n\tmat3 mat = mInv * transposeMat3( mat3( T1, T2, N ) );\n\tvec3 coords[ 4 ];\n\tcoords[ 0 ] = mat * ( rectCoords[ 0 ] - P );\n\tcoords[ 1 ] = mat * ( rectCoords[ 1 ] - P );\n\tcoords[ 2 ] = mat * ( rectCoords[ 2 ] - P );\n\tcoords[ 3 ] = mat * ( rectCoords[ 3 ] - P );\n\tcoords[ 0 ] = normalize( coords[ 0 ] );\n\tcoords[ 1 ] = normalize( coords[ 1 ] );\n\tcoords[ 2 ] = normalize( coords[ 2 ] );\n\tcoords[ 3 ] = normalize( coords[ 3 ] );\n\tvec3 vectorFormFactor = vec3( 0.0 );\n\tvectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 0 ], coords[ 1 ] );\n\tvectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 1 ], coords[ 2 ] );\n\tvectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 2 ], coords[ 3 ] );\n\tvectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 3 ], coords[ 0 ] );\n\tfloat result = LTC_ClippedSphereFormFactor( vectorFormFactor );\n\treturn vec3( result );\n}\n#if defined( USE_SHEEN )\nfloat D_Charlie( float roughness, float dotNH ) {\n\tfloat alpha = pow2( roughness );\n\tfloat invAlpha = 1.0 / alpha;\n\tfloat cos2h = dotNH * dotNH;\n\tfloat sin2h = max( 1.0 - cos2h, 0.0078125 );\n\treturn ( 2.0 + invAlpha ) * pow( sin2h, invAlpha * 0.5 ) / ( 2.0 * PI );\n}\nfloat V_Neubelt( float dotNV, float dotNL ) {\n\treturn saturate( 1.0 / ( 4.0 * ( dotNL + dotNV - dotNL * dotNV ) ) );\n}\nvec3 BRDF_Sheen( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, vec3 sheenColor, const in float sheenRoughness ) {\n\tvec3 halfDir = normalize( lightDir + viewDir );\n\tfloat dotNL = saturate( dot( normal, lightDir ) );\n\tfloat dotNV = saturate( dot( normal, viewDir ) );\n\tfloat dotNH = saturate( dot( normal, halfDir ) );\n\tfloat D = D_Charlie( sheenRoughness, dotNH );\n\tfloat V = V_Neubelt( dotNV, dotNL );\n\treturn sheenColor * ( D * V );\n}\n#endif\nfloat IBLSheenBRDF( const in vec3 normal, const in vec3 viewDir, const in float roughness ) {\n\tfloat dotNV = saturate( dot( normal, viewDir ) );\n\tfloat r2 = roughness * roughness;\n\tfloat a = roughness < 0.25 ? -339.2 * r2 + 161.4 * roughness - 25.9 : -8.48 * r2 + 14.3 * roughness - 9.95;\n\tfloat b = roughness < 0.25 ? 44.0 * r2 - 23.7 * roughness + 3.26 : 1.97 * r2 - 3.27 * roughness + 0.72;\n\tfloat DG = exp( a * dotNV + b ) + ( roughness < 0.25 ? 0.0 : 0.1 * ( roughness - 0.25 ) );\n\treturn saturate( DG * RECIPROCAL_PI );\n}\nvec2 DFGApprox( const in vec3 normal, const in vec3 viewDir, const in float roughness ) {\n\tfloat dotNV = saturate( dot( normal, viewDir ) );\n\tconst vec4 c0 = vec4( - 1, - 0.0275, - 0.572, 0.022 );\n\tconst vec4 c1 = vec4( 1, 0.0425, 1.04, - 0.04 );\n\tvec4 r = roughness * c0 + c1;\n\tfloat a004 = min( r.x * r.x, exp2( - 9.28 * dotNV ) ) * r.x + r.y;\n\tvec2 fab = vec2( - 1.04, 1.04 ) * a004 + r.zw;\n\treturn fab;\n}\nvec3 EnvironmentBRDF( const in vec3 normal, const in vec3 viewDir, const in vec3 specularColor, const in float specularF90, const in float roughness ) {\n\tvec2 fab = DFGApprox( normal, viewDir, roughness );\n\treturn specularColor * fab.x + specularF90 * fab.y;\n}\n#ifdef USE_IRIDESCENCE\nvoid computeMultiscatteringIridescence( const in vec3 normal, const in vec3 viewDir, const in vec3 specularColor, const in float specularF90, const in float iridescence, const in vec3 iridescenceF0, const in float roughness, inout vec3 singleScatter, inout vec3 multiScatter ) {\n#else\nvoid computeMultiscattering( const in vec3 normal, const in vec3 viewDir, const in vec3 specularColor, const in float specularF90, const in float roughness, inout vec3 singleScatter, inout vec3 multiScatter ) {\n#endif\n\tvec2 fab = DFGApprox( normal, viewDir, roughness );\n\t#ifdef USE_IRIDESCENCE\n\t\tvec3 Fr = mix( specularColor, iridescenceF0, iridescence );\n\t#else\n\t\tvec3 Fr = specularColor;\n\t#endif\n\tvec3 FssEss = Fr * fab.x + specularF90 * fab.y;\n\tfloat Ess = fab.x + fab.y;\n\tfloat Ems = 1.0 - Ess;\n\tvec3 Favg = Fr + ( 1.0 - Fr ) * 0.047619;\tvec3 Fms = FssEss * Favg / ( 1.0 - Ems * Favg );\n\tsingleScatter += FssEss;\n\tmultiScatter += Fms * Ems;\n}\n#if NUM_RECT_AREA_LIGHTS > 0\n\tvoid RE_Direct_RectArea_Physical( const in RectAreaLight rectAreaLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {\n\t\tvec3 normal = geometryNormal;\n\t\tvec3 viewDir = geometryViewDir;\n\t\tvec3 position = geometryPosition;\n\t\tvec3 lightPos = rectAreaLight.position;\n\t\tvec3 halfWidth = rectAreaLight.halfWidth;\n\t\tvec3 halfHeight = rectAreaLight.halfHeight;\n\t\tvec3 lightColor = rectAreaLight.color;\n\t\tfloat roughness = material.roughness;\n\t\tvec3 rectCoords[ 4 ];\n\t\trectCoords[ 0 ] = lightPos + halfWidth - halfHeight;\t\trectCoords[ 1 ] = lightPos - halfWidth - halfHeight;\n\t\trectCoords[ 2 ] = lightPos - halfWidth + halfHeight;\n\t\trectCoords[ 3 ] = lightPos + halfWidth + halfHeight;\n\t\tvec2 uv = LTC_Uv( normal, viewDir, roughness );\n\t\tvec4 t1 = texture2D( ltc_1, uv );\n\t\tvec4 t2 = texture2D( ltc_2, uv );\n\t\tmat3 mInv = mat3(\n\t\t\tvec3( t1.x, 0, t1.y ),\n\t\t\tvec3( 0, 1, 0 ),\n\t\t\tvec3( t1.z, 0, t1.w )\n\t\t);\n\t\tvec3 fresnel = ( material.specularColor * t2.x + ( vec3( 1.0 ) - material.specularColor ) * t2.y );\n\t\treflectedLight.directSpecular += lightColor * fresnel * LTC_Evaluate( normal, viewDir, position, mInv, rectCoords );\n\t\treflectedLight.directDiffuse += lightColor * material.diffuseColor * LTC_Evaluate( normal, viewDir, position, mat3( 1.0 ), rectCoords );\n\t}\n#endif\nvoid RE_Direct_Physical( const in IncidentLight directLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {\n\tfloat dotNL = saturate( dot( geometryNormal, directLight.direction ) );\n\tvec3 irradiance = dotNL * directLight.color;\n\t#ifdef USE_CLEARCOAT\n\t\tfloat dotNLcc = saturate( dot( geometryClearcoatNormal, directLight.direction ) );\n\t\tvec3 ccIrradiance = dotNLcc * directLight.color;\n\t\tclearcoatSpecularDirect += ccIrradiance * BRDF_GGX_Clearcoat( directLight.direction, geometryViewDir, geometryClearcoatNormal, material );\n\t#endif\n\t#ifdef USE_SHEEN\n\t\tsheenSpecularDirect += irradiance * BRDF_Sheen( directLight.direction, geometryViewDir, geometryNormal, material.sheenColor, material.sheenRoughness );\n\t#endif\n\treflectedLight.directSpecular += irradiance * BRDF_GGX( directLight.direction, geometryViewDir, geometryNormal, material );\n\treflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );\n}\nvoid RE_IndirectDiffuse_Physical( const in vec3 irradiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {\n\treflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );\n}\nvoid RE_IndirectSpecular_Physical( const in vec3 radiance, const in vec3 irradiance, const in vec3 clearcoatRadiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in PhysicalMaterial material, inout ReflectedLight reflectedLight) {\n\t#ifdef USE_CLEARCOAT\n\t\tclearcoatSpecularIndirect += clearcoatRadiance * EnvironmentBRDF( geometryClearcoatNormal, geometryViewDir, material.clearcoatF0, material.clearcoatF90, material.clearcoatRoughness );\n\t#endif\n\t#ifdef USE_SHEEN\n\t\tsheenSpecularIndirect += irradiance * material.sheenColor * IBLSheenBRDF( geometryNormal, geometryViewDir, material.sheenRoughness );\n\t#endif\n\tvec3 singleScattering = vec3( 0.0 );\n\tvec3 multiScattering = vec3( 0.0 );\n\tvec3 cosineWeightedIrradiance = irradiance * RECIPROCAL_PI;\n\t#ifdef USE_IRIDESCENCE\n\t\tcomputeMultiscatteringIridescence( geometryNormal, geometryViewDir, material.specularColor, material.specularF90, material.iridescence, material.iridescenceFresnel, material.roughness, singleScattering, multiScattering );\n\t#else\n\t\tcomputeMultiscattering( geometryNormal, geometryViewDir, material.specularColor, material.specularF90, material.roughness, singleScattering, multiScattering );\n\t#endif\n\tvec3 totalScattering = singleScattering + multiScattering;\n\tvec3 diffuse = material.diffuseColor * ( 1.0 - max( max( totalScattering.r, totalScattering.g ), totalScattering.b ) );\n\treflectedLight.indirectSpecular += radiance * singleScattering;\n\treflectedLight.indirectSpecular += multiScattering * cosineWeightedIrradiance;\n\treflectedLight.indirectDiffuse += diffuse * cosineWeightedIrradiance;\n}\n#define RE_Direct\t\t\t\tRE_Direct_Physical\n#define RE_Direct_RectArea\t\tRE_Direct_RectArea_Physical\n#define RE_IndirectDiffuse\t\tRE_IndirectDiffuse_Physical\n#define RE_IndirectSpecular\t\tRE_IndirectSpecular_Physical\nfloat computeSpecularOcclusion( const in float dotNV, const in float ambientOcclusion, const in float roughness ) {\n\treturn saturate( pow( dotNV + ambientOcclusion, exp2( - 16.0 * roughness - 1.0 ) ) - 1.0 + ambientOcclusion );\n}",lights_fragment_begin:"\nvec3 geometryPosition = - vViewPosition;\nvec3 geometryNormal = normal;\nvec3 geometryViewDir = ( isOrthographic ) ? vec3( 0, 0, 1 ) : normalize( vViewPosition );\nvec3 geometryClearcoatNormal = vec3( 0.0 );\n#ifdef USE_CLEARCOAT\n\tgeometryClearcoatNormal = clearcoatNormal;\n#endif\n#ifdef USE_IRIDESCENCE\n\tfloat dotNVi = saturate( dot( normal, geometryViewDir ) );\n\tif ( material.iridescenceThickness == 0.0 ) {\n\t\tmaterial.iridescence = 0.0;\n\t} else {\n\t\tmaterial.iridescence = saturate( material.iridescence );\n\t}\n\tif ( material.iridescence > 0.0 ) {\n\t\tmaterial.iridescenceFresnel = evalIridescence( 1.0, material.iridescenceIOR, dotNVi, material.iridescenceThickness, material.specularColor );\n\t\tmaterial.iridescenceF0 = Schlick_to_F0( material.iridescenceFresnel, 1.0, dotNVi );\n\t}\n#endif\nIncidentLight directLight;\n#if ( NUM_POINT_LIGHTS > 0 ) && defined( RE_Direct )\n\tPointLight pointLight;\n\t#if defined( USE_SHADOWMAP ) && NUM_POINT_LIGHT_SHADOWS > 0\n\tPointLightShadow pointLightShadow;\n\t#endif\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_POINT_LIGHTS; i ++ ) {\n\t\tpointLight = pointLights[ i ];\n\t\tgetPointLightInfo( pointLight, geometryPosition, directLight );\n\t\t#if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_POINT_LIGHT_SHADOWS )\n\t\tpointLightShadow = pointLightShadows[ i ];\n\t\tdirectLight.color *= ( directLight.visible && receiveShadow ) ? getPointShadow( pointShadowMap[ i ], pointLightShadow.shadowMapSize, pointLightShadow.shadowIntensity, pointLightShadow.shadowBias, pointLightShadow.shadowRadius, vPointShadowCoord[ i ], pointLightShadow.shadowCameraNear, pointLightShadow.shadowCameraFar ) : 1.0;\n\t\t#endif\n\t\tRE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );\n\t}\n\t#pragma unroll_loop_end\n#endif\n#if ( NUM_SPOT_LIGHTS > 0 ) && defined( RE_Direct )\n\tSpotLight spotLight;\n\tvec4 spotColor;\n\tvec3 spotLightCoord;\n\tbool inSpotLightMap;\n\t#if defined( USE_SHADOWMAP ) && NUM_SPOT_LIGHT_SHADOWS > 0\n\tSpotLightShadow spotLightShadow;\n\t#endif\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_SPOT_LIGHTS; i ++ ) {\n\t\tspotLight = spotLights[ i ];\n\t\tgetSpotLightInfo( spotLight, geometryPosition, directLight );\n\t\t#if ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS )\n\t\t#define SPOT_LIGHT_MAP_INDEX UNROLLED_LOOP_INDEX\n\t\t#elif ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS )\n\t\t#define SPOT_LIGHT_MAP_INDEX NUM_SPOT_LIGHT_MAPS\n\t\t#else\n\t\t#define SPOT_LIGHT_MAP_INDEX ( UNROLLED_LOOP_INDEX - NUM_SPOT_LIGHT_SHADOWS + NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS )\n\t\t#endif\n\t\t#if ( SPOT_LIGHT_MAP_INDEX < NUM_SPOT_LIGHT_MAPS )\n\t\t\tspotLightCoord = vSpotLightCoord[ i ].xyz / vSpotLightCoord[ i ].w;\n\t\t\tinSpotLightMap = all( lessThan( abs( spotLightCoord * 2. - 1. ), vec3( 1.0 ) ) );\n\t\t\tspotColor = texture2D( spotLightMap[ SPOT_LIGHT_MAP_INDEX ], spotLightCoord.xy );\n\t\t\tdirectLight.color = inSpotLightMap ? directLight.color * spotColor.rgb : directLight.color;\n\t\t#endif\n\t\t#undef SPOT_LIGHT_MAP_INDEX\n\t\t#if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS )\n\t\tspotLightShadow = spotLightShadows[ i ];\n\t\tdirectLight.color *= ( directLight.visible && receiveShadow ) ? getShadow( spotShadowMap[ i ], spotLightShadow.shadowMapSize, spotLightShadow.shadowIntensity, spotLightShadow.shadowBias, spotLightShadow.shadowRadius, vSpotLightCoord[ i ] ) : 1.0;\n\t\t#endif\n\t\tRE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );\n\t}\n\t#pragma unroll_loop_end\n#endif\n#if ( NUM_DIR_LIGHTS > 0 ) && defined( RE_Direct )\n\tDirectionalLight directionalLight;\n\t#if defined( USE_SHADOWMAP ) && NUM_DIR_LIGHT_SHADOWS > 0\n\tDirectionalLightShadow directionalLightShadow;\n\t#endif\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_DIR_LIGHTS; i ++ ) {\n\t\tdirectionalLight = directionalLights[ i ];\n\t\tgetDirectionalLightInfo( directionalLight, directLight );\n\t\t#if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_DIR_LIGHT_SHADOWS )\n\t\tdirectionalLightShadow = directionalLightShadows[ i ];\n\t\tdirectLight.color *= ( directLight.visible && receiveShadow ) ? getShadow( directionalShadowMap[ i ], directionalLightShadow.shadowMapSize, directionalLightShadow.shadowIntensity, directionalLightShadow.shadowBias, directionalLightShadow.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0;\n\t\t#endif\n\t\tRE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );\n\t}\n\t#pragma unroll_loop_end\n#endif\n#if ( NUM_RECT_AREA_LIGHTS > 0 ) && defined( RE_Direct_RectArea )\n\tRectAreaLight rectAreaLight;\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_RECT_AREA_LIGHTS; i ++ ) {\n\t\trectAreaLight = rectAreaLights[ i ];\n\t\tRE_Direct_RectArea( rectAreaLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );\n\t}\n\t#pragma unroll_loop_end\n#endif\n#if defined( RE_IndirectDiffuse )\n\tvec3 iblIrradiance = vec3( 0.0 );\n\tvec3 irradiance = getAmbientLightIrradiance( ambientLightColor );\n\t#if defined( USE_LIGHT_PROBES )\n\t\tirradiance += getLightProbeIrradiance( lightProbe, geometryNormal );\n\t#endif\n\t#if ( NUM_HEMI_LIGHTS > 0 )\n\t\t#pragma unroll_loop_start\n\t\tfor ( int i = 0; i < NUM_HEMI_LIGHTS; i ++ ) {\n\t\t\tirradiance += getHemisphereLightIrradiance( hemisphereLights[ i ], geometryNormal );\n\t\t}\n\t\t#pragma unroll_loop_end\n\t#endif\n#endif\n#if defined( RE_IndirectSpecular )\n\tvec3 radiance = vec3( 0.0 );\n\tvec3 clearcoatRadiance = vec3( 0.0 );\n#endif",lights_fragment_maps:"#if defined( RE_IndirectDiffuse )\n\t#ifdef USE_LIGHTMAP\n\t\tvec4 lightMapTexel = texture2D( lightMap, vLightMapUv );\n\t\tvec3 lightMapIrradiance = lightMapTexel.rgb * lightMapIntensity;\n\t\tirradiance += lightMapIrradiance;\n\t#endif\n\t#if defined( USE_ENVMAP ) && defined( STANDARD ) && defined( ENVMAP_TYPE_CUBE_UV )\n\t\tiblIrradiance += getIBLIrradiance( geometryNormal );\n\t#endif\n#endif\n#if defined( USE_ENVMAP ) && defined( RE_IndirectSpecular )\n\t#ifdef USE_ANISOTROPY\n\t\tradiance += getIBLAnisotropyRadiance( geometryViewDir, geometryNormal, material.roughness, material.anisotropyB, material.anisotropy );\n\t#else\n\t\tradiance += getIBLRadiance( geometryViewDir, geometryNormal, material.roughness );\n\t#endif\n\t#ifdef USE_CLEARCOAT\n\t\tclearcoatRadiance += getIBLRadiance( geometryViewDir, geometryClearcoatNormal, material.clearcoatRoughness );\n\t#endif\n#endif",lights_fragment_end:"#if defined( RE_IndirectDiffuse )\n\tRE_IndirectDiffuse( irradiance, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );\n#endif\n#if defined( RE_IndirectSpecular )\n\tRE_IndirectSpecular( radiance, iblIrradiance, clearcoatRadiance, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );\n#endif",logdepthbuf_fragment:"#if defined( USE_LOGDEPTHBUF )\n\tgl_FragDepth = vIsPerspective == 0.0 ? gl_FragCoord.z : log2( vFragDepth ) * logDepthBufFC * 0.5;\n#endif",logdepthbuf_pars_fragment:"#if defined( USE_LOGDEPTHBUF )\n\tuniform float logDepthBufFC;\n\tvarying float vFragDepth;\n\tvarying float vIsPerspective;\n#endif",logdepthbuf_pars_vertex:"#ifdef USE_LOGDEPTHBUF\n\tvarying float vFragDepth;\n\tvarying float vIsPerspective;\n#endif",logdepthbuf_vertex:"#ifdef USE_LOGDEPTHBUF\n\tvFragDepth = 1.0 + gl_Position.w;\n\tvIsPerspective = float( isPerspectiveMatrix( projectionMatrix ) );\n#endif",map_fragment:"#ifdef USE_MAP\n\tvec4 sampledDiffuseColor = texture2D( map, vMapUv );\n\t#ifdef DECODE_VIDEO_TEXTURE\n\t\tsampledDiffuseColor = sRGBTransferEOTF( sampledDiffuseColor );\n\t#endif\n\tdiffuseColor *= sampledDiffuseColor;\n#endif",map_pars_fragment:"#ifdef USE_MAP\n\tuniform sampler2D map;\n#endif",map_particle_fragment:"#if defined( USE_MAP ) || defined( USE_ALPHAMAP )\n\t#if defined( USE_POINTS_UV )\n\t\tvec2 uv = vUv;\n\t#else\n\t\tvec2 uv = ( uvTransform * vec3( gl_PointCoord.x, 1.0 - gl_PointCoord.y, 1 ) ).xy;\n\t#endif\n#endif\n#ifdef USE_MAP\n\tdiffuseColor *= texture2D( map, uv );\n#endif\n#ifdef USE_ALPHAMAP\n\tdiffuseColor.a *= texture2D( alphaMap, uv ).g;\n#endif",map_particle_pars_fragment:"#if defined( USE_POINTS_UV )\n\tvarying vec2 vUv;\n#else\n\t#if defined( USE_MAP ) || defined( USE_ALPHAMAP )\n\t\tuniform mat3 uvTransform;\n\t#endif\n#endif\n#ifdef USE_MAP\n\tuniform sampler2D map;\n#endif\n#ifdef USE_ALPHAMAP\n\tuniform sampler2D alphaMap;\n#endif",metalnessmap_fragment:"float metalnessFactor = metalness;\n#ifdef USE_METALNESSMAP\n\tvec4 texelMetalness = texture2D( metalnessMap, vMetalnessMapUv );\n\tmetalnessFactor *= texelMetalness.b;\n#endif",metalnessmap_pars_fragment:"#ifdef USE_METALNESSMAP\n\tuniform sampler2D metalnessMap;\n#endif",morphinstance_vertex:"#ifdef USE_INSTANCING_MORPH\n\tfloat morphTargetInfluences[ MORPHTARGETS_COUNT ];\n\tfloat morphTargetBaseInfluence = texelFetch( morphTexture, ivec2( 0, gl_InstanceID ), 0 ).r;\n\tfor ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {\n\t\tmorphTargetInfluences[i] = texelFetch( morphTexture, ivec2( i + 1, gl_InstanceID ), 0 ).r;\n\t}\n#endif",morphcolor_vertex:"#if defined( USE_MORPHCOLORS )\n\tvColor *= morphTargetBaseInfluence;\n\tfor ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {\n\t\t#if defined( USE_COLOR_ALPHA )\n\t\t\tif ( morphTargetInfluences[ i ] != 0.0 ) vColor += getMorph( gl_VertexID, i, 2 ) * morphTargetInfluences[ i ];\n\t\t#elif defined( USE_COLOR )\n\t\t\tif ( morphTargetInfluences[ i ] != 0.0 ) vColor += getMorph( gl_VertexID, i, 2 ).rgb * morphTargetInfluences[ i ];\n\t\t#endif\n\t}\n#endif",morphnormal_vertex:"#ifdef USE_MORPHNORMALS\n\tobjectNormal *= morphTargetBaseInfluence;\n\tfor ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {\n\t\tif ( morphTargetInfluences[ i ] != 0.0 ) objectNormal += getMorph( gl_VertexID, i, 1 ).xyz * morphTargetInfluences[ i ];\n\t}\n#endif",morphtarget_pars_vertex:"#ifdef USE_MORPHTARGETS\n\t#ifndef USE_INSTANCING_MORPH\n\t\tuniform float morphTargetBaseInfluence;\n\t\tuniform float morphTargetInfluences[ MORPHTARGETS_COUNT ];\n\t#endif\n\tuniform sampler2DArray morphTargetsTexture;\n\tuniform ivec2 morphTargetsTextureSize;\n\tvec4 getMorph( const in int vertexIndex, const in int morphTargetIndex, const in int offset ) {\n\t\tint texelIndex = vertexIndex * MORPHTARGETS_TEXTURE_STRIDE + offset;\n\t\tint y = texelIndex / morphTargetsTextureSize.x;\n\t\tint x = texelIndex - y * morphTargetsTextureSize.x;\n\t\tivec3 morphUV = ivec3( x, y, morphTargetIndex );\n\t\treturn texelFetch( morphTargetsTexture, morphUV, 0 );\n\t}\n#endif",morphtarget_vertex:"#ifdef USE_MORPHTARGETS\n\ttransformed *= morphTargetBaseInfluence;\n\tfor ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {\n\t\tif ( morphTargetInfluences[ i ] != 0.0 ) transformed += getMorph( gl_VertexID, i, 0 ).xyz * morphTargetInfluences[ i ];\n\t}\n#endif",normal_fragment_begin:"float faceDirection = gl_FrontFacing ? 1.0 : - 1.0;\n#ifdef FLAT_SHADED\n\tvec3 fdx = dFdx( vViewPosition );\n\tvec3 fdy = dFdy( vViewPosition );\n\tvec3 normal = normalize( cross( fdx, fdy ) );\n#else\n\tvec3 normal = normalize( vNormal );\n\t#ifdef DOUBLE_SIDED\n\t\tnormal *= faceDirection;\n\t#endif\n#endif\n#if defined( USE_NORMALMAP_TANGENTSPACE ) || defined( USE_CLEARCOAT_NORMALMAP ) || defined( USE_ANISOTROPY )\n\t#ifdef USE_TANGENT\n\t\tmat3 tbn = mat3( normalize( vTangent ), normalize( vBitangent ), normal );\n\t#else\n\t\tmat3 tbn = getTangentFrame( - vViewPosition, normal,\n\t\t#if defined( USE_NORMALMAP )\n\t\t\tvNormalMapUv\n\t\t#elif defined( USE_CLEARCOAT_NORMALMAP )\n\t\t\tvClearcoatNormalMapUv\n\t\t#else\n\t\t\tvUv\n\t\t#endif\n\t\t);\n\t#endif\n\t#if defined( DOUBLE_SIDED ) && ! defined( FLAT_SHADED )\n\t\ttbn[0] *= faceDirection;\n\t\ttbn[1] *= faceDirection;\n\t#endif\n#endif\n#ifdef USE_CLEARCOAT_NORMALMAP\n\t#ifdef USE_TANGENT\n\t\tmat3 tbn2 = mat3( normalize( vTangent ), normalize( vBitangent ), normal );\n\t#else\n\t\tmat3 tbn2 = getTangentFrame( - vViewPosition, normal, vClearcoatNormalMapUv );\n\t#endif\n\t#if defined( DOUBLE_SIDED ) && ! defined( FLAT_SHADED )\n\t\ttbn2[0] *= faceDirection;\n\t\ttbn2[1] *= faceDirection;\n\t#endif\n#endif\nvec3 nonPerturbedNormal = normal;",normal_fragment_maps:"#ifdef USE_NORMALMAP_OBJECTSPACE\n\tnormal = texture2D( normalMap, vNormalMapUv ).xyz * 2.0 - 1.0;\n\t#ifdef FLIP_SIDED\n\t\tnormal = - normal;\n\t#endif\n\t#ifdef DOUBLE_SIDED\n\t\tnormal = normal * faceDirection;\n\t#endif\n\tnormal = normalize( normalMatrix * normal );\n#elif defined( USE_NORMALMAP_TANGENTSPACE )\n\tvec3 mapN = texture2D( normalMap, vNormalMapUv ).xyz * 2.0 - 1.0;\n\tmapN.xy *= normalScale;\n\tnormal = normalize( tbn * mapN );\n#elif defined( USE_BUMPMAP )\n\tnormal = perturbNormalArb( - vViewPosition, normal, dHdxy_fwd(), faceDirection );\n#endif",normal_pars_fragment:"#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n\t#ifdef USE_TANGENT\n\t\tvarying vec3 vTangent;\n\t\tvarying vec3 vBitangent;\n\t#endif\n#endif",normal_pars_vertex:"#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n\t#ifdef USE_TANGENT\n\t\tvarying vec3 vTangent;\n\t\tvarying vec3 vBitangent;\n\t#endif\n#endif",normal_vertex:"#ifndef FLAT_SHADED\n\tvNormal = normalize( transformedNormal );\n\t#ifdef USE_TANGENT\n\t\tvTangent = normalize( transformedTangent );\n\t\tvBitangent = normalize( cross( vNormal, vTangent ) * tangent.w );\n\t#endif\n#endif",normalmap_pars_fragment:"#ifdef USE_NORMALMAP\n\tuniform sampler2D normalMap;\n\tuniform vec2 normalScale;\n#endif\n#ifdef USE_NORMALMAP_OBJECTSPACE\n\tuniform mat3 normalMatrix;\n#endif\n#if ! defined ( USE_TANGENT ) && ( defined ( USE_NORMALMAP_TANGENTSPACE ) || defined ( USE_CLEARCOAT_NORMALMAP ) || defined( USE_ANISOTROPY ) )\n\tmat3 getTangentFrame( vec3 eye_pos, vec3 surf_norm, vec2 uv ) {\n\t\tvec3 q0 = dFdx( eye_pos.xyz );\n\t\tvec3 q1 = dFdy( eye_pos.xyz );\n\t\tvec2 st0 = dFdx( uv.st );\n\t\tvec2 st1 = dFdy( uv.st );\n\t\tvec3 N = surf_norm;\n\t\tvec3 q1perp = cross( q1, N );\n\t\tvec3 q0perp = cross( N, q0 );\n\t\tvec3 T = q1perp * st0.x + q0perp * st1.x;\n\t\tvec3 B = q1perp * st0.y + q0perp * st1.y;\n\t\tfloat det = max( dot( T, T ), dot( B, B ) );\n\t\tfloat scale = ( det == 0.0 ) ? 0.0 : inversesqrt( det );\n\t\treturn mat3( T * scale, B * scale, N );\n\t}\n#endif",clearcoat_normal_fragment_begin:"#ifdef USE_CLEARCOAT\n\tvec3 clearcoatNormal = nonPerturbedNormal;\n#endif",clearcoat_normal_fragment_maps:"#ifdef USE_CLEARCOAT_NORMALMAP\n\tvec3 clearcoatMapN = texture2D( clearcoatNormalMap, vClearcoatNormalMapUv ).xyz * 2.0 - 1.0;\n\tclearcoatMapN.xy *= clearcoatNormalScale;\n\tclearcoatNormal = normalize( tbn2 * clearcoatMapN );\n#endif",clearcoat_pars_fragment:"#ifdef USE_CLEARCOATMAP\n\tuniform sampler2D clearcoatMap;\n#endif\n#ifdef USE_CLEARCOAT_NORMALMAP\n\tuniform sampler2D clearcoatNormalMap;\n\tuniform vec2 clearcoatNormalScale;\n#endif\n#ifdef USE_CLEARCOAT_ROUGHNESSMAP\n\tuniform sampler2D clearcoatRoughnessMap;\n#endif",iridescence_pars_fragment:"#ifdef USE_IRIDESCENCEMAP\n\tuniform sampler2D iridescenceMap;\n#endif\n#ifdef USE_IRIDESCENCE_THICKNESSMAP\n\tuniform sampler2D iridescenceThicknessMap;\n#endif",opaque_fragment:"#ifdef OPAQUE\ndiffuseColor.a = 1.0;\n#endif\n#ifdef USE_TRANSMISSION\ndiffuseColor.a *= material.transmissionAlpha;\n#endif\ngl_FragColor = vec4( outgoingLight, diffuseColor.a );",packing:"vec3 packNormalToRGB( const in vec3 normal ) {\n\treturn normalize( normal ) * 0.5 + 0.5;\n}\nvec3 unpackRGBToNormal( const in vec3 rgb ) {\n\treturn 2.0 * rgb.xyz - 1.0;\n}\nconst float PackUpscale = 256. / 255.;const float UnpackDownscale = 255. / 256.;const float ShiftRight8 = 1. / 256.;\nconst float Inv255 = 1. / 255.;\nconst vec4 PackFactors = vec4( 1.0, 256.0, 256.0 * 256.0, 256.0 * 256.0 * 256.0 );\nconst vec2 UnpackFactors2 = vec2( UnpackDownscale, 1.0 / PackFactors.g );\nconst vec3 UnpackFactors3 = vec3( UnpackDownscale / PackFactors.rg, 1.0 / PackFactors.b );\nconst vec4 UnpackFactors4 = vec4( UnpackDownscale / PackFactors.rgb, 1.0 / PackFactors.a );\nvec4 packDepthToRGBA( const in float v ) {\n\tif( v <= 0.0 )\n\t\treturn vec4( 0., 0., 0., 0. );\n\tif( v >= 1.0 )\n\t\treturn vec4( 1., 1., 1., 1. );\n\tfloat vuf;\n\tfloat af = modf( v * PackFactors.a, vuf );\n\tfloat bf = modf( vuf * ShiftRight8, vuf );\n\tfloat gf = modf( vuf * ShiftRight8, vuf );\n\treturn vec4( vuf * Inv255, gf * PackUpscale, bf * PackUpscale, af );\n}\nvec3 packDepthToRGB( const in float v ) {\n\tif( v <= 0.0 )\n\t\treturn vec3( 0., 0., 0. );\n\tif( v >= 1.0 )\n\t\treturn vec3( 1., 1., 1. );\n\tfloat vuf;\n\tfloat bf = modf( v * PackFactors.b, vuf );\n\tfloat gf = modf( vuf * ShiftRight8, vuf );\n\treturn vec3( vuf * Inv255, gf * PackUpscale, bf );\n}\nvec2 packDepthToRG( const in float v ) {\n\tif( v <= 0.0 )\n\t\treturn vec2( 0., 0. );\n\tif( v >= 1.0 )\n\t\treturn vec2( 1., 1. );\n\tfloat vuf;\n\tfloat gf = modf( v * 256., vuf );\n\treturn vec2( vuf * Inv255, gf );\n}\nfloat unpackRGBAToDepth( const in vec4 v ) {\n\treturn dot( v, UnpackFactors4 );\n}\nfloat unpackRGBToDepth( const in vec3 v ) {\n\treturn dot( v, UnpackFactors3 );\n}\nfloat unpackRGToDepth( const in vec2 v ) {\n\treturn v.r * UnpackFactors2.r + v.g * UnpackFactors2.g;\n}\nvec4 pack2HalfToRGBA( const in vec2 v ) {\n\tvec4 r = vec4( v.x, fract( v.x * 255.0 ), v.y, fract( v.y * 255.0 ) );\n\treturn vec4( r.x - r.y / 255.0, r.y, r.z - r.w / 255.0, r.w );\n}\nvec2 unpackRGBATo2Half( const in vec4 v ) {\n\treturn vec2( v.x + ( v.y / 255.0 ), v.z + ( v.w / 255.0 ) );\n}\nfloat viewZToOrthographicDepth( const in float viewZ, const in float near, const in float far ) {\n\treturn ( viewZ + near ) / ( near - far );\n}\nfloat orthographicDepthToViewZ( const in float depth, const in float near, const in float far ) {\n\treturn depth * ( near - far ) - near;\n}\nfloat viewZToPerspectiveDepth( const in float viewZ, const in float near, const in float far ) {\n\treturn ( ( near + viewZ ) * far ) / ( ( far - near ) * viewZ );\n}\nfloat perspectiveDepthToViewZ( const in float depth, const in float near, const in float far ) {\n\treturn ( near * far ) / ( ( far - near ) * depth - far );\n}",premultiplied_alpha_fragment:"#ifdef PREMULTIPLIED_ALPHA\n\tgl_FragColor.rgb *= gl_FragColor.a;\n#endif",project_vertex:"vec4 mvPosition = vec4( transformed, 1.0 );\n#ifdef USE_BATCHING\n\tmvPosition = batchingMatrix * mvPosition;\n#endif\n#ifdef USE_INSTANCING\n\tmvPosition = instanceMatrix * mvPosition;\n#endif\nmvPosition = modelViewMatrix * mvPosition;\ngl_Position = projectionMatrix * mvPosition;",dithering_fragment:"#ifdef DITHERING\n\tgl_FragColor.rgb = dithering( gl_FragColor.rgb );\n#endif",dithering_pars_fragment:"#ifdef DITHERING\n\tvec3 dithering( vec3 color ) {\n\t\tfloat grid_position = rand( gl_FragCoord.xy );\n\t\tvec3 dither_shift_RGB = vec3( 0.25 / 255.0, -0.25 / 255.0, 0.25 / 255.0 );\n\t\tdither_shift_RGB = mix( 2.0 * dither_shift_RGB, -2.0 * dither_shift_RGB, grid_position );\n\t\treturn color + dither_shift_RGB;\n\t}\n#endif",roughnessmap_fragment:"float roughnessFactor = roughness;\n#ifdef USE_ROUGHNESSMAP\n\tvec4 texelRoughness = texture2D( roughnessMap, vRoughnessMapUv );\n\troughnessFactor *= texelRoughness.g;\n#endif",roughnessmap_pars_fragment:"#ifdef USE_ROUGHNESSMAP\n\tuniform sampler2D roughnessMap;\n#endif",shadowmap_pars_fragment:"#if NUM_SPOT_LIGHT_COORDS > 0\n\tvarying vec4 vSpotLightCoord[ NUM_SPOT_LIGHT_COORDS ];\n#endif\n#if NUM_SPOT_LIGHT_MAPS > 0\n\tuniform sampler2D spotLightMap[ NUM_SPOT_LIGHT_MAPS ];\n#endif\n#ifdef USE_SHADOWMAP\n\t#if NUM_DIR_LIGHT_SHADOWS > 0\n\t\tuniform sampler2D directionalShadowMap[ NUM_DIR_LIGHT_SHADOWS ];\n\t\tvarying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHT_SHADOWS ];\n\t\tstruct DirectionalLightShadow {\n\t\t\tfloat shadowIntensity;\n\t\t\tfloat shadowBias;\n\t\t\tfloat shadowNormalBias;\n\t\t\tfloat shadowRadius;\n\t\t\tvec2 shadowMapSize;\n\t\t};\n\t\tuniform DirectionalLightShadow directionalLightShadows[ NUM_DIR_LIGHT_SHADOWS ];\n\t#endif\n\t#if NUM_SPOT_LIGHT_SHADOWS > 0\n\t\tuniform sampler2D spotShadowMap[ NUM_SPOT_LIGHT_SHADOWS ];\n\t\tstruct SpotLightShadow {\n\t\t\tfloat shadowIntensity;\n\t\t\tfloat shadowBias;\n\t\t\tfloat shadowNormalBias;\n\t\t\tfloat shadowRadius;\n\t\t\tvec2 shadowMapSize;\n\t\t};\n\t\tuniform SpotLightShadow spotLightShadows[ NUM_SPOT_LIGHT_SHADOWS ];\n\t#endif\n\t#if NUM_POINT_LIGHT_SHADOWS > 0\n\t\tuniform sampler2D pointShadowMap[ NUM_POINT_LIGHT_SHADOWS ];\n\t\tvarying vec4 vPointShadowCoord[ NUM_POINT_LIGHT_SHADOWS ];\n\t\tstruct PointLightShadow {\n\t\t\tfloat shadowIntensity;\n\t\t\tfloat shadowBias;\n\t\t\tfloat shadowNormalBias;\n\t\t\tfloat shadowRadius;\n\t\t\tvec2 shadowMapSize;\n\t\t\tfloat shadowCameraNear;\n\t\t\tfloat shadowCameraFar;\n\t\t};\n\t\tuniform PointLightShadow pointLightShadows[ NUM_POINT_LIGHT_SHADOWS ];\n\t#endif\n\tfloat texture2DCompare( sampler2D depths, vec2 uv, float compare ) {\n\t\treturn step( compare, unpackRGBAToDepth( texture2D( depths, uv ) ) );\n\t}\n\tvec2 texture2DDistribution( sampler2D shadow, vec2 uv ) {\n\t\treturn unpackRGBATo2Half( texture2D( shadow, uv ) );\n\t}\n\tfloat VSMShadow (sampler2D shadow, vec2 uv, float compare ){\n\t\tfloat occlusion = 1.0;\n\t\tvec2 distribution = texture2DDistribution( shadow, uv );\n\t\tfloat hard_shadow = step( compare , distribution.x );\n\t\tif (hard_shadow != 1.0 ) {\n\t\t\tfloat distance = compare - distribution.x ;\n\t\t\tfloat variance = max( 0.00000, distribution.y * distribution.y );\n\t\t\tfloat softness_probability = variance / (variance + distance * distance );\t\t\tsoftness_probability = clamp( ( softness_probability - 0.3 ) / ( 0.95 - 0.3 ), 0.0, 1.0 );\t\t\tocclusion = clamp( max( hard_shadow, softness_probability ), 0.0, 1.0 );\n\t\t}\n\t\treturn occlusion;\n\t}\n\tfloat getShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowIntensity, float shadowBias, float shadowRadius, vec4 shadowCoord ) {\n\t\tfloat shadow = 1.0;\n\t\tshadowCoord.xyz /= shadowCoord.w;\n\t\tshadowCoord.z += shadowBias;\n\t\tbool inFrustum = shadowCoord.x >= 0.0 && shadowCoord.x <= 1.0 && shadowCoord.y >= 0.0 && shadowCoord.y <= 1.0;\n\t\tbool frustumTest = inFrustum && shadowCoord.z <= 1.0;\n\t\tif ( frustumTest ) {\n\t\t#if defined( SHADOWMAP_TYPE_PCF )\n\t\t\tvec2 texelSize = vec2( 1.0 ) / shadowMapSize;\n\t\t\tfloat dx0 = - texelSize.x * shadowRadius;\n\t\t\tfloat dy0 = - texelSize.y * shadowRadius;\n\t\t\tfloat dx1 = + texelSize.x * shadowRadius;\n\t\t\tfloat dy1 = + texelSize.y * shadowRadius;\n\t\t\tfloat dx2 = dx0 / 2.0;\n\t\t\tfloat dy2 = dy0 / 2.0;\n\t\t\tfloat dx3 = dx1 / 2.0;\n\t\t\tfloat dy3 = dy1 / 2.0;\n\t\t\tshadow = (\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, dy0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, dy0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, dy2 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy2 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, dy2 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, 0.0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, 0.0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy, shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, 0.0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, 0.0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, dy3 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy3 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, dy3 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, dy1 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy1 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, dy1 ), shadowCoord.z )\n\t\t\t) * ( 1.0 / 17.0 );\n\t\t#elif defined( SHADOWMAP_TYPE_PCF_SOFT )\n\t\t\tvec2 texelSize = vec2( 1.0 ) / shadowMapSize;\n\t\t\tfloat dx = texelSize.x;\n\t\t\tfloat dy = texelSize.y;\n\t\t\tvec2 uv = shadowCoord.xy;\n\t\t\tvec2 f = fract( uv * shadowMapSize + 0.5 );\n\t\t\tuv -= f * texelSize;\n\t\t\tshadow = (\n\t\t\t\ttexture2DCompare( shadowMap, uv, shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, uv + vec2( dx, 0.0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, uv + vec2( 0.0, dy ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, uv + texelSize, shadowCoord.z ) +\n\t\t\t\tmix( texture2DCompare( shadowMap, uv + vec2( -dx, 0.0 ), shadowCoord.z ),\n\t\t\t\t\t texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, 0.0 ), shadowCoord.z ),\n\t\t\t\t\t f.x ) +\n\t\t\t\tmix( texture2DCompare( shadowMap, uv + vec2( -dx, dy ), shadowCoord.z ),\n\t\t\t\t\t texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, dy ), shadowCoord.z ),\n\t\t\t\t\t f.x ) +\n\t\t\t\tmix( texture2DCompare( shadowMap, uv + vec2( 0.0, -dy ), shadowCoord.z ),\n\t\t\t\t\t texture2DCompare( shadowMap, uv + vec2( 0.0, 2.0 * dy ), shadowCoord.z ),\n\t\t\t\t\t f.y ) +\n\t\t\t\tmix( texture2DCompare( shadowMap, uv + vec2( dx, -dy ), shadowCoord.z ),\n\t\t\t\t\t texture2DCompare( shadowMap, uv + vec2( dx, 2.0 * dy ), shadowCoord.z ),\n\t\t\t\t\t f.y ) +\n\t\t\t\tmix( mix( texture2DCompare( shadowMap, uv + vec2( -dx, -dy ), shadowCoord.z ),\n\t\t\t\t\t\t texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, -dy ), shadowCoord.z ),\n\t\t\t\t\t\t f.x ),\n\t\t\t\t\t mix( texture2DCompare( shadowMap, uv + vec2( -dx, 2.0 * dy ), shadowCoord.z ),\n\t\t\t\t\t\t texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, 2.0 * dy ), shadowCoord.z ),\n\t\t\t\t\t\t f.x ),\n\t\t\t\t\t f.y )\n\t\t\t) * ( 1.0 / 9.0 );\n\t\t#elif defined( SHADOWMAP_TYPE_VSM )\n\t\t\tshadow = VSMShadow( shadowMap, shadowCoord.xy, shadowCoord.z );\n\t\t#else\n\t\t\tshadow = texture2DCompare( shadowMap, shadowCoord.xy, shadowCoord.z );\n\t\t#endif\n\t\t}\n\t\treturn mix( 1.0, shadow, shadowIntensity );\n\t}\n\tvec2 cubeToUV( vec3 v, float texelSizeY ) {\n\t\tvec3 absV = abs( v );\n\t\tfloat scaleToCube = 1.0 / max( absV.x, max( absV.y, absV.z ) );\n\t\tabsV *= scaleToCube;\n\t\tv *= scaleToCube * ( 1.0 - 2.0 * texelSizeY );\n\t\tvec2 planar = v.xy;\n\t\tfloat almostATexel = 1.5 * texelSizeY;\n\t\tfloat almostOne = 1.0 - almostATexel;\n\t\tif ( absV.z >= almostOne ) {\n\t\t\tif ( v.z > 0.0 )\n\t\t\t\tplanar.x = 4.0 - v.x;\n\t\t} else if ( absV.x >= almostOne ) {\n\t\t\tfloat signX = sign( v.x );\n\t\t\tplanar.x = v.z * signX + 2.0 * signX;\n\t\t} else if ( absV.y >= almostOne ) {\n\t\t\tfloat signY = sign( v.y );\n\t\t\tplanar.x = v.x + 2.0 * signY + 2.0;\n\t\t\tplanar.y = v.z * signY - 2.0;\n\t\t}\n\t\treturn vec2( 0.125, 0.25 ) * planar + vec2( 0.375, 0.75 );\n\t}\n\tfloat getPointShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowIntensity, float shadowBias, float shadowRadius, vec4 shadowCoord, float shadowCameraNear, float shadowCameraFar ) {\n\t\tfloat shadow = 1.0;\n\t\tvec3 lightToPosition = shadowCoord.xyz;\n\t\t\n\t\tfloat lightToPositionLength = length( lightToPosition );\n\t\tif ( lightToPositionLength - shadowCameraFar <= 0.0 && lightToPositionLength - shadowCameraNear >= 0.0 ) {\n\t\t\tfloat dp = ( lightToPositionLength - shadowCameraNear ) / ( shadowCameraFar - shadowCameraNear );\t\t\tdp += shadowBias;\n\t\t\tvec3 bd3D = normalize( lightToPosition );\n\t\t\tvec2 texelSize = vec2( 1.0 ) / ( shadowMapSize * vec2( 4.0, 2.0 ) );\n\t\t\t#if defined( SHADOWMAP_TYPE_PCF ) || defined( SHADOWMAP_TYPE_PCF_SOFT ) || defined( SHADOWMAP_TYPE_VSM )\n\t\t\t\tvec2 offset = vec2( - 1, 1 ) * shadowRadius * texelSize.y;\n\t\t\t\tshadow = (\n\t\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.xyy, texelSize.y ), dp ) +\n\t\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.yyy, texelSize.y ), dp ) +\n\t\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.xyx, texelSize.y ), dp ) +\n\t\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.yyx, texelSize.y ), dp ) +\n\t\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D, texelSize.y ), dp ) +\n\t\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.xxy, texelSize.y ), dp ) +\n\t\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.yxy, texelSize.y ), dp ) +\n\t\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.xxx, texelSize.y ), dp ) +\n\t\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.yxx, texelSize.y ), dp )\n\t\t\t\t) * ( 1.0 / 9.0 );\n\t\t\t#else\n\t\t\t\tshadow = texture2DCompare( shadowMap, cubeToUV( bd3D, texelSize.y ), dp );\n\t\t\t#endif\n\t\t}\n\t\treturn mix( 1.0, shadow, shadowIntensity );\n\t}\n#endif",shadowmap_pars_vertex:"#if NUM_SPOT_LIGHT_COORDS > 0\n\tuniform mat4 spotLightMatrix[ NUM_SPOT_LIGHT_COORDS ];\n\tvarying vec4 vSpotLightCoord[ NUM_SPOT_LIGHT_COORDS ];\n#endif\n#ifdef USE_SHADOWMAP\n\t#if NUM_DIR_LIGHT_SHADOWS > 0\n\t\tuniform mat4 directionalShadowMatrix[ NUM_DIR_LIGHT_SHADOWS ];\n\t\tvarying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHT_SHADOWS ];\n\t\tstruct DirectionalLightShadow {\n\t\t\tfloat shadowIntensity;\n\t\t\tfloat shadowBias;\n\t\t\tfloat shadowNormalBias;\n\t\t\tfloat shadowRadius;\n\t\t\tvec2 shadowMapSize;\n\t\t};\n\t\tuniform DirectionalLightShadow directionalLightShadows[ NUM_DIR_LIGHT_SHADOWS ];\n\t#endif\n\t#if NUM_SPOT_LIGHT_SHADOWS > 0\n\t\tstruct SpotLightShadow {\n\t\t\tfloat shadowIntensity;\n\t\t\tfloat shadowBias;\n\t\t\tfloat shadowNormalBias;\n\t\t\tfloat shadowRadius;\n\t\t\tvec2 shadowMapSize;\n\t\t};\n\t\tuniform SpotLightShadow spotLightShadows[ NUM_SPOT_LIGHT_SHADOWS ];\n\t#endif\n\t#if NUM_POINT_LIGHT_SHADOWS > 0\n\t\tuniform mat4 pointShadowMatrix[ NUM_POINT_LIGHT_SHADOWS ];\n\t\tvarying vec4 vPointShadowCoord[ NUM_POINT_LIGHT_SHADOWS ];\n\t\tstruct PointLightShadow {\n\t\t\tfloat shadowIntensity;\n\t\t\tfloat shadowBias;\n\t\t\tfloat shadowNormalBias;\n\t\t\tfloat shadowRadius;\n\t\t\tvec2 shadowMapSize;\n\t\t\tfloat shadowCameraNear;\n\t\t\tfloat shadowCameraFar;\n\t\t};\n\t\tuniform PointLightShadow pointLightShadows[ NUM_POINT_LIGHT_SHADOWS ];\n\t#endif\n#endif",shadowmap_vertex:"#if ( defined( USE_SHADOWMAP ) && ( NUM_DIR_LIGHT_SHADOWS > 0 || NUM_POINT_LIGHT_SHADOWS > 0 ) ) || ( NUM_SPOT_LIGHT_COORDS > 0 )\n\tvec3 shadowWorldNormal = inverseTransformDirection( transformedNormal, viewMatrix );\n\tvec4 shadowWorldPosition;\n#endif\n#if defined( USE_SHADOWMAP )\n\t#if NUM_DIR_LIGHT_SHADOWS > 0\n\t\t#pragma unroll_loop_start\n\t\tfor ( int i = 0; i < NUM_DIR_LIGHT_SHADOWS; i ++ ) {\n\t\t\tshadowWorldPosition = worldPosition + vec4( shadowWorldNormal * directionalLightShadows[ i ].shadowNormalBias, 0 );\n\t\t\tvDirectionalShadowCoord[ i ] = directionalShadowMatrix[ i ] * shadowWorldPosition;\n\t\t}\n\t\t#pragma unroll_loop_end\n\t#endif\n\t#if NUM_POINT_LIGHT_SHADOWS > 0\n\t\t#pragma unroll_loop_start\n\t\tfor ( int i = 0; i < NUM_POINT_LIGHT_SHADOWS; i ++ ) {\n\t\t\tshadowWorldPosition = worldPosition + vec4( shadowWorldNormal * pointLightShadows[ i ].shadowNormalBias, 0 );\n\t\t\tvPointShadowCoord[ i ] = pointShadowMatrix[ i ] * shadowWorldPosition;\n\t\t}\n\t\t#pragma unroll_loop_end\n\t#endif\n#endif\n#if NUM_SPOT_LIGHT_COORDS > 0\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_SPOT_LIGHT_COORDS; i ++ ) {\n\t\tshadowWorldPosition = worldPosition;\n\t\t#if ( defined( USE_SHADOWMAP ) && UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS )\n\t\t\tshadowWorldPosition.xyz += shadowWorldNormal * spotLightShadows[ i ].shadowNormalBias;\n\t\t#endif\n\t\tvSpotLightCoord[ i ] = spotLightMatrix[ i ] * shadowWorldPosition;\n\t}\n\t#pragma unroll_loop_end\n#endif",shadowmask_pars_fragment:"float getShadowMask() {\n\tfloat shadow = 1.0;\n\t#ifdef USE_SHADOWMAP\n\t#if NUM_DIR_LIGHT_SHADOWS > 0\n\tDirectionalLightShadow directionalLight;\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_DIR_LIGHT_SHADOWS; i ++ ) {\n\t\tdirectionalLight = directionalLightShadows[ i ];\n\t\tshadow *= receiveShadow ? getShadow( directionalShadowMap[ i ], directionalLight.shadowMapSize, directionalLight.shadowIntensity, directionalLight.shadowBias, directionalLight.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0;\n\t}\n\t#pragma unroll_loop_end\n\t#endif\n\t#if NUM_SPOT_LIGHT_SHADOWS > 0\n\tSpotLightShadow spotLight;\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_SPOT_LIGHT_SHADOWS; i ++ ) {\n\t\tspotLight = spotLightShadows[ i ];\n\t\tshadow *= receiveShadow ? getShadow( spotShadowMap[ i ], spotLight.shadowMapSize, spotLight.shadowIntensity, spotLight.shadowBias, spotLight.shadowRadius, vSpotLightCoord[ i ] ) : 1.0;\n\t}\n\t#pragma unroll_loop_end\n\t#endif\n\t#if NUM_POINT_LIGHT_SHADOWS > 0\n\tPointLightShadow pointLight;\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_POINT_LIGHT_SHADOWS; i ++ ) {\n\t\tpointLight = pointLightShadows[ i ];\n\t\tshadow *= receiveShadow ? getPointShadow( pointShadowMap[ i ], pointLight.shadowMapSize, pointLight.shadowIntensity, pointLight.shadowBias, pointLight.shadowRadius, vPointShadowCoord[ i ], pointLight.shadowCameraNear, pointLight.shadowCameraFar ) : 1.0;\n\t}\n\t#pragma unroll_loop_end\n\t#endif\n\t#endif\n\treturn shadow;\n}",skinbase_vertex:"#ifdef USE_SKINNING\n\tmat4 boneMatX = getBoneMatrix( skinIndex.x );\n\tmat4 boneMatY = getBoneMatrix( skinIndex.y );\n\tmat4 boneMatZ = getBoneMatrix( skinIndex.z );\n\tmat4 boneMatW = getBoneMatrix( skinIndex.w );\n#endif",skinning_pars_vertex:"#ifdef USE_SKINNING\n\tuniform mat4 bindMatrix;\n\tuniform mat4 bindMatrixInverse;\n\tuniform highp sampler2D boneTexture;\n\tmat4 getBoneMatrix( const in float i ) {\n\t\tint size = textureSize( boneTexture, 0 ).x;\n\t\tint j = int( i ) * 4;\n\t\tint x = j % size;\n\t\tint y = j / size;\n\t\tvec4 v1 = texelFetch( boneTexture, ivec2( x, y ), 0 );\n\t\tvec4 v2 = texelFetch( boneTexture, ivec2( x + 1, y ), 0 );\n\t\tvec4 v3 = texelFetch( boneTexture, ivec2( x + 2, y ), 0 );\n\t\tvec4 v4 = texelFetch( boneTexture, ivec2( x + 3, y ), 0 );\n\t\treturn mat4( v1, v2, v3, v4 );\n\t}\n#endif",skinning_vertex:"#ifdef USE_SKINNING\n\tvec4 skinVertex = bindMatrix * vec4( transformed, 1.0 );\n\tvec4 skinned = vec4( 0.0 );\n\tskinned += boneMatX * skinVertex * skinWeight.x;\n\tskinned += boneMatY * skinVertex * skinWeight.y;\n\tskinned += boneMatZ * skinVertex * skinWeight.z;\n\tskinned += boneMatW * skinVertex * skinWeight.w;\n\ttransformed = ( bindMatrixInverse * skinned ).xyz;\n#endif",skinnormal_vertex:"#ifdef USE_SKINNING\n\tmat4 skinMatrix = mat4( 0.0 );\n\tskinMatrix += skinWeight.x * boneMatX;\n\tskinMatrix += skinWeight.y * boneMatY;\n\tskinMatrix += skinWeight.z * boneMatZ;\n\tskinMatrix += skinWeight.w * boneMatW;\n\tskinMatrix = bindMatrixInverse * skinMatrix * bindMatrix;\n\tobjectNormal = vec4( skinMatrix * vec4( objectNormal, 0.0 ) ).xyz;\n\t#ifdef USE_TANGENT\n\t\tobjectTangent = vec4( skinMatrix * vec4( objectTangent, 0.0 ) ).xyz;\n\t#endif\n#endif",specularmap_fragment:"float specularStrength;\n#ifdef USE_SPECULARMAP\n\tvec4 texelSpecular = texture2D( specularMap, vSpecularMapUv );\n\tspecularStrength = texelSpecular.r;\n#else\n\tspecularStrength = 1.0;\n#endif",specularmap_pars_fragment:"#ifdef USE_SPECULARMAP\n\tuniform sampler2D specularMap;\n#endif",tonemapping_fragment:"#if defined( TONE_MAPPING )\n\tgl_FragColor.rgb = toneMapping( gl_FragColor.rgb );\n#endif",tonemapping_pars_fragment:"#ifndef saturate\n#define saturate( a ) clamp( a, 0.0, 1.0 )\n#endif\nuniform float toneMappingExposure;\nvec3 LinearToneMapping( vec3 color ) {\n\treturn saturate( toneMappingExposure * color );\n}\nvec3 ReinhardToneMapping( vec3 color ) {\n\tcolor *= toneMappingExposure;\n\treturn saturate( color / ( vec3( 1.0 ) + color ) );\n}\nvec3 CineonToneMapping( vec3 color ) {\n\tcolor *= toneMappingExposure;\n\tcolor = max( vec3( 0.0 ), color - 0.004 );\n\treturn pow( ( color * ( 6.2 * color + 0.5 ) ) / ( color * ( 6.2 * color + 1.7 ) + 0.06 ), vec3( 2.2 ) );\n}\nvec3 RRTAndODTFit( vec3 v ) {\n\tvec3 a = v * ( v + 0.0245786 ) - 0.000090537;\n\tvec3 b = v * ( 0.983729 * v + 0.4329510 ) + 0.238081;\n\treturn a / b;\n}\nvec3 ACESFilmicToneMapping( vec3 color ) {\n\tconst mat3 ACESInputMat = mat3(\n\t\tvec3( 0.59719, 0.07600, 0.02840 ),\t\tvec3( 0.35458, 0.90834, 0.13383 ),\n\t\tvec3( 0.04823, 0.01566, 0.83777 )\n\t);\n\tconst mat3 ACESOutputMat = mat3(\n\t\tvec3( 1.60475, -0.10208, -0.00327 ),\t\tvec3( -0.53108, 1.10813, -0.07276 ),\n\t\tvec3( -0.07367, -0.00605, 1.07602 )\n\t);\n\tcolor *= toneMappingExposure / 0.6;\n\tcolor = ACESInputMat * color;\n\tcolor = RRTAndODTFit( color );\n\tcolor = ACESOutputMat * color;\n\treturn saturate( color );\n}\nconst mat3 LINEAR_REC2020_TO_LINEAR_SRGB = mat3(\n\tvec3( 1.6605, - 0.1246, - 0.0182 ),\n\tvec3( - 0.5876, 1.1329, - 0.1006 ),\n\tvec3( - 0.0728, - 0.0083, 1.1187 )\n);\nconst mat3 LINEAR_SRGB_TO_LINEAR_REC2020 = mat3(\n\tvec3( 0.6274, 0.0691, 0.0164 ),\n\tvec3( 0.3293, 0.9195, 0.0880 ),\n\tvec3( 0.0433, 0.0113, 0.8956 )\n);\nvec3 agxDefaultContrastApprox( vec3 x ) {\n\tvec3 x2 = x * x;\n\tvec3 x4 = x2 * x2;\n\treturn + 15.5 * x4 * x2\n\t\t- 40.14 * x4 * x\n\t\t+ 31.96 * x4\n\t\t- 6.868 * x2 * x\n\t\t+ 0.4298 * x2\n\t\t+ 0.1191 * x\n\t\t- 0.00232;\n}\nvec3 AgXToneMapping( vec3 color ) {\n\tconst mat3 AgXInsetMatrix = mat3(\n\t\tvec3( 0.856627153315983, 0.137318972929847, 0.11189821299995 ),\n\t\tvec3( 0.0951212405381588, 0.761241990602591, 0.0767994186031903 ),\n\t\tvec3( 0.0482516061458583, 0.101439036467562, 0.811302368396859 )\n\t);\n\tconst mat3 AgXOutsetMatrix = mat3(\n\t\tvec3( 1.1271005818144368, - 0.1413297634984383, - 0.14132976349843826 ),\n\t\tvec3( - 0.11060664309660323, 1.157823702216272, - 0.11060664309660294 ),\n\t\tvec3( - 0.016493938717834573, - 0.016493938717834257, 1.2519364065950405 )\n\t);\n\tconst float AgxMinEv = - 12.47393;\tconst float AgxMaxEv = 4.026069;\n\tcolor *= toneMappingExposure;\n\tcolor = LINEAR_SRGB_TO_LINEAR_REC2020 * color;\n\tcolor = AgXInsetMatrix * color;\n\tcolor = max( color, 1e-10 );\tcolor = log2( color );\n\tcolor = ( color - AgxMinEv ) / ( AgxMaxEv - AgxMinEv );\n\tcolor = clamp( color, 0.0, 1.0 );\n\tcolor = agxDefaultContrastApprox( color );\n\tcolor = AgXOutsetMatrix * color;\n\tcolor = pow( max( vec3( 0.0 ), color ), vec3( 2.2 ) );\n\tcolor = LINEAR_REC2020_TO_LINEAR_SRGB * color;\n\tcolor = clamp( color, 0.0, 1.0 );\n\treturn color;\n}\nvec3 NeutralToneMapping( vec3 color ) {\n\tconst float StartCompression = 0.8 - 0.04;\n\tconst float Desaturation = 0.15;\n\tcolor *= toneMappingExposure;\n\tfloat x = min( color.r, min( color.g, color.b ) );\n\tfloat offset = x < 0.08 ? x - 6.25 * x * x : 0.04;\n\tcolor -= offset;\n\tfloat peak = max( color.r, max( color.g, color.b ) );\n\tif ( peak < StartCompression ) return color;\n\tfloat d = 1. - StartCompression;\n\tfloat newPeak = 1. - d * d / ( peak + d - StartCompression );\n\tcolor *= newPeak / peak;\n\tfloat g = 1. - 1. / ( Desaturation * ( peak - newPeak ) + 1. );\n\treturn mix( color, vec3( newPeak ), g );\n}\nvec3 CustomToneMapping( vec3 color ) { return color; }",transmission_fragment:"#ifdef USE_TRANSMISSION\n\tmaterial.transmission = transmission;\n\tmaterial.transmissionAlpha = 1.0;\n\tmaterial.thickness = thickness;\n\tmaterial.attenuationDistance = attenuationDistance;\n\tmaterial.attenuationColor = attenuationColor;\n\t#ifdef USE_TRANSMISSIONMAP\n\t\tmaterial.transmission *= texture2D( transmissionMap, vTransmissionMapUv ).r;\n\t#endif\n\t#ifdef USE_THICKNESSMAP\n\t\tmaterial.thickness *= texture2D( thicknessMap, vThicknessMapUv ).g;\n\t#endif\n\tvec3 pos = vWorldPosition;\n\tvec3 v = normalize( cameraPosition - pos );\n\tvec3 n = inverseTransformDirection( normal, viewMatrix );\n\tvec4 transmitted = getIBLVolumeRefraction(\n\t\tn, v, material.roughness, material.diffuseColor, material.specularColor, material.specularF90,\n\t\tpos, modelMatrix, viewMatrix, projectionMatrix, material.dispersion, material.ior, material.thickness,\n\t\tmaterial.attenuationColor, material.attenuationDistance );\n\tmaterial.transmissionAlpha = mix( material.transmissionAlpha, transmitted.a, material.transmission );\n\ttotalDiffuse = mix( totalDiffuse, transmitted.rgb, material.transmission );\n#endif",transmission_pars_fragment:"#ifdef USE_TRANSMISSION\n\tuniform float transmission;\n\tuniform float thickness;\n\tuniform float attenuationDistance;\n\tuniform vec3 attenuationColor;\n\t#ifdef USE_TRANSMISSIONMAP\n\t\tuniform sampler2D transmissionMap;\n\t#endif\n\t#ifdef USE_THICKNESSMAP\n\t\tuniform sampler2D thicknessMap;\n\t#endif\n\tuniform vec2 transmissionSamplerSize;\n\tuniform sampler2D transmissionSamplerMap;\n\tuniform mat4 modelMatrix;\n\tuniform mat4 projectionMatrix;\n\tvarying vec3 vWorldPosition;\n\tfloat w0( float a ) {\n\t\treturn ( 1.0 / 6.0 ) * ( a * ( a * ( - a + 3.0 ) - 3.0 ) + 1.0 );\n\t}\n\tfloat w1( float a ) {\n\t\treturn ( 1.0 / 6.0 ) * ( a * a * ( 3.0 * a - 6.0 ) + 4.0 );\n\t}\n\tfloat w2( float a ){\n\t\treturn ( 1.0 / 6.0 ) * ( a * ( a * ( - 3.0 * a + 3.0 ) + 3.0 ) + 1.0 );\n\t}\n\tfloat w3( float a ) {\n\t\treturn ( 1.0 / 6.0 ) * ( a * a * a );\n\t}\n\tfloat g0( float a ) {\n\t\treturn w0( a ) + w1( a );\n\t}\n\tfloat g1( float a ) {\n\t\treturn w2( a ) + w3( a );\n\t}\n\tfloat h0( float a ) {\n\t\treturn - 1.0 + w1( a ) / ( w0( a ) + w1( a ) );\n\t}\n\tfloat h1( float a ) {\n\t\treturn 1.0 + w3( a ) / ( w2( a ) + w3( a ) );\n\t}\n\tvec4 bicubic( sampler2D tex, vec2 uv, vec4 texelSize, float lod ) {\n\t\tuv = uv * texelSize.zw + 0.5;\n\t\tvec2 iuv = floor( uv );\n\t\tvec2 fuv = fract( uv );\n\t\tfloat g0x = g0( fuv.x );\n\t\tfloat g1x = g1( fuv.x );\n\t\tfloat h0x = h0( fuv.x );\n\t\tfloat h1x = h1( fuv.x );\n\t\tfloat h0y = h0( fuv.y );\n\t\tfloat h1y = h1( fuv.y );\n\t\tvec2 p0 = ( vec2( iuv.x + h0x, iuv.y + h0y ) - 0.5 ) * texelSize.xy;\n\t\tvec2 p1 = ( vec2( iuv.x + h1x, iuv.y + h0y ) - 0.5 ) * texelSize.xy;\n\t\tvec2 p2 = ( vec2( iuv.x + h0x, iuv.y + h1y ) - 0.5 ) * texelSize.xy;\n\t\tvec2 p3 = ( vec2( iuv.x + h1x, iuv.y + h1y ) - 0.5 ) * texelSize.xy;\n\t\treturn g0( fuv.y ) * ( g0x * textureLod( tex, p0, lod ) + g1x * textureLod( tex, p1, lod ) ) +\n\t\t\tg1( fuv.y ) * ( g0x * textureLod( tex, p2, lod ) + g1x * textureLod( tex, p3, lod ) );\n\t}\n\tvec4 textureBicubic( sampler2D sampler, vec2 uv, float lod ) {\n\t\tvec2 fLodSize = vec2( textureSize( sampler, int( lod ) ) );\n\t\tvec2 cLodSize = vec2( textureSize( sampler, int( lod + 1.0 ) ) );\n\t\tvec2 fLodSizeInv = 1.0 / fLodSize;\n\t\tvec2 cLodSizeInv = 1.0 / cLodSize;\n\t\tvec4 fSample = bicubic( sampler, uv, vec4( fLodSizeInv, fLodSize ), floor( lod ) );\n\t\tvec4 cSample = bicubic( sampler, uv, vec4( cLodSizeInv, cLodSize ), ceil( lod ) );\n\t\treturn mix( fSample, cSample, fract( lod ) );\n\t}\n\tvec3 getVolumeTransmissionRay( const in vec3 n, const in vec3 v, const in float thickness, const in float ior, const in mat4 modelMatrix ) {\n\t\tvec3 refractionVector = refract( - v, normalize( n ), 1.0 / ior );\n\t\tvec3 modelScale;\n\t\tmodelScale.x = length( vec3( modelMatrix[ 0 ].xyz ) );\n\t\tmodelScale.y = length( vec3( modelMatrix[ 1 ].xyz ) );\n\t\tmodelScale.z = length( vec3( modelMatrix[ 2 ].xyz ) );\n\t\treturn normalize( refractionVector ) * thickness * modelScale;\n\t}\n\tfloat applyIorToRoughness( const in float roughness, const in float ior ) {\n\t\treturn roughness * clamp( ior * 2.0 - 2.0, 0.0, 1.0 );\n\t}\n\tvec4 getTransmissionSample( const in vec2 fragCoord, const in float roughness, const in float ior ) {\n\t\tfloat lod = log2( transmissionSamplerSize.x ) * applyIorToRoughness( roughness, ior );\n\t\treturn textureBicubic( transmissionSamplerMap, fragCoord.xy, lod );\n\t}\n\tvec3 volumeAttenuation( const in float transmissionDistance, const in vec3 attenuationColor, const in float attenuationDistance ) {\n\t\tif ( isinf( attenuationDistance ) ) {\n\t\t\treturn vec3( 1.0 );\n\t\t} else {\n\t\t\tvec3 attenuationCoefficient = -log( attenuationColor ) / attenuationDistance;\n\t\t\tvec3 transmittance = exp( - attenuationCoefficient * transmissionDistance );\t\t\treturn transmittance;\n\t\t}\n\t}\n\tvec4 getIBLVolumeRefraction( const in vec3 n, const in vec3 v, const in float roughness, const in vec3 diffuseColor,\n\t\tconst in vec3 specularColor, const in float specularF90, const in vec3 position, const in mat4 modelMatrix,\n\t\tconst in mat4 viewMatrix, const in mat4 projMatrix, const in float dispersion, const in float ior, const in float thickness,\n\t\tconst in vec3 attenuationColor, const in float attenuationDistance ) {\n\t\tvec4 transmittedLight;\n\t\tvec3 transmittance;\n\t\t#ifdef USE_DISPERSION\n\t\t\tfloat halfSpread = ( ior - 1.0 ) * 0.025 * dispersion;\n\t\t\tvec3 iors = vec3( ior - halfSpread, ior, ior + halfSpread );\n\t\t\tfor ( int i = 0; i < 3; i ++ ) {\n\t\t\t\tvec3 transmissionRay = getVolumeTransmissionRay( n, v, thickness, iors[ i ], modelMatrix );\n\t\t\t\tvec3 refractedRayExit = position + transmissionRay;\n\t\t\n\t\t\t\tvec4 ndcPos = projMatrix * viewMatrix * vec4( refractedRayExit, 1.0 );\n\t\t\t\tvec2 refractionCoords = ndcPos.xy / ndcPos.w;\n\t\t\t\trefractionCoords += 1.0;\n\t\t\t\trefractionCoords /= 2.0;\n\t\t\n\t\t\t\tvec4 transmissionSample = getTransmissionSample( refractionCoords, roughness, iors[ i ] );\n\t\t\t\ttransmittedLight[ i ] = transmissionSample[ i ];\n\t\t\t\ttransmittedLight.a += transmissionSample.a;\n\t\t\t\ttransmittance[ i ] = diffuseColor[ i ] * volumeAttenuation( length( transmissionRay ), attenuationColor, attenuationDistance )[ i ];\n\t\t\t}\n\t\t\ttransmittedLight.a /= 3.0;\n\t\t\n\t\t#else\n\t\t\n\t\t\tvec3 transmissionRay = getVolumeTransmissionRay( n, v, thickness, ior, modelMatrix );\n\t\t\tvec3 refractedRayExit = position + transmissionRay;\n\t\t\tvec4 ndcPos = projMatrix * viewMatrix * vec4( refractedRayExit, 1.0 );\n\t\t\tvec2 refractionCoords = ndcPos.xy / ndcPos.w;\n\t\t\trefractionCoords += 1.0;\n\t\t\trefractionCoords /= 2.0;\n\t\t\ttransmittedLight = getTransmissionSample( refractionCoords, roughness, ior );\n\t\t\ttransmittance = diffuseColor * volumeAttenuation( length( transmissionRay ), attenuationColor, attenuationDistance );\n\t\t\n\t\t#endif\n\t\tvec3 attenuatedColor = transmittance * transmittedLight.rgb;\n\t\tvec3 F = EnvironmentBRDF( n, v, specularColor, specularF90, roughness );\n\t\tfloat transmittanceFactor = ( transmittance.r + transmittance.g + transmittance.b ) / 3.0;\n\t\treturn vec4( ( 1.0 - F ) * attenuatedColor, 1.0 - ( 1.0 - transmittedLight.a ) * transmittanceFactor );\n\t}\n#endif",uv_pars_fragment:"#if defined( USE_UV ) || defined( USE_ANISOTROPY )\n\tvarying vec2 vUv;\n#endif\n#ifdef USE_MAP\n\tvarying vec2 vMapUv;\n#endif\n#ifdef USE_ALPHAMAP\n\tvarying vec2 vAlphaMapUv;\n#endif\n#ifdef USE_LIGHTMAP\n\tvarying vec2 vLightMapUv;\n#endif\n#ifdef USE_AOMAP\n\tvarying vec2 vAoMapUv;\n#endif\n#ifdef USE_BUMPMAP\n\tvarying vec2 vBumpMapUv;\n#endif\n#ifdef USE_NORMALMAP\n\tvarying vec2 vNormalMapUv;\n#endif\n#ifdef USE_EMISSIVEMAP\n\tvarying vec2 vEmissiveMapUv;\n#endif\n#ifdef USE_METALNESSMAP\n\tvarying vec2 vMetalnessMapUv;\n#endif\n#ifdef USE_ROUGHNESSMAP\n\tvarying vec2 vRoughnessMapUv;\n#endif\n#ifdef USE_ANISOTROPYMAP\n\tvarying vec2 vAnisotropyMapUv;\n#endif\n#ifdef USE_CLEARCOATMAP\n\tvarying vec2 vClearcoatMapUv;\n#endif\n#ifdef USE_CLEARCOAT_NORMALMAP\n\tvarying vec2 vClearcoatNormalMapUv;\n#endif\n#ifdef USE_CLEARCOAT_ROUGHNESSMAP\n\tvarying vec2 vClearcoatRoughnessMapUv;\n#endif\n#ifdef USE_IRIDESCENCEMAP\n\tvarying vec2 vIridescenceMapUv;\n#endif\n#ifdef USE_IRIDESCENCE_THICKNESSMAP\n\tvarying vec2 vIridescenceThicknessMapUv;\n#endif\n#ifdef USE_SHEEN_COLORMAP\n\tvarying vec2 vSheenColorMapUv;\n#endif\n#ifdef USE_SHEEN_ROUGHNESSMAP\n\tvarying vec2 vSheenRoughnessMapUv;\n#endif\n#ifdef USE_SPECULARMAP\n\tvarying vec2 vSpecularMapUv;\n#endif\n#ifdef USE_SPECULAR_COLORMAP\n\tvarying vec2 vSpecularColorMapUv;\n#endif\n#ifdef USE_SPECULAR_INTENSITYMAP\n\tvarying vec2 vSpecularIntensityMapUv;\n#endif\n#ifdef USE_TRANSMISSIONMAP\n\tuniform mat3 transmissionMapTransform;\n\tvarying vec2 vTransmissionMapUv;\n#endif\n#ifdef USE_THICKNESSMAP\n\tuniform mat3 thicknessMapTransform;\n\tvarying vec2 vThicknessMapUv;\n#endif",uv_pars_vertex:"#if defined( USE_UV ) || defined( USE_ANISOTROPY )\n\tvarying vec2 vUv;\n#endif\n#ifdef USE_MAP\n\tuniform mat3 mapTransform;\n\tvarying vec2 vMapUv;\n#endif\n#ifdef USE_ALPHAMAP\n\tuniform mat3 alphaMapTransform;\n\tvarying vec2 vAlphaMapUv;\n#endif\n#ifdef USE_LIGHTMAP\n\tuniform mat3 lightMapTransform;\n\tvarying vec2 vLightMapUv;\n#endif\n#ifdef USE_AOMAP\n\tuniform mat3 aoMapTransform;\n\tvarying vec2 vAoMapUv;\n#endif\n#ifdef USE_BUMPMAP\n\tuniform mat3 bumpMapTransform;\n\tvarying vec2 vBumpMapUv;\n#endif\n#ifdef USE_NORMALMAP\n\tuniform mat3 normalMapTransform;\n\tvarying vec2 vNormalMapUv;\n#endif\n#ifdef USE_DISPLACEMENTMAP\n\tuniform mat3 displacementMapTransform;\n\tvarying vec2 vDisplacementMapUv;\n#endif\n#ifdef USE_EMISSIVEMAP\n\tuniform mat3 emissiveMapTransform;\n\tvarying vec2 vEmissiveMapUv;\n#endif\n#ifdef USE_METALNESSMAP\n\tuniform mat3 metalnessMapTransform;\n\tvarying vec2 vMetalnessMapUv;\n#endif\n#ifdef USE_ROUGHNESSMAP\n\tuniform mat3 roughnessMapTransform;\n\tvarying vec2 vRoughnessMapUv;\n#endif\n#ifdef USE_ANISOTROPYMAP\n\tuniform mat3 anisotropyMapTransform;\n\tvarying vec2 vAnisotropyMapUv;\n#endif\n#ifdef USE_CLEARCOATMAP\n\tuniform mat3 clearcoatMapTransform;\n\tvarying vec2 vClearcoatMapUv;\n#endif\n#ifdef USE_CLEARCOAT_NORMALMAP\n\tuniform mat3 clearcoatNormalMapTransform;\n\tvarying vec2 vClearcoatNormalMapUv;\n#endif\n#ifdef USE_CLEARCOAT_ROUGHNESSMAP\n\tuniform mat3 clearcoatRoughnessMapTransform;\n\tvarying vec2 vClearcoatRoughnessMapUv;\n#endif\n#ifdef USE_SHEEN_COLORMAP\n\tuniform mat3 sheenColorMapTransform;\n\tvarying vec2 vSheenColorMapUv;\n#endif\n#ifdef USE_SHEEN_ROUGHNESSMAP\n\tuniform mat3 sheenRoughnessMapTransform;\n\tvarying vec2 vSheenRoughnessMapUv;\n#endif\n#ifdef USE_IRIDESCENCEMAP\n\tuniform mat3 iridescenceMapTransform;\n\tvarying vec2 vIridescenceMapUv;\n#endif\n#ifdef USE_IRIDESCENCE_THICKNESSMAP\n\tuniform mat3 iridescenceThicknessMapTransform;\n\tvarying vec2 vIridescenceThicknessMapUv;\n#endif\n#ifdef USE_SPECULARMAP\n\tuniform mat3 specularMapTransform;\n\tvarying vec2 vSpecularMapUv;\n#endif\n#ifdef USE_SPECULAR_COLORMAP\n\tuniform mat3 specularColorMapTransform;\n\tvarying vec2 vSpecularColorMapUv;\n#endif\n#ifdef USE_SPECULAR_INTENSITYMAP\n\tuniform mat3 specularIntensityMapTransform;\n\tvarying vec2 vSpecularIntensityMapUv;\n#endif\n#ifdef USE_TRANSMISSIONMAP\n\tuniform mat3 transmissionMapTransform;\n\tvarying vec2 vTransmissionMapUv;\n#endif\n#ifdef USE_THICKNESSMAP\n\tuniform mat3 thicknessMapTransform;\n\tvarying vec2 vThicknessMapUv;\n#endif",uv_vertex:"#if defined( USE_UV ) || defined( USE_ANISOTROPY )\n\tvUv = vec3( uv, 1 ).xy;\n#endif\n#ifdef USE_MAP\n\tvMapUv = ( mapTransform * vec3( MAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_ALPHAMAP\n\tvAlphaMapUv = ( alphaMapTransform * vec3( ALPHAMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_LIGHTMAP\n\tvLightMapUv = ( lightMapTransform * vec3( LIGHTMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_AOMAP\n\tvAoMapUv = ( aoMapTransform * vec3( AOMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_BUMPMAP\n\tvBumpMapUv = ( bumpMapTransform * vec3( BUMPMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_NORMALMAP\n\tvNormalMapUv = ( normalMapTransform * vec3( NORMALMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_DISPLACEMENTMAP\n\tvDisplacementMapUv = ( displacementMapTransform * vec3( DISPLACEMENTMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_EMISSIVEMAP\n\tvEmissiveMapUv = ( emissiveMapTransform * vec3( EMISSIVEMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_METALNESSMAP\n\tvMetalnessMapUv = ( metalnessMapTransform * vec3( METALNESSMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_ROUGHNESSMAP\n\tvRoughnessMapUv = ( roughnessMapTransform * vec3( ROUGHNESSMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_ANISOTROPYMAP\n\tvAnisotropyMapUv = ( anisotropyMapTransform * vec3( ANISOTROPYMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_CLEARCOATMAP\n\tvClearcoatMapUv = ( clearcoatMapTransform * vec3( CLEARCOATMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_CLEARCOAT_NORMALMAP\n\tvClearcoatNormalMapUv = ( clearcoatNormalMapTransform * vec3( CLEARCOAT_NORMALMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_CLEARCOAT_ROUGHNESSMAP\n\tvClearcoatRoughnessMapUv = ( clearcoatRoughnessMapTransform * vec3( CLEARCOAT_ROUGHNESSMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_IRIDESCENCEMAP\n\tvIridescenceMapUv = ( iridescenceMapTransform * vec3( IRIDESCENCEMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_IRIDESCENCE_THICKNESSMAP\n\tvIridescenceThicknessMapUv = ( iridescenceThicknessMapTransform * vec3( IRIDESCENCE_THICKNESSMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_SHEEN_COLORMAP\n\tvSheenColorMapUv = ( sheenColorMapTransform * vec3( SHEEN_COLORMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_SHEEN_ROUGHNESSMAP\n\tvSheenRoughnessMapUv = ( sheenRoughnessMapTransform * vec3( SHEEN_ROUGHNESSMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_SPECULARMAP\n\tvSpecularMapUv = ( specularMapTransform * vec3( SPECULARMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_SPECULAR_COLORMAP\n\tvSpecularColorMapUv = ( specularColorMapTransform * vec3( SPECULAR_COLORMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_SPECULAR_INTENSITYMAP\n\tvSpecularIntensityMapUv = ( specularIntensityMapTransform * vec3( SPECULAR_INTENSITYMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_TRANSMISSIONMAP\n\tvTransmissionMapUv = ( transmissionMapTransform * vec3( TRANSMISSIONMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_THICKNESSMAP\n\tvThicknessMapUv = ( thicknessMapTransform * vec3( THICKNESSMAP_UV, 1 ) ).xy;\n#endif",worldpos_vertex:"#if defined( USE_ENVMAP ) || defined( DISTANCE ) || defined ( USE_SHADOWMAP ) || defined ( USE_TRANSMISSION ) || NUM_SPOT_LIGHT_COORDS > 0\n\tvec4 worldPosition = vec4( transformed, 1.0 );\n\t#ifdef USE_BATCHING\n\t\tworldPosition = batchingMatrix * worldPosition;\n\t#endif\n\t#ifdef USE_INSTANCING\n\t\tworldPosition = instanceMatrix * worldPosition;\n\t#endif\n\tworldPosition = modelMatrix * worldPosition;\n#endif",background_vert:"varying vec2 vUv;\nuniform mat3 uvTransform;\nvoid main() {\n\tvUv = ( uvTransform * vec3( uv, 1 ) ).xy;\n\tgl_Position = vec4( position.xy, 1.0, 1.0 );\n}",background_frag:"uniform sampler2D t2D;\nuniform float backgroundIntensity;\nvarying vec2 vUv;\nvoid main() {\n\tvec4 texColor = texture2D( t2D, vUv );\n\t#ifdef DECODE_VIDEO_TEXTURE\n\t\ttexColor = vec4( mix( pow( texColor.rgb * 0.9478672986 + vec3( 0.0521327014 ), vec3( 2.4 ) ), texColor.rgb * 0.0773993808, vec3( lessThanEqual( texColor.rgb, vec3( 0.04045 ) ) ) ), texColor.w );\n\t#endif\n\ttexColor.rgb *= backgroundIntensity;\n\tgl_FragColor = texColor;\n\t#include \n\t#include \n}",backgroundCube_vert:"varying vec3 vWorldDirection;\n#include \nvoid main() {\n\tvWorldDirection = transformDirection( position, modelMatrix );\n\t#include \n\t#include \n\tgl_Position.z = gl_Position.w;\n}",backgroundCube_frag:"#ifdef ENVMAP_TYPE_CUBE\n\tuniform samplerCube envMap;\n#elif defined( ENVMAP_TYPE_CUBE_UV )\n\tuniform sampler2D envMap;\n#endif\nuniform float flipEnvMap;\nuniform float backgroundBlurriness;\nuniform float backgroundIntensity;\nuniform mat3 backgroundRotation;\nvarying vec3 vWorldDirection;\n#include \nvoid main() {\n\t#ifdef ENVMAP_TYPE_CUBE\n\t\tvec4 texColor = textureCube( envMap, backgroundRotation * vec3( flipEnvMap * vWorldDirection.x, vWorldDirection.yz ) );\n\t#elif defined( ENVMAP_TYPE_CUBE_UV )\n\t\tvec4 texColor = textureCubeUV( envMap, backgroundRotation * vWorldDirection, backgroundBlurriness );\n\t#else\n\t\tvec4 texColor = vec4( 0.0, 0.0, 0.0, 1.0 );\n\t#endif\n\ttexColor.rgb *= backgroundIntensity;\n\tgl_FragColor = texColor;\n\t#include \n\t#include \n}",cube_vert:"varying vec3 vWorldDirection;\n#include \nvoid main() {\n\tvWorldDirection = transformDirection( position, modelMatrix );\n\t#include \n\t#include \n\tgl_Position.z = gl_Position.w;\n}",cube_frag:"uniform samplerCube tCube;\nuniform float tFlip;\nuniform float opacity;\nvarying vec3 vWorldDirection;\nvoid main() {\n\tvec4 texColor = textureCube( tCube, vec3( tFlip * vWorldDirection.x, vWorldDirection.yz ) );\n\tgl_FragColor = texColor;\n\tgl_FragColor.a *= opacity;\n\t#include \n\t#include \n}",depth_vert:"#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvarying vec2 vHighPrecisionZW;\nvoid main() {\n\t#include \n\t#include \n\t#include \n\t#include \n\t#ifdef USE_DISPLACEMENTMAP\n\t\t#include \n\t\t#include \n\t\t#include \n\t#endif\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tvHighPrecisionZW = gl_Position.zw;\n}",depth_frag:"#if DEPTH_PACKING == 3200\n\tuniform float opacity;\n#endif\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvarying vec2 vHighPrecisionZW;\nvoid main() {\n\tvec4 diffuseColor = vec4( 1.0 );\n\t#include \n\t#if DEPTH_PACKING == 3200\n\t\tdiffuseColor.a = opacity;\n\t#endif\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tfloat fragCoordZ = 0.5 * vHighPrecisionZW[0] / vHighPrecisionZW[1] + 0.5;\n\t#if DEPTH_PACKING == 3200\n\t\tgl_FragColor = vec4( vec3( 1.0 - fragCoordZ ), opacity );\n\t#elif DEPTH_PACKING == 3201\n\t\tgl_FragColor = packDepthToRGBA( fragCoordZ );\n\t#elif DEPTH_PACKING == 3202\n\t\tgl_FragColor = vec4( packDepthToRGB( fragCoordZ ), 1.0 );\n\t#elif DEPTH_PACKING == 3203\n\t\tgl_FragColor = vec4( packDepthToRG( fragCoordZ ), 0.0, 1.0 );\n\t#endif\n}",distanceRGBA_vert:"#define DISTANCE\nvarying vec3 vWorldPosition;\n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\t#include \n\t#include \n\t#include \n\t#ifdef USE_DISPLACEMENTMAP\n\t\t#include \n\t\t#include \n\t\t#include \n\t#endif\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tvWorldPosition = worldPosition.xyz;\n}",distanceRGBA_frag:"#define DISTANCE\nuniform vec3 referencePosition;\nuniform float nearDistance;\nuniform float farDistance;\nvarying vec3 vWorldPosition;\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main () {\n\tvec4 diffuseColor = vec4( 1.0 );\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tfloat dist = length( vWorldPosition - referencePosition );\n\tdist = ( dist - nearDistance ) / ( farDistance - nearDistance );\n\tdist = saturate( dist );\n\tgl_FragColor = packDepthToRGBA( dist );\n}",equirect_vert:"varying vec3 vWorldDirection;\n#include \nvoid main() {\n\tvWorldDirection = transformDirection( position, modelMatrix );\n\t#include \n\t#include \n}",equirect_frag:"uniform sampler2D tEquirect;\nvarying vec3 vWorldDirection;\n#include \nvoid main() {\n\tvec3 direction = normalize( vWorldDirection );\n\tvec2 sampleUV = equirectUv( direction );\n\tgl_FragColor = texture2D( tEquirect, sampleUV );\n\t#include \n\t#include \n}",linedashed_vert:"uniform float scale;\nattribute float lineDistance;\nvarying float vLineDistance;\n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\tvLineDistance = scale * lineDistance;\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n}",linedashed_frag:"uniform vec3 diffuse;\nuniform float opacity;\nuniform float dashSize;\nuniform float totalSize;\nvarying float vLineDistance;\n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include \n\tif ( mod( vLineDistance, totalSize ) > dashSize ) {\n\t\tdiscard;\n\t}\n\tvec3 outgoingLight = vec3( 0.0 );\n\t#include \n\t#include \n\t#include \n\toutgoingLight = diffuseColor.rgb;\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n}",meshbasic_vert:"#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#if defined ( USE_ENVMAP ) || defined ( USE_SKINNING )\n\t\t#include \n\t\t#include \n\t\t#include \n\t\t#include \n\t\t#include \n\t#endif\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n}",meshbasic_frag:"uniform vec3 diffuse;\nuniform float opacity;\n#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n#endif\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n\t#ifdef USE_LIGHTMAP\n\t\tvec4 lightMapTexel = texture2D( lightMap, vLightMapUv );\n\t\treflectedLight.indirectDiffuse += lightMapTexel.rgb * lightMapIntensity * RECIPROCAL_PI;\n\t#else\n\t\treflectedLight.indirectDiffuse += vec3( 1.0 );\n\t#endif\n\t#include \n\treflectedLight.indirectDiffuse *= diffuseColor.rgb;\n\tvec3 outgoingLight = reflectedLight.indirectDiffuse;\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n}",meshlambert_vert:"#define LAMBERT\nvarying vec3 vViewPosition;\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tvViewPosition = - mvPosition.xyz;\n\t#include \n\t#include \n\t#include \n\t#include \n}",meshlambert_frag:"#define LAMBERT\nuniform vec3 diffuse;\nuniform vec3 emissive;\nuniform float opacity;\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include \n\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n\tvec3 totalEmissiveRadiance = emissive;\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tvec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + totalEmissiveRadiance;\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n}",meshmatcap_vert:"#define MATCAP\nvarying vec3 vViewPosition;\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tvViewPosition = - mvPosition.xyz;\n}",meshmatcap_frag:"#define MATCAP\nuniform vec3 diffuse;\nuniform float opacity;\nuniform sampler2D matcap;\nvarying vec3 vViewPosition;\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tvec3 viewDir = normalize( vViewPosition );\n\tvec3 x = normalize( vec3( viewDir.z, 0.0, - viewDir.x ) );\n\tvec3 y = cross( viewDir, x );\n\tvec2 uv = vec2( dot( x, normal ), dot( y, normal ) ) * 0.495 + 0.5;\n\t#ifdef USE_MATCAP\n\t\tvec4 matcapColor = texture2D( matcap, uv );\n\t#else\n\t\tvec4 matcapColor = vec4( vec3( mix( 0.2, 0.8, uv.y ) ), 1.0 );\n\t#endif\n\tvec3 outgoingLight = diffuseColor.rgb * matcapColor.rgb;\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n}",meshnormal_vert:"#define NORMAL\n#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE )\n\tvarying vec3 vViewPosition;\n#endif\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE )\n\tvViewPosition = - mvPosition.xyz;\n#endif\n}",meshnormal_frag:"#define NORMAL\nuniform float opacity;\n#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE )\n\tvarying vec3 vViewPosition;\n#endif\n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\tvec4 diffuseColor = vec4( 0.0, 0.0, 0.0, opacity );\n\t#include \n\t#include \n\t#include \n\t#include \n\tgl_FragColor = vec4( packNormalToRGB( normal ), diffuseColor.a );\n\t#ifdef OPAQUE\n\t\tgl_FragColor.a = 1.0;\n\t#endif\n}",meshphong_vert:"#define PHONG\nvarying vec3 vViewPosition;\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tvViewPosition = - mvPosition.xyz;\n\t#include \n\t#include \n\t#include \n\t#include \n}",meshphong_frag:"#define PHONG\nuniform vec3 diffuse;\nuniform vec3 emissive;\nuniform vec3 specular;\nuniform float shininess;\nuniform float opacity;\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include \n\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n\tvec3 totalEmissiveRadiance = emissive;\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tvec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + reflectedLight.directSpecular + reflectedLight.indirectSpecular + totalEmissiveRadiance;\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n}",meshphysical_vert:"#define STANDARD\nvarying vec3 vViewPosition;\n#ifdef USE_TRANSMISSION\n\tvarying vec3 vWorldPosition;\n#endif\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tvViewPosition = - mvPosition.xyz;\n\t#include \n\t#include \n\t#include \n#ifdef USE_TRANSMISSION\n\tvWorldPosition = worldPosition.xyz;\n#endif\n}",meshphysical_frag:"#define STANDARD\n#ifdef PHYSICAL\n\t#define IOR\n\t#define USE_SPECULAR\n#endif\nuniform vec3 diffuse;\nuniform vec3 emissive;\nuniform float roughness;\nuniform float metalness;\nuniform float opacity;\n#ifdef IOR\n\tuniform float ior;\n#endif\n#ifdef USE_SPECULAR\n\tuniform float specularIntensity;\n\tuniform vec3 specularColor;\n\t#ifdef USE_SPECULAR_COLORMAP\n\t\tuniform sampler2D specularColorMap;\n\t#endif\n\t#ifdef USE_SPECULAR_INTENSITYMAP\n\t\tuniform sampler2D specularIntensityMap;\n\t#endif\n#endif\n#ifdef USE_CLEARCOAT\n\tuniform float clearcoat;\n\tuniform float clearcoatRoughness;\n#endif\n#ifdef USE_DISPERSION\n\tuniform float dispersion;\n#endif\n#ifdef USE_IRIDESCENCE\n\tuniform float iridescence;\n\tuniform float iridescenceIOR;\n\tuniform float iridescenceThicknessMinimum;\n\tuniform float iridescenceThicknessMaximum;\n#endif\n#ifdef USE_SHEEN\n\tuniform vec3 sheenColor;\n\tuniform float sheenRoughness;\n\t#ifdef USE_SHEEN_COLORMAP\n\t\tuniform sampler2D sheenColorMap;\n\t#endif\n\t#ifdef USE_SHEEN_ROUGHNESSMAP\n\t\tuniform sampler2D sheenRoughnessMap;\n\t#endif\n#endif\n#ifdef USE_ANISOTROPY\n\tuniform vec2 anisotropyVector;\n\t#ifdef USE_ANISOTROPYMAP\n\t\tuniform sampler2D anisotropyMap;\n\t#endif\n#endif\nvarying vec3 vViewPosition;\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include \n\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n\tvec3 totalEmissiveRadiance = emissive;\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tvec3 totalDiffuse = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse;\n\tvec3 totalSpecular = reflectedLight.directSpecular + reflectedLight.indirectSpecular;\n\t#include \n\tvec3 outgoingLight = totalDiffuse + totalSpecular + totalEmissiveRadiance;\n\t#ifdef USE_SHEEN\n\t\tfloat sheenEnergyComp = 1.0 - 0.157 * max3( material.sheenColor );\n\t\toutgoingLight = outgoingLight * sheenEnergyComp + sheenSpecularDirect + sheenSpecularIndirect;\n\t#endif\n\t#ifdef USE_CLEARCOAT\n\t\tfloat dotNVcc = saturate( dot( geometryClearcoatNormal, geometryViewDir ) );\n\t\tvec3 Fcc = F_Schlick( material.clearcoatF0, material.clearcoatF90, dotNVcc );\n\t\toutgoingLight = outgoingLight * ( 1.0 - material.clearcoat * Fcc ) + ( clearcoatSpecularDirect + clearcoatSpecularIndirect ) * material.clearcoat;\n\t#endif\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n}",meshtoon_vert:"#define TOON\nvarying vec3 vViewPosition;\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tvViewPosition = - mvPosition.xyz;\n\t#include \n\t#include \n\t#include \n}",meshtoon_frag:"#define TOON\nuniform vec3 diffuse;\nuniform vec3 emissive;\nuniform float opacity;\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include \n\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n\tvec3 totalEmissiveRadiance = emissive;\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tvec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + totalEmissiveRadiance;\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n}",points_vert:"uniform float size;\nuniform float scale;\n#include \n#include \n#include \n#include \n#include \n#include \n#ifdef USE_POINTS_UV\n\tvarying vec2 vUv;\n\tuniform mat3 uvTransform;\n#endif\nvoid main() {\n\t#ifdef USE_POINTS_UV\n\t\tvUv = ( uvTransform * vec3( uv, 1 ) ).xy;\n\t#endif\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tgl_PointSize = size;\n\t#ifdef USE_SIZEATTENUATION\n\t\tbool isPerspective = isPerspectiveMatrix( projectionMatrix );\n\t\tif ( isPerspective ) gl_PointSize *= ( scale / - mvPosition.z );\n\t#endif\n\t#include \n\t#include \n\t#include \n\t#include \n}",points_frag:"uniform vec3 diffuse;\nuniform float opacity;\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include \n\tvec3 outgoingLight = vec3( 0.0 );\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\toutgoingLight = diffuseColor.rgb;\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n}",shadow_vert:"#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n}",shadow_frag:"uniform vec3 color;\nuniform float opacity;\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\tgl_FragColor = vec4( color, opacity * ( 1.0 - getShadowMask() ) );\n\t#include \n\t#include \n\t#include \n}",sprite_vert:"uniform float rotation;\nuniform vec2 center;\n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\tvec4 mvPosition = modelViewMatrix[ 3 ];\n\tvec2 scale = vec2( length( modelMatrix[ 0 ].xyz ), length( modelMatrix[ 1 ].xyz ) );\n\t#ifndef USE_SIZEATTENUATION\n\t\tbool isPerspective = isPerspectiveMatrix( projectionMatrix );\n\t\tif ( isPerspective ) scale *= - mvPosition.z;\n\t#endif\n\tvec2 alignedPosition = ( position.xy - ( center - vec2( 0.5 ) ) ) * scale;\n\tvec2 rotatedPosition;\n\trotatedPosition.x = cos( rotation ) * alignedPosition.x - sin( rotation ) * alignedPosition.y;\n\trotatedPosition.y = sin( rotation ) * alignedPosition.x + cos( rotation ) * alignedPosition.y;\n\tmvPosition.xy += rotatedPosition;\n\tgl_Position = projectionMatrix * mvPosition;\n\t#include \n\t#include \n\t#include \n}",sprite_frag:"uniform vec3 diffuse;\nuniform float opacity;\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include \n\tvec3 outgoingLight = vec3( 0.0 );\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\toutgoingLight = diffuseColor.rgb;\n\t#include \n\t#include \n\t#include \n\t#include \n}"},br={common:{diffuse:{value:new gi(16777215)},opacity:{value:1},map:{value:null},mapTransform:{value:new xt},alphaMap:{value:null},alphaMapTransform:{value:new xt},alphaTest:{value:0}},specularmap:{specularMap:{value:null},specularMapTransform:{value:new xt}},envmap:{envMap:{value:null},envMapRotation:{value:new xt},flipEnvMap:{value:-1},reflectivity:{value:1},ior:{value:1.5},refractionRatio:{value:.98}},aomap:{aoMap:{value:null},aoMapIntensity:{value:1},aoMapTransform:{value:new xt}},lightmap:{lightMap:{value:null},lightMapIntensity:{value:1},lightMapTransform:{value:new xt}},bumpmap:{bumpMap:{value:null},bumpMapTransform:{value:new xt},bumpScale:{value:1}},normalmap:{normalMap:{value:null},normalMapTransform:{value:new xt},normalScale:{value:new _t(1,1)}},displacementmap:{displacementMap:{value:null},displacementMapTransform:{value:new xt},displacementScale:{value:1},displacementBias:{value:0}},emissivemap:{emissiveMap:{value:null},emissiveMapTransform:{value:new xt}},metalnessmap:{metalnessMap:{value:null},metalnessMapTransform:{value:new xt}},roughnessmap:{roughnessMap:{value:null},roughnessMapTransform:{value:new xt}},gradientmap:{gradientMap:{value:null}},fog:{fogDensity:{value:25e-5},fogNear:{value:1},fogFar:{value:2e3},fogColor:{value:new gi(16777215)}},lights:{ambientLightColor:{value:[]},lightProbe:{value:[]},directionalLights:{value:[],properties:{direction:{},color:{}}},directionalLightShadows:{value:[],properties:{shadowIntensity:1,shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{}}},directionalShadowMap:{value:[]},directionalShadowMatrix:{value:[]},spotLights:{value:[],properties:{color:{},position:{},direction:{},distance:{},coneCos:{},penumbraCos:{},decay:{}}},spotLightShadows:{value:[],properties:{shadowIntensity:1,shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{}}},spotLightMap:{value:[]},spotShadowMap:{value:[]},spotLightMatrix:{value:[]},pointLights:{value:[],properties:{color:{},position:{},decay:{},distance:{}}},pointLightShadows:{value:[],properties:{shadowIntensity:1,shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{},shadowCameraNear:{},shadowCameraFar:{}}},pointShadowMap:{value:[]},pointShadowMatrix:{value:[]},hemisphereLights:{value:[],properties:{direction:{},skyColor:{},groundColor:{}}},rectAreaLights:{value:[],properties:{color:{},position:{},width:{},height:{}}},ltc_1:{value:null},ltc_2:{value:null}},points:{diffuse:{value:new gi(16777215)},opacity:{value:1},size:{value:1},scale:{value:1},map:{value:null},alphaMap:{value:null},alphaMapTransform:{value:new xt},alphaTest:{value:0},uvTransform:{value:new xt}},sprite:{diffuse:{value:new gi(16777215)},opacity:{value:1},center:{value:new _t(.5,.5)},rotation:{value:0},map:{value:null},mapTransform:{value:new xt},alphaMap:{value:null},alphaMapTransform:{value:new xt},alphaTest:{value:0}}},Mr={basic:{uniforms:$i([br.common,br.specularmap,br.envmap,br.aomap,br.lightmap,br.fog]),vertexShader:wr.meshbasic_vert,fragmentShader:wr.meshbasic_frag},lambert:{uniforms:$i([br.common,br.specularmap,br.envmap,br.aomap,br.lightmap,br.emissivemap,br.bumpmap,br.normalmap,br.displacementmap,br.fog,br.lights,{emissive:{value:new gi(0)}}]),vertexShader:wr.meshlambert_vert,fragmentShader:wr.meshlambert_frag},phong:{uniforms:$i([br.common,br.specularmap,br.envmap,br.aomap,br.lightmap,br.emissivemap,br.bumpmap,br.normalmap,br.displacementmap,br.fog,br.lights,{emissive:{value:new gi(0)},specular:{value:new gi(1118481)},shininess:{value:30}}]),vertexShader:wr.meshphong_vert,fragmentShader:wr.meshphong_frag},standard:{uniforms:$i([br.common,br.envmap,br.aomap,br.lightmap,br.emissivemap,br.bumpmap,br.normalmap,br.displacementmap,br.roughnessmap,br.metalnessmap,br.fog,br.lights,{emissive:{value:new gi(0)},roughness:{value:1},metalness:{value:0},envMapIntensity:{value:1}}]),vertexShader:wr.meshphysical_vert,fragmentShader:wr.meshphysical_frag},toon:{uniforms:$i([br.common,br.aomap,br.lightmap,br.emissivemap,br.bumpmap,br.normalmap,br.displacementmap,br.gradientmap,br.fog,br.lights,{emissive:{value:new gi(0)}}]),vertexShader:wr.meshtoon_vert,fragmentShader:wr.meshtoon_frag},matcap:{uniforms:$i([br.common,br.bumpmap,br.normalmap,br.displacementmap,br.fog,{matcap:{value:null}}]),vertexShader:wr.meshmatcap_vert,fragmentShader:wr.meshmatcap_frag},points:{uniforms:$i([br.points,br.fog]),vertexShader:wr.points_vert,fragmentShader:wr.points_frag},dashed:{uniforms:$i([br.common,br.fog,{scale:{value:1},dashSize:{value:1},totalSize:{value:2}}]),vertexShader:wr.linedashed_vert,fragmentShader:wr.linedashed_frag},depth:{uniforms:$i([br.common,br.displacementmap]),vertexShader:wr.depth_vert,fragmentShader:wr.depth_frag},normal:{uniforms:$i([br.common,br.bumpmap,br.normalmap,br.displacementmap,{opacity:{value:1}}]),vertexShader:wr.meshnormal_vert,fragmentShader:wr.meshnormal_frag},sprite:{uniforms:$i([br.sprite,br.fog]),vertexShader:wr.sprite_vert,fragmentShader:wr.sprite_frag},background:{uniforms:{uvTransform:{value:new xt},t2D:{value:null},backgroundIntensity:{value:1}},vertexShader:wr.background_vert,fragmentShader:wr.background_frag},backgroundCube:{uniforms:{envMap:{value:null},flipEnvMap:{value:-1},backgroundBlurriness:{value:0},backgroundIntensity:{value:1},backgroundRotation:{value:new xt}},vertexShader:wr.backgroundCube_vert,fragmentShader:wr.backgroundCube_frag},cube:{uniforms:{tCube:{value:null},tFlip:{value:-1},opacity:{value:1}},vertexShader:wr.cube_vert,fragmentShader:wr.cube_frag},equirect:{uniforms:{tEquirect:{value:null}},vertexShader:wr.equirect_vert,fragmentShader:wr.equirect_frag},distanceRGBA:{uniforms:$i([br.common,br.displacementmap,{referencePosition:{value:new Yt},nearDistance:{value:1},farDistance:{value:1e3}}]),vertexShader:wr.distanceRGBA_vert,fragmentShader:wr.distanceRGBA_frag},shadow:{uniforms:$i([br.lights,br.fog,{color:{value:new gi(0)},opacity:{value:1}}]),vertexShader:wr.shadow_vert,fragmentShader:wr.shadow_frag}};Mr.physical={uniforms:$i([Mr.standard.uniforms,{clearcoat:{value:0},clearcoatMap:{value:null},clearcoatMapTransform:{value:new xt},clearcoatNormalMap:{value:null},clearcoatNormalMapTransform:{value:new xt},clearcoatNormalScale:{value:new _t(1,1)},clearcoatRoughness:{value:0},clearcoatRoughnessMap:{value:null},clearcoatRoughnessMapTransform:{value:new xt},dispersion:{value:0},iridescence:{value:0},iridescenceMap:{value:null},iridescenceMapTransform:{value:new xt},iridescenceIOR:{value:1.3},iridescenceThicknessMinimum:{value:100},iridescenceThicknessMaximum:{value:400},iridescenceThicknessMap:{value:null},iridescenceThicknessMapTransform:{value:new xt},sheen:{value:0},sheenColor:{value:new gi(0)},sheenColorMap:{value:null},sheenColorMapTransform:{value:new xt},sheenRoughness:{value:1},sheenRoughnessMap:{value:null},sheenRoughnessMapTransform:{value:new xt},transmission:{value:0},transmissionMap:{value:null},transmissionMapTransform:{value:new xt},transmissionSamplerSize:{value:new _t},transmissionSamplerMap:{value:null},thickness:{value:0},thicknessMap:{value:null},thicknessMapTransform:{value:new xt},attenuationDistance:{value:0},attenuationColor:{value:new gi(0)},specularColor:{value:new gi(1,1,1)},specularColorMap:{value:null},specularColorMapTransform:{value:new xt},specularIntensity:{value:1},specularIntensityMap:{value:null},specularIntensityMapTransform:{value:new xt},anisotropyVector:{value:new _t},anisotropyMap:{value:null},anisotropyMapTransform:{value:new xt}}]),vertexShader:wr.meshphysical_vert,fragmentShader:wr.meshphysical_frag};const Tr={r:0,b:0,g:0},Er=new Un,Ar=new Mn;function Pr(e,t,n,i,r,a,s){const o=new gi(0);let l,c,h=!0===a?0:1,d=null,u=0,p=null;function f(e){let i=!0===e.isScene?e.background:null;return i&&i.isTexture&&(i=(e.backgroundBlurriness>0?n:t).get(i)),i}function m(t,n){t.getRGB(Tr,er(e)),i.buffers.color.setClear(Tr.r,Tr.g,Tr.b,n,s)}return{getClearColor:function(){return o},setClearColor:function(e,t=1){o.set(e),h=t,m(o,h)},getClearAlpha:function(){return h},setClearAlpha:function(e){h=e,m(o,h)},render:function(t){let n=!1;const r=f(t);null===r?m(o,h):r&&r.isColor&&(m(r,1),n=!0);const a=e.xr.getEnvironmentBlendMode();"additive"===a?i.buffers.color.setClear(0,0,0,1,s):"alpha-blend"===a&&i.buffers.color.setClear(0,0,0,0,s),(e.autoClear||n)&&(i.buffers.depth.setTest(!0),i.buffers.depth.setMask(!0),i.buffers.color.setMask(!0),e.clear(e.autoClearColor,e.autoClearDepth,e.autoClearStencil))},addToRenderList:function(t,n){const i=f(n);i&&(i.isCubeTexture||i.mapping===O)?(void 0===c&&(c=new Zi(new Ji(1,1,1),new nr({name:"BackgroundCubeMaterial",uniforms:Qi(Mr.backgroundCube.uniforms),vertexShader:Mr.backgroundCube.vertexShader,fragmentShader:Mr.backgroundCube.fragmentShader,side:1,depthTest:!1,depthWrite:!1,fog:!1})),c.geometry.deleteAttribute("normal"),c.geometry.deleteAttribute("uv"),c.onBeforeRender=function(e,t,n){this.matrixWorld.copyPosition(n.matrixWorld)},Object.defineProperty(c.material,"envMap",{get:function(){return this.uniforms.envMap.value}}),r.update(c)),Er.copy(n.backgroundRotation),Er.x*=-1,Er.y*=-1,Er.z*=-1,i.isCubeTexture&&!1===i.isRenderTargetTexture&&(Er.y*=-1,Er.z*=-1),c.material.uniforms.envMap.value=i,c.material.uniforms.flipEnvMap.value=i.isCubeTexture&&!1===i.isRenderTargetTexture?-1:1,c.material.uniforms.backgroundBlurriness.value=n.backgroundBlurriness,c.material.uniforms.backgroundIntensity.value=n.backgroundIntensity,c.material.uniforms.backgroundRotation.value.setFromMatrix4(Ar.makeRotationFromEuler(Er)),c.material.toneMapped=Et.getTransfer(i.colorSpace)!==Xe,d===i&&u===i.version&&p===e.toneMapping||(c.material.needsUpdate=!0,d=i,u=i.version,p=e.toneMapping),c.layers.enableAll(),t.unshift(c,c.geometry,c.material,0,0,null)):i&&i.isTexture&&(void 0===l&&(l=new Zi(new Sr(2,2),new nr({name:"BackgroundMaterial",uniforms:Qi(Mr.background.uniforms),vertexShader:Mr.background.vertexShader,fragmentShader:Mr.background.fragmentShader,side:0,depthTest:!1,depthWrite:!1,fog:!1})),l.geometry.deleteAttribute("normal"),Object.defineProperty(l.material,"map",{get:function(){return this.uniforms.t2D.value}}),r.update(l)),l.material.uniforms.t2D.value=i,l.material.uniforms.backgroundIntensity.value=n.backgroundIntensity,l.material.toneMapped=Et.getTransfer(i.colorSpace)!==Xe,!0===i.matrixAutoUpdate&&i.updateMatrix(),l.material.uniforms.uvTransform.value.copy(i.matrix),d===i&&u===i.version&&p===e.toneMapping||(l.material.needsUpdate=!0,d=i,u=i.version,p=e.toneMapping),l.layers.enableAll(),t.unshift(l,l.geometry,l.material,0,0,null))}}}function Rr(e,t){const n=e.getParameter(e.MAX_VERTEX_ATTRIBS),i={},r=c(null);let a=r,s=!1;function o(t){return e.bindVertexArray(t)}function l(t){return e.deleteVertexArray(t)}function c(e){const t=[],i=[],r=[];for(let e=0;e=0){const n=r[t];let i=s[t];if(void 0===i&&("instanceMatrix"===t&&e.instanceMatrix&&(i=e.instanceMatrix),"instanceColor"===t&&e.instanceColor&&(i=e.instanceColor)),void 0===n)return!0;if(n.attribute!==i)return!0;if(i&&n.data!==i.data)return!0;o++}return a.attributesNum!==o||a.index!==i}(n,m,l,g),v&&function(e,t,n,i){const r={},s=t.attributes;let o=0;const l=n.getAttributes();for(const t in l)if(l[t].location>=0){let n=s[t];void 0===n&&("instanceMatrix"===t&&e.instanceMatrix&&(n=e.instanceMatrix),"instanceColor"===t&&e.instanceColor&&(n=e.instanceColor));const i={};i.attribute=n,n&&n.data&&(i.data=n.data),r[t]=i,o++}a.attributes=r,a.attributesNum=o,a.index=i}(n,m,l,g),null!==g&&t.update(g,e.ELEMENT_ARRAY_BUFFER),(v||s)&&(s=!1,function(n,i,r,a){h();const s=a.attributes,o=r.getAttributes(),l=i.defaultAttributeValues;for(const i in o){const r=o[i];if(r.location>=0){let o=s[i];if(void 0===o&&("instanceMatrix"===i&&n.instanceMatrix&&(o=n.instanceMatrix),"instanceColor"===i&&n.instanceColor&&(o=n.instanceColor)),void 0!==o){const i=o.normalized,s=o.itemSize,l=t.get(o);if(void 0===l)continue;const c=l.buffer,h=l.type,p=l.bytesPerElement,m=h===e.INT||h===e.UNSIGNED_INT||o.gpuType===Y;if(o.isInterleavedBufferAttribute){const t=o.data,l=t.stride,g=o.offset;if(t.isInstancedInterleavedBuffer){for(let e=0;e0&&e.getShaderPrecisionFormat(e.FRAGMENT_SHADER,e.HIGH_FLOAT).precision>0)return"highp";t="mediump"}return"mediump"===t&&e.getShaderPrecisionFormat(e.VERTEX_SHADER,e.MEDIUM_FLOAT).precision>0&&e.getShaderPrecisionFormat(e.FRAGMENT_SHADER,e.MEDIUM_FLOAT).precision>0?"mediump":"lowp"}let s=void 0!==n.precision?n.precision:"highp";const o=a(s);o!==s&&(console.warn("THREE.WebGLRenderer:",s,"not supported, using",o,"instead."),s=o);const l=!0===n.logarithmicDepthBuffer,c=!0===n.reverseDepthBuffer&&t.has("EXT_clip_control"),h=e.getParameter(e.MAX_TEXTURE_IMAGE_UNITS),d=e.getParameter(e.MAX_VERTEX_TEXTURE_IMAGE_UNITS);return{isWebGL2:!0,getMaxAnisotropy:function(){if(void 0!==r)return r;if(!0===t.has("EXT_texture_filter_anisotropic")){const n=t.get("EXT_texture_filter_anisotropic");r=e.getParameter(n.MAX_TEXTURE_MAX_ANISOTROPY_EXT)}else r=0;return r},getMaxPrecision:a,textureFormatReadable:function(t){return t===ee||i.convert(t)===e.getParameter(e.IMPLEMENTATION_COLOR_READ_FORMAT)},textureTypeReadable:function(n){const r=n===K&&(t.has("EXT_color_buffer_half_float")||t.has("EXT_color_buffer_float"));return!(n!==j&&i.convert(n)!==e.getParameter(e.IMPLEMENTATION_COLOR_READ_TYPE)&&n!==Z&&!r)},precision:s,logarithmicDepthBuffer:l,reverseDepthBuffer:c,maxTextures:h,maxVertexTextures:d,maxTextureSize:e.getParameter(e.MAX_TEXTURE_SIZE),maxCubemapSize:e.getParameter(e.MAX_CUBE_MAP_TEXTURE_SIZE),maxAttributes:e.getParameter(e.MAX_VERTEX_ATTRIBS),maxVertexUniforms:e.getParameter(e.MAX_VERTEX_UNIFORM_VECTORS),maxVaryings:e.getParameter(e.MAX_VARYING_VECTORS),maxFragmentUniforms:e.getParameter(e.MAX_FRAGMENT_UNIFORM_VECTORS),vertexTextures:d>0,maxSamples:e.getParameter(e.MAX_SAMPLES)}}function Lr(e){const t=this;let n=null,i=0,r=!1,a=!1;const s=new mr,o=new xt,l={value:null,needsUpdate:!1};function c(e,n,i,r){const a=null!==e?e.length:0;let c=null;if(0!==a){if(c=l.value,!0!==r||null===c){const t=i+4*a,r=n.matrixWorldInverse;o.getNormalMatrix(r),(null===c||c.length0),t.numPlanes=i,t.numIntersection=0);else{const e=a?0:i,t=4*e;let r=f.clippingState||null;l.value=r,r=c(d,o,t,h);for(let e=0;e!==t;++e)r[e]=n[e];f.clippingState=r,this.numIntersection=u?this.numPlanes:0,this.numPlanes+=e}}}function Ir(e){let t=new WeakMap;function n(e,t){return 303===t?e.mapping=I:304===t&&(e.mapping=U),e}function i(e){const n=e.target;n.removeEventListener("dispose",i);const r=t.get(n);void 0!==r&&(t.delete(n),r.dispose())}return{get:function(r){if(r&&r.isTexture){const a=r.mapping;if(303===a||304===a){if(t.has(r))return n(t.get(r).texture,r.mapping);{const a=r.image;if(a&&a.height>0){const s=new dr(a.height);return s.fromEquirectangularTexture(e,r),t.set(r,s),r.addEventListener("dispose",i),n(s.texture,r.mapping)}return null}}}return r},dispose:function(){t=new WeakMap}}}class Ur extends ir{constructor(e=-1,t=1,n=1,i=-1,r=.1,a=2e3){super(),this.isOrthographicCamera=!0,this.type="OrthographicCamera",this.zoom=1,this.view=null,this.left=e,this.right=t,this.top=n,this.bottom=i,this.near=r,this.far=a,this.updateProjectionMatrix()}copy(e,t){return super.copy(e,t),this.left=e.left,this.right=e.right,this.top=e.top,this.bottom=e.bottom,this.near=e.near,this.far=e.far,this.zoom=e.zoom,this.view=null===e.view?null:Object.assign({},e.view),this}setViewOffset(e,t,n,i,r,a){null===this.view&&(this.view={enabled:!0,fullWidth:1,fullHeight:1,offsetX:0,offsetY:0,width:1,height:1}),this.view.enabled=!0,this.view.fullWidth=e,this.view.fullHeight=t,this.view.offsetX=n,this.view.offsetY=i,this.view.width=r,this.view.height=a,this.updateProjectionMatrix()}clearViewOffset(){null!==this.view&&(this.view.enabled=!1),this.updateProjectionMatrix()}updateProjectionMatrix(){const e=(this.right-this.left)/(2*this.zoom),t=(this.top-this.bottom)/(2*this.zoom),n=(this.right+this.left)/2,i=(this.top+this.bottom)/2;let r=n-e,a=n+e,s=i+t,o=i-t;if(null!==this.view&&this.view.enabled){const e=(this.right-this.left)/this.view.fullWidth/this.zoom,t=(this.top-this.bottom)/this.view.fullHeight/this.zoom;r+=e*this.view.offsetX,a=r+e*this.view.width,s-=t*this.view.offsetY,o=s-t*this.view.height}this.projectionMatrix.makeOrthographic(r,a,s,o,this.near,this.far,this.coordinateSystem),this.projectionMatrixInverse.copy(this.projectionMatrix).invert()}toJSON(e){const t=super.toJSON(e);return t.object.zoom=this.zoom,t.object.left=this.left,t.object.right=this.right,t.object.top=this.top,t.object.bottom=this.bottom,t.object.near=this.near,t.object.far=this.far,null!==this.view&&(t.object.view=Object.assign({},this.view)),t}}const Or=[.125,.215,.35,.446,.526,.582],Nr=new Ur,Fr=new gi;let Br=null,zr=0,kr=0,Hr=!1;const Vr=(1+Math.sqrt(5))/2,Gr=1/Vr,Wr=[new Yt(-Vr,Gr,0),new Yt(Vr,Gr,0),new Yt(-Gr,0,Vr),new Yt(Gr,0,Vr),new Yt(0,Vr,-Gr),new Yt(0,Vr,Gr),new Yt(-1,1,-1),new Yt(1,1,-1),new Yt(-1,1,1),new Yt(1,1,1)];class jr{constructor(e){this._renderer=e,this._pingPongRenderTarget=null,this._lodMax=0,this._cubeSize=0,this._lodPlanes=[],this._sizeLods=[],this._sigmas=[],this._blurMaterial=null,this._cubemapMaterial=null,this._equirectMaterial=null,this._compileMaterial(this._blurMaterial)}fromScene(e,t=0,n=.1,i=100){Br=this._renderer.getRenderTarget(),zr=this._renderer.getActiveCubeFace(),kr=this._renderer.getActiveMipmapLevel(),Hr=this._renderer.xr.enabled,this._renderer.xr.enabled=!1,this._setSize(256);const r=this._allocateTargets();return r.depthBuffer=!0,this._sceneToCubeUV(e,n,i,r),t>0&&this._blur(r,0,0,t),this._applyPMREM(r),this._cleanup(r),r}fromEquirectangular(e,t=null){return this._fromTexture(e,t)}fromCubemap(e,t=null){return this._fromTexture(e,t)}compileCubemapShader(){null===this._cubemapMaterial&&(this._cubemapMaterial=Zr(),this._compileMaterial(this._cubemapMaterial))}compileEquirectangularShader(){null===this._equirectMaterial&&(this._equirectMaterial=qr(),this._compileMaterial(this._equirectMaterial))}dispose(){this._dispose(),null!==this._cubemapMaterial&&this._cubemapMaterial.dispose(),null!==this._equirectMaterial&&this._equirectMaterial.dispose()}_setSize(e){this._lodMax=Math.floor(Math.log2(e)),this._cubeSize=Math.pow(2,this._lodMax)}_dispose(){null!==this._blurMaterial&&this._blurMaterial.dispose(),null!==this._pingPongRenderTarget&&this._pingPongRenderTarget.dispose();for(let e=0;ee-4?o=Or[s-e+4-1]:0===s&&(o=0),i.push(o);const l=1/(a-2),c=-l,h=1+l,d=[c,c,h,c,h,h,c,c,h,h,c,h],u=6,p=6,f=3,m=2,g=1,v=new Float32Array(f*p*u),_=new Float32Array(m*p*u),x=new Float32Array(g*p*u);for(let e=0;e2?0:-1,i=[t,n,0,t+2/3,n,0,t+2/3,n+1,0,t,n,0,t+2/3,n+1,0,t,n+1,0];v.set(i,f*p*e),_.set(d,m*p*e);const r=[e,e,e,e,e,e];x.set(r,g*p*e)}const y=new Fi;y.setAttribute("position",new Ei(v,f)),y.setAttribute("uv",new Ei(_,m)),y.setAttribute("faceIndex",new Ei(x,g)),t.push(y),r>4&&r--}return{lodPlanes:t,sizeLods:n,sigmas:i}}(i)),this._blurMaterial=function(e,t,n){const i=new Float32Array(20),r=new Yt(0,1,0);return new nr({name:"SphericalGaussianBlur",defines:{n:20,CUBEUV_TEXEL_WIDTH:1/t,CUBEUV_TEXEL_HEIGHT:1/n,CUBEUV_MAX_MIP:`${e}.0`},uniforms:{envMap:{value:null},samples:{value:1},weights:{value:i},latitudinal:{value:!1},dTheta:{value:0},mipInt:{value:0},poleAxis:{value:r}},vertexShader:"\n\n\t\tprecision mediump float;\n\t\tprecision mediump int;\n\n\t\tattribute float faceIndex;\n\n\t\tvarying vec3 vOutputDirection;\n\n\t\t// RH coordinate system; PMREM face-indexing convention\n\t\tvec3 getDirection( vec2 uv, float face ) {\n\n\t\t\tuv = 2.0 * uv - 1.0;\n\n\t\t\tvec3 direction = vec3( uv, 1.0 );\n\n\t\t\tif ( face == 0.0 ) {\n\n\t\t\t\tdirection = direction.zyx; // ( 1, v, u ) pos x\n\n\t\t\t} else if ( face == 1.0 ) {\n\n\t\t\t\tdirection = direction.xzy;\n\t\t\t\tdirection.xz *= -1.0; // ( -u, 1, -v ) pos y\n\n\t\t\t} else if ( face == 2.0 ) {\n\n\t\t\t\tdirection.x *= -1.0; // ( -u, v, 1 ) pos z\n\n\t\t\t} else if ( face == 3.0 ) {\n\n\t\t\t\tdirection = direction.zyx;\n\t\t\t\tdirection.xz *= -1.0; // ( -1, v, -u ) neg x\n\n\t\t\t} else if ( face == 4.0 ) {\n\n\t\t\t\tdirection = direction.xzy;\n\t\t\t\tdirection.xy *= -1.0; // ( -u, -1, v ) neg y\n\n\t\t\t} else if ( face == 5.0 ) {\n\n\t\t\t\tdirection.z *= -1.0; // ( u, v, -1 ) neg z\n\n\t\t\t}\n\n\t\t\treturn direction;\n\n\t\t}\n\n\t\tvoid main() {\n\n\t\t\tvOutputDirection = getDirection( uv, faceIndex );\n\t\t\tgl_Position = vec4( position, 1.0 );\n\n\t\t}\n\t",fragmentShader:"\n\n\t\t\tprecision mediump float;\n\t\t\tprecision mediump int;\n\n\t\t\tvarying vec3 vOutputDirection;\n\n\t\t\tuniform sampler2D envMap;\n\t\t\tuniform int samples;\n\t\t\tuniform float weights[ n ];\n\t\t\tuniform bool latitudinal;\n\t\t\tuniform float dTheta;\n\t\t\tuniform float mipInt;\n\t\t\tuniform vec3 poleAxis;\n\n\t\t\t#define ENVMAP_TYPE_CUBE_UV\n\t\t\t#include \n\n\t\t\tvec3 getSample( float theta, vec3 axis ) {\n\n\t\t\t\tfloat cosTheta = cos( theta );\n\t\t\t\t// Rodrigues' axis-angle rotation\n\t\t\t\tvec3 sampleDirection = vOutputDirection * cosTheta\n\t\t\t\t\t+ cross( axis, vOutputDirection ) * sin( theta )\n\t\t\t\t\t+ axis * dot( axis, vOutputDirection ) * ( 1.0 - cosTheta );\n\n\t\t\t\treturn bilinearCubeUV( envMap, sampleDirection, mipInt );\n\n\t\t\t}\n\n\t\t\tvoid main() {\n\n\t\t\t\tvec3 axis = latitudinal ? poleAxis : cross( poleAxis, vOutputDirection );\n\n\t\t\t\tif ( all( equal( axis, vec3( 0.0 ) ) ) ) {\n\n\t\t\t\t\taxis = vec3( vOutputDirection.z, 0.0, - vOutputDirection.x );\n\n\t\t\t\t}\n\n\t\t\t\taxis = normalize( axis );\n\n\t\t\t\tgl_FragColor = vec4( 0.0, 0.0, 0.0, 1.0 );\n\t\t\t\tgl_FragColor.rgb += weights[ 0 ] * getSample( 0.0, axis );\n\n\t\t\t\tfor ( int i = 1; i < n; i++ ) {\n\n\t\t\t\t\tif ( i >= samples ) {\n\n\t\t\t\t\t\tbreak;\n\n\t\t\t\t\t}\n\n\t\t\t\t\tfloat theta = dTheta * float( i );\n\t\t\t\t\tgl_FragColor.rgb += weights[ i ] * getSample( -1.0 * theta, axis );\n\t\t\t\t\tgl_FragColor.rgb += weights[ i ] * getSample( theta, axis );\n\n\t\t\t\t}\n\n\t\t\t}\n\t\t",blending:0,depthTest:!1,depthWrite:!1})}(i,e,t)}return i}_compileMaterial(e){const t=new Zi(this._lodPlanes[0],e);this._renderer.compile(t,Nr)}_sceneToCubeUV(e,t,n,i){const r=new or(90,1,t,n),a=[1,-1,1,1,1,1],s=[1,1,1,-1,-1,-1],o=this._renderer,l=o.autoClear,c=o.toneMapping;o.getClearColor(Fr),o.toneMapping=0,o.autoClear=!1;const h=new yi({name:"PMREM.Background",side:1,depthWrite:!1,depthTest:!1}),d=new Zi(new Ji,h);let u=!1;const p=e.background;p?p.isColor&&(h.color.copy(p),e.background=null,u=!0):(h.color.copy(Fr),u=!0);for(let t=0;t<6;t++){const n=t%3;0===n?(r.up.set(0,a[t],0),r.lookAt(s[t],0,0)):1===n?(r.up.set(0,0,a[t]),r.lookAt(0,s[t],0)):(r.up.set(0,a[t],0),r.lookAt(0,0,s[t]));const l=this._cubeSize;Yr(i,n*l,t>2?l:0,l,l),o.setRenderTarget(i),u&&o.render(d,r),o.render(e,r)}d.geometry.dispose(),d.material.dispose(),o.toneMapping=c,o.autoClear=l,e.background=p}_textureToCubeUV(e,t){const n=this._renderer,i=e.mapping===I||e.mapping===U;i?(null===this._cubemapMaterial&&(this._cubemapMaterial=Zr()),this._cubemapMaterial.uniforms.flipEnvMap.value=!1===e.isRenderTargetTexture?-1:1):null===this._equirectMaterial&&(this._equirectMaterial=qr());const r=i?this._cubemapMaterial:this._equirectMaterial,a=new Zi(this._lodPlanes[0],r);r.uniforms.envMap.value=e;const s=this._cubeSize;Yr(t,0,0,3*s,2*s),n.setRenderTarget(t),n.render(a,Nr)}_applyPMREM(e){const t=this._renderer,n=t.autoClear;t.autoClear=!1;const i=this._lodPlanes.length;for(let t=1;t20&&console.warn(`sigmaRadians, ${r}, is too large and will clip, as it requested ${f} samples when the maximum is set to 20`);const m=[];let g=0;for(let e=0;e<20;++e){const t=e/p,n=Math.exp(-t*t/2);m.push(n),0===e?g+=n:ev-4?i-v+4:0),4*(this._cubeSize-_),3*_,2*_),o.setRenderTarget(t),o.render(c,Nr)}}function Xr(e,t,n){const i=new Gt(e,t,n);return i.texture.mapping=O,i.texture.name="PMREM.cubeUv",i.scissorTest=!0,i}function Yr(e,t,n,i,r){e.viewport.set(t,n,i,r),e.scissor.set(t,n,i,r)}function qr(){return new nr({name:"EquirectangularToCubeUV",uniforms:{envMap:{value:null}},vertexShader:"\n\n\t\tprecision mediump float;\n\t\tprecision mediump int;\n\n\t\tattribute float faceIndex;\n\n\t\tvarying vec3 vOutputDirection;\n\n\t\t// RH coordinate system; PMREM face-indexing convention\n\t\tvec3 getDirection( vec2 uv, float face ) {\n\n\t\t\tuv = 2.0 * uv - 1.0;\n\n\t\t\tvec3 direction = vec3( uv, 1.0 );\n\n\t\t\tif ( face == 0.0 ) {\n\n\t\t\t\tdirection = direction.zyx; // ( 1, v, u ) pos x\n\n\t\t\t} else if ( face == 1.0 ) {\n\n\t\t\t\tdirection = direction.xzy;\n\t\t\t\tdirection.xz *= -1.0; // ( -u, 1, -v ) pos y\n\n\t\t\t} else if ( face == 2.0 ) {\n\n\t\t\t\tdirection.x *= -1.0; // ( -u, v, 1 ) pos z\n\n\t\t\t} else if ( face == 3.0 ) {\n\n\t\t\t\tdirection = direction.zyx;\n\t\t\t\tdirection.xz *= -1.0; // ( -1, v, -u ) neg x\n\n\t\t\t} else if ( face == 4.0 ) {\n\n\t\t\t\tdirection = direction.xzy;\n\t\t\t\tdirection.xy *= -1.0; // ( -u, -1, v ) neg y\n\n\t\t\t} else if ( face == 5.0 ) {\n\n\t\t\t\tdirection.z *= -1.0; // ( u, v, -1 ) neg z\n\n\t\t\t}\n\n\t\t\treturn direction;\n\n\t\t}\n\n\t\tvoid main() {\n\n\t\t\tvOutputDirection = getDirection( uv, faceIndex );\n\t\t\tgl_Position = vec4( position, 1.0 );\n\n\t\t}\n\t",fragmentShader:"\n\n\t\t\tprecision mediump float;\n\t\t\tprecision mediump int;\n\n\t\t\tvarying vec3 vOutputDirection;\n\n\t\t\tuniform sampler2D envMap;\n\n\t\t\t#include \n\n\t\t\tvoid main() {\n\n\t\t\t\tvec3 outputDirection = normalize( vOutputDirection );\n\t\t\t\tvec2 uv = equirectUv( outputDirection );\n\n\t\t\t\tgl_FragColor = vec4( texture2D ( envMap, uv ).rgb, 1.0 );\n\n\t\t\t}\n\t\t",blending:0,depthTest:!1,depthWrite:!1})}function Zr(){return new nr({name:"CubemapToCubeUV",uniforms:{envMap:{value:null},flipEnvMap:{value:-1}},vertexShader:"\n\n\t\tprecision mediump float;\n\t\tprecision mediump int;\n\n\t\tattribute float faceIndex;\n\n\t\tvarying vec3 vOutputDirection;\n\n\t\t// RH coordinate system; PMREM face-indexing convention\n\t\tvec3 getDirection( vec2 uv, float face ) {\n\n\t\t\tuv = 2.0 * uv - 1.0;\n\n\t\t\tvec3 direction = vec3( uv, 1.0 );\n\n\t\t\tif ( face == 0.0 ) {\n\n\t\t\t\tdirection = direction.zyx; // ( 1, v, u ) pos x\n\n\t\t\t} else if ( face == 1.0 ) {\n\n\t\t\t\tdirection = direction.xzy;\n\t\t\t\tdirection.xz *= -1.0; // ( -u, 1, -v ) pos y\n\n\t\t\t} else if ( face == 2.0 ) {\n\n\t\t\t\tdirection.x *= -1.0; // ( -u, v, 1 ) pos z\n\n\t\t\t} else if ( face == 3.0 ) {\n\n\t\t\t\tdirection = direction.zyx;\n\t\t\t\tdirection.xz *= -1.0; // ( -1, v, -u ) neg x\n\n\t\t\t} else if ( face == 4.0 ) {\n\n\t\t\t\tdirection = direction.xzy;\n\t\t\t\tdirection.xy *= -1.0; // ( -u, -1, v ) neg y\n\n\t\t\t} else if ( face == 5.0 ) {\n\n\t\t\t\tdirection.z *= -1.0; // ( u, v, -1 ) neg z\n\n\t\t\t}\n\n\t\t\treturn direction;\n\n\t\t}\n\n\t\tvoid main() {\n\n\t\t\tvOutputDirection = getDirection( uv, faceIndex );\n\t\t\tgl_Position = vec4( position, 1.0 );\n\n\t\t}\n\t",fragmentShader:"\n\n\t\t\tprecision mediump float;\n\t\t\tprecision mediump int;\n\n\t\t\tuniform float flipEnvMap;\n\n\t\t\tvarying vec3 vOutputDirection;\n\n\t\t\tuniform samplerCube envMap;\n\n\t\t\tvoid main() {\n\n\t\t\t\tgl_FragColor = textureCube( envMap, vec3( flipEnvMap * vOutputDirection.x, vOutputDirection.yz ) );\n\n\t\t\t}\n\t\t",blending:0,depthTest:!1,depthWrite:!1})}function Kr(e){let t=new WeakMap,n=null;function i(e){const n=e.target;n.removeEventListener("dispose",i);const r=t.get(n);void 0!==r&&(t.delete(n),r.dispose())}return{get:function(r){if(r&&r.isTexture){const a=r.mapping,s=303===a||304===a,o=a===I||a===U;if(s||o){let a=t.get(r);const l=void 0!==a?a.texture.pmremVersion:0;if(r.isRenderTargetTexture&&r.pmremVersion!==l)return null===n&&(n=new jr(e)),a=s?n.fromEquirectangular(r,a):n.fromCubemap(r,a),a.texture.pmremVersion=r.pmremVersion,t.set(r,a),a.texture;if(void 0!==a)return a.texture;{const l=r.image;return s&&l&&l.height>0||o&&l&&function(e){let t=0;for(let n=0;n<6;n++)void 0!==e[n]&&t++;return 6===t}(l)?(null===n&&(n=new jr(e)),a=s?n.fromEquirectangular(r):n.fromCubemap(r),a.texture.pmremVersion=r.pmremVersion,t.set(r,a),r.addEventListener("dispose",i),a.texture):null}}}return r},dispose:function(){t=new WeakMap,null!==n&&(n.dispose(),n=null)}}}function Jr(e){const t={};function n(n){if(void 0!==t[n])return t[n];let i;switch(n){case"WEBGL_depth_texture":i=e.getExtension("WEBGL_depth_texture")||e.getExtension("MOZ_WEBGL_depth_texture")||e.getExtension("WEBKIT_WEBGL_depth_texture");break;case"EXT_texture_filter_anisotropic":i=e.getExtension("EXT_texture_filter_anisotropic")||e.getExtension("MOZ_EXT_texture_filter_anisotropic")||e.getExtension("WEBKIT_EXT_texture_filter_anisotropic");break;case"WEBGL_compressed_texture_s3tc":i=e.getExtension("WEBGL_compressed_texture_s3tc")||e.getExtension("MOZ_WEBGL_compressed_texture_s3tc")||e.getExtension("WEBKIT_WEBGL_compressed_texture_s3tc");break;case"WEBGL_compressed_texture_pvrtc":i=e.getExtension("WEBGL_compressed_texture_pvrtc")||e.getExtension("WEBKIT_WEBGL_compressed_texture_pvrtc");break;default:i=e.getExtension(n)}return t[n]=i,i}return{has:function(e){return null!==n(e)},init:function(){n("EXT_color_buffer_float"),n("WEBGL_clip_cull_distance"),n("OES_texture_float_linear"),n("EXT_color_buffer_half_float"),n("WEBGL_multisampled_render_to_texture"),n("WEBGL_render_shared_exponent")},get:function(e){const t=n(e);return null===t&&Tt("THREE.WebGLRenderer: "+e+" extension not supported."),t}}}function Qr(e,t,n,i){const r={},a=new WeakMap;function s(e){const o=e.target;null!==o.index&&t.remove(o.index);for(const e in o.attributes)t.remove(o.attributes[e]);for(const e in o.morphAttributes){const n=o.morphAttributes[e];for(let e=0,i=n.length;et.maxTextureSize&&(y=Math.ceil(x/t.maxTextureSize),x=t.maxTextureSize);const S=new Float32Array(x*y*4*h),w=new Wt(S,x,y,h);w.type=Z,w.needsUpdate=!0;const b=4*_;for(let T=0;T0)return e;const r=t*n;let a=ca[r];if(void 0===a&&(a=new Float32Array(r),ca[r]=a),0!==t){i.toArray(a,0);for(let i=1,r=0;i!==t;++i)r+=n,e[i].toArray(a,r)}return a}function ma(e,t){if(e.length!==t.length)return!1;for(let n=0,i=e.length;n":" "} ${r}: ${n[e]}`)}return i.join("\n")}(e.getShaderSource(t),i)}return r}function ps(e,t){const n=function(e){Et._getMatrix(ds,Et.workingColorSpace,e);const t=`mat3( ${ds.elements.map((e=>e.toFixed(4)))} )`;switch(Et.getTransfer(e)){case je:return[t,"LinearTransferOETF"];case Xe:return[t,"sRGBTransferOETF"];default:return console.warn("THREE.WebGLProgram: Unsupported color space: ",e),[t,"LinearTransferOETF"]}}(t);return[`vec4 ${e}( vec4 value ) {`,`\treturn ${n[1]}( vec4( value.rgb * ${n[0]}, value.a ) );`,"}"].join("\n")}function fs(e,t){let n;switch(t){case 1:n="Linear";break;case 2:n="Reinhard";break;case 3:n="Cineon";break;case 4:n="ACESFilmic";break;case 6:n="AgX";break;case 7:n="Neutral";break;case 5:n="Custom";break;default:console.warn("THREE.WebGLProgram: Unsupported toneMapping:",t),n="Linear"}return"vec3 "+e+"( vec3 color ) { return "+n+"ToneMapping( color ); }"}const ms=new Yt;function gs(e){return""!==e}function vs(e,t){const n=t.numSpotLightShadows+t.numSpotLightMaps-t.numSpotLightShadowsWithMaps;return e.replace(/NUM_DIR_LIGHTS/g,t.numDirLights).replace(/NUM_SPOT_LIGHTS/g,t.numSpotLights).replace(/NUM_SPOT_LIGHT_MAPS/g,t.numSpotLightMaps).replace(/NUM_SPOT_LIGHT_COORDS/g,n).replace(/NUM_RECT_AREA_LIGHTS/g,t.numRectAreaLights).replace(/NUM_POINT_LIGHTS/g,t.numPointLights).replace(/NUM_HEMI_LIGHTS/g,t.numHemiLights).replace(/NUM_DIR_LIGHT_SHADOWS/g,t.numDirLightShadows).replace(/NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS/g,t.numSpotLightShadowsWithMaps).replace(/NUM_SPOT_LIGHT_SHADOWS/g,t.numSpotLightShadows).replace(/NUM_POINT_LIGHT_SHADOWS/g,t.numPointLightShadows)}function _s(e,t){return e.replace(/NUM_CLIPPING_PLANES/g,t.numClippingPlanes).replace(/UNION_CLIPPING_PLANES/g,t.numClippingPlanes-t.numClipIntersection)}const xs=/^[ \t]*#include +<([\w\d./]+)>/gm;function ys(e){return e.replace(xs,ws)}const Ss=new Map;function ws(e,t){let n=wr[t];if(void 0===n){const e=Ss.get(t);if(void 0===e)throw new Error("Can not resolve #include <"+t+">");n=wr[e],console.warn('THREE.WebGLRenderer: Shader chunk "%s" has been deprecated. Use "%s" instead.',t,e)}return ys(n)}const bs=/#pragma unroll_loop_start\s+for\s*\(\s*int\s+i\s*=\s*(\d+)\s*;\s*i\s*<\s*(\d+)\s*;\s*i\s*\+\+\s*\)\s*{([\s\S]+?)}\s+#pragma unroll_loop_end/g;function Ms(e){return e.replace(bs,Ts)}function Ts(e,t,n,i){let r="";for(let e=parseInt(t);e0&&(g+="\n"),v=["#define SHADER_TYPE "+n.shaderType,"#define SHADER_NAME "+n.shaderName,f].filter(gs).join("\n"),v.length>0&&(v+="\n")):(g=[Es(n),"#define SHADER_TYPE "+n.shaderType,"#define SHADER_NAME "+n.shaderName,f,n.extensionClipCullDistance?"#define USE_CLIP_DISTANCE":"",n.batching?"#define USE_BATCHING":"",n.batchingColor?"#define USE_BATCHING_COLOR":"",n.instancing?"#define USE_INSTANCING":"",n.instancingColor?"#define USE_INSTANCING_COLOR":"",n.instancingMorph?"#define USE_INSTANCING_MORPH":"",n.useFog&&n.fog?"#define USE_FOG":"",n.useFog&&n.fogExp2?"#define FOG_EXP2":"",n.map?"#define USE_MAP":"",n.envMap?"#define USE_ENVMAP":"",n.envMap?"#define "+h:"",n.lightMap?"#define USE_LIGHTMAP":"",n.aoMap?"#define USE_AOMAP":"",n.bumpMap?"#define USE_BUMPMAP":"",n.normalMap?"#define USE_NORMALMAP":"",n.normalMapObjectSpace?"#define USE_NORMALMAP_OBJECTSPACE":"",n.normalMapTangentSpace?"#define USE_NORMALMAP_TANGENTSPACE":"",n.displacementMap?"#define USE_DISPLACEMENTMAP":"",n.emissiveMap?"#define USE_EMISSIVEMAP":"",n.anisotropy?"#define USE_ANISOTROPY":"",n.anisotropyMap?"#define USE_ANISOTROPYMAP":"",n.clearcoatMap?"#define USE_CLEARCOATMAP":"",n.clearcoatRoughnessMap?"#define USE_CLEARCOAT_ROUGHNESSMAP":"",n.clearcoatNormalMap?"#define USE_CLEARCOAT_NORMALMAP":"",n.iridescenceMap?"#define USE_IRIDESCENCEMAP":"",n.iridescenceThicknessMap?"#define USE_IRIDESCENCE_THICKNESSMAP":"",n.specularMap?"#define USE_SPECULARMAP":"",n.specularColorMap?"#define USE_SPECULAR_COLORMAP":"",n.specularIntensityMap?"#define USE_SPECULAR_INTENSITYMAP":"",n.roughnessMap?"#define USE_ROUGHNESSMAP":"",n.metalnessMap?"#define USE_METALNESSMAP":"",n.alphaMap?"#define USE_ALPHAMAP":"",n.alphaHash?"#define USE_ALPHAHASH":"",n.transmission?"#define USE_TRANSMISSION":"",n.transmissionMap?"#define USE_TRANSMISSIONMAP":"",n.thicknessMap?"#define USE_THICKNESSMAP":"",n.sheenColorMap?"#define USE_SHEEN_COLORMAP":"",n.sheenRoughnessMap?"#define USE_SHEEN_ROUGHNESSMAP":"",n.mapUv?"#define MAP_UV "+n.mapUv:"",n.alphaMapUv?"#define ALPHAMAP_UV "+n.alphaMapUv:"",n.lightMapUv?"#define LIGHTMAP_UV "+n.lightMapUv:"",n.aoMapUv?"#define AOMAP_UV "+n.aoMapUv:"",n.emissiveMapUv?"#define EMISSIVEMAP_UV "+n.emissiveMapUv:"",n.bumpMapUv?"#define BUMPMAP_UV "+n.bumpMapUv:"",n.normalMapUv?"#define NORMALMAP_UV "+n.normalMapUv:"",n.displacementMapUv?"#define DISPLACEMENTMAP_UV "+n.displacementMapUv:"",n.metalnessMapUv?"#define METALNESSMAP_UV "+n.metalnessMapUv:"",n.roughnessMapUv?"#define ROUGHNESSMAP_UV "+n.roughnessMapUv:"",n.anisotropyMapUv?"#define ANISOTROPYMAP_UV "+n.anisotropyMapUv:"",n.clearcoatMapUv?"#define CLEARCOATMAP_UV "+n.clearcoatMapUv:"",n.clearcoatNormalMapUv?"#define CLEARCOAT_NORMALMAP_UV "+n.clearcoatNormalMapUv:"",n.clearcoatRoughnessMapUv?"#define CLEARCOAT_ROUGHNESSMAP_UV "+n.clearcoatRoughnessMapUv:"",n.iridescenceMapUv?"#define IRIDESCENCEMAP_UV "+n.iridescenceMapUv:"",n.iridescenceThicknessMapUv?"#define IRIDESCENCE_THICKNESSMAP_UV "+n.iridescenceThicknessMapUv:"",n.sheenColorMapUv?"#define SHEEN_COLORMAP_UV "+n.sheenColorMapUv:"",n.sheenRoughnessMapUv?"#define SHEEN_ROUGHNESSMAP_UV "+n.sheenRoughnessMapUv:"",n.specularMapUv?"#define SPECULARMAP_UV "+n.specularMapUv:"",n.specularColorMapUv?"#define SPECULAR_COLORMAP_UV "+n.specularColorMapUv:"",n.specularIntensityMapUv?"#define SPECULAR_INTENSITYMAP_UV "+n.specularIntensityMapUv:"",n.transmissionMapUv?"#define TRANSMISSIONMAP_UV "+n.transmissionMapUv:"",n.thicknessMapUv?"#define THICKNESSMAP_UV "+n.thicknessMapUv:"",n.vertexTangents&&!1===n.flatShading?"#define USE_TANGENT":"",n.vertexColors?"#define USE_COLOR":"",n.vertexAlphas?"#define USE_COLOR_ALPHA":"",n.vertexUv1s?"#define USE_UV1":"",n.vertexUv2s?"#define USE_UV2":"",n.vertexUv3s?"#define USE_UV3":"",n.pointsUvs?"#define USE_POINTS_UV":"",n.flatShading?"#define FLAT_SHADED":"",n.skinning?"#define USE_SKINNING":"",n.morphTargets?"#define USE_MORPHTARGETS":"",n.morphNormals&&!1===n.flatShading?"#define USE_MORPHNORMALS":"",n.morphColors?"#define USE_MORPHCOLORS":"",n.morphTargetsCount>0?"#define MORPHTARGETS_TEXTURE_STRIDE "+n.morphTextureStride:"",n.morphTargetsCount>0?"#define MORPHTARGETS_COUNT "+n.morphTargetsCount:"",n.doubleSided?"#define DOUBLE_SIDED":"",n.flipSided?"#define FLIP_SIDED":"",n.shadowMapEnabled?"#define USE_SHADOWMAP":"",n.shadowMapEnabled?"#define "+l:"",n.sizeAttenuation?"#define USE_SIZEATTENUATION":"",n.numLightProbes>0?"#define USE_LIGHT_PROBES":"",n.logarithmicDepthBuffer?"#define USE_LOGDEPTHBUF":"",n.reverseDepthBuffer?"#define USE_REVERSEDEPTHBUF":"","uniform mat4 modelMatrix;","uniform mat4 modelViewMatrix;","uniform mat4 projectionMatrix;","uniform mat4 viewMatrix;","uniform mat3 normalMatrix;","uniform vec3 cameraPosition;","uniform bool isOrthographic;","#ifdef USE_INSTANCING","\tattribute mat4 instanceMatrix;","#endif","#ifdef USE_INSTANCING_COLOR","\tattribute vec3 instanceColor;","#endif","#ifdef USE_INSTANCING_MORPH","\tuniform sampler2D morphTexture;","#endif","attribute vec3 position;","attribute vec3 normal;","attribute vec2 uv;","#ifdef USE_UV1","\tattribute vec2 uv1;","#endif","#ifdef USE_UV2","\tattribute vec2 uv2;","#endif","#ifdef USE_UV3","\tattribute vec2 uv3;","#endif","#ifdef USE_TANGENT","\tattribute vec4 tangent;","#endif","#if defined( USE_COLOR_ALPHA )","\tattribute vec4 color;","#elif defined( USE_COLOR )","\tattribute vec3 color;","#endif","#ifdef USE_SKINNING","\tattribute vec4 skinIndex;","\tattribute vec4 skinWeight;","#endif","\n"].filter(gs).join("\n"),v=[Es(n),"#define SHADER_TYPE "+n.shaderType,"#define SHADER_NAME "+n.shaderName,f,n.useFog&&n.fog?"#define USE_FOG":"",n.useFog&&n.fogExp2?"#define FOG_EXP2":"",n.alphaToCoverage?"#define ALPHA_TO_COVERAGE":"",n.map?"#define USE_MAP":"",n.matcap?"#define USE_MATCAP":"",n.envMap?"#define USE_ENVMAP":"",n.envMap?"#define "+c:"",n.envMap?"#define "+h:"",n.envMap?"#define "+d:"",u?"#define CUBEUV_TEXEL_WIDTH "+u.texelWidth:"",u?"#define CUBEUV_TEXEL_HEIGHT "+u.texelHeight:"",u?"#define CUBEUV_MAX_MIP "+u.maxMip+".0":"",n.lightMap?"#define USE_LIGHTMAP":"",n.aoMap?"#define USE_AOMAP":"",n.bumpMap?"#define USE_BUMPMAP":"",n.normalMap?"#define USE_NORMALMAP":"",n.normalMapObjectSpace?"#define USE_NORMALMAP_OBJECTSPACE":"",n.normalMapTangentSpace?"#define USE_NORMALMAP_TANGENTSPACE":"",n.emissiveMap?"#define USE_EMISSIVEMAP":"",n.anisotropy?"#define USE_ANISOTROPY":"",n.anisotropyMap?"#define USE_ANISOTROPYMAP":"",n.clearcoat?"#define USE_CLEARCOAT":"",n.clearcoatMap?"#define USE_CLEARCOATMAP":"",n.clearcoatRoughnessMap?"#define USE_CLEARCOAT_ROUGHNESSMAP":"",n.clearcoatNormalMap?"#define USE_CLEARCOAT_NORMALMAP":"",n.dispersion?"#define USE_DISPERSION":"",n.iridescence?"#define USE_IRIDESCENCE":"",n.iridescenceMap?"#define USE_IRIDESCENCEMAP":"",n.iridescenceThicknessMap?"#define USE_IRIDESCENCE_THICKNESSMAP":"",n.specularMap?"#define USE_SPECULARMAP":"",n.specularColorMap?"#define USE_SPECULAR_COLORMAP":"",n.specularIntensityMap?"#define USE_SPECULAR_INTENSITYMAP":"",n.roughnessMap?"#define USE_ROUGHNESSMAP":"",n.metalnessMap?"#define USE_METALNESSMAP":"",n.alphaMap?"#define USE_ALPHAMAP":"",n.alphaTest?"#define USE_ALPHATEST":"",n.alphaHash?"#define USE_ALPHAHASH":"",n.sheen?"#define USE_SHEEN":"",n.sheenColorMap?"#define USE_SHEEN_COLORMAP":"",n.sheenRoughnessMap?"#define USE_SHEEN_ROUGHNESSMAP":"",n.transmission?"#define USE_TRANSMISSION":"",n.transmissionMap?"#define USE_TRANSMISSIONMAP":"",n.thicknessMap?"#define USE_THICKNESSMAP":"",n.vertexTangents&&!1===n.flatShading?"#define USE_TANGENT":"",n.vertexColors||n.instancingColor||n.batchingColor?"#define USE_COLOR":"",n.vertexAlphas?"#define USE_COLOR_ALPHA":"",n.vertexUv1s?"#define USE_UV1":"",n.vertexUv2s?"#define USE_UV2":"",n.vertexUv3s?"#define USE_UV3":"",n.pointsUvs?"#define USE_POINTS_UV":"",n.gradientMap?"#define USE_GRADIENTMAP":"",n.flatShading?"#define FLAT_SHADED":"",n.doubleSided?"#define DOUBLE_SIDED":"",n.flipSided?"#define FLIP_SIDED":"",n.shadowMapEnabled?"#define USE_SHADOWMAP":"",n.shadowMapEnabled?"#define "+l:"",n.premultipliedAlpha?"#define PREMULTIPLIED_ALPHA":"",n.numLightProbes>0?"#define USE_LIGHT_PROBES":"",n.decodeVideoTexture?"#define DECODE_VIDEO_TEXTURE":"",n.decodeVideoTextureEmissive?"#define DECODE_VIDEO_TEXTURE_EMISSIVE":"",n.logarithmicDepthBuffer?"#define USE_LOGDEPTHBUF":"",n.reverseDepthBuffer?"#define USE_REVERSEDEPTHBUF":"","uniform mat4 viewMatrix;","uniform vec3 cameraPosition;","uniform bool isOrthographic;",0!==n.toneMapping?"#define TONE_MAPPING":"",0!==n.toneMapping?wr.tonemapping_pars_fragment:"",0!==n.toneMapping?fs("toneMapping",n.toneMapping):"",n.dithering?"#define DITHERING":"",n.opaque?"#define OPAQUE":"",wr.colorspace_pars_fragment,ps("linearToOutputTexel",n.outputColorSpace),(Et.getLuminanceCoefficients(ms),["float luminance( const in vec3 rgb ) {",`\tconst vec3 weights = vec3( ${ms.x.toFixed(4)}, ${ms.y.toFixed(4)}, ${ms.z.toFixed(4)} );`,"\treturn dot( weights, rgb );","}"].join("\n")),n.useDepthPacking?"#define DEPTH_PACKING "+n.depthPacking:"","\n"].filter(gs).join("\n")),s=ys(s),s=vs(s,n),s=_s(s,n),o=ys(o),o=vs(o,n),o=_s(o,n),s=Ms(s),o=Ms(o),!0!==n.isRawShaderMaterial&&(_="#version 300 es\n",g=[p,"#define attribute in","#define varying out","#define texture2D texture"].join("\n")+"\n"+g,v=["#define varying in",n.glslVersion===it?"":"layout(location = 0) out highp vec4 pc_fragColor;",n.glslVersion===it?"":"#define gl_FragColor pc_fragColor","#define gl_FragDepthEXT gl_FragDepth","#define texture2D texture","#define textureCube texture","#define texture2DProj textureProj","#define texture2DLodEXT textureLod","#define texture2DProjLodEXT textureProjLod","#define textureCubeLodEXT textureLod","#define texture2DGradEXT textureGrad","#define texture2DProjGradEXT textureProjGrad","#define textureCubeGradEXT textureGrad"].join("\n")+"\n"+v);const x=_+g+s,y=_+v+o,S=cs(r,r.VERTEX_SHADER,x),w=cs(r,r.FRAGMENT_SHADER,y);function b(t){if(e.debug.checkShaderErrors){const n=r.getProgramInfoLog(m).trim(),i=r.getShaderInfoLog(S).trim(),a=r.getShaderInfoLog(w).trim();let s=!0,o=!0;if(!1===r.getProgramParameter(m,r.LINK_STATUS))if(s=!1,"function"==typeof e.debug.onShaderError)e.debug.onShaderError(r,m,S,w);else{const e=us(r,S,"vertex"),i=us(r,w,"fragment");console.error("THREE.WebGLProgram: Shader Error "+r.getError()+" - VALIDATE_STATUS "+r.getProgramParameter(m,r.VALIDATE_STATUS)+"\n\nMaterial Name: "+t.name+"\nMaterial Type: "+t.type+"\n\nProgram Info Log: "+n+"\n"+e+"\n"+i)}else""!==n?console.warn("THREE.WebGLProgram: Program Info Log:",n):""!==i&&""!==a||(o=!1);o&&(t.diagnostics={runnable:s,programLog:n,vertexShader:{log:i,prefix:g},fragmentShader:{log:a,prefix:v}})}r.deleteShader(S),r.deleteShader(w),M=new ls(r,m),T=function(e,t){const n={},i=e.getProgramParameter(t,e.ACTIVE_ATTRIBUTES);for(let r=0;r0,q=a.clearcoat>0,Z=a.dispersion>0,K=a.iridescence>0,J=a.sheen>0,Q=a.transmission>0,$=Y&&!!a.anisotropyMap,ee=q&&!!a.clearcoatMap,te=q&&!!a.clearcoatNormalMap,ne=q&&!!a.clearcoatRoughnessMap,ie=K&&!!a.iridescenceMap,re=K&&!!a.iridescenceThicknessMap,ae=J&&!!a.sheenColorMap,se=J&&!!a.sheenRoughnessMap,oe=!!a.specularMap,le=!!a.specularColorMap,ce=!!a.specularIntensityMap,he=Q&&!!a.transmissionMap,de=Q&&!!a.thicknessMap,ue=!!a.gradientMap,pe=!!a.alphaMap,fe=a.alphaTest>0,me=!!a.alphaHash,ge=!!a.extensions;let ve=0;a.toneMapped&&(null!==D&&!0!==D.isXRRenderTarget||(ve=e.toneMapping));const _e={shaderID:b,shaderType:a.type,shaderName:a.name,vertexShader:E,fragmentShader:A,defines:a.defines,customVertexShaderID:P,customFragmentShaderID:R,isRawShaderMaterial:!0===a.isRawShaderMaterial,glslVersion:a.glslVersion,precision:p,batching:U,batchingColor:U&&null!==v._colorsTexture,instancing:I,instancingColor:I&&null!==v.instanceColor,instancingMorph:I&&null!==v.morphTexture,supportsVertexTextures:u,outputColorSpace:null===D?e.outputColorSpace:!0===D.isXRRenderTarget?D.texture.colorSpace:We,alphaToCoverage:!!a.alphaToCoverage,map:N,matcap:F,envMap:B,envMapMode:B&&S.mapping,envMapCubeUVHeight:w,aoMap:z,lightMap:k,bumpMap:H,normalMap:V,displacementMap:u&&G,emissiveMap:W,normalMapObjectSpace:V&&1===a.normalMapType,normalMapTangentSpace:V&&0===a.normalMapType,metalnessMap:j,roughnessMap:X,anisotropy:Y,anisotropyMap:$,clearcoat:q,clearcoatMap:ee,clearcoatNormalMap:te,clearcoatRoughnessMap:ne,dispersion:Z,iridescence:K,iridescenceMap:ie,iridescenceThicknessMap:re,sheen:J,sheenColorMap:ae,sheenRoughnessMap:se,specularMap:oe,specularColorMap:le,specularIntensityMap:ce,transmission:Q,transmissionMap:he,thicknessMap:de,gradientMap:ue,opaque:!1===a.transparent&&1===a.blending&&!1===a.alphaToCoverage,alphaMap:pe,alphaTest:fe,alphaHash:me,combine:a.combine,mapUv:N&&m(a.map.channel),aoMapUv:z&&m(a.aoMap.channel),lightMapUv:k&&m(a.lightMap.channel),bumpMapUv:H&&m(a.bumpMap.channel),normalMapUv:V&&m(a.normalMap.channel),displacementMapUv:G&&m(a.displacementMap.channel),emissiveMapUv:W&&m(a.emissiveMap.channel),metalnessMapUv:j&&m(a.metalnessMap.channel),roughnessMapUv:X&&m(a.roughnessMap.channel),anisotropyMapUv:$&&m(a.anisotropyMap.channel),clearcoatMapUv:ee&&m(a.clearcoatMap.channel),clearcoatNormalMapUv:te&&m(a.clearcoatNormalMap.channel),clearcoatRoughnessMapUv:ne&&m(a.clearcoatRoughnessMap.channel),iridescenceMapUv:ie&&m(a.iridescenceMap.channel),iridescenceThicknessMapUv:re&&m(a.iridescenceThicknessMap.channel),sheenColorMapUv:ae&&m(a.sheenColorMap.channel),sheenRoughnessMapUv:se&&m(a.sheenRoughnessMap.channel),specularMapUv:oe&&m(a.specularMap.channel),specularColorMapUv:le&&m(a.specularColorMap.channel),specularIntensityMapUv:ce&&m(a.specularIntensityMap.channel),transmissionMapUv:he&&m(a.transmissionMap.channel),thicknessMapUv:de&&m(a.thicknessMap.channel),alphaMapUv:pe&&m(a.alphaMap.channel),vertexTangents:!!x.attributes.tangent&&(V||Y),vertexColors:a.vertexColors,vertexAlphas:!0===a.vertexColors&&!!x.attributes.color&&4===x.attributes.color.itemSize,pointsUvs:!0===v.isPoints&&!!x.attributes.uv&&(N||pe),fog:!!_,useFog:!0===a.fog,fogExp2:!!_&&_.isFogExp2,flatShading:!0===a.flatShading,sizeAttenuation:!0===a.sizeAttenuation,logarithmicDepthBuffer:d,reverseDepthBuffer:L,skinning:!0===v.isSkinnedMesh,morphTargets:void 0!==x.morphAttributes.position,morphNormals:void 0!==x.morphAttributes.normal,morphColors:void 0!==x.morphAttributes.color,morphTargetsCount:T,morphTextureStride:C,numDirLights:o.directional.length,numPointLights:o.point.length,numSpotLights:o.spot.length,numSpotLightMaps:o.spotLightMap.length,numRectAreaLights:o.rectArea.length,numHemiLights:o.hemi.length,numDirLightShadows:o.directionalShadowMap.length,numPointLightShadows:o.pointShadowMap.length,numSpotLightShadows:o.spotShadowMap.length,numSpotLightShadowsWithMaps:o.numSpotLightShadowsWithMaps,numLightProbes:o.numLightProbes,numClippingPlanes:s.numPlanes,numClipIntersection:s.numIntersection,dithering:a.dithering,shadowMapEnabled:e.shadowMap.enabled&&h.length>0,shadowMapType:e.shadowMap.type,toneMapping:ve,decodeVideoTexture:N&&!0===a.map.isVideoTexture&&Et.getTransfer(a.map.colorSpace)===Xe,decodeVideoTextureEmissive:W&&!0===a.emissiveMap.isVideoTexture&&Et.getTransfer(a.emissiveMap.colorSpace)===Xe,premultipliedAlpha:a.premultipliedAlpha,doubleSided:2===a.side,flipSided:1===a.side,useDepthPacking:a.depthPacking>=0,depthPacking:a.depthPacking||0,index0AttributeName:a.index0AttributeName,extensionClipCullDistance:ge&&!0===a.extensions.clipCullDistance&&i.has("WEBGL_clip_cull_distance"),extensionMultiDraw:(ge&&!0===a.extensions.multiDraw||U)&&i.has("WEBGL_multi_draw"),rendererExtensionParallelShaderCompile:i.has("KHR_parallel_shader_compile"),customProgramCacheKey:a.customProgramCacheKey()};return _e.vertexUv1s=c.has(1),_e.vertexUv2s=c.has(2),_e.vertexUv3s=c.has(3),c.clear(),_e},getProgramCacheKey:function(t){const n=[];if(t.shaderID?n.push(t.shaderID):(n.push(t.customVertexShaderID),n.push(t.customFragmentShaderID)),void 0!==t.defines)for(const e in t.defines)n.push(e),n.push(t.defines[e]);return!1===t.isRawShaderMaterial&&(function(e,t){e.push(t.precision),e.push(t.outputColorSpace),e.push(t.envMapMode),e.push(t.envMapCubeUVHeight),e.push(t.mapUv),e.push(t.alphaMapUv),e.push(t.lightMapUv),e.push(t.aoMapUv),e.push(t.bumpMapUv),e.push(t.normalMapUv),e.push(t.displacementMapUv),e.push(t.emissiveMapUv),e.push(t.metalnessMapUv),e.push(t.roughnessMapUv),e.push(t.anisotropyMapUv),e.push(t.clearcoatMapUv),e.push(t.clearcoatNormalMapUv),e.push(t.clearcoatRoughnessMapUv),e.push(t.iridescenceMapUv),e.push(t.iridescenceThicknessMapUv),e.push(t.sheenColorMapUv),e.push(t.sheenRoughnessMapUv),e.push(t.specularMapUv),e.push(t.specularColorMapUv),e.push(t.specularIntensityMapUv),e.push(t.transmissionMapUv),e.push(t.thicknessMapUv),e.push(t.combine),e.push(t.fogExp2),e.push(t.sizeAttenuation),e.push(t.morphTargetsCount),e.push(t.morphAttributeCount),e.push(t.numDirLights),e.push(t.numPointLights),e.push(t.numSpotLights),e.push(t.numSpotLightMaps),e.push(t.numHemiLights),e.push(t.numRectAreaLights),e.push(t.numDirLightShadows),e.push(t.numPointLightShadows),e.push(t.numSpotLightShadows),e.push(t.numSpotLightShadowsWithMaps),e.push(t.numLightProbes),e.push(t.shadowMapType),e.push(t.toneMapping),e.push(t.numClippingPlanes),e.push(t.numClipIntersection),e.push(t.depthPacking)}(n,t),function(e,t){o.disableAll(),t.supportsVertexTextures&&o.enable(0),t.instancing&&o.enable(1),t.instancingColor&&o.enable(2),t.instancingMorph&&o.enable(3),t.matcap&&o.enable(4),t.envMap&&o.enable(5),t.normalMapObjectSpace&&o.enable(6),t.normalMapTangentSpace&&o.enable(7),t.clearcoat&&o.enable(8),t.iridescence&&o.enable(9),t.alphaTest&&o.enable(10),t.vertexColors&&o.enable(11),t.vertexAlphas&&o.enable(12),t.vertexUv1s&&o.enable(13),t.vertexUv2s&&o.enable(14),t.vertexUv3s&&o.enable(15),t.vertexTangents&&o.enable(16),t.anisotropy&&o.enable(17),t.alphaHash&&o.enable(18),t.batching&&o.enable(19),t.dispersion&&o.enable(20),t.batchingColor&&o.enable(21),e.push(o.mask),o.disableAll(),t.fog&&o.enable(0),t.useFog&&o.enable(1),t.flatShading&&o.enable(2),t.logarithmicDepthBuffer&&o.enable(3),t.reverseDepthBuffer&&o.enable(4),t.skinning&&o.enable(5),t.morphTargets&&o.enable(6),t.morphNormals&&o.enable(7),t.morphColors&&o.enable(8),t.premultipliedAlpha&&o.enable(9),t.shadowMapEnabled&&o.enable(10),t.doubleSided&&o.enable(11),t.flipSided&&o.enable(12),t.useDepthPacking&&o.enable(13),t.dithering&&o.enable(14),t.transmission&&o.enable(15),t.sheen&&o.enable(16),t.opaque&&o.enable(17),t.pointsUvs&&o.enable(18),t.decodeVideoTexture&&o.enable(19),t.decodeVideoTextureEmissive&&o.enable(20),t.alphaToCoverage&&o.enable(21),e.push(o.mask)}(n,t),n.push(e.outputColorSpace)),n.push(t.customProgramCacheKey),n.join()},getUniforms:function(e){const t=f[e.type];let n;if(t){const e=Mr[t];n=tr.clone(e.uniforms)}else n=e.uniforms;return n},acquireProgram:function(t,n){let i;for(let e=0,t=h.length;e0?i.push(h):!0===s.transparent?r.push(h):n.push(h)},unshift:function(e,t,s,o,l,c){const h=a(e,t,s,o,l,c);s.transmission>0?i.unshift(h):!0===s.transparent?r.unshift(h):n.unshift(h)},finish:function(){for(let n=t,i=e.length;n1&&n.sort(e||Is),i.length>1&&i.sort(t||Us),r.length>1&&r.sort(t||Us)}}}function Ns(){let e=new WeakMap;return{get:function(t,n){const i=e.get(t);let r;return void 0===i?(r=new Os,e.set(t,[r])):n>=i.length?(r=new Os,i.push(r)):r=i[n],r},dispose:function(){e=new WeakMap}}}function Fs(){const e={};return{get:function(t){if(void 0!==e[t.id])return e[t.id];let n;switch(t.type){case"DirectionalLight":n={direction:new Yt,color:new gi};break;case"SpotLight":n={position:new Yt,direction:new Yt,color:new gi,distance:0,coneCos:0,penumbraCos:0,decay:0};break;case"PointLight":n={position:new Yt,color:new gi,distance:0,decay:0};break;case"HemisphereLight":n={direction:new Yt,skyColor:new gi,groundColor:new gi};break;case"RectAreaLight":n={color:new gi,position:new Yt,halfWidth:new Yt,halfHeight:new Yt}}return e[t.id]=n,n}}}let Bs=0;function zs(e,t){return(t.castShadow?2:0)-(e.castShadow?2:0)+(t.map?1:0)-(e.map?1:0)}function ks(e){const t=new Fs,n=function(){const e={};return{get:function(t){if(void 0!==e[t.id])return e[t.id];let n;switch(t.type){case"DirectionalLight":case"SpotLight":n={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new _t};break;case"PointLight":n={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new _t,shadowCameraNear:1,shadowCameraFar:1e3}}return e[t.id]=n,n}}}(),i={version:0,hash:{directionalLength:-1,pointLength:-1,spotLength:-1,rectAreaLength:-1,hemiLength:-1,numDirectionalShadows:-1,numPointShadows:-1,numSpotShadows:-1,numSpotMaps:-1,numLightProbes:-1},ambient:[0,0,0],probe:[],directional:[],directionalShadow:[],directionalShadowMap:[],directionalShadowMatrix:[],spot:[],spotLightMap:[],spotShadow:[],spotShadowMap:[],spotLightMatrix:[],rectArea:[],rectAreaLTC1:null,rectAreaLTC2:null,point:[],pointShadow:[],pointShadowMap:[],pointShadowMatrix:[],hemi:[],numSpotLightShadowsWithMaps:0,numLightProbes:0};for(let e=0;e<9;e++)i.probe.push(new Yt);const r=new Yt,a=new Mn,s=new Mn;return{setup:function(r){let a=0,s=0,o=0;for(let e=0;e<9;e++)i.probe[e].set(0,0,0);let l=0,c=0,h=0,d=0,u=0,p=0,f=0,m=0,g=0,v=0,_=0;r.sort(zs);for(let e=0,x=r.length;e0&&(!0===e.has("OES_texture_float_linear")?(i.rectAreaLTC1=br.LTC_FLOAT_1,i.rectAreaLTC2=br.LTC_FLOAT_2):(i.rectAreaLTC1=br.LTC_HALF_1,i.rectAreaLTC2=br.LTC_HALF_2)),i.ambient[0]=a,i.ambient[1]=s,i.ambient[2]=o;const x=i.hash;x.directionalLength===l&&x.pointLength===c&&x.spotLength===h&&x.rectAreaLength===d&&x.hemiLength===u&&x.numDirectionalShadows===p&&x.numPointShadows===f&&x.numSpotShadows===m&&x.numSpotMaps===g&&x.numLightProbes===_||(i.directional.length=l,i.spot.length=h,i.rectArea.length=d,i.point.length=c,i.hemi.length=u,i.directionalShadow.length=p,i.directionalShadowMap.length=p,i.pointShadow.length=f,i.pointShadowMap.length=f,i.spotShadow.length=m,i.spotShadowMap.length=m,i.directionalShadowMatrix.length=p,i.pointShadowMatrix.length=f,i.spotLightMatrix.length=m+g-v,i.spotLightMap.length=g,i.numSpotLightShadowsWithMaps=v,i.numLightProbes=_,x.directionalLength=l,x.pointLength=c,x.spotLength=h,x.rectAreaLength=d,x.hemiLength=u,x.numDirectionalShadows=p,x.numPointShadows=f,x.numSpotShadows=m,x.numSpotMaps=g,x.numLightProbes=_,i.version=Bs++)},setupView:function(e,t){let n=0,o=0,l=0,c=0,h=0;const d=t.matrixWorldInverse;for(let t=0,u=e.length;t=r.length?(a=new Hs(e),r.push(a)):a=r[i],a},dispose:function(){t=new WeakMap}}}class Gs extends xi{static get type(){return"MeshDepthMaterial"}constructor(e){super(),this.isMeshDepthMaterial=!0,this.depthPacking=3200,this.map=null,this.alphaMap=null,this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.wireframe=!1,this.wireframeLinewidth=1,this.setValues(e)}copy(e){return super.copy(e),this.depthPacking=e.depthPacking,this.map=e.map,this.alphaMap=e.alphaMap,this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this}}class Ws extends xi{static get type(){return"MeshDistanceMaterial"}constructor(e){super(),this.isMeshDistanceMaterial=!0,this.map=null,this.alphaMap=null,this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.setValues(e)}copy(e){return super.copy(e),this.map=e.map,this.alphaMap=e.alphaMap,this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this}}function js(e,t,n){let s=new _r;const o=new _t,l=new _t,c=new Ht,h=new Gs({depthPacking:3201}),d=new Ws,u={},p=n.maxTextureSize,f={[i]:1,[r]:0,[a]:2},m=new nr({defines:{VSM_SAMPLES:8},uniforms:{shadow_pass:{value:null},resolution:{value:new _t},radius:{value:4}},vertexShader:"void main() {\n\tgl_Position = vec4( position, 1.0 );\n}",fragmentShader:"uniform sampler2D shadow_pass;\nuniform vec2 resolution;\nuniform float radius;\n#include \nvoid main() {\n\tconst float samples = float( VSM_SAMPLES );\n\tfloat mean = 0.0;\n\tfloat squared_mean = 0.0;\n\tfloat uvStride = samples <= 1.0 ? 0.0 : 2.0 / ( samples - 1.0 );\n\tfloat uvStart = samples <= 1.0 ? 0.0 : - 1.0;\n\tfor ( float i = 0.0; i < samples; i ++ ) {\n\t\tfloat uvOffset = uvStart + i * uvStride;\n\t\t#ifdef HORIZONTAL_PASS\n\t\t\tvec2 distribution = unpackRGBATo2Half( texture2D( shadow_pass, ( gl_FragCoord.xy + vec2( uvOffset, 0.0 ) * radius ) / resolution ) );\n\t\t\tmean += distribution.x;\n\t\t\tsquared_mean += distribution.y * distribution.y + distribution.x * distribution.x;\n\t\t#else\n\t\t\tfloat depth = unpackRGBAToDepth( texture2D( shadow_pass, ( gl_FragCoord.xy + vec2( 0.0, uvOffset ) * radius ) / resolution ) );\n\t\t\tmean += depth;\n\t\t\tsquared_mean += depth * depth;\n\t\t#endif\n\t}\n\tmean = mean / samples;\n\tsquared_mean = squared_mean / samples;\n\tfloat std_dev = sqrt( squared_mean - mean * mean );\n\tgl_FragColor = pack2HalfToRGBA( vec2( mean, std_dev ) );\n}"}),g=m.clone();g.defines.HORIZONTAL_PASS=1;const v=new Fi;v.setAttribute("position",new Ei(new Float32Array([-1,-1,.5,3,-1,.5,-1,3,.5]),3));const _=new Zi(v,m),x=this;this.enabled=!1,this.autoUpdate=!0,this.needsUpdate=!1,this.type=1;let y=this.type;function S(n,i){const r=t.update(_);m.defines.VSM_SAMPLES!==n.blurSamples&&(m.defines.VSM_SAMPLES=n.blurSamples,g.defines.VSM_SAMPLES=n.blurSamples,m.needsUpdate=!0,g.needsUpdate=!0),null===n.mapPass&&(n.mapPass=new Gt(o.x,o.y)),m.uniforms.shadow_pass.value=n.map.texture,m.uniforms.resolution.value=n.mapSize,m.uniforms.radius.value=n.radius,e.setRenderTarget(n.mapPass),e.clear(),e.renderBufferDirect(i,null,r,m,_,null),g.uniforms.shadow_pass.value=n.mapPass.texture,g.uniforms.resolution.value=n.mapSize,g.uniforms.radius.value=n.radius,e.setRenderTarget(n.map),e.clear(),e.renderBufferDirect(i,null,r,g,_,null)}function w(t,n,i,r){let a=null;const s=!0===i.isPointLight?t.customDistanceMaterial:t.customDepthMaterial;if(void 0!==s)a=s;else if(a=!0===i.isPointLight?d:h,e.localClippingEnabled&&!0===n.clipShadows&&Array.isArray(n.clippingPlanes)&&0!==n.clippingPlanes.length||n.displacementMap&&0!==n.displacementScale||n.alphaMap&&n.alphaTest>0||n.map&&n.alphaTest>0){const e=a.uuid,t=n.uuid;let i=u[e];void 0===i&&(i={},u[e]=i);let r=i[t];void 0===r&&(r=a.clone(),i[t]=r,n.addEventListener("dispose",M)),a=r}return a.visible=n.visible,a.wireframe=n.wireframe,a.side=3===r?null!==n.shadowSide?n.shadowSide:n.side:null!==n.shadowSide?n.shadowSide:f[n.side],a.alphaMap=n.alphaMap,a.alphaTest=n.alphaTest,a.map=n.map,a.clipShadows=n.clipShadows,a.clippingPlanes=n.clippingPlanes,a.clipIntersection=n.clipIntersection,a.displacementMap=n.displacementMap,a.displacementScale=n.displacementScale,a.displacementBias=n.displacementBias,a.wireframeLinewidth=n.wireframeLinewidth,a.linewidth=n.linewidth,!0===i.isPointLight&&!0===a.isMeshDistanceMaterial&&(e.properties.get(a).light=i),a}function b(n,i,r,a,o){if(!1===n.visible)return;if(n.layers.test(i.layers)&&(n.isMesh||n.isLine||n.isPoints)&&(n.castShadow||n.receiveShadow&&3===o)&&(!n.frustumCulled||s.intersectsObject(n))){n.modelViewMatrix.multiplyMatrices(r.matrixWorldInverse,n.matrixWorld);const s=t.update(n),l=n.material;if(Array.isArray(l)){const t=s.groups;for(let c=0,h=t.length;cp||o.y>p)&&(o.x>p&&(l.x=Math.floor(p/m.x),o.x=l.x*m.x,h.mapSize.x=l.x),o.y>p&&(l.y=Math.floor(p/m.y),o.y=l.y*m.y,h.mapSize.y=l.y)),null===h.map||!0===u||!0===f){const e=3!==this.type?{minFilter:z,magFilter:z}:{};null!==h.map&&h.map.dispose(),h.map=new Gt(o.x,o.y,e),h.map.texture.name=a.name+".shadowMap",h.camera.updateProjectionMatrix()}e.setRenderTarget(h.map),e.clear();const g=h.getViewportCount();for(let e=0;e=1):-1!==Z.indexOf("OpenGL ES")&&(q=parseFloat(/^OpenGL ES (\d)/.exec(Z)[1]),Y=q>=2);let K=null,J={};const Q=e.getParameter(e.SCISSOR_BOX),$=e.getParameter(e.VIEWPORT),ee=(new Ht).fromArray(Q),te=(new Ht).fromArray($);function ne(t,n,i,r){const a=new Uint8Array(4),s=e.createTexture();e.bindTexture(t,s),e.texParameteri(t,e.TEXTURE_MIN_FILTER,e.NEAREST),e.texParameteri(t,e.TEXTURE_MAG_FILTER,e.NEAREST);for(let s=0;sn||r.height>n)&&(i=n/Math.max(r.width,r.height)),i<1){if("undefined"!=typeof HTMLImageElement&&e instanceof HTMLImageElement||"undefined"!=typeof HTMLCanvasElement&&e instanceof HTMLCanvasElement||"undefined"!=typeof ImageBitmap&&e instanceof ImageBitmap||"undefined"!=typeof VideoFrame&&e instanceof VideoFrame){const n=Math.floor(i*r.width),a=Math.floor(i*r.height);void 0===d&&(d=f(n,a));const s=t?f(n,a):d;return s.width=n,s.height=a,s.getContext("2d").drawImage(e,0,0,n,a),console.warn("THREE.WebGLRenderer: Texture has been resized from ("+r.width+"x"+r.height+") to ("+n+"x"+a+")."),s}return"data"in e&&console.warn("THREE.WebGLRenderer: Image in DataTexture is too big ("+r.width+"x"+r.height+")."),e}return e}function g(e){return e.generateMipmaps}function v(t){e.generateMipmap(t)}function _(t){return t.isWebGLCubeRenderTarget?e.TEXTURE_CUBE_MAP:t.isWebGL3DRenderTarget?e.TEXTURE_3D:t.isWebGLArrayRenderTarget||t.isCompressedArrayTexture?e.TEXTURE_2D_ARRAY:e.TEXTURE_2D}function x(n,i,r,a,s=!1){if(null!==n){if(void 0!==e[n])return e[n];console.warn("THREE.WebGLRenderer: Attempt to use non-existing WebGL internal format '"+n+"'")}let o=i;if(i===e.RED&&(r===e.FLOAT&&(o=e.R32F),r===e.HALF_FLOAT&&(o=e.R16F),r===e.UNSIGNED_BYTE&&(o=e.R8)),i===e.RED_INTEGER&&(r===e.UNSIGNED_BYTE&&(o=e.R8UI),r===e.UNSIGNED_SHORT&&(o=e.R16UI),r===e.UNSIGNED_INT&&(o=e.R32UI),r===e.BYTE&&(o=e.R8I),r===e.SHORT&&(o=e.R16I),r===e.INT&&(o=e.R32I)),i===e.RG&&(r===e.FLOAT&&(o=e.RG32F),r===e.HALF_FLOAT&&(o=e.RG16F),r===e.UNSIGNED_BYTE&&(o=e.RG8)),i===e.RG_INTEGER&&(r===e.UNSIGNED_BYTE&&(o=e.RG8UI),r===e.UNSIGNED_SHORT&&(o=e.RG16UI),r===e.UNSIGNED_INT&&(o=e.RG32UI),r===e.BYTE&&(o=e.RG8I),r===e.SHORT&&(o=e.RG16I),r===e.INT&&(o=e.RG32I)),i===e.RGB_INTEGER&&(r===e.UNSIGNED_BYTE&&(o=e.RGB8UI),r===e.UNSIGNED_SHORT&&(o=e.RGB16UI),r===e.UNSIGNED_INT&&(o=e.RGB32UI),r===e.BYTE&&(o=e.RGB8I),r===e.SHORT&&(o=e.RGB16I),r===e.INT&&(o=e.RGB32I)),i===e.RGBA_INTEGER&&(r===e.UNSIGNED_BYTE&&(o=e.RGBA8UI),r===e.UNSIGNED_SHORT&&(o=e.RGBA16UI),r===e.UNSIGNED_INT&&(o=e.RGBA32UI),r===e.BYTE&&(o=e.RGBA8I),r===e.SHORT&&(o=e.RGBA16I),r===e.INT&&(o=e.RGBA32I)),i===e.RGB&&r===e.UNSIGNED_INT_5_9_9_9_REV&&(o=e.RGB9_E5),i===e.RGBA){const t=s?je:Et.getTransfer(a);r===e.FLOAT&&(o=e.RGBA32F),r===e.HALF_FLOAT&&(o=e.RGBA16F),r===e.UNSIGNED_BYTE&&(o=t===Xe?e.SRGB8_ALPHA8:e.RGBA8),r===e.UNSIGNED_SHORT_4_4_4_4&&(o=e.RGBA4),r===e.UNSIGNED_SHORT_5_5_5_1&&(o=e.RGB5_A1)}return o!==e.R16F&&o!==e.R32F&&o!==e.RG16F&&o!==e.RG32F&&o!==e.RGBA16F&&o!==e.RGBA32F||t.get("EXT_color_buffer_float"),o}function y(t,n){let i;return t?null===n||n===q||n===$?i=e.DEPTH24_STENCIL8:n===Z?i=e.DEPTH32F_STENCIL8:n===X&&(i=e.DEPTH24_STENCIL8,console.warn("DepthTexture: 16 bit depth attachment is not supported with stencil. Using 24-bit attachment.")):null===n||n===q||n===$?i=e.DEPTH_COMPONENT24:n===Z?i=e.DEPTH_COMPONENT32F:n===X&&(i=e.DEPTH_COMPONENT16),i}function S(e,t){return!0===g(e)||e.isFramebufferTexture&&e.minFilter!==z&&e.minFilter!==V?Math.log2(Math.max(t.width,t.height))+1:void 0!==e.mipmaps&&e.mipmaps.length>0?e.mipmaps.length:e.isCompressedTexture&&Array.isArray(e.image)?t.mipmaps.length:1}function w(e){const t=e.target;t.removeEventListener("dispose",w),function(e){const t=i.get(e);if(void 0===t.__webglInit)return;const n=e.source,r=u.get(n);if(r){const i=r[t.__cacheKey];i.usedTimes--,0===i.usedTimes&&M(e),0===Object.keys(r).length&&u.delete(n)}i.remove(e)}(t),t.isVideoTexture&&h.delete(t)}function b(t){const n=t.target;n.removeEventListener("dispose",b),function(t){const n=i.get(t);if(t.depthTexture&&(t.depthTexture.dispose(),i.remove(t.depthTexture)),t.isWebGLCubeRenderTarget)for(let t=0;t<6;t++){if(Array.isArray(n.__webglFramebuffer[t]))for(let i=0;i0&&a.__version!==t.version){const e=t.image;if(null===e)console.warn("THREE.WebGLRenderer: Texture marked for update but no image data found.");else{if(!1!==e.complete)return void L(a,t,r);console.warn("THREE.WebGLRenderer: Texture marked for update but image is incomplete")}}n.bindTexture(e.TEXTURE_2D,a.__webglTexture,e.TEXTURE0+r)}const A={[N]:e.REPEAT,[F]:e.CLAMP_TO_EDGE,[B]:e.MIRRORED_REPEAT},P={[z]:e.NEAREST,[k]:e.NEAREST_MIPMAP_NEAREST,[H]:e.NEAREST_MIPMAP_LINEAR,[V]:e.LINEAR,[G]:e.LINEAR_MIPMAP_NEAREST,[W]:e.LINEAR_MIPMAP_LINEAR},R={[qe]:e.NEVER,[tt]:e.ALWAYS,[Ze]:e.LESS,[Je]:e.LEQUAL,[Ke]:e.EQUAL,[et]:e.GEQUAL,[Qe]:e.GREATER,[$e]:e.NOTEQUAL};function C(n,a){if(a.type!==Z||!1!==t.has("OES_texture_float_linear")||a.magFilter!==V&&a.magFilter!==G&&a.magFilter!==H&&a.magFilter!==W&&a.minFilter!==V&&a.minFilter!==G&&a.minFilter!==H&&a.minFilter!==W||console.warn("THREE.WebGLRenderer: Unable to use linear filtering with floating point textures. OES_texture_float_linear not supported on this device."),e.texParameteri(n,e.TEXTURE_WRAP_S,A[a.wrapS]),e.texParameteri(n,e.TEXTURE_WRAP_T,A[a.wrapT]),n!==e.TEXTURE_3D&&n!==e.TEXTURE_2D_ARRAY||e.texParameteri(n,e.TEXTURE_WRAP_R,A[a.wrapR]),e.texParameteri(n,e.TEXTURE_MAG_FILTER,P[a.magFilter]),e.texParameteri(n,e.TEXTURE_MIN_FILTER,P[a.minFilter]),a.compareFunction&&(e.texParameteri(n,e.TEXTURE_COMPARE_MODE,e.COMPARE_REF_TO_TEXTURE),e.texParameteri(n,e.TEXTURE_COMPARE_FUNC,R[a.compareFunction])),!0===t.has("EXT_texture_filter_anisotropic")){if(a.magFilter===z)return;if(a.minFilter!==H&&a.minFilter!==W)return;if(a.type===Z&&!1===t.has("OES_texture_float_linear"))return;if(a.anisotropy>1||i.get(a).__currentAnisotropy){const s=t.get("EXT_texture_filter_anisotropic");e.texParameterf(n,s.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(a.anisotropy,r.getMaxAnisotropy())),i.get(a).__currentAnisotropy=a.anisotropy}}}function D(t,n){let i=!1;void 0===t.__webglInit&&(t.__webglInit=!0,n.addEventListener("dispose",w));const r=n.source;let a=u.get(r);void 0===a&&(a={},u.set(r,a));const o=function(e){const t=[];return t.push(e.wrapS),t.push(e.wrapT),t.push(e.wrapR||0),t.push(e.magFilter),t.push(e.minFilter),t.push(e.anisotropy),t.push(e.internalFormat),t.push(e.format),t.push(e.type),t.push(e.generateMipmaps),t.push(e.premultiplyAlpha),t.push(e.flipY),t.push(e.unpackAlignment),t.push(e.colorSpace),t.join()}(n);if(o!==t.__cacheKey){void 0===a[o]&&(a[o]={texture:e.createTexture(),usedTimes:0},s.memory.textures++,i=!0),a[o].usedTimes++;const r=a[t.__cacheKey];void 0!==r&&(a[t.__cacheKey].usedTimes--,0===r.usedTimes&&M(n)),t.__cacheKey=o,t.__webglTexture=a[o].texture}return i}function L(t,s,o){let l=e.TEXTURE_2D;(s.isDataArrayTexture||s.isCompressedArrayTexture)&&(l=e.TEXTURE_2D_ARRAY),s.isData3DTexture&&(l=e.TEXTURE_3D);const c=D(t,s),h=s.source;n.bindTexture(l,t.__webglTexture,e.TEXTURE0+o);const d=i.get(h);if(h.version!==d.__version||!0===c){n.activeTexture(e.TEXTURE0+o);const t=Et.getPrimaries(Et.workingColorSpace),i=s.colorSpace===Ve?null:Et.getPrimaries(s.colorSpace),u=s.colorSpace===Ve||t===i?e.NONE:e.BROWSER_DEFAULT_WEBGL;e.pixelStorei(e.UNPACK_FLIP_Y_WEBGL,s.flipY),e.pixelStorei(e.UNPACK_PREMULTIPLY_ALPHA_WEBGL,s.premultiplyAlpha),e.pixelStorei(e.UNPACK_ALIGNMENT,s.unpackAlignment),e.pixelStorei(e.UNPACK_COLORSPACE_CONVERSION_WEBGL,u);let p=m(s.image,!1,r.maxTextureSize);p=ie(s,p);const f=a.convert(s.format,s.colorSpace),_=a.convert(s.type);let w,b=x(s.internalFormat,f,_,s.colorSpace,s.isVideoTexture);C(l,s);const M=s.mipmaps,T=!0!==s.isVideoTexture,E=void 0===d.__version||!0===c,A=h.dataReady,P=S(s,p);if(s.isDepthTexture)b=y(s.format===ne,s.type),E&&(T?n.texStorage2D(e.TEXTURE_2D,1,b,p.width,p.height):n.texImage2D(e.TEXTURE_2D,0,b,p.width,p.height,0,f,_,null));else if(s.isDataTexture)if(M.length>0){T&&E&&n.texStorage2D(e.TEXTURE_2D,P,b,M[0].width,M[0].height);for(let t=0,i=M.length;t0){const i=qs(w.width,w.height,s.format,s.type);for(const r of s.layerUpdates){const a=w.data.subarray(r*i/w.data.BYTES_PER_ELEMENT,(r+1)*i/w.data.BYTES_PER_ELEMENT);n.compressedTexSubImage3D(e.TEXTURE_2D_ARRAY,t,0,0,r,w.width,w.height,1,f,a)}s.clearLayerUpdates()}else n.compressedTexSubImage3D(e.TEXTURE_2D_ARRAY,t,0,0,0,w.width,w.height,p.depth,f,w.data)}else n.compressedTexImage3D(e.TEXTURE_2D_ARRAY,t,b,w.width,w.height,p.depth,0,w.data,0,0);else console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()");else T?A&&n.texSubImage3D(e.TEXTURE_2D_ARRAY,t,0,0,0,w.width,w.height,p.depth,f,_,w.data):n.texImage3D(e.TEXTURE_2D_ARRAY,t,b,w.width,w.height,p.depth,0,f,_,w.data)}else{T&&E&&n.texStorage2D(e.TEXTURE_2D,P,b,M[0].width,M[0].height);for(let t=0,i=M.length;t0){const t=qs(p.width,p.height,s.format,s.type);for(const i of s.layerUpdates){const r=p.data.subarray(i*t/p.data.BYTES_PER_ELEMENT,(i+1)*t/p.data.BYTES_PER_ELEMENT);n.texSubImage3D(e.TEXTURE_2D_ARRAY,0,0,0,i,p.width,p.height,1,f,_,r)}s.clearLayerUpdates()}else n.texSubImage3D(e.TEXTURE_2D_ARRAY,0,0,0,0,p.width,p.height,p.depth,f,_,p.data)}else n.texImage3D(e.TEXTURE_2D_ARRAY,0,b,p.width,p.height,p.depth,0,f,_,p.data);else if(s.isData3DTexture)T?(E&&n.texStorage3D(e.TEXTURE_3D,P,b,p.width,p.height,p.depth),A&&n.texSubImage3D(e.TEXTURE_3D,0,0,0,0,p.width,p.height,p.depth,f,_,p.data)):n.texImage3D(e.TEXTURE_3D,0,b,p.width,p.height,p.depth,0,f,_,p.data);else if(s.isFramebufferTexture){if(E)if(T)n.texStorage2D(e.TEXTURE_2D,P,b,p.width,p.height);else{let t=p.width,i=p.height;for(let r=0;r>=1,i>>=1}}else if(M.length>0){if(T&&E){const t=re(M[0]);n.texStorage2D(e.TEXTURE_2D,P,b,t.width,t.height)}for(let t=0,i=M.length;t>h),i=Math.max(1,r.height>>h);c===e.TEXTURE_3D||c===e.TEXTURE_2D_ARRAY?n.texImage3D(c,h,p,t,i,r.depth,0,d,u,null):n.texImage2D(c,h,p,t,i,0,d,u,null)}n.bindFramebuffer(e.FRAMEBUFFER,t),Q(r)?o.framebufferTexture2DMultisampleEXT(e.FRAMEBUFFER,l,c,m.__webglTexture,0,J(r)):(c===e.TEXTURE_2D||c>=e.TEXTURE_CUBE_MAP_POSITIVE_X&&c<=e.TEXTURE_CUBE_MAP_NEGATIVE_Z)&&e.framebufferTexture2D(e.FRAMEBUFFER,l,c,m.__webglTexture,h),n.bindFramebuffer(e.FRAMEBUFFER,null)}function U(t,n,i){if(e.bindRenderbuffer(e.RENDERBUFFER,t),n.depthBuffer){const r=n.depthTexture,a=r&&r.isDepthTexture?r.type:null,s=y(n.stencilBuffer,a),l=n.stencilBuffer?e.DEPTH_STENCIL_ATTACHMENT:e.DEPTH_ATTACHMENT,c=J(n);Q(n)?o.renderbufferStorageMultisampleEXT(e.RENDERBUFFER,c,s,n.width,n.height):i?e.renderbufferStorageMultisample(e.RENDERBUFFER,c,s,n.width,n.height):e.renderbufferStorage(e.RENDERBUFFER,s,n.width,n.height),e.framebufferRenderbuffer(e.FRAMEBUFFER,l,e.RENDERBUFFER,t)}else{const t=n.textures;for(let r=0;r{delete r.__boundDepthTexture,delete r.__depthDisposeCallback,e.removeEventListener("dispose",t)};e.addEventListener("dispose",t),r.__depthDisposeCallback=t}r.__boundDepthTexture=e}if(t.depthTexture&&!r.__autoAllocateDepthBuffer){if(a)throw new Error("target.depthTexture not supported in Cube render targets");!function(t,r){if(r&&r.isWebGLCubeRenderTarget)throw new Error("Depth Texture with cube render targets is not supported");if(n.bindFramebuffer(e.FRAMEBUFFER,t),!r.depthTexture||!r.depthTexture.isDepthTexture)throw new Error("renderTarget.depthTexture must be an instance of THREE.DepthTexture");const a=i.get(r.depthTexture);a.__renderTarget=r,a.__webglTexture&&r.depthTexture.image.width===r.width&&r.depthTexture.image.height===r.height||(r.depthTexture.image.width=r.width,r.depthTexture.image.height=r.height,r.depthTexture.needsUpdate=!0),E(r.depthTexture,0);const s=a.__webglTexture,l=J(r);if(r.depthTexture.format===te)Q(r)?o.framebufferTexture2DMultisampleEXT(e.FRAMEBUFFER,e.DEPTH_ATTACHMENT,e.TEXTURE_2D,s,0,l):e.framebufferTexture2D(e.FRAMEBUFFER,e.DEPTH_ATTACHMENT,e.TEXTURE_2D,s,0);else{if(r.depthTexture.format!==ne)throw new Error("Unknown depthTexture format");Q(r)?o.framebufferTexture2DMultisampleEXT(e.FRAMEBUFFER,e.DEPTH_STENCIL_ATTACHMENT,e.TEXTURE_2D,s,0,l):e.framebufferTexture2D(e.FRAMEBUFFER,e.DEPTH_STENCIL_ATTACHMENT,e.TEXTURE_2D,s,0)}}(r.__webglFramebuffer,t)}else if(a){r.__webglDepthbuffer=[];for(let i=0;i<6;i++)if(n.bindFramebuffer(e.FRAMEBUFFER,r.__webglFramebuffer[i]),void 0===r.__webglDepthbuffer[i])r.__webglDepthbuffer[i]=e.createRenderbuffer(),U(r.__webglDepthbuffer[i],t,!1);else{const n=t.stencilBuffer?e.DEPTH_STENCIL_ATTACHMENT:e.DEPTH_ATTACHMENT,a=r.__webglDepthbuffer[i];e.bindRenderbuffer(e.RENDERBUFFER,a),e.framebufferRenderbuffer(e.FRAMEBUFFER,n,e.RENDERBUFFER,a)}}else if(n.bindFramebuffer(e.FRAMEBUFFER,r.__webglFramebuffer),void 0===r.__webglDepthbuffer)r.__webglDepthbuffer=e.createRenderbuffer(),U(r.__webglDepthbuffer,t,!1);else{const n=t.stencilBuffer?e.DEPTH_STENCIL_ATTACHMENT:e.DEPTH_ATTACHMENT,i=r.__webglDepthbuffer;e.bindRenderbuffer(e.RENDERBUFFER,i),e.framebufferRenderbuffer(e.FRAMEBUFFER,n,e.RENDERBUFFER,i)}n.bindFramebuffer(e.FRAMEBUFFER,null)}const Y=[],K=[];function J(e){return Math.min(r.maxSamples,e.samples)}function Q(e){const n=i.get(e);return e.samples>0&&!0===t.has("WEBGL_multisampled_render_to_texture")&&!1!==n.__useRenderToTexture}function ie(e,t){const n=e.colorSpace,i=e.format,r=e.type;return!0===e.isCompressedTexture||!0===e.isVideoTexture||n!==We&&n!==Ve&&(Et.getTransfer(n)===Xe?i===ee&&r===j||console.warn("THREE.WebGLTextures: sRGB encoded textures have to use RGBAFormat and UnsignedByteType."):console.error("THREE.WebGLTextures: Unsupported texture color space:",n)),t}function re(e){return"undefined"!=typeof HTMLImageElement&&e instanceof HTMLImageElement?(c.width=e.naturalWidth||e.width,c.height=e.naturalHeight||e.height):"undefined"!=typeof VideoFrame&&e instanceof VideoFrame?(c.width=e.displayWidth,c.height=e.displayHeight):(c.width=e.width,c.height=e.height),c}this.allocateTextureUnit=function(){const e=T;return e>=r.maxTextures&&console.warn("THREE.WebGLTextures: Trying to use "+e+" texture units while this GPU supports only "+r.maxTextures),T+=1,e},this.resetTextureUnits=function(){T=0},this.setTexture2D=E,this.setTexture2DArray=function(t,r){const a=i.get(t);t.version>0&&a.__version!==t.version?L(a,t,r):n.bindTexture(e.TEXTURE_2D_ARRAY,a.__webglTexture,e.TEXTURE0+r)},this.setTexture3D=function(t,r){const a=i.get(t);t.version>0&&a.__version!==t.version?L(a,t,r):n.bindTexture(e.TEXTURE_3D,a.__webglTexture,e.TEXTURE0+r)},this.setTextureCube=function(t,s){const o=i.get(t);t.version>0&&o.__version!==t.version?function(t,s,o){if(6!==s.image.length)return;const l=D(t,s),c=s.source;n.bindTexture(e.TEXTURE_CUBE_MAP,t.__webglTexture,e.TEXTURE0+o);const h=i.get(c);if(c.version!==h.__version||!0===l){n.activeTexture(e.TEXTURE0+o);const t=Et.getPrimaries(Et.workingColorSpace),i=s.colorSpace===Ve?null:Et.getPrimaries(s.colorSpace),d=s.colorSpace===Ve||t===i?e.NONE:e.BROWSER_DEFAULT_WEBGL;e.pixelStorei(e.UNPACK_FLIP_Y_WEBGL,s.flipY),e.pixelStorei(e.UNPACK_PREMULTIPLY_ALPHA_WEBGL,s.premultiplyAlpha),e.pixelStorei(e.UNPACK_ALIGNMENT,s.unpackAlignment),e.pixelStorei(e.UNPACK_COLORSPACE_CONVERSION_WEBGL,d);const u=s.isCompressedTexture||s.image[0].isCompressedTexture,p=s.image[0]&&s.image[0].isDataTexture,f=[];for(let e=0;e<6;e++)f[e]=u||p?p?s.image[e].image:s.image[e]:m(s.image[e],!0,r.maxCubemapSize),f[e]=ie(s,f[e]);const _=f[0],y=a.convert(s.format,s.colorSpace),w=a.convert(s.type),b=x(s.internalFormat,y,w,s.colorSpace),M=!0!==s.isVideoTexture,T=void 0===h.__version||!0===l,E=c.dataReady;let A,P=S(s,_);if(C(e.TEXTURE_CUBE_MAP,s),u){M&&T&&n.texStorage2D(e.TEXTURE_CUBE_MAP,P,b,_.width,_.height);for(let t=0;t<6;t++){A=f[t].mipmaps;for(let i=0;i0&&P++;const t=re(f[0]);n.texStorage2D(e.TEXTURE_CUBE_MAP,P,b,t.width,t.height)}for(let t=0;t<6;t++)if(p){M?E&&n.texSubImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+t,0,0,0,f[t].width,f[t].height,y,w,f[t].data):n.texImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+t,0,b,f[t].width,f[t].height,0,y,w,f[t].data);for(let i=0;i1;if(d||(void 0===l.__webglTexture&&(l.__webglTexture=e.createTexture()),l.__version=r.version,s.memory.textures++),h){o.__webglFramebuffer=[];for(let t=0;t<6;t++)if(r.mipmaps&&r.mipmaps.length>0){o.__webglFramebuffer[t]=[];for(let n=0;n0){o.__webglFramebuffer=[];for(let t=0;t0&&!1===Q(t)){o.__webglMultisampledFramebuffer=e.createFramebuffer(),o.__webglColorRenderbuffer=[],n.bindFramebuffer(e.FRAMEBUFFER,o.__webglMultisampledFramebuffer);for(let n=0;n0)for(let i=0;i0)for(let n=0;n0)if(!1===Q(t)){const r=t.textures,a=t.width,s=t.height;let o=e.COLOR_BUFFER_BIT;const c=t.stencilBuffer?e.DEPTH_STENCIL_ATTACHMENT:e.DEPTH_ATTACHMENT,h=i.get(t),d=r.length>1;if(d)for(let t=0;to+c?(l.inputState.pinching=!1,this.dispatchEvent({type:"pinchend",handedness:e.handedness,target:this})):!l.inputState.pinching&&s<=o-c&&(l.inputState.pinching=!0,this.dispatchEvent({type:"pinchstart",handedness:e.handedness,target:this}))}else null!==o&&e.gripSpace&&(r=t.getPose(e.gripSpace,n),null!==r&&(o.matrix.fromArray(r.transform.matrix),o.matrix.decompose(o.position,o.rotation,o.scale),o.matrixWorldNeedsUpdate=!0,r.linearVelocity?(o.hasLinearVelocity=!0,o.linearVelocity.copy(r.linearVelocity)):o.hasLinearVelocity=!1,r.angularVelocity?(o.hasAngularVelocity=!0,o.angularVelocity.copy(r.angularVelocity)):o.hasAngularVelocity=!1));null!==s&&(i=t.getPose(e.targetRaySpace,n),null===i&&null!==r&&(i=r),null!==i&&(s.matrix.fromArray(i.transform.matrix),s.matrix.decompose(s.position,s.rotation,s.scale),s.matrixWorldNeedsUpdate=!0,i.linearVelocity?(s.hasLinearVelocity=!0,s.linearVelocity.copy(i.linearVelocity)):s.hasLinearVelocity=!1,i.angularVelocity?(s.hasAngularVelocity=!0,s.angularVelocity.copy(i.angularVelocity)):s.hasAngularVelocity=!1,this.dispatchEvent($s)))}return null!==s&&(s.visible=null!==i),null!==o&&(o.visible=null!==r),null!==l&&(l.visible=null!==a),this}_getHandJoint(e,t){if(void 0===e.joints[t.jointName]){const n=new Qs;n.matrixAutoUpdate=!1,n.visible=!1,e.joints[t.jointName]=n,e.add(n)}return e.joints[t.jointName]}}class to{constructor(){this.texture=null,this.mesh=null,this.depthNear=0,this.depthFar=0}init(e,t,n){if(null===this.texture){const i=new kt;e.properties.get(i).__webglTexture=t.texture,t.depthNear==n.depthNear&&t.depthFar==n.depthFar||(this.depthNear=t.depthNear,this.depthFar=t.depthFar),this.texture=i}}getMesh(e){if(null!==this.texture&&null===this.mesh){const t=e.cameras[0].viewport,n=new nr({vertexShader:"\nvoid main() {\n\n\tgl_Position = vec4( position, 1.0 );\n\n}",fragmentShader:"\nuniform sampler2DArray depthColor;\nuniform float depthWidth;\nuniform float depthHeight;\n\nvoid main() {\n\n\tvec2 coord = vec2( gl_FragCoord.x / depthWidth, gl_FragCoord.y / depthHeight );\n\n\tif ( coord.x >= 1.0 ) {\n\n\t\tgl_FragDepth = texture( depthColor, vec3( coord.x - 1.0, coord.y, 1 ) ).r;\n\n\t} else {\n\n\t\tgl_FragDepth = texture( depthColor, vec3( coord.x, coord.y, 0 ) ).r;\n\n\t}\n\n}",uniforms:{depthColor:{value:this.texture},depthWidth:{value:t.z},depthHeight:{value:t.w}}});this.mesh=new Zi(new Sr(20,20),n)}return this.mesh}reset(){this.texture=null,this.mesh=null}getDepthTexture(){return this.texture}}class no extends st{constructor(e,t){super();const n=this;let i=null,r=1,a=null,s="local-floor",o=1,l=null,c=null,h=null,d=null,u=null,p=null;const f=new to,m=t.getContextAttributes();let g=null,v=null;const _=[],x=[],y=new _t;let S=null;const w=new or;w.viewport=new Ht;const b=new or;b.viewport=new Ht;const M=[w,b],T=new Js;let E=null,A=null;function P(e){const t=x.indexOf(e.inputSource);if(-1===t)return;const n=_[t];void 0!==n&&(n.update(e.inputSource,e.frame,l||a),n.dispatchEvent({type:e.type,data:e.inputSource}))}function R(){i.removeEventListener("select",P),i.removeEventListener("selectstart",P),i.removeEventListener("selectend",P),i.removeEventListener("squeeze",P),i.removeEventListener("squeezestart",P),i.removeEventListener("squeezeend",P),i.removeEventListener("end",R),i.removeEventListener("inputsourceschange",C);for(let e=0;e<_.length;e++){const t=x[e];null!==t&&(x[e]=null,_[e].disconnect(t))}E=null,A=null,f.reset(),e.setRenderTarget(g),u=null,d=null,h=null,i=null,v=null,O.stop(),n.isPresenting=!1,e.setPixelRatio(S),e.setSize(y.width,y.height,!1),n.dispatchEvent({type:"sessionend"})}function C(e){for(let t=0;t=0&&(x[i]=null,_[i].disconnect(n))}for(let t=0;t=x.length){x.push(n),i=e;break}if(null===x[e]){x[e]=n,i=e;break}}if(-1===i)break}const r=_[i];r&&r.connect(n)}}this.cameraAutoUpdate=!0,this.enabled=!1,this.isPresenting=!1,this.getController=function(e){let t=_[e];return void 0===t&&(t=new eo,_[e]=t),t.getTargetRaySpace()},this.getControllerGrip=function(e){let t=_[e];return void 0===t&&(t=new eo,_[e]=t),t.getGripSpace()},this.getHand=function(e){let t=_[e];return void 0===t&&(t=new eo,_[e]=t),t.getHandSpace()},this.setFramebufferScaleFactor=function(e){r=e,!0===n.isPresenting&&console.warn("THREE.WebXRManager: Cannot change framebuffer scale while presenting.")},this.setReferenceSpaceType=function(e){s=e,!0===n.isPresenting&&console.warn("THREE.WebXRManager: Cannot change reference space type while presenting.")},this.getReferenceSpace=function(){return l||a},this.setReferenceSpace=function(e){l=e},this.getBaseLayer=function(){return null!==d?d:u},this.getBinding=function(){return h},this.getFrame=function(){return p},this.getSession=function(){return i},this.setSession=async function(c){if(i=c,null!==i){if(g=e.getRenderTarget(),i.addEventListener("select",P),i.addEventListener("selectstart",P),i.addEventListener("selectend",P),i.addEventListener("squeeze",P),i.addEventListener("squeezestart",P),i.addEventListener("squeezeend",P),i.addEventListener("end",R),i.addEventListener("inputsourceschange",C),!0!==m.xrCompatible&&await t.makeXRCompatible(),S=e.getPixelRatio(),e.getSize(y),void 0===i.renderState.layers){const n={antialias:m.antialias,alpha:!0,depth:m.depth,stencil:m.stencil,framebufferScaleFactor:r};u=new XRWebGLLayer(i,t,n),i.updateRenderState({baseLayer:u}),e.setPixelRatio(1),e.setSize(u.framebufferWidth,u.framebufferHeight,!1),v=new Gt(u.framebufferWidth,u.framebufferHeight,{format:ee,type:j,colorSpace:e.outputColorSpace,stencilBuffer:m.stencil})}else{let n=null,a=null,s=null;m.depth&&(s=m.stencil?t.DEPTH24_STENCIL8:t.DEPTH_COMPONENT24,n=m.stencil?ne:te,a=m.stencil?$:q);const o={colorFormat:t.RGBA8,depthFormat:s,scaleFactor:r};h=new XRWebGLBinding(i,t),d=h.createProjectionLayer(o),i.updateRenderState({layers:[d]}),e.setPixelRatio(1),e.setSize(d.textureWidth,d.textureHeight,!1),v=new Gt(d.textureWidth,d.textureHeight,{format:ee,type:j,depthTexture:new ia(d.textureWidth,d.textureHeight,a,void 0,void 0,void 0,void 0,void 0,void 0,n),stencilBuffer:m.stencil,colorSpace:e.outputColorSpace,samples:m.antialias?4:0,resolveDepthBuffer:!1===d.ignoreDepthValues})}v.isXRRenderTarget=!0,this.setFoveation(o),l=null,a=await i.requestReferenceSpace(s),O.setContext(i),O.start(),n.isPresenting=!0,n.dispatchEvent({type:"sessionstart"})}},this.getEnvironmentBlendMode=function(){if(null!==i)return i.environmentBlendMode},this.getDepthTexture=function(){return f.getDepthTexture()};const D=new Yt,L=new Yt;function I(e,t){null===t?e.matrixWorld.copy(e.matrix):e.matrixWorld.multiplyMatrices(t.matrixWorld,e.matrix),e.matrixWorldInverse.copy(e.matrixWorld).invert()}this.updateCamera=function(e){if(null===i)return;let t=e.near,n=e.far;null!==f.texture&&(f.depthNear>0&&(t=f.depthNear),f.depthFar>0&&(n=f.depthFar)),T.near=b.near=w.near=t,T.far=b.far=w.far=n,E===T.near&&A===T.far||(i.updateRenderState({depthNear:T.near,depthFar:T.far}),E=T.near,A=T.far),w.layers.mask=2|e.layers.mask,b.layers.mask=4|e.layers.mask,T.layers.mask=w.layers.mask|b.layers.mask;const r=e.parent,a=T.cameras;I(T,r);for(let e=0;e0&&(e.alphaTest.value=i.alphaTest);const r=t.get(i),a=r.envMap,s=r.envMapRotation;a&&(e.envMap.value=a,io.copy(s),io.x*=-1,io.y*=-1,io.z*=-1,a.isCubeTexture&&!1===a.isRenderTargetTexture&&(io.y*=-1,io.z*=-1),e.envMapRotation.value.setFromMatrix4(ro.makeRotationFromEuler(io)),e.flipEnvMap.value=a.isCubeTexture&&!1===a.isRenderTargetTexture?-1:1,e.reflectivity.value=i.reflectivity,e.ior.value=i.ior,e.refractionRatio.value=i.refractionRatio),i.lightMap&&(e.lightMap.value=i.lightMap,e.lightMapIntensity.value=i.lightMapIntensity,n(i.lightMap,e.lightMapTransform)),i.aoMap&&(e.aoMap.value=i.aoMap,e.aoMapIntensity.value=i.aoMapIntensity,n(i.aoMap,e.aoMapTransform))}return{refreshFogUniforms:function(t,n){n.color.getRGB(t.fogColor.value,er(e)),n.isFog?(t.fogNear.value=n.near,t.fogFar.value=n.far):n.isFogExp2&&(t.fogDensity.value=n.density)},refreshMaterialUniforms:function(e,r,a,s,o){r.isMeshBasicMaterial||r.isMeshLambertMaterial?i(e,r):r.isMeshToonMaterial?(i(e,r),function(e,t){t.gradientMap&&(e.gradientMap.value=t.gradientMap)}(e,r)):r.isMeshPhongMaterial?(i(e,r),function(e,t){e.specular.value.copy(t.specular),e.shininess.value=Math.max(t.shininess,1e-4)}(e,r)):r.isMeshStandardMaterial?(i(e,r),function(e,t){e.metalness.value=t.metalness,t.metalnessMap&&(e.metalnessMap.value=t.metalnessMap,n(t.metalnessMap,e.metalnessMapTransform)),e.roughness.value=t.roughness,t.roughnessMap&&(e.roughnessMap.value=t.roughnessMap,n(t.roughnessMap,e.roughnessMapTransform)),t.envMap&&(e.envMapIntensity.value=t.envMapIntensity)}(e,r),r.isMeshPhysicalMaterial&&function(e,t,i){e.ior.value=t.ior,t.sheen>0&&(e.sheenColor.value.copy(t.sheenColor).multiplyScalar(t.sheen),e.sheenRoughness.value=t.sheenRoughness,t.sheenColorMap&&(e.sheenColorMap.value=t.sheenColorMap,n(t.sheenColorMap,e.sheenColorMapTransform)),t.sheenRoughnessMap&&(e.sheenRoughnessMap.value=t.sheenRoughnessMap,n(t.sheenRoughnessMap,e.sheenRoughnessMapTransform))),t.clearcoat>0&&(e.clearcoat.value=t.clearcoat,e.clearcoatRoughness.value=t.clearcoatRoughness,t.clearcoatMap&&(e.clearcoatMap.value=t.clearcoatMap,n(t.clearcoatMap,e.clearcoatMapTransform)),t.clearcoatRoughnessMap&&(e.clearcoatRoughnessMap.value=t.clearcoatRoughnessMap,n(t.clearcoatRoughnessMap,e.clearcoatRoughnessMapTransform)),t.clearcoatNormalMap&&(e.clearcoatNormalMap.value=t.clearcoatNormalMap,n(t.clearcoatNormalMap,e.clearcoatNormalMapTransform),e.clearcoatNormalScale.value.copy(t.clearcoatNormalScale),1===t.side&&e.clearcoatNormalScale.value.negate())),t.dispersion>0&&(e.dispersion.value=t.dispersion),t.iridescence>0&&(e.iridescence.value=t.iridescence,e.iridescenceIOR.value=t.iridescenceIOR,e.iridescenceThicknessMinimum.value=t.iridescenceThicknessRange[0],e.iridescenceThicknessMaximum.value=t.iridescenceThicknessRange[1],t.iridescenceMap&&(e.iridescenceMap.value=t.iridescenceMap,n(t.iridescenceMap,e.iridescenceMapTransform)),t.iridescenceThicknessMap&&(e.iridescenceThicknessMap.value=t.iridescenceThicknessMap,n(t.iridescenceThicknessMap,e.iridescenceThicknessMapTransform))),t.transmission>0&&(e.transmission.value=t.transmission,e.transmissionSamplerMap.value=i.texture,e.transmissionSamplerSize.value.set(i.width,i.height),t.transmissionMap&&(e.transmissionMap.value=t.transmissionMap,n(t.transmissionMap,e.transmissionMapTransform)),e.thickness.value=t.thickness,t.thicknessMap&&(e.thicknessMap.value=t.thicknessMap,n(t.thicknessMap,e.thicknessMapTransform)),e.attenuationDistance.value=t.attenuationDistance,e.attenuationColor.value.copy(t.attenuationColor)),t.anisotropy>0&&(e.anisotropyVector.value.set(t.anisotropy*Math.cos(t.anisotropyRotation),t.anisotropy*Math.sin(t.anisotropyRotation)),t.anisotropyMap&&(e.anisotropyMap.value=t.anisotropyMap,n(t.anisotropyMap,e.anisotropyMapTransform))),e.specularIntensity.value=t.specularIntensity,e.specularColor.value.copy(t.specularColor),t.specularColorMap&&(e.specularColorMap.value=t.specularColorMap,n(t.specularColorMap,e.specularColorMapTransform)),t.specularIntensityMap&&(e.specularIntensityMap.value=t.specularIntensityMap,n(t.specularIntensityMap,e.specularIntensityMapTransform))}(e,r,o)):r.isMeshMatcapMaterial?(i(e,r),function(e,t){t.matcap&&(e.matcap.value=t.matcap)}(e,r)):r.isMeshDepthMaterial?i(e,r):r.isMeshDistanceMaterial?(i(e,r),function(e,n){const i=t.get(n).light;e.referencePosition.value.setFromMatrixPosition(i.matrixWorld),e.nearDistance.value=i.shadow.camera.near,e.farDistance.value=i.shadow.camera.far}(e,r)):r.isMeshNormalMaterial?i(e,r):r.isLineBasicMaterial?(function(e,t){e.diffuse.value.copy(t.color),e.opacity.value=t.opacity,t.map&&(e.map.value=t.map,n(t.map,e.mapTransform))}(e,r),r.isLineDashedMaterial&&function(e,t){e.dashSize.value=t.dashSize,e.totalSize.value=t.dashSize+t.gapSize,e.scale.value=t.scale}(e,r)):r.isPointsMaterial?function(e,t,i,r){e.diffuse.value.copy(t.color),e.opacity.value=t.opacity,e.size.value=t.size*i,e.scale.value=.5*r,t.map&&(e.map.value=t.map,n(t.map,e.uvTransform)),t.alphaMap&&(e.alphaMap.value=t.alphaMap,n(t.alphaMap,e.alphaMapTransform)),t.alphaTest>0&&(e.alphaTest.value=t.alphaTest)}(e,r,a,s):r.isSpriteMaterial?function(e,t){e.diffuse.value.copy(t.color),e.opacity.value=t.opacity,e.rotation.value=t.rotation,t.map&&(e.map.value=t.map,n(t.map,e.mapTransform)),t.alphaMap&&(e.alphaMap.value=t.alphaMap,n(t.alphaMap,e.alphaMapTransform)),t.alphaTest>0&&(e.alphaTest.value=t.alphaTest)}(e,r):r.isShadowMaterial?(e.color.value.copy(r.color),e.opacity.value=r.opacity):r.isShaderMaterial&&(r.uniformsNeedUpdate=!1)}}}function so(e,t,n,i){let r={},a={},s=[];const o=e.getParameter(e.MAX_UNIFORM_BUFFER_BINDINGS);function l(e,t,n,i){const r=e.value,a=t+"_"+n;if(void 0===i[a])return i[a]="number"==typeof r||"boolean"==typeof r?r:r.clone(),!0;{const e=i[a];if("number"==typeof r||"boolean"==typeof r){if(e!==r)return i[a]=r,!0}else if(!1===e.equals(r))return e.copy(r),!0}return!1}function c(e){const t={boundary:0,storage:0};return"number"==typeof e||"boolean"==typeof e?(t.boundary=4,t.storage=4):e.isVector2?(t.boundary=8,t.storage=8):e.isVector3||e.isColor?(t.boundary=16,t.storage=12):e.isVector4?(t.boundary=16,t.storage=16):e.isMatrix3?(t.boundary=48,t.storage=48):e.isMatrix4?(t.boundary=64,t.storage=64):e.isTexture?console.warn("THREE.WebGLRenderer: Texture samplers can not be part of an uniforms group."):console.warn("THREE.WebGLRenderer: Unsupported uniform value type.",e),t}function h(t){const n=t.target;n.removeEventListener("dispose",h);const i=s.indexOf(n.__bindingPointIndex);s.splice(i,1),e.deleteBuffer(r[n.id]),delete r[n.id],delete a[n.id]}return{bind:function(e,t){const n=t.program;i.uniformBlockBinding(e,n)},update:function(n,d){let u=r[n.id];void 0===u&&(function(e){const t=e.uniforms;let n=0;for(let e=0,i=t.length;e0&&(n+=16-i),e.__size=n,e.__cache={}}(n),u=function(t){const n=function(){for(let e=0;e0&&(t.object.backgroundBlurriness=this.backgroundBlurriness),1!==this.backgroundIntensity&&(t.object.backgroundIntensity=this.backgroundIntensity),t.object.backgroundRotation=this.backgroundRotation.toArray(),1!==this.environmentIntensity&&(t.object.environmentIntensity=this.environmentIntensity),t.object.environmentRotation=this.environmentRotation.toArray(),t}}class lo{constructor(e,t){this.isInterleavedBuffer=!0,this.array=e,this.stride=t,this.count=void 0!==e?e.length/t:0,this.usage=nt,this.updateRanges=[],this.version=0,this.uuid=ht()}onUploadCallback(){}set needsUpdate(e){!0===e&&this.version++}setUsage(e){return this.usage=e,this}addUpdateRange(e,t){this.updateRanges.push({start:e,count:t})}clearUpdateRanges(){this.updateRanges.length=0}copy(e){return this.array=new e.array.constructor(e.array),this.count=e.count,this.stride=e.stride,this.usage=e.usage,this}copyAt(e,t,n){e*=this.stride,n*=t.stride;for(let i=0,r=this.stride;i0){const n=e[t[0]];if(void 0!==n){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let e=0,t=n.length;ei)return;Vo.applyMatrix4(e.matrixWorld);const o=t.ray.origin.distanceTo(Vo);return ot.far?void 0:{distance:o,point:Go.clone().applyMatrix4(e.matrixWorld),index:r,face:null,faceIndex:null,barycoord:null,object:e}}const Xo=new Yt,Yo=new Yt;class qo extends Wo{constructor(e,t){super(e,t),this.isLineSegments=!0,this.type="LineSegments"}computeLineDistances(){const e=this.geometry;if(null===e.index){const t=e.attributes.position,n=[];for(let e=0,i=t.count;e0){const n=e[t[0]];if(void 0!==n){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let e=0,t=n.length;er.far)return;a.push({distance:l,distanceToRay:Math.sqrt(o),point:n,index:t,face:null,faceIndex:null,barycoord:null,object:s})}}class il{constructor(){this.type="Curve",this.arcLengthDivisions=200}getPoint(){return console.warn("THREE.Curve: .getPoint() not implemented."),null}getPointAt(e,t){const n=this.getUtoTmapping(e);return this.getPoint(n,t)}getPoints(e=5){const t=[];for(let n=0;n<=e;n++)t.push(this.getPoint(n/e));return t}getSpacedPoints(e=5){const t=[];for(let n=0;n<=e;n++)t.push(this.getPointAt(n/e));return t}getLength(){const e=this.getLengths();return e[e.length-1]}getLengths(e=this.arcLengthDivisions){if(this.cacheArcLengths&&this.cacheArcLengths.length===e+1&&!this.needsUpdate)return this.cacheArcLengths;this.needsUpdate=!1;const t=[];let n,i=this.getPoint(0),r=0;t.push(0);for(let a=1;a<=e;a++)n=this.getPoint(a/e),r+=n.distanceTo(i),t.push(r),i=n;return this.cacheArcLengths=t,t}updateArcLengths(){this.needsUpdate=!0,this.getLengths()}getUtoTmapping(e,t){const n=this.getLengths();let i=0;const r=n.length;let a;a=t||e*n[r-1];let s,o=0,l=r-1;for(;o<=l;)if(i=Math.floor(o+(l-o)/2),s=n[i]-a,s<0)o=i+1;else{if(!(s>0)){l=i;break}l=i-1}if(i=l,n[i]===a)return i/(r-1);const c=n[i];return(i+(a-c)/(n[i+1]-c))/(r-1)}getTangent(e,t){const n=1e-4;let i=e-n,r=e+n;i<0&&(i=0),r>1&&(r=1);const a=this.getPoint(i),s=this.getPoint(r),o=t||(a.isVector2?new _t:new Yt);return o.copy(s).sub(a).normalize(),o}getTangentAt(e,t){const n=this.getUtoTmapping(e);return this.getTangent(n,t)}computeFrenetFrames(e,t){const n=new Yt,i=[],r=[],a=[],s=new Yt,o=new Mn;for(let t=0;t<=e;t++){const n=t/e;i[t]=this.getTangentAt(n,new Yt)}r[0]=new Yt,a[0]=new Yt;let l=Number.MAX_VALUE;const c=Math.abs(i[0].x),h=Math.abs(i[0].y),d=Math.abs(i[0].z);c<=l&&(l=c,n.set(1,0,0)),h<=l&&(l=h,n.set(0,1,0)),d<=l&&n.set(0,0,1),s.crossVectors(i[0],n).normalize(),r[0].crossVectors(i[0],s),a[0].crossVectors(i[0],r[0]);for(let t=1;t<=e;t++){if(r[t]=r[t-1].clone(),a[t]=a[t-1].clone(),s.crossVectors(i[t-1],i[t]),s.length()>Number.EPSILON){s.normalize();const e=Math.acos(dt(i[t-1].dot(i[t]),-1,1));r[t].applyMatrix4(o.makeRotationAxis(s,e))}a[t].crossVectors(i[t],r[t])}if(!0===t){let t=Math.acos(dt(r[0].dot(r[e]),-1,1));t/=e,i[0].dot(s.crossVectors(r[0],r[e]))>0&&(t=-t);for(let n=1;n<=e;n++)r[n].applyMatrix4(o.makeRotationAxis(i[n],t*n)),a[n].crossVectors(i[n],r[n])}return{tangents:i,normals:r,binormals:a}}clone(){return(new this.constructor).copy(this)}copy(e){return this.arcLengthDivisions=e.arcLengthDivisions,this}toJSON(){const e={metadata:{version:4.6,type:"Curve",generator:"Curve.toJSON"}};return e.arcLengthDivisions=this.arcLengthDivisions,e.type=this.type,e}fromJSON(e){return this.arcLengthDivisions=e.arcLengthDivisions,this}}class rl extends il{constructor(e=0,t=0,n=1,i=1,r=0,a=2*Math.PI,s=!1,o=0){super(),this.isEllipseCurve=!0,this.type="EllipseCurve",this.aX=e,this.aY=t,this.xRadius=n,this.yRadius=i,this.aStartAngle=r,this.aEndAngle=a,this.aClockwise=s,this.aRotation=o}getPoint(e,t=new _t){const n=t,i=2*Math.PI;let r=this.aEndAngle-this.aStartAngle;const a=Math.abs(r)i;)r-=i;r0?0:(Math.floor(Math.abs(l)/r)+1)*r:0===c&&l===r-1&&(l=r-2,c=1),this.closed||l>0?s=i[(l-1)%r]:(sl.subVectors(i[0],i[1]).add(i[0]),s=sl);const h=i[l%r],d=i[(l+1)%r];if(this.closed||l+2i.length-2?i.length-1:a+1],h=i[a>i.length-3?i.length-1:a+2];return n.set(dl(s,o.x,l.x,c.x,h.x),dl(s,o.y,l.y,c.y,h.y)),n}copy(e){super.copy(e),this.points=[];for(let t=0,n=e.points.length;t0||0!==i)&&(c.push(a,s,l),_+=3),(t>0||i!==r-1)&&(c.push(s,o,l),_+=3)}l.addGroup(g,_,0),g+=_}(),!1===a&&(e>0&&v(!0),t>0&&v(!1)),this.setIndex(c),this.setAttribute("position",new Ri(h,3)),this.setAttribute("normal",new Ri(d,3)),this.setAttribute("uv",new Ri(u,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new vl(e.radiusTop,e.radiusBottom,e.height,e.radialSegments,e.heightSegments,e.openEnded,e.thetaStart,e.thetaLength)}}class _l extends Fi{constructor(e=[],t=[],n=1,i=0){super(),this.type="PolyhedronGeometry",this.parameters={vertices:e,indices:t,radius:n,detail:i};const r=[],a=[];function s(e,t,n,i){const r=i+1,a=[];for(let i=0;i<=r;i++){a[i]=[];const s=e.clone().lerp(n,i/r),o=t.clone().lerp(n,i/r),l=r-i;for(let e=0;e<=l;e++)a[i][e]=0===e&&i===r?s:s.clone().lerp(o,e/l)}for(let e=0;e.9&&s<.1&&(t<.2&&(a[e+0]+=1),n<.2&&(a[e+2]+=1),i<.2&&(a[e+4]+=1))}}()}(),this.setAttribute("position",new Ri(r,3)),this.setAttribute("normal",new Ri(r.slice(),3)),this.setAttribute("uv",new Ri(a,2)),0===i?this.computeVertexNormals():this.normalizeNormals()}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new _l(e.vertices,e.indices,e.radius,e.details)}}class xl extends _l{constructor(e=1,t=0){super([1,0,0,-1,0,0,0,1,0,0,-1,0,0,0,1,0,0,-1],[0,2,4,0,4,3,0,3,5,0,5,2,1,2,5,1,5,3,1,3,4,1,4,2],e,t),this.type="OctahedronGeometry",this.parameters={radius:e,detail:t}}static fromJSON(e){return new xl(e.radius,e.detail)}}class yl extends Fi{constructor(e=.5,t=1,n=32,i=1,r=0,a=2*Math.PI){super(),this.type="RingGeometry",this.parameters={innerRadius:e,outerRadius:t,thetaSegments:n,phiSegments:i,thetaStart:r,thetaLength:a},n=Math.max(3,n);const s=[],o=[],l=[],c=[];let h=e;const d=(t-e)/(i=Math.max(1,i)),u=new Yt,p=new _t;for(let e=0;e<=i;e++){for(let e=0;e<=n;e++){const i=r+e/n*a;u.x=h*Math.cos(i),u.y=h*Math.sin(i),o.push(u.x,u.y,u.z),l.push(0,0,1),p.x=(u.x/t+1)/2,p.y=(u.y/t+1)/2,c.push(p.x,p.y)}h+=d}for(let e=0;e0)&&u.push(t,r,l),(e!==n-1||o0!=e>0&&this.version++,this._anisotropy=e}get clearcoat(){return this._clearcoat}set clearcoat(e){this._clearcoat>0!=e>0&&this.version++,this._clearcoat=e}get iridescence(){return this._iridescence}set iridescence(e){this._iridescence>0!=e>0&&this.version++,this._iridescence=e}get dispersion(){return this._dispersion}set dispersion(e){this._dispersion>0!=e>0&&this.version++,this._dispersion=e}get sheen(){return this._sheen}set sheen(e){this._sheen>0!=e>0&&this.version++,this._sheen=e}get transmission(){return this._transmission}set transmission(e){this._transmission>0!=e>0&&this.version++,this._transmission=e}copy(e){return super.copy(e),this.defines={STANDARD:"",PHYSICAL:""},this.anisotropy=e.anisotropy,this.anisotropyRotation=e.anisotropyRotation,this.anisotropyMap=e.anisotropyMap,this.clearcoat=e.clearcoat,this.clearcoatMap=e.clearcoatMap,this.clearcoatRoughness=e.clearcoatRoughness,this.clearcoatRoughnessMap=e.clearcoatRoughnessMap,this.clearcoatNormalMap=e.clearcoatNormalMap,this.clearcoatNormalScale.copy(e.clearcoatNormalScale),this.dispersion=e.dispersion,this.ior=e.ior,this.iridescence=e.iridescence,this.iridescenceMap=e.iridescenceMap,this.iridescenceIOR=e.iridescenceIOR,this.iridescenceThicknessRange=[...e.iridescenceThicknessRange],this.iridescenceThicknessMap=e.iridescenceThicknessMap,this.sheen=e.sheen,this.sheenColor.copy(e.sheenColor),this.sheenColorMap=e.sheenColorMap,this.sheenRoughness=e.sheenRoughness,this.sheenRoughnessMap=e.sheenRoughnessMap,this.transmission=e.transmission,this.transmissionMap=e.transmissionMap,this.thickness=e.thickness,this.thicknessMap=e.thicknessMap,this.attenuationDistance=e.attenuationDistance,this.attenuationColor.copy(e.attenuationColor),this.specularIntensity=e.specularIntensity,this.specularIntensityMap=e.specularIntensityMap,this.specularColor.copy(e.specularColor),this.specularColorMap=e.specularColorMap,this}}class Al extends xi{static get type(){return"MeshPhongMaterial"}constructor(e){super(),this.isMeshPhongMaterial=!0,this.color=new gi(16777215),this.specular=new gi(1118481),this.shininess=30,this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new gi(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=0,this.normalScale=new _t(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new Un,this.combine=0,this.reflectivity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.flatShading=!1,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.specular.copy(e.specular),this.shininess=e.shininess,this.map=e.map,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.emissive.copy(e.emissive),this.emissiveMap=e.emissiveMap,this.emissiveIntensity=e.emissiveIntensity,this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.specularMap=e.specularMap,this.alphaMap=e.alphaMap,this.envMap=e.envMap,this.envMapRotation.copy(e.envMapRotation),this.combine=e.combine,this.reflectivity=e.reflectivity,this.refractionRatio=e.refractionRatio,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.flatShading=e.flatShading,this.fog=e.fog,this}}class Pl extends xi{static get type(){return"MeshNormalMaterial"}constructor(e){super(),this.isMeshNormalMaterial=!0,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=0,this.normalScale=new _t(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.wireframe=!1,this.wireframeLinewidth=1,this.flatShading=!1,this.setValues(e)}copy(e){return super.copy(e),this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.flatShading=e.flatShading,this}}class Rl extends xi{static get type(){return"MeshLambertMaterial"}constructor(e){super(),this.isMeshLambertMaterial=!0,this.color=new gi(16777215),this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new gi(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=0,this.normalScale=new _t(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new Un,this.combine=0,this.reflectivity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.flatShading=!1,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.emissive.copy(e.emissive),this.emissiveMap=e.emissiveMap,this.emissiveIntensity=e.emissiveIntensity,this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.specularMap=e.specularMap,this.alphaMap=e.alphaMap,this.envMap=e.envMap,this.envMapRotation.copy(e.envMapRotation),this.combine=e.combine,this.reflectivity=e.reflectivity,this.refractionRatio=e.refractionRatio,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.flatShading=e.flatShading,this.fog=e.fog,this}}function Cl(e,t,n){return!e||!n&&e.constructor===t?e:"number"==typeof t.BYTES_PER_ELEMENT?new t(e):Array.prototype.slice.call(e)}function Dl(e){const t=e.length,n=new Array(t);for(let e=0;e!==t;++e)n[e]=e;return n.sort((function(t,n){return e[t]-e[n]})),n}function Ll(e,t,n){const i=e.length,r=new e.constructor(i);for(let a=0,s=0;s!==i;++a){const i=n[a]*t;for(let n=0;n!==t;++n)r[s++]=e[i+n]}return r}function Il(e,t,n,i){let r=1,a=e[0];for(;void 0!==a&&void 0===a[i];)a=e[r++];if(void 0===a)return;let s=a[i];if(void 0!==s)if(Array.isArray(s))do{s=a[i],void 0!==s&&(t.push(a.time),n.push.apply(n,s)),a=e[r++]}while(void 0!==a);else if(void 0!==s.toArray)do{s=a[i],void 0!==s&&(t.push(a.time),s.toArray(n,n.length)),a=e[r++]}while(void 0!==a);else do{s=a[i],void 0!==s&&(t.push(a.time),n.push(s)),a=e[r++]}while(void 0!==a)}class Ul{constructor(e,t,n,i){this.parameterPositions=e,this._cachedIndex=0,this.resultBuffer=void 0!==i?i:new t.constructor(n),this.sampleValues=t,this.valueSize=n,this.settings=null,this.DefaultSettings_={}}evaluate(e){const t=this.parameterPositions;let n=this._cachedIndex,i=t[n],r=t[n-1];e:{t:{let a;n:{i:if(!(e=r)break e;{const s=t[1];e=r)break t}a=n,n=0}}for(;n>>1;et;)--a;if(++a,0!==r||a!==i){r>=a&&(a=Math.max(a,1),r=a-1);const e=this.getValueSize();this.times=n.slice(r,a),this.values=this.values.slice(r*e,a*e)}return this}validate(){let e=!0;const t=this.getValueSize();t-Math.floor(t)!=0&&(console.error("THREE.KeyframeTrack: Invalid value size in track.",this),e=!1);const n=this.times,i=this.values,r=n.length;0===r&&(console.error("THREE.KeyframeTrack: Track is empty.",this),e=!1);let a=null;for(let t=0;t!==r;t++){const i=n[t];if("number"==typeof i&&isNaN(i)){console.error("THREE.KeyframeTrack: Time is not a valid number.",this,t,i),e=!1;break}if(null!==a&&a>i){console.error("THREE.KeyframeTrack: Out of order keys.",this,t,i,a),e=!1;break}a=i}if(void 0!==i&&(s=i,ArrayBuffer.isView(s)&&!(s instanceof DataView)))for(let t=0,n=i.length;t!==n;++t){const n=i[t];if(isNaN(n)){console.error("THREE.KeyframeTrack: Value is not a valid number.",this,t,n),e=!1;break}}var s;return e}optimize(){const e=this.times.slice(),t=this.values.slice(),n=this.getValueSize(),i=this.getInterpolation()===He,r=e.length-1;let a=1;for(let s=1;s0){e[a]=e[r];for(let e=r*n,i=a*n,s=0;s!==n;++s)t[i+s]=t[e+s];++a}return a!==e.length?(this.times=e.slice(0,a),this.values=t.slice(0,a*n)):(this.times=e,this.values=t),this}clone(){const e=this.times.slice(),t=this.values.slice(),n=new(0,this.constructor)(this.name,e,t);return n.createInterpolant=this.createInterpolant,n}}Bl.prototype.TimeBufferType=Float32Array,Bl.prototype.ValueBufferType=Float32Array,Bl.prototype.DefaultInterpolation=ke;class zl extends Bl{constructor(e,t,n){super(e,t,n)}}zl.prototype.ValueTypeName="bool",zl.prototype.ValueBufferType=Array,zl.prototype.DefaultInterpolation=ze,zl.prototype.InterpolantFactoryMethodLinear=void 0,zl.prototype.InterpolantFactoryMethodSmooth=void 0;class kl extends Bl{}kl.prototype.ValueTypeName="color";class Hl extends Bl{}Hl.prototype.ValueTypeName="number";class Vl extends Ul{constructor(e,t,n,i){super(e,t,n,i)}interpolate_(e,t,n,i){const r=this.resultBuffer,a=this.sampleValues,s=this.valueSize,o=(n-t)/(i-t);let l=e*s;for(let e=l+s;l!==e;l+=4)Xt.slerpFlat(r,0,a,l-s,a,l,o);return r}}class Gl extends Bl{InterpolantFactoryMethodLinear(e){return new Vl(this.times,this.values,this.getValueSize(),e)}}Gl.prototype.ValueTypeName="quaternion",Gl.prototype.InterpolantFactoryMethodSmooth=void 0;class Wl extends Bl{constructor(e,t,n){super(e,t,n)}}Wl.prototype.ValueTypeName="string",Wl.prototype.ValueBufferType=Array,Wl.prototype.DefaultInterpolation=ze,Wl.prototype.InterpolantFactoryMethodLinear=void 0,Wl.prototype.InterpolantFactoryMethodSmooth=void 0;class jl extends Bl{}jl.prototype.ValueTypeName="vector";class Xl{constructor(e="",t=-1,n=[],i=2500){this.name=e,this.tracks=n,this.duration=t,this.blendMode=i,this.uuid=ht(),this.duration<0&&this.resetDuration()}static parse(e){const t=[],n=e.tracks,i=1/(e.fps||1);for(let e=0,r=n.length;e!==r;++e)t.push(Yl(n[e]).scale(i));const r=new this(e.name,e.duration,t,e.blendMode);return r.uuid=e.uuid,r}static toJSON(e){const t=[],n=e.tracks,i={name:e.name,duration:e.duration,tracks:t,uuid:e.uuid,blendMode:e.blendMode};for(let e=0,i=n.length;e!==i;++e)t.push(Bl.toJSON(n[e]));return i}static CreateFromMorphTargetSequence(e,t,n,i){const r=t.length,a=[];for(let e=0;e1){const e=a[1];let t=i[e];t||(i[e]=t=[]),t.push(n)}}const a=[];for(const e in i)a.push(this.CreateFromMorphTargetSequence(e,i[e],t,n));return a}static parseAnimation(e,t){if(!e)return console.error("THREE.AnimationClip: No animation in JSONLoader data."),null;const n=function(e,t,n,i,r){if(0!==n.length){const a=[],s=[];Il(n,a,s,i),0!==a.length&&r.push(new e(t,a,s))}},i=[],r=e.name||"default",a=e.fps||30,s=e.blendMode;let o=e.length||-1;const l=e.hierarchy||[];for(let e=0;e{t&&t(r),this.manager.itemEnd(e)}),0),r;if(void 0!==Ql[e])return void Ql[e].push({onLoad:t,onProgress:n,onError:i});Ql[e]=[],Ql[e].push({onLoad:t,onProgress:n,onError:i});const a=new Request(e,{headers:new Headers(this.requestHeader),credentials:this.withCredentials?"include":"same-origin"}),s=this.mimeType,o=this.responseType;fetch(a).then((t=>{if(200===t.status||0===t.status){if(0===t.status&&console.warn("THREE.FileLoader: HTTP Status 0 received."),"undefined"==typeof ReadableStream||void 0===t.body||void 0===t.body.getReader)return t;const n=Ql[e],i=t.body.getReader(),r=t.headers.get("X-File-Size")||t.headers.get("Content-Length"),a=r?parseInt(r):0,s=0!==a;let o=0;const l=new ReadableStream({start(e){!function t(){i.read().then((({done:i,value:r})=>{if(i)e.close();else{o+=r.byteLength;const i=new ProgressEvent("progress",{lengthComputable:s,loaded:o,total:a});for(let e=0,t=n.length;e{e.error(t)}))}()}});return new Response(l)}throw new $l(`fetch for "${t.url}" responded with ${t.status}: ${t.statusText}`,t)})).then((e=>{switch(o){case"arraybuffer":return e.arrayBuffer();case"blob":return e.blob();case"document":return e.text().then((e=>(new DOMParser).parseFromString(e,s)));case"json":return e.json();default:if(void 0===s)return e.text();{const t=/charset="?([^;"\s]*)"?/i.exec(s),n=t&&t[1]?t[1].toLowerCase():void 0,i=new TextDecoder(n);return e.arrayBuffer().then((e=>i.decode(e)))}}})).then((t=>{ql.add(e,t);const n=Ql[e];delete Ql[e];for(let e=0,i=n.length;e{const n=Ql[e];if(void 0===n)throw this.manager.itemError(e),t;delete Ql[e];for(let e=0,i=n.length;e{this.manager.itemEnd(e)})),this.manager.itemStart(e)}setResponseType(e){return this.responseType=e,this}setMimeType(e){return this.mimeType=e,this}}class tc extends Jl{constructor(e){super(e)}load(e,t,n,i){void 0!==this.path&&(e=this.path+e),e=this.manager.resolveURL(e);const r=this,a=ql.get(e);if(void 0!==a)return r.manager.itemStart(e),setTimeout((function(){t&&t(a),r.manager.itemEnd(e)}),0),a;const s=wt("img");function o(){c(),ql.add(e,this),t&&t(this),r.manager.itemEnd(e)}function l(t){c(),i&&i(t),r.manager.itemError(e),r.manager.itemEnd(e)}function c(){s.removeEventListener("load",o,!1),s.removeEventListener("error",l,!1)}return s.addEventListener("load",o,!1),s.addEventListener("error",l,!1),"data:"!==e.slice(0,5)&&void 0!==this.crossOrigin&&(s.crossOrigin=this.crossOrigin),r.manager.itemStart(e),s.src=e,s}}class nc extends Jl{constructor(e){super(e)}load(e,t,n,i){const r=this,a=new bo,s=new ec(this.manager);return s.setResponseType("arraybuffer"),s.setRequestHeader(this.requestHeader),s.setPath(this.path),s.setWithCredentials(r.withCredentials),s.load(e,(function(e){let n;try{n=r.parse(e)}catch(e){if(void 0===i)return void console.error(e);i(e)}void 0!==n.image?a.image=n.image:void 0!==n.data&&(a.image.width=n.width,a.image.height=n.height,a.image.data=n.data),a.wrapS=void 0!==n.wrapS?n.wrapS:F,a.wrapT=void 0!==n.wrapT?n.wrapT:F,a.magFilter=void 0!==n.magFilter?n.magFilter:V,a.minFilter=void 0!==n.minFilter?n.minFilter:V,a.anisotropy=void 0!==n.anisotropy?n.anisotropy:1,void 0!==n.colorSpace&&(a.colorSpace=n.colorSpace),void 0!==n.flipY&&(a.flipY=n.flipY),void 0!==n.format&&(a.format=n.format),void 0!==n.type&&(a.type=n.type),void 0!==n.mipmaps&&(a.mipmaps=n.mipmaps,a.minFilter=W),1===n.mipmapCount&&(a.minFilter=V),void 0!==n.generateMipmaps&&(a.generateMipmaps=n.generateMipmaps),a.needsUpdate=!0,t&&t(a,n)}),n,i),a}}class ic extends Jl{constructor(e){super(e)}load(e,t,n,i){const r=new kt,a=new tc(this.manager);return a.setCrossOrigin(this.crossOrigin),a.setPath(this.path),a.load(e,(function(e){r.image=e,r.needsUpdate=!0,void 0!==t&&t(r)}),n,i),r}}class rc extends Jn{constructor(e,t=1){super(),this.isLight=!0,this.type="Light",this.color=new gi(e),this.intensity=t}dispose(){}copy(e,t){return super.copy(e,t),this.color.copy(e.color),this.intensity=e.intensity,this}toJSON(e){const t=super.toJSON(e);return t.object.color=this.color.getHex(),t.object.intensity=this.intensity,void 0!==this.groundColor&&(t.object.groundColor=this.groundColor.getHex()),void 0!==this.distance&&(t.object.distance=this.distance),void 0!==this.angle&&(t.object.angle=this.angle),void 0!==this.decay&&(t.object.decay=this.decay),void 0!==this.penumbra&&(t.object.penumbra=this.penumbra),void 0!==this.shadow&&(t.object.shadow=this.shadow.toJSON()),void 0!==this.target&&(t.object.target=this.target.uuid),t}}const ac=new Mn,sc=new Yt,oc=new Yt;class lc{constructor(e){this.camera=e,this.intensity=1,this.bias=0,this.normalBias=0,this.radius=1,this.blurSamples=8,this.mapSize=new _t(512,512),this.map=null,this.mapPass=null,this.matrix=new Mn,this.autoUpdate=!0,this.needsUpdate=!1,this._frustum=new _r,this._frameExtents=new _t(1,1),this._viewportCount=1,this._viewports=[new Ht(0,0,1,1)]}getViewportCount(){return this._viewportCount}getFrustum(){return this._frustum}updateMatrices(e){const t=this.camera,n=this.matrix;sc.setFromMatrixPosition(e.matrixWorld),t.position.copy(sc),oc.setFromMatrixPosition(e.target.matrixWorld),t.lookAt(oc),t.updateMatrixWorld(),ac.multiplyMatrices(t.projectionMatrix,t.matrixWorldInverse),this._frustum.setFromProjectionMatrix(ac),n.set(.5,0,0,.5,0,.5,0,.5,0,0,.5,.5,0,0,0,1),n.multiply(ac)}getViewport(e){return this._viewports[e]}getFrameExtents(){return this._frameExtents}dispose(){this.map&&this.map.dispose(),this.mapPass&&this.mapPass.dispose()}copy(e){return this.camera=e.camera.clone(),this.intensity=e.intensity,this.bias=e.bias,this.radius=e.radius,this.mapSize.copy(e.mapSize),this}clone(){return(new this.constructor).copy(this)}toJSON(){const e={};return 1!==this.intensity&&(e.intensity=this.intensity),0!==this.bias&&(e.bias=this.bias),0!==this.normalBias&&(e.normalBias=this.normalBias),1!==this.radius&&(e.radius=this.radius),512===this.mapSize.x&&512===this.mapSize.y||(e.mapSize=this.mapSize.toArray()),e.camera=this.camera.toJSON(!1).object,delete e.camera.matrix,e}}class cc extends lc{constructor(){super(new or(50,1,.5,500)),this.isSpotLightShadow=!0,this.focus=1}updateMatrices(e){const t=this.camera,n=2*ct*e.angle*this.focus,i=this.mapSize.width/this.mapSize.height,r=e.distance||t.far;n===t.fov&&i===t.aspect&&r===t.far||(t.fov=n,t.aspect=i,t.far=r,t.updateProjectionMatrix()),super.updateMatrices(e)}copy(e){return super.copy(e),this.focus=e.focus,this}}class hc extends rc{constructor(e,t,n=0,i=Math.PI/3,r=0,a=2){super(e,t),this.isSpotLight=!0,this.type="SpotLight",this.position.copy(Jn.DEFAULT_UP),this.updateMatrix(),this.target=new Jn,this.distance=n,this.angle=i,this.penumbra=r,this.decay=a,this.map=null,this.shadow=new cc}get power(){return this.intensity*Math.PI}set power(e){this.intensity=e/Math.PI}dispose(){this.shadow.dispose()}copy(e,t){return super.copy(e,t),this.distance=e.distance,this.angle=e.angle,this.penumbra=e.penumbra,this.decay=e.decay,this.target=e.target.clone(),this.shadow=e.shadow.clone(),this}}const dc=new Mn,uc=new Yt,pc=new Yt;class fc extends lc{constructor(){super(new or(90,1,.5,500)),this.isPointLightShadow=!0,this._frameExtents=new _t(4,2),this._viewportCount=6,this._viewports=[new Ht(2,1,1,1),new Ht(0,1,1,1),new Ht(3,1,1,1),new Ht(1,1,1,1),new Ht(3,0,1,1),new Ht(1,0,1,1)],this._cubeDirections=[new Yt(1,0,0),new Yt(-1,0,0),new Yt(0,0,1),new Yt(0,0,-1),new Yt(0,1,0),new Yt(0,-1,0)],this._cubeUps=[new Yt(0,1,0),new Yt(0,1,0),new Yt(0,1,0),new Yt(0,1,0),new Yt(0,0,1),new Yt(0,0,-1)]}updateMatrices(e,t=0){const n=this.camera,i=this.matrix,r=e.distance||n.far;r!==n.far&&(n.far=r,n.updateProjectionMatrix()),uc.setFromMatrixPosition(e.matrixWorld),n.position.copy(uc),pc.copy(n.position),pc.add(this._cubeDirections[t]),n.up.copy(this._cubeUps[t]),n.lookAt(pc),n.updateMatrixWorld(),i.makeTranslation(-uc.x,-uc.y,-uc.z),dc.multiplyMatrices(n.projectionMatrix,n.matrixWorldInverse),this._frustum.setFromProjectionMatrix(dc)}}class mc extends rc{constructor(e,t,n=0,i=2){super(e,t),this.isPointLight=!0,this.type="PointLight",this.distance=n,this.decay=i,this.shadow=new fc}get power(){return 4*this.intensity*Math.PI}set power(e){this.intensity=e/(4*Math.PI)}dispose(){this.shadow.dispose()}copy(e,t){return super.copy(e,t),this.distance=e.distance,this.decay=e.decay,this.shadow=e.shadow.clone(),this}}class gc extends lc{constructor(){super(new Ur(-5,5,5,-5,.5,500)),this.isDirectionalLightShadow=!0}}class vc extends rc{constructor(e,t){super(e,t),this.isDirectionalLight=!0,this.type="DirectionalLight",this.position.copy(Jn.DEFAULT_UP),this.updateMatrix(),this.target=new Jn,this.shadow=new gc}dispose(){this.shadow.dispose()}copy(e){return super.copy(e),this.target=e.target.clone(),this.shadow=e.shadow.clone(),this}}class _c extends rc{constructor(e,t){super(e,t),this.isAmbientLight=!0,this.type="AmbientLight"}}class xc extends rc{constructor(e,t,n=10,i=10){super(e,t),this.isRectAreaLight=!0,this.type="RectAreaLight",this.width=n,this.height=i}get power(){return this.intensity*this.width*this.height*Math.PI}set power(e){this.intensity=e/(this.width*this.height*Math.PI)}copy(e){return super.copy(e),this.width=e.width,this.height=e.height,this}toJSON(e){const t=super.toJSON(e);return t.object.width=this.width,t.object.height=this.height,t}}class yc{static decodeText(e){if(console.warn("THREE.LoaderUtils: decodeText() has been deprecated with r165 and will be removed with r175. Use TextDecoder instead."),"undefined"!=typeof TextDecoder)return(new TextDecoder).decode(e);let t="";for(let n=0,i=e.length;n{t&&t(n),r.manager.itemEnd(e)})).catch((e=>{i&&i(e)})):(setTimeout((function(){t&&t(a),r.manager.itemEnd(e)}),0),a);const s={};s.credentials="anonymous"===this.crossOrigin?"same-origin":"include",s.headers=this.requestHeader;const o=fetch(e,s).then((function(e){return e.blob()})).then((function(e){return createImageBitmap(e,Object.assign(r.options,{colorSpaceConversion:"none"}))})).then((function(n){return ql.add(e,n),t&&t(n),r.manager.itemEnd(e),n})).catch((function(t){i&&i(t),ql.remove(e),r.manager.itemError(e),r.manager.itemEnd(e)}));ql.add(e,o),r.manager.itemStart(e)}}const wc="\\[\\]\\.:\\/",bc=new RegExp("["+wc+"]","g"),Mc="[^"+wc+"]",Tc="[^"+wc.replace("\\.","")+"]",Ec=new RegExp("^"+/((?:WC+[\/:])*)/.source.replace("WC",Mc)+/(WCOD+)?/.source.replace("WCOD",Tc)+/(?:\.(WC+)(?:\[(.+)\])?)?/.source.replace("WC",Mc)+/\.(WC+)(?:\[(.+)\])?/.source.replace("WC",Mc)+"$"),Ac=["material","materials","bones","map"];class Pc{constructor(e,t,n){this.path=t,this.parsedPath=n||Pc.parseTrackName(t),this.node=Pc.findNode(e,this.parsedPath.nodeName),this.rootNode=e,this.getValue=this._getValue_unbound,this.setValue=this._setValue_unbound}static create(e,t,n){return e&&e.isAnimationObjectGroup?new Pc.Composite(e,t,n):new Pc(e,t,n)}static sanitizeNodeName(e){return e.replace(/\s/g,"_").replace(bc,"")}static parseTrackName(e){const t=Ec.exec(e);if(null===t)throw new Error("PropertyBinding: Cannot parse trackName: "+e);const n={nodeName:t[2],objectName:t[3],objectIndex:t[4],propertyName:t[5],propertyIndex:t[6]},i=n.nodeName&&n.nodeName.lastIndexOf(".");if(void 0!==i&&-1!==i){const e=n.nodeName.substring(i+1);-1!==Ac.indexOf(e)&&(n.nodeName=n.nodeName.substring(0,i),n.objectName=e)}if(null===n.propertyName||0===n.propertyName.length)throw new Error("PropertyBinding: can not parse propertyName from trackName: "+e);return n}static findNode(e,t){if(void 0===t||""===t||"."===t||-1===t||t===e.name||t===e.uuid)return e;if(e.skeleton){const n=e.skeleton.getBoneByName(t);if(void 0!==n)return n}if(e.children){const n=function(e){for(let i=0;i{var t;switch(e.type){default:break;case"ambient":const n=new _c(new gi(e.color),0);this._lightSources.push(n);break;case"rectArea":const r=new Yt(e.position.x,e.position.y,e.position.z);if(this.lightSourceScale&&r.length()this._scene.add(e)))}removeFromScene(){this._lightSources.forEach((e=>this._scene.remove(e)))}reload(){this.removeFromScene(),this.addToScene()}}zc.noLightSources=[],zc.defaultLightSources=[{type:"ambient",color:"#ffffff"},{type:"rectArea",position:{x:0,y:5,z:3},color:"#ffffff",intensity:60,castShadow:!0},{type:"rectArea",position:{x:-5,y:3,z:2},color:"#ffffff",intensity:60,castShadow:!1}],zc.fifeLightSources=[{type:"ambient",color:"#ffffff"},{type:"rectArea",position:{x:0,y:5,z:0},color:"#ffffff",intensity:40,castShadow:!0},{type:"rectArea",position:{x:5,y:5,z:5},color:"#ffffff",intensity:60,castShadow:!0},{type:"rectArea",position:{x:-5,y:5,z:5},color:"#ffffff",intensity:60,castShadow:!0},{type:"rectArea",position:{x:5,y:5,z:-5},color:"#ffffff",intensity:60,castShadow:!0},{type:"rectArea",position:{x:-5,y:5,z:-5},color:"#ffffff",intensity:60,castShadow:!0}];const kc={uniforms:{tDiffuse:{value:null},colorTransform:{value:new Mn},colorBase:{value:new Ht(0,0,0,0)},multiplyChannels:{value:0},uvTransform:{value:new xt}},vertexShader:"\n varying vec2 vUv;\n uniform mat3 uvTransform;\n \n void main() {\n vUv = (uvTransform * vec3(uv, 1.0)).xy;\n gl_Position = (projectionMatrix * modelViewMatrix * vec4(position, 1.0)).xyww;\n }",fragmentShader:"\n uniform sampler2D tDiffuse;\n uniform mat4 colorTransform;\n uniform vec4 colorBase;\n uniform float multiplyChannels;\n varying vec2 vUv;\n \n void main() {\n vec4 color = texture2D(tDiffuse, vUv);\n #if PREMULTIPLIED_ALPHA == 1\n if (color.a > 0.0) color.rgb /= color.a;\n #endif\n color = colorTransform * color + colorBase;\n color.rgb = mix(color.rgb, vec3(color.r * color.g * color.b), multiplyChannels);\n #if LINEAR_TO_SRGB == 1\n color.rgb = mix(color.rgb * 12.92, 1.055 * pow(color.rgb, vec3(0.41666)) - 0.055, step(0.0031308, color.rgb));\n #endif\n gl_FragColor = color;\n }"},Hc=new Mn,Vc=(new Mn).set(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,0),Gc=(new Mn).set(0,0,0,1,0,0,0,1,0,0,0,1,0,0,0,0),Wc=(new Mn).set(1,0,0,0,1,0,0,0,1,0,0,0,0,0,0,1),jc=((new Mn).set(0,1,0,0,0,1,0,0,0,1,0,0,0,0,0,1),(new Mn).set(0,0,1,0,0,0,1,0,0,0,1,0,0,0,0,1),(new Mn).set(1,0,0,0,1,0,0,0,1,0,0,0,0,0,0,1)),Xc=new Ht(0,0,0,0),Yc=new Ht(0,0,0,1),qc=new xt,Zc=(new xt).set(1,0,0,0,-1,1,0,0,1),Kc="additive";class Jc extends nr{constructor(e,t=Kc,n=!1,i=!1){const r=t===Kc?{blendSrc:v,blendDst:c,blendEquation:s,blendSrcAlpha:m,blendDstAlpha:c,blendEquationAlpha:s}:{};super(Object.assign({uniforms:tr.clone(kc.uniforms),vertexShader:kc.vertexShader,fragmentShader:kc.fragmentShader,defines:{LINEAR_TO_SRGB:n?1:0,PREMULTIPLIED_ALPHA:i?1:0},transparent:!0,depthTest:!1,depthWrite:!1},r)),this.update(e)}update(e){return void 0!==(null==e?void 0:e.texture)&&(this.uniforms.tDiffuse.value=null==e?void 0:e.texture),void 0!==(null==e?void 0:e.colorTransform)&&(this.uniforms.colorTransform.value=null==e?void 0:e.colorTransform),void 0!==(null==e?void 0:e.colorBase)&&(this.uniforms.colorBase.value=null==e?void 0:e.colorBase),void 0!==(null==e?void 0:e.multiplyChannels)&&(this.uniforms.multiplyChannels.value=null==e?void 0:e.multiplyChannels),void 0!==(null==e?void 0:e.uvTransform)&&(this.uniforms.uvTransform.value=null==e?void 0:e.uvTransform),void 0!==(null==e?void 0:e.blending)&&(this.blending=null==e?void 0:e.blending),void 0!==(null==e?void 0:e.blendSrc)&&(this.blendSrc=null==e?void 0:e.blendSrc),void 0!==(null==e?void 0:e.blendDst)&&(this.blendDst=null==e?void 0:e.blendDst),void 0!==(null==e?void 0:e.blendEquation)&&(this.blendEquation=null==e?void 0:e.blendEquation),void 0!==(null==e?void 0:e.blendSrcAlpha)&&(this.blendSrcAlpha=null==e?void 0:e.blendSrcAlpha),void 0!==(null==e?void 0:e.blendDstAlpha)&&(this.blendDstAlpha=null==e?void 0:e.blendDstAlpha),void 0!==(null==e?void 0:e.blendEquationAlpha)&&(this.blendEquationAlpha=null==e?void 0:e.blendEquationAlpha),this}}const Qc={uniforms:{tDiffuse:{value:null},rangeMin:{value:new _t(1/512,1/512)},rangeMax:{value:new _t(1/512,1/512)}},vertexShader:"\n varying vec2 vUv;\n void main() {\n vUv = uv;\n gl_Position = projectionMatrix * modelViewMatrix * vec4(position, 1.0);\n }",fragmentShader:"\n uniform sampler2D tDiffuse;\n uniform vec2 rangeMin;\n uniform vec2 rangeMax;\n varying vec2 vUv;\n \n void main() {\n vec4 baseColor = texture2D(tDiffuse, vUv);\n vec2 blur = mix(rangeMax, rangeMin, baseColor.a);\n vec4 sum = vec4( 0.0 );\n sum += texture2D(tDiffuse, vUv - 1.0 * blur) * 0.051;\n sum += texture2D(tDiffuse, vUv - 0.75 * blur) * 0.0918;\n sum += texture2D(tDiffuse, vUv - 0.5 * blur) * 0.12245;\n sum += texture2D(tDiffuse, vUv - 0.25 * blur) * 0.1531;\n sum += baseColor * 0.1633;\n sum += texture2D(tDiffuse, vUv + 0.25 * blur) * 0.1531;\n sum += texture2D(tDiffuse, vUv + 0.5 * blur) * 0.12245;\n sum += texture2D(tDiffuse, vUv + 0.75 * blur) * 0.0918;\n sum += texture2D(tDiffuse, vUv + 1.0 * blur) * 0.051;\n gl_FragColor = sum;\n }"};new _t(.1,.9),new _t(.1,.9);class $c extends nr{constructor(e){super({defines:Object.assign({},$c._linearDepthShader.defines),uniforms:tr.clone($c._linearDepthShader.uniforms),vertexShader:$c._linearDepthShader.vertexShader,fragmentShader:$c._linearDepthShader.fragmentShader,blending:0}),this.update(e)}update(e){if(void 0!==(null==e?void 0:e.depthTexture)&&(this.uniforms.tDepth.value=null==e?void 0:e.depthTexture),void 0!==(null==e?void 0:e.camera)){const t=(null==e?void 0:e.camera)||(null==e?void 0:e.camera);this.uniforms.cameraNear.value=t.near,this.uniforms.cameraFar.value=t.far}return void 0!==(null==e?void 0:e.depthFilter)&&(this.uniforms.depthFilter.value=null==e?void 0:e.depthFilter),this}}$c._linearDepthShader={uniforms:{tDepth:{value:null},depthFilter:{value:new Ht(1,0,0,0)},cameraNear:{value:.1},cameraFar:{value:1}},defines:{PERSPECTIVE_CAMERA:1,ALPHA_DEPTH:0},vertexShader:"varying vec2 vUv;\n void main() {\n vUv = uv;\n gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n }",fragmentShader:"uniform sampler2D tDepth;\n uniform vec4 depthFilter;\n uniform float cameraNear;\n uniform float cameraFar;\n varying vec2 vUv;\n \n #include \n \n float getLinearDepth(const in vec2 screenPosition) {\n float fragCoordZ = dot(texture2D(tDepth, screenPosition), depthFilter);\n #if PERSPECTIVE_CAMERA == 1\n float viewZ = perspectiveDepthToViewZ(fragCoordZ, cameraNear, cameraFar);\n return viewZToOrthographicDepth(viewZ, cameraNear, cameraFar);\n #else\n return fragCoordZ;\n #endif\n }\n \n void main() {\n float depth = getLinearDepth(vUv);\n gl_FragColor = vec4(vec3(1.0 - depth), 1.0);\n }"};class eh{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 th=new Ur(-1,1,1,-1,0,1),nh=new class extends Fi{constructor(){super(),this.setAttribute("position",new Ri([-1,3,0,-1,-1,0,3,-1,0],3)),this.setAttribute("uv",new Ri([0,2,0,0,2,0],2))}};class ih{constructor(e){this._mesh=new Zi(nh,e)}dispose(){this._mesh.geometry.dispose()}render(e){e.render(this._mesh,th)}get material(){return this._mesh.material}set material(e){this._mesh.material=e}}class rh{constructor(e=Math){this.grad3=[[1,1,0],[-1,1,0],[1,-1,0],[-1,-1,0],[1,0,1],[-1,0,1],[1,0,-1],[-1,0,-1],[0,1,1],[0,-1,1],[0,1,-1],[0,-1,-1]],this.grad4=[[0,1,1,1],[0,1,1,-1],[0,1,-1,1],[0,1,-1,-1],[0,-1,1,1],[0,-1,1,-1],[0,-1,-1,1],[0,-1,-1,-1],[1,0,1,1],[1,0,1,-1],[1,0,-1,1],[1,0,-1,-1],[-1,0,1,1],[-1,0,1,-1],[-1,0,-1,1],[-1,0,-1,-1],[1,1,0,1],[1,1,0,-1],[1,-1,0,1],[1,-1,0,-1],[-1,1,0,1],[-1,1,0,-1],[-1,-1,0,1],[-1,-1,0,-1],[1,1,1,0],[1,1,-1,0],[1,-1,1,0],[1,-1,-1,0],[-1,1,1,0],[-1,1,-1,0],[-1,-1,1,0],[-1,-1,-1,0]],this.p=[];for(let t=0;t<256;t++)this.p[t]=Math.floor(256*e.random());this.perm=[];for(let e=0;e<512;e++)this.perm[e]=this.p[255&e];this.simplex=[[0,1,2,3],[0,1,3,2],[0,0,0,0],[0,2,3,1],[0,0,0,0],[0,0,0,0],[0,0,0,0],[1,2,3,0],[0,2,1,3],[0,0,0,0],[0,3,1,2],[0,3,2,1],[0,0,0,0],[0,0,0,0],[0,0,0,0],[1,3,2,0],[0,0,0,0],[0,0,0,0],[0,0,0,0],[0,0,0,0],[0,0,0,0],[0,0,0,0],[0,0,0,0],[0,0,0,0],[1,2,0,3],[0,0,0,0],[1,3,0,2],[0,0,0,0],[0,0,0,0],[0,0,0,0],[2,3,0,1],[2,3,1,0],[1,0,2,3],[1,0,3,2],[0,0,0,0],[0,0,0,0],[0,0,0,0],[2,0,3,1],[0,0,0,0],[2,1,3,0],[0,0,0,0],[0,0,0,0],[0,0,0,0],[0,0,0,0],[0,0,0,0],[0,0,0,0],[0,0,0,0],[0,0,0,0],[2,0,1,3],[0,0,0,0],[0,0,0,0],[0,0,0,0],[3,0,1,2],[3,0,2,1],[0,0,0,0],[3,1,2,0],[2,1,0,3],[0,0,0,0],[0,0,0,0],[0,0,0,0],[3,1,0,2],[0,0,0,0],[3,2,0,1],[3,2,1,0]]}dot(e,t,n){return e[0]*t+e[1]*n}dot3(e,t,n,i){return e[0]*t+e[1]*n+e[2]*i}dot4(e,t,n,i,r){return e[0]*t+e[1]*n+e[2]*i+e[3]*r}noise(e,t){let n,i,r;const a=(e+t)*(.5*(Math.sqrt(3)-1)),s=Math.floor(e+a),o=Math.floor(t+a),l=(3-Math.sqrt(3))/6,c=(s+o)*l,h=e-(s-c),d=t-(o-c);let u,p;h>d?(u=1,p=0):(u=0,p=1);const f=h-u+l,m=d-p+l,g=h-1+2*l,v=d-1+2*l,_=255&s,x=255&o,y=this.perm[_+this.perm[x]]%12,S=this.perm[_+u+this.perm[x+p]]%12,w=this.perm[_+1+this.perm[x+1]]%12;let b=.5-h*h-d*d;b<0?n=0:(b*=b,n=b*b*this.dot(this.grad3[y],h,d));let M=.5-f*f-m*m;M<0?i=0:(M*=M,i=M*M*this.dot(this.grad3[S],f,m));let T=.5-g*g-v*v;return T<0?r=0:(T*=T,r=T*T*this.dot(this.grad3[w],g,v)),70*(n+i+r)}noise3d(e,t,n){let i,r,a,s;const o=(e+t+n)*(1/3),l=Math.floor(e+o),c=Math.floor(t+o),h=Math.floor(n+o),d=1/6,u=(l+c+h)*d,p=e-(l-u),f=t-(c-u),m=n-(h-u);let g,v,_,x,y,S;p>=f?f>=m?(g=1,v=0,_=0,x=1,y=1,S=0):p>=m?(g=1,v=0,_=0,x=1,y=0,S=1):(g=0,v=0,_=1,x=1,y=0,S=1):fS?32:0)+(y>w?16:0)+(S>w?8:0)+(y>b?4:0)+(S>b?2:0)+(w>b?1:0),T=a[M][0]>=3?1:0,E=a[M][1]>=3?1:0,A=a[M][2]>=3?1:0,P=a[M][3]>=3?1:0,R=a[M][0]>=2?1:0,C=a[M][1]>=2?1:0,D=a[M][2]>=2?1:0,L=a[M][3]>=2?1:0,I=a[M][0]>=1?1:0,U=a[M][1]>=1?1:0,O=a[M][2]>=1?1:0,N=a[M][3]>=1?1:0,F=y-T+l,B=S-E+l,z=w-A+l,k=b-P+l,H=y-R+2*l,V=S-C+2*l,G=w-D+2*l,W=b-L+2*l,j=y-I+3*l,X=S-U+3*l,Y=w-O+3*l,q=b-N+3*l,Z=y-1+4*l,K=S-1+4*l,J=w-1+4*l,Q=b-1+4*l,$=255&m,ee=255&g,te=255&v,ne=255&_,ie=s[$+s[ee+s[te+s[ne]]]]%32,re=s[$+T+s[ee+E+s[te+A+s[ne+P]]]]%32,ae=s[$+R+s[ee+C+s[te+D+s[ne+L]]]]%32,se=s[$+I+s[ee+U+s[te+O+s[ne+N]]]]%32,oe=s[$+1+s[ee+1+s[te+1+s[ne+1]]]]%32;let le=.6-y*y-S*S-w*w-b*b;le<0?c=0:(le*=le,c=le*le*this.dot4(r[ie],y,S,w,b));let ce=.6-F*F-B*B-z*z-k*k;ce<0?h=0:(ce*=ce,h=ce*ce*this.dot4(r[re],F,B,z,k));let he=.6-H*H-V*V-G*G-W*W;he<0?d=0:(he*=he,d=he*he*this.dot4(r[ae],H,V,G,W));let de=.6-j*j-X*X-Y*Y-q*q;de<0?u=0:(de*=de,u=de*de*this.dot4(r[se],j,X,Y,q));let ue=.6-Z*Z-K*K-J*J-Q*Q;return ue<0?p=0:(ue*=ue,p=ue*ue*this.dot4(r[oe],Z,K,J,Q)),27*(c+h+d+u+p)}}const ah=new ic,sh=e=>{const t=new Uint8Array([Math.floor(255*e.r),Math.floor(255*e.g),Math.floor(255*e.b),255]),n=new bo(t,1,1);return n.needsUpdate=!0,n},oh=(e,t,n)=>{n&&e(sh(n)),t&&ah.load(t,e)};class lh{constructor(){this.bounds=new Kt(new Yt(-1,-1,-1),new Yt(1,1,1)),this.size=new Yt(2,2,2),this.center=new Yt(0,0,0),this.maxSceneDistanceFromCenter=Math.sqrt(3),this.maxSceneDistanceFrom0=Math.sqrt(3)}copyFrom(e){this.bounds.copy(e.bounds),this.size.copy(e.size),this.center.copy(e.center),this.maxSceneDistanceFromCenter=e.maxSceneDistanceFromCenter,this.maxSceneDistanceFrom0=e.maxSceneDistanceFrom0}updateFromObject(e){e.updateMatrixWorld(),this.bounds.setFromObject(e),this.updateFromBox(this.bounds)}updateFromBox(e){this.bounds!==e&&this.bounds.copy(e),this.bounds.getSize(this.size),this.bounds.getCenter(this.center),this.maxSceneDistanceFromCenter=this.size.length()/2,this.maxSceneDistanceFrom0=new Yt(Math.max(Math.abs(this.bounds.min.x),Math.abs(this.bounds.max.x)),Math.max(Math.abs(this.bounds.min.y),Math.abs(this.bounds.max.y)),Math.max(Math.abs(this.bounds.min.z),Math.abs(this.bounds.max.z))).length()}updateCameraViewVolumeFromBounds(e){e.updateMatrixWorld();const t=this.bounds.clone().applyMatrix4(e.matrixWorldInverse);e instanceof Ur?((e,t)=>{e.left=t.min.x,e.right=t.max.x,e.bottom=t.min.y,e.top=t.max.y,e.near=Math.min(-t.min.z,-t.max.z),e.far=Math.max(-t.min.z,-t.max.z),e.updateProjectionMatrix()})(e,t):e instanceof or&&((e,t)=>{const n=Math.min(-t.min.z,-t.max.z),i=Math.max(-t.min.z,-t.max.z);if(n<.001)return;const r=Math.max(Math.abs(t.min.x),Math.abs(t.max.x)),a=Math.max(Math.abs(t.min.y),Math.abs(t.max.y));e.aspect=r/a,e.fov=vt(2*Math.atan2(a,n)),e.near=n,e.far=i,e.updateProjectionMatrix()})(e,t)}getNearAndFarForPerspectiveCamera(e,t=1){const n=e.clone().sub(this.center).length();return[Math.max(.01,n-this.maxSceneDistanceFromCenter-.01),n+this.maxSceneDistanceFromCenter*t+.01]}}const ch=e=>e.capabilities.maxSamples;class hh{changed(e){var t,n;const i=!(null===(t=this._lastCameraProjection)||void 0===t?void 0:t.equals(e.projectionMatrix))||!(null===(n=this._lastCameraWorld)||void 0===n?void 0:n.equals(e.matrixWorld));return this._lastCameraProjection=e.projectionMatrix.clone(),this._lastCameraWorld=e.matrixWorld.clone(),i}}class dh{constructor(){this._originalClearColor=new gi,this._originalClearAlpha=0,this._originalAutoClear=!1,this._originalRenderTarget=null,this._screenSpaceQuad=new ih(void 0),this._emptyScene=new oo,this._defaultCamera=new or}renderWithOverrideMaterial(e,t,n,i,r,a,s){this._backup(e),this._prepareRenderer(e,r,a,s);const o=t.overrideMaterial;t.overrideMaterial=i,e.render(t,n),t.overrideMaterial=o,this._restore(e)}clear(e,t,n,i){this._backup(e),this._prepareRenderer(e,t,n,i),e.render(this._emptyScene,this._defaultCamera),this._restore(e)}render(e,t,n,i,r,a){this._backup(e),this._prepareRenderer(e,i,r,a),e.render(t,n),this._restore(e)}renderScreenSpace(e,t,n,i,r){this._backup(e),this._prepareRenderer(e,n,i,r),this._screenSpaceQuad.material=t,this._screenSpaceQuad.render(e),this._restore(e)}_prepareRenderer(e,t,n,i){e.setRenderTarget(t),e.autoClear=!1,null!=n&&(e.setClearColor(n),e.setClearAlpha(i||0),e.clear())}_backup(e){e.getClearColor(this._originalClearColor),this._originalClearAlpha=e.getClearAlpha(),this._originalAutoClear=e.autoClear,this._originalRenderTarget=e.getRenderTarget()}_restore(e){e.setClearColor(this._originalClearColor),e.setClearAlpha(this._originalClearAlpha),e.setRenderTarget(this._originalRenderTarget),e.autoClear=this._originalAutoClear}}class uh{constructor(e,t){var n;this._passRenderer=null!==(n=null==t?void 0:t.passRenderer)&&void 0!==n?n:new dh,this._blurMaterial=new nr(null!=e?e:Qc),this._blurMaterial.depthTest=!1}dispose(){this._blurMaterial.dispose()}render(e,t,n,i){this._blurMaterial.uniforms.tDiffuse.value=t[0].texture,this._blurMaterial.uniforms.rangeMin.value.x=n[0],this._blurMaterial.uniforms.rangeMin.value.y=0,this._blurMaterial.uniforms.rangeMax.value.x=i[0],this._blurMaterial.uniforms.rangeMax.value.y=0,this._passRenderer.renderScreenSpace(e,this._blurMaterial,t[1]),this._blurMaterial.uniforms.tDiffuse.value=t[1].texture,this._blurMaterial.uniforms.rangeMin.value.x=0,this._blurMaterial.uniforms.rangeMin.value.y=n[1],this._blurMaterial.uniforms.rangeMax.value.x=0,this._blurMaterial.uniforms.rangeMax.value.y=i[1],this._passRenderer.renderScreenSpace(e,this._blurMaterial,t[2])}}const ph=e.p+"9ba94fd0181997dfa7e8.png",fh="OnlyShadow",mh="Transparent",gh="Parquet",vh="Pavement",_h={},xh=e=>{let t=_h[e];if(!t){switch(e){default:t=new Tl;break;case fh:t=new Ml,t.opacity=.5;break;case mh:t=new Tl,t.transparent=!0,t.opacity=0;break;case"White":t=new Tl;break;case gh:{const e=new El;oh((t=>{yh(t),e.map=t}),"TexturesCom_Wood_ParquetChevron7_1K_albedo.jpg",new gi(1,.6,.2)),oh((t=>{yh(t),e.normalMap=t}),"TexturesCom_Wood_ParquetChevron7_1K_normal.jpg"),oh((t=>{yh(t),e.roughnessMap=t}),"TexturesCom_Wood_ParquetChevron7_1K_roughness.jpg"),e.aoMapIntensity=0,e.roughness=1,e.metalness=0,e.envMapIntensity=.5,t=e;break}case vh:{const e=new El;oh((t=>{yh(t),e.map=t}),"TexturesCom_Pavement_HerringboneNew_1K_albedo.jpg",new gi(.6,.3,0)),oh((t=>{yh(t),e.normalMap=t}),"TexturesCom_Pavement_HerringboneNew_1K_normal.jpg"),oh((t=>{yh(t),e.roughnessMap=t}),"TexturesCom_Pavement_HerringboneNew_1K_roughness.jpg"),oh((t=>{yh(t),e.aoMap=t}),"TexturesCom_Pavement_HerringboneNew_1K_ao.jpg"),e.aoMapIntensity=1,e.roughness=1,e.metalness=0,e.envMapIntensity=.5,t=e;break}}_h[e]=t}return t},yh=e=>{e.anisotropy=16,e.wrapS=N,e.wrapT=N,e.repeat.set(1e5,1e5)},Sh=e=>{const t=Math.atan2(e.y,e.x)/(2*Math.PI)+.5,n=Math.asin(e.z)/Math.PI+.5;return new _t(t,n)};class wh{get colorRenderTarget(){var e;return this._colorRenderTarget=null!==(e=this._colorRenderTarget)&&void 0!==e?e:new Gt,this._colorRenderTarget}environmentMapDecodeTarget(e){var t;const n=e.capabilities.isWebGL2?Z:j;return this._environmentMapDecodeTarget=null!==(t=this._environmentMapDecodeTarget)&&void 0!==t?t:new Gt(1,1,{type:n}),this._environmentMapDecodeTarget}environmentMapDecodeMaterial(e){var t,n;return e?(this._equirectangularDecodeMaterial=null!==(t=this._equirectangularDecodeMaterial)&&void 0!==t?t:new Eh(!0,!1),this._equirectangularDecodeMaterial):(this._pmremDecodeMaterial=null!==(n=this._pmremDecodeMaterial)&&void 0!==n?n:new Eh(!1,!1),this._pmremDecodeMaterial)}get camera(){var e;return this._camera=null!==(e=this._camera)&&void 0!==e?e:new Ur(-1,1,1,-1,-1,1),this._camera}scaleTexture(e,t,n,i){var r;this.colorRenderTarget.setSize(n,i),this._planeMesh=null!==(r=this._planeMesh)&&void 0!==r?r:new Zi(new Sr(2,2),new yi({map:t}));const a=e.getRenderTarget();e.setRenderTarget(this.colorRenderTarget),e.render(this._planeMesh,this.camera),e.setRenderTarget(a);const s=this.environmentMapDecodeTarget(e).texture,o=new Uint8Array(n*i*4);return e.readRenderTargetPixels(this.colorRenderTarget,0,0,n,i,o),{texture:s,pixels:o,sRgbaPixels:!1}}newGrayscaleTexture(e,t,n,i){var r;const a=this.environmentMapDecodeMaterial("PMREM.cubeUv"===t.name),s=this.environmentMapDecodeTarget(e);s.setSize(n,i),a.setSourceTexture(t),this._planeMesh=null!==(r=this._planeMesh)&&void 0!==r?r:new Zi(new Sr(2,2),a);const o=e.getRenderTarget();e.setRenderTarget(s),e.render(this._planeMesh,this.camera),e.setRenderTarget(o);const l=s.texture,c=s.texture.type===Z,h=c?new Float32Array(n*i*4):new Uint8Array(n*i*4);return e.readRenderTargetPixels(s,0,0,n,i,h),{texture:l,pixels:h,sRgbaPixels:c}}}const bh={tDiffuse:{value:null}},Mh="\n varying vec2 vUv;\n void main() {\n vUv = uv;\n gl_Position = (projectionMatrix * modelViewMatrix * vec4(position, 1.0)).xyww;\n }",Th="\n uniform sampler2D tDiffuse;\n varying vec2 vUv;\n \n float getFace( vec3 direction ) {\n vec3 absDirection = abs( direction );\n float face = - 1.0;\n if ( absDirection.x > absDirection.z ) {\n if ( absDirection.x > absDirection.y )\n face = direction.x > 0.0 ? 0.0 : 3.0;\n else\n face = direction.y > 0.0 ? 1.0 : 4.0;\n } else {\n if ( absDirection.z > absDirection.y )\n face = direction.z > 0.0 ? 2.0 : 5.0;\n else\n face = direction.y > 0.0 ? 1.0 : 4.0;\n }\n return face;\n }\n\n vec2 getUV( vec3 direction, float face ) {\n vec2 uv;\n if ( face == 0.0 ) {\n uv = vec2( direction.z, direction.y ) / abs( direction.x ); // pos x\n } else if ( face == 1.0 ) {\n uv = vec2( - direction.x, - direction.z ) / abs( direction.y ); // pos y\n } else if ( face == 2.0 ) {\n uv = vec2( - direction.x, direction.y ) / abs( direction.z ); // pos z\n } else if ( face == 3.0 ) {\n uv = vec2( - direction.z, direction.y ) / abs( direction.x ); // neg x\n } else if ( face == 4.0 ) {\n uv = vec2( - direction.x, direction.z ) / abs( direction.y ); // neg y\n } else {\n uv = vec2( direction.x, direction.y ) / abs( direction.z ); // neg z\n }\n return 0.5 * ( uv + 1.0 );\n }\n\n void main() {\n #if PMREM_DECODE == 1\n float altitude = (vUv.y - 0.5) * 3.141593;\n float azimuth = vUv.x * 2.0 * 3.141593;\n vec3 direction = vec3(\n cos(altitude) * cos(azimuth) * -1.0, \n sin(altitude), \n cos(altitude) * sin(azimuth) * -1.0\n );\n float face = getFace(direction);\n vec2 uv = getUV(direction, face) / vec2(3.0, 4.0);\n if (face > 2.5) {\n uv.y += 0.25;\n face -= 3.0;\n }\n uv.x += face / 3.0;\n vec4 color = texture2D(tDiffuse, uv);\n #else\n vec4 color = texture2D(tDiffuse, vUv);\n #endif \n #if GRAYSCALE_CONVERT == 1\n float grayscale = dot(color.rgb, vec3(0.2126, 0.7152, 0.0722));\n //float grayscale = dot(color.rgb, vec3(1.0/3.0));\n gl_FragColor = vec4(vec3(grayscale), 1.0);\n #else\n gl_FragColor = vec4(color.rgb, 1.0);\n #endif\n }";class Eh extends nr{constructor(e,t){super({uniforms:tr.clone(bh),vertexShader:Mh,fragmentShader:Th,defines:{PMREM_DECODE:e?1:0,GRAYSCALE_CONVERT:t?1:0}})}setSourceTexture(e){this.uniforms.tDiffuse.value=e}}class Ah{constructor(e){var t,n,i,r;this.samplePoints=[],this.sampleUVs=[],this.grayscaleTexture={texture:new kt,pixels:new Uint8Array(0),sRgbaPixels:!1},this.detectorTexture=new kt,this.detectorArray=new Float32Array(0),this.lightSamples=[],this.lightGraph=new Rh(0),this.lightSources=[],this._grayScale=new Yt(.2126,.7152,.0722),this._createEquirectangularSamplePoints=e=>{const t=[];for(let n=0;nSh(e)))}detectLightSources(e,t,n){var i;this.textureData=n,this._textureConverter=null!==(i=this._textureConverter)&&void 0!==i?i:new wh,this.grayscaleTexture=this._textureConverter.newGrayscaleTexture(e,t,this._width,this._height),this.detectorArray=this._redFromRgbaToNormalizedFloatArray(this.grayscaleTexture.pixels,this.grayscaleTexture.sRgbaPixels),this.detectorTexture=this._grayscaleTextureFromFloatArray(this.detectorArray,this._width,this._height),this.lightSamples=this._filterLightSamples(this._sampleThreshold),this.lightGraph=this._findClusterSegments(this.lightSamples,this._sampleThreshold),this.lightGraph.findConnectedComponents(),this.lightSources=this.createLightSourcesFromLightGraph(this.lightSamples,this.lightGraph),this.lightSources.sort(((e,t)=>t.maxIntensity-e.maxIntensity))}_redFromRgbaToNormalizedFloatArray(e,t,n){const i=new Float32Array(e.length/4);let r=1,a=0;for(let t=0;te&&t.push(new Ph(this.samplePoints[n],i))}return t}_detectorTextureLuminanceValueFromUV(e){const t=Math.floor(e.x*this._width),n=Math.floor(e.y*this._height)*this._width+t;return this.detectorArray[n]}_originalLuminanceValueFromUV(e){if(!(this.textureData&&this.textureData.data&&this.textureData._width&&this.textureData._height))return 256*this._detectorTextureLuminanceValueFromUV(e);const t=Math.floor(e.x*this.textureData._width),n=Math.floor(e.y*this.textureData._height);let i=0;for(let e=Math.max(0,t-2);e1){l=!1;break}}else c=0}l&&(r.adjacent[a].push(s),r.adjacent[s].push(a),r.edges.push([a,s]))}return r}createLightSourcesFromLightGraph(e,t){const n=t.components.filter((e=>e.length>1)).map((t=>new Ch(t.map((t=>e[t])))));return n.forEach((e=>e.calculateLightSourceProperties((e=>this._originalLuminanceValueFromUV(e))))),n}}class Ph{constructor(e,t){this.position=e,this.uv=t}}class Rh{constructor(e){this.edges=[],this.adjacent=[],this.components=[],this.noOfNodes=e;for(let t=0;tt.length-e.length))}_dfs(e,t,n){t[e]=!0,n.push(e);for(const i of this.adjacent[e])t[i]||this._dfs(i,t,n)}}class Ch{constructor(e){this.position=new Yt,this.uv=new _t,this.averageIntensity=0,this.maxIntensity=0,this.size=0,this.lightSamples=e}calculateLightSourceProperties(e){this.position=new Yt,this.averageIntensity=0,this.maxIntensity=0;for(const t of this.lightSamples){this.position.add(t.position);const n=e(t.uv);this.averageIntensity+=n,this.maxIntensity=Math.max(this.maxIntensity,n)}this.averageIntensity/=this.lightSamples.length,this.position.normalize(),this.uv=Sh(this.position);let t=0;for(const e of this.lightSamples)t+=e.position.distanceTo(this.position);t/=this.lightSamples.length,this.size=t/Math.PI}}class Dh{constructor(e){this._lightSourceDetector=e}static createPlane(e,t){const n=new Sr(2,1),i=null!=t?t:new yi({color:12632256,side:2}),r=new Zi(n,i);return r.position.z=-.1,e.add(r),r}createDebugScene(e,t){this._scene=e,this._createLightGraphInMap(this._lightSourceDetector.sampleUVs,this._lightSourceDetector.lightSamples,this._lightSourceDetector.lightGraph,t)}_createLightGraphInMap(e,t,n,i){const r=[],a=[];for(let e=0;ee.uv)),o=a.map((e=>e.uv)),l=e.filter((e=>!s.includes(e)&&!o.includes(e)));this._createSamplePointsInMap(l,.005,16711680),this._createSamplePointsInMap(s,.01,255),this._createSamplePointsInMap(o,.01,65280),this._createClusterLinesInMap(this._lightSourceDetector.lightSamples,this._lightSourceDetector.lightGraph.edges,128);const c=this._lightSourceDetector.lightSources.map((e=>e.uv));this._createSamplePointsInMap(c,.015,16776960);let h=this._lightSourceDetector.lightSources;void 0!==i&&i>=0&&i{var t;const n=new Zi(i,r);n.position.copy(this._uvToMapPosition(e)),n.name="samplePoint",null===(t=this._scene)||void 0===t||t.add(n)}))}_createCirclesInMap(e,t){const n=new yi({color:t,transparent:!0,opacity:.5});e.forEach((e=>{var t;const i=new gl(e.size,8,4),r=new Zi(i,n);r.position.copy(this._uvToMapPosition(e.uv)),r.name="samplePoint",null===(t=this._scene)||void 0===t||t.add(r)}))}_createClusterLinesInMap(e,t,n){var i;const r=new No({color:n}),a=[];t.forEach((t=>{for(let n=1;n.5){const e=(i.y+r.y)/2,t=i.x{(new ec).setResponseType("arraybuffer").load(this._path+e,(e=>{this.parseData_(e),t(this._cubeTexture)}))}))}parseHeader_(e){const t=new DataView(e,0,30);this._size=t.getUint16(0),this._maxLod=t.getUint8(2),this._colorSpace=t.getUint16(3)?We:Ge,this._type=t.getUint16(5),this._format=t.getUint16(7),this._lightDirection.x=t.getFloat32(9),this._lightDirection.y=t.getFloat32(13),this._lightDirection.z=t.getFloat32(17)}parseBufferData_(e,t){let n=this._size;const i=Math.log2(this._size)+1;this._cubeTextures=[];for(let r=0;r{t.isMesh&&(e.add(t.geometry),e.add(t.material))}));for(const t of e)t.dispose()}}function zh(e){const t=new yi;return t.color.setScalar(e),t}var kh=Uint8Array,Hh=Uint16Array,Vh=Int32Array,Gh=new kh([0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0,0,0,0]),Wh=new kh([0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13,0,0]),jh=new kh([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),Xh=function(e,t){for(var n=new Hh(31),i=0;i<31;++i)n[i]=t+=1<>1|(21845&$h)<<1;ed=(61680&(ed=(52428&ed)>>2|(13107&ed)<<2))>>4|(3855&ed)<<4,Qh[$h]=((65280&ed)>>8|(255&ed)<<8)>>1}var td=function(e,t,n){for(var i=e.length,r=0,a=new Hh(t);r>l]=c}else for(s=new Hh(i),r=0;r>15-e[r]);return s},nd=new kh(288);for($h=0;$h<144;++$h)nd[$h]=8;for($h=144;$h<256;++$h)nd[$h]=9;for($h=256;$h<280;++$h)nd[$h]=7;for($h=280;$h<288;++$h)nd[$h]=8;var id=new kh(32);for($h=0;$h<32;++$h)id[$h]=5;var rd=td(nd,9,1),ad=td(id,5,1),sd=function(e){for(var t=e[0],n=1;nt&&(t=e[n]);return t},od=function(e,t,n){var i=t/8|0;return(e[i]|e[i+1]<<8)>>(7&t)&n},ld=function(e,t){var n=t/8|0;return(e[n]|e[n+1]<<8|e[n+2]<<16)>>(7&t)},cd=["unexpected EOF","invalid block type","invalid length/literal","invalid distance","stream finished","no stream handler",,"no callback","invalid UTF-8 data","extra field too long","date not in range 1980-2099","filename too long","stream finishing","invalid zip data"],hd=function(e,t,n){var i=new Error(t||cd[e]);if(i.code=e,Error.captureStackTrace&&Error.captureStackTrace(i,hd),!n)throw i;return i},dd=function(e,t,n,i){var r=e.length,a=i?i.length:0;if(!r||t.f&&!t.l)return n||new kh(0);var s=!n,o=s||2!=t.i,l=t.i;s&&(n=new kh(3*r));var c,h=function(e){var t=n.length;if(e>t){var i=new kh(Math.max(2*t,e));i.set(n),n=i}},d=t.f||0,u=t.p||0,p=t.b||0,f=t.l,m=t.d,g=t.m,v=t.n,_=8*r;do{if(!f){d=od(e,u,1);var x=od(e,u+1,3);if(u+=3,!x){var y=e[(c=u,(D=4+((c+7)/8|0))-4)]|e[D-3]<<8,S=D+y;if(S>r){l&&hd(0);break}o&&h(p+y),n.set(e.subarray(D,S),p),t.b=p+=y,t.p=u=8*S,t.f=d;continue}if(1==x)f=rd,m=ad,g=9,v=5;else if(2==x){var w=od(e,u,31)+257,b=od(e,u+10,15)+4,M=w+od(e,u+5,31)+1;u+=14;for(var T=new kh(M),E=new kh(19),A=0;A>4)<16)T[A++]=D;else{var I=0,U=0;for(16==D?(U=3+od(e,u,3),u+=2,I=T[A-1]):17==D?(U=3+od(e,u,7),u+=3):18==D&&(U=11+od(e,u,127),u+=7);U--;)T[A++]=I}}var O=T.subarray(0,w),N=T.subarray(w);g=sd(O),v=sd(N),f=td(O,g,1),m=td(N,v,1)}else hd(1);if(u>_){l&&hd(0);break}}o&&h(p+131072);for(var F=(1<>4;if((u+=15&I)>_){l&&hd(0);break}if(I||hd(2),k<256)n[p++]=k;else{if(256==k){z=u,f=null;break}var H=k-254;if(k>264){var V=Gh[A=k-257];H=od(e,u,(1<>4;if(G||hd(3),u+=15&G,N=Jh[W],W>3&&(V=Wh[W],N+=ld(e,u)&(1<_){l&&hd(0);break}o&&h(p+131072);var j=p+H;if(pe.length)&&(n=e.length),new kh(e.subarray(t,n))}(n,0,p):n.subarray(0,p)},ud=new kh(0);function pd(e,t){return dd(e.subarray((n=e,i=t&&t.dictionary,(8!=(15&n[0])||n[0]>>4>7||(n[0]<<8|n[1])%31)&&hd(6,"invalid zlib data"),(n[1]>>5&1)==+!i&&hd(6,"invalid zlib data: "+(32&n[1]?"need":"unexpected")+" dictionary"),2+(n[1]>>3&4)),-4),{i:2},t&&t.out,t&&t.dictionary);var n,i}var fd="undefined"!=typeof TextDecoder&&new TextDecoder;try{fd.decode(ud,{stream:!0})}catch(e){}"function"==typeof queueMicrotask?queueMicrotask:"function"==typeof setTimeout&&setTimeout;class md extends nc{constructor(e){super(e),this.type=K}parse(e){const t=65536,n=14,i=65537,r=Math.pow(2.7182818,2.2),a={l:0,c:0,lc:0};function s(e,t,n,i,r){for(;n>n&(1<>6}const h={c:0,lc:0};function d(e,t,n,i){e=e<<8|F(n,i),t+=8,h.c=e,h.lc=t}const u={c:0,lc:0};function p(e,t,n,i,r,a,s,o,l){if(e==t){i<8&&(d(n,i,r,a),n=h.c,i=h.lc);let e=n>>(i-=8);if(e=new Uint8Array([e])[0],o.value+e>l)return!1;const t=s[o.value-1];for(;e-- >0;)s[o.value++]=t}else{if(!(o.value32767?t-65536:t}const g={a:0,b:0};function v(e,t){const n=m(e),i=m(t),r=n+(1&i)+(i>>1),a=r,s=r-i;g.a=a,g.b=s}function _(e,t){const n=f(e),i=f(t),r=n-(i>>1)&65535,a=i+r-32768&65535;g.a=a,g.b=r}function x(e,t,n,i,r,a,s){const o=s<16384,l=n>r?r:n;let c,h,d=1;for(;d<=l;)d<<=1;for(d>>=1,c=d,d>>=1;d>=1;){h=0;const s=h+a*(r-c),l=a*d,u=a*c,p=i*d,f=i*c;let m,x,y,S;for(;h<=s;h+=u){let r=h;const a=h+i*(n-c);for(;r<=a;r+=f){const n=r+p,i=r+l,a=i+p;o?(v(e[r+t],e[i+t]),m=g.a,y=g.b,v(e[n+t],e[a+t]),x=g.a,S=g.b,v(m,x),e[r+t]=g.a,e[n+t]=g.b,v(y,S),e[i+t]=g.a,e[a+t]=g.b):(_(e[r+t],e[i+t]),m=g.a,y=g.b,_(e[n+t],e[a+t]),x=g.a,S=g.b,_(m,x),e[r+t]=g.a,e[n+t]=g.b,_(y,S),e[i+t]=g.a,e[a+t]=g.b)}if(n&d){const n=r+l;o?v(e[r+t],e[n+t]):_(e[r+t],e[n+t]),m=g.a,e[n+t]=g.b,e[r+t]=m}}if(r&d){let r=h;const a=h+i*(n-c);for(;r<=a;r+=f){const n=r+p;o?v(e[r+t],e[n+t]):_(e[r+t],e[n+t]),m=g.a,e[n+t]=g.b,e[r+t]=m}}c=d,d>>=1}return h}function y(e,t,r,f,m,g){const v=r.value,_=N(t,r),x=N(t,r);r.value+=4;const y=N(t,r);if(r.value+=4,_<0||_>=i||x<0||x>=i)throw new Error("Something wrong with HUF_ENCSIZE");const S=new Array(i),w=new Array(16384);if(function(e){for(let t=0;t<16384;t++)e[t]={},e[t].len=0,e[t].lit=0,e[t].p=null}(w),function(e,t,n,r,l,c){const h=t;let d=0,u=0;for(;r<=l;r++){if(h.value-t.value>n)return!1;s(6,d,u,e,h);const i=a.l;if(d=a.c,u=a.lc,c[r]=i,63==i){if(h.value-t.value>n)throw new Error("Something wrong with hufUnpackEncTable");s(8,d,u,e,h);let i=a.l+6;if(d=a.c,u=a.lc,r+i>l+1)throw new Error("Something wrong with hufUnpackEncTable");for(;i--;)c[r++]=0;r--}else if(i>=59){let e=i-59+2;if(r+e>l+1)throw new Error("Something wrong with hufUnpackEncTable");for(;e--;)c[r++]=0;r--}}!function(e){for(let e=0;e<=58;++e)o[e]=0;for(let t=0;t0;--e){const n=t+o[e]>>1;o[e]=t,t=n}for(let t=0;t0&&(e[t]=n|o[n]++<<6)}}(c)}(e,r,f-(r.value-v),_,x,S),y>8*(f-(r.value-v)))throw new Error("Something wrong with hufUncompress");!function(e,t,i,r){for(;t<=i;t++){const i=c(e[t]),a=l(e[t]);if(i>>a)throw new Error("Invalid table entry");if(a>n){const e=r[i>>a-n];if(e.len)throw new Error("Invalid table entry");if(e.lit++,e.p){const t=e.p;e.p=new Array(e.lit);for(let n=0;n0;s--){const s=r[(i<=n;){const a=t[g>>v-n&16383];if(a.len)v-=a.len,p(a.lit,s,g,v,i,r,f,m,_),g=u.c,v=u.lc;else{if(!a.p)throw new Error("hufDecode issues");let t;for(t=0;t=n&&c(e[a.p[t]])==(g>>v-n&(1<>=y,v-=y;v>0;){const e=t[g<a||(t[r++]=e[n++],r>a));)t[r++]=e[i++]}function b(e){let t=e.byteLength;const n=new Array;let i=0;const r=new DataView(e);for(;t>0;){const e=r.getInt8(i++);if(e<0){const a=-e;t-=a+1;for(let e=0;e>8==255?r+=255&i:(n[r]=i,r++),e.value++}function T(e){const t=.5*Math.cos(.7853975),n=.5*Math.cos(3.14159/16),i=.5*Math.cos(3.14159/8),r=.5*Math.cos(3*3.14159/16),a=.5*Math.cos(.981746875),s=.5*Math.cos(3*3.14159/8),o=.5*Math.cos(1.374445625),l=new Array(4),c=new Array(4),h=new Array(4),d=new Array(4);for(let u=0;u<8;++u){const p=8*u;l[0]=i*e[p+2],l[1]=s*e[p+2],l[2]=i*e[p+6],l[3]=s*e[p+6],c[0]=n*e[p+1]+r*e[p+3]+a*e[p+5]+o*e[p+7],c[1]=r*e[p+1]-o*e[p+3]-n*e[p+5]-a*e[p+7],c[2]=a*e[p+1]-n*e[p+3]+o*e[p+5]+r*e[p+7],c[3]=o*e[p+1]-a*e[p+3]+r*e[p+5]-n*e[p+7],h[0]=t*(e[p+0]+e[p+4]),h[3]=t*(e[p+0]-e[p+4]),h[1]=l[0]+l[3],h[2]=l[1]-l[2],d[0]=h[0]+h[1],d[1]=h[3]+h[2],d[2]=h[3]-h[2],d[3]=h[0]-h[1],e[p+0]=d[0]+c[0],e[p+1]=d[1]+c[1],e[p+2]=d[2]+c[2],e[p+3]=d[3]+c[3],e[p+4]=d[3]-c[3],e[p+5]=d[2]-c[2],e[p+6]=d[1]-c[1],e[p+7]=d[0]-c[0]}for(let u=0;u<8;++u)l[0]=i*e[16+u],l[1]=s*e[16+u],l[2]=i*e[48+u],l[3]=s*e[48+u],c[0]=n*e[8+u]+r*e[24+u]+a*e[40+u]+o*e[56+u],c[1]=r*e[8+u]-o*e[24+u]-n*e[40+u]-a*e[56+u],c[2]=a*e[8+u]-n*e[24+u]+o*e[40+u]+r*e[56+u],c[3]=o*e[8+u]-a*e[24+u]+r*e[40+u]-n*e[56+u],h[0]=t*(e[u]+e[32+u]),h[3]=t*(e[u]-e[32+u]),h[1]=l[0]+l[3],h[2]=l[1]-l[2],d[0]=h[0]+h[1],d[1]=h[3]+h[2],d[2]=h[3]-h[2],d[3]=h[0]-h[1],e[0+u]=d[0]+c[0],e[8+u]=d[1]+c[1],e[16+u]=d[2]+c[2],e[24+u]=d[3]+c[3],e[32+u]=d[3]-c[3],e[40+u]=d[2]-c[2],e[48+u]=d[1]-c[1],e[56+u]=d[0]-c[0]}function E(e){for(let t=0;t<64;++t){const n=e[0][t],i=e[1][t],r=e[2][t];e[0][t]=n+1.5747*r,e[1][t]=n-.1873*i-.4682*r,e[2][t]=n+1.8556*i}}function A(e,t,n){for(let a=0;a<64;++a)t[n+a]=bi.toHalfFloat((i=e[a])<=1?Math.sign(i)*Math.pow(Math.abs(i),2.2):Math.sign(i)*Math.pow(r,Math.abs(i)-1));var i}function P(e){return new DataView(e.array.buffer,e.offset.value,e.size)}function R(e){const t=e.viewer.buffer.slice(e.offset.value,e.offset.value+e.size),n=new Uint8Array(b(t)),i=new Uint8Array(n.length);return S(n),w(n,i),new DataView(i.buffer)}function C(e){const t=pd(e.array.slice(e.offset.value,e.offset.value+e.size)),n=new Uint8Array(t.length);return S(t),w(t,n),new DataView(n.buffer)}function D(e){const n=e.viewer,i={value:e.offset.value},r=new Uint16Array(e.columns*e.lines*(e.inputChannels.length*e.type)),a=new Uint8Array(8192);let s=0;const o=new Array(e.inputChannels.length);for(let t=0,n=e.inputChannels.length;t=8192)throw new Error("Something is wrong with PIZ_COMPRESSION BITMAP_SIZE");if(l<=c)for(let e=0;e>3]&1<<(7&r))&&(n[i++]=r);const r=i-1;for(;i0;){const e=U(t.buffer,n),i=B(t,n),r=i>>2&3,o=new Int8Array([(i>>4)-1])[0],l=B(t,n);a.push({name:e,index:o,type:l,compression:r}),s-=e.length+3}const o=te.channels,l=new Array(e.inputChannels.length);for(let t=0;t=0&&(c.idx[i.index]=t),e.offset=t)}}let h,d,u;if(r.acCompressedSize>0)switch(r.acCompression){case 0:h=new Uint16Array(r.totalAcUncompressedCount),y(e.array,t,n,r.acCompressedSize,h,r.totalAcUncompressedCount);break;case 1:const i=pd(e.array.slice(n.value,n.value+r.totalAcUncompressedCount));h=new Uint16Array(i.buffer),n.value+=r.totalAcUncompressedCount}if(r.dcCompressedSize>0){const t={array:e.array,offset:n,size:r.dcCompressedSize};d=new Uint16Array(C(t).buffer),n.value+=r.dcCompressedSize}r.rleRawSize>0&&(u=b(pd(e.array.slice(n.value,n.value+r.rleCompressedSize)).buffer),n.value+=r.rleCompressedSize);let p=0;const f=new Array(l.length);for(let e=0;e>10,n=1023&e;return(e>>15?-1:1)*(t?31===t?n?NaN:1/0:Math.pow(2,t-15)*(1+n/1024):n/1024*6103515625e-14)}function G(e,t){const n=e.getUint16(t.value,!0);return t.value+=2,n}function W(e,t){return V(G(e,t))}function j(e,t,n,i,r){return"string"===i||"stringvector"===i||"iccProfile"===i?function(e,t,n){const i=(new TextDecoder).decode(new Uint8Array(e).slice(t.value,t.value+n));return t.value=t.value+n,i}(t,n,r):"chlist"===i?function(e,t,n,i){const r=n.value,a=[];for(;n.value>4]}}(e,n):"lineOrder"===i?function(e,t){return["INCREASING_Y","DECREASING_Y","RANDOM_Y"][B(e,t)]}(e,n):"float"===i?k(e,n):"v2f"===i?function(e,t){return[k(e,t),k(e,t)]}(e,n):"v3f"===i?function(e,t){return[k(e,t),k(e,t),k(e,t)]}(e,n):"int"===i?O(e,n):"rational"===i?function(e,t){return[O(e,t),N(e,t)]}(e,n):"timecode"===i?function(e,t){return[N(e,t),N(e,t)]}(e,n):"preview"===i?(n.value+=r,"skipped"):void(n.value+=r)}function X(e,t,n,i){const r=new Array(e);for(let a=0;ae.width?e.width-a:e.blockWidth,e.lines=s+e.blockHeight>e.height?e.height-s:e.blockHeight;const o=e.columns*e.totalBytes,l=e.sizee.height?e.height-r:e.blockHeight;const a=e.columns*e.totalBytes,s=e.size=e.height)continue;const l=t*a,c=(e.height-1-o)*e.outLineWidth;for(let t=0;te:a.scanOrder=e=>a.height-1-e,4==a.outputChannels?(a.format=ee,a.colorSpace=We):(a.format=ie,a.colorSpace=Ve),e.spec.singleTile){a.blockHeight=e.tiles.ySize,a.blockWidth=e.tiles.xSize;const n=function(e,t,n){let i=0;switch(e.levelMode){case"ONE_LEVEL":i=1;break;case"MIPMAP_LEVELS":i=function(e,t){const n=Math.log2(e);return"ROUND_DOWN"==t?Math.floor(n):Math.ceil(n)}(Math.max(t,n),e.roundingMode)+1;break;case"RIPMAP_LEVELS":throw new Error("THREE.EXRLoader: RIPMAP_LEVELS tiles currently unsupported.")}return i}(e.tiles,a.width,a.height),r=X(n,a.width,e.tiles.xSize,e.tiles.roundingMode),s=X(n,a.height,e.tiles.ySize,e.tiles.roundingMode);a.tileCount=r[0]*s[0];for(let e=0;e(r=o.indexOf("\n"))&&a=e.byteLength||!(l=n(e)))&&t(1,"no header found"),(c=l.match(/^#\?(\S+)/))||t(3,"bad initial token"),o.valid|=1,o.programtype=c[1],o.string+=l+"\n";l=n(e),!1!==l;)if(o.string+=l+"\n","#"!==l.charAt(0)){if((c=l.match(i))&&(o.gamma=parseFloat(c[1])),(c=l.match(r))&&(o.exposure=parseFloat(c[1])),(c=l.match(a))&&(o.valid|=2,o.format=c[1]),(c=l.match(s))&&(o.valid|=4,o.height=parseInt(c[1],10),o.width=parseInt(c[2],10)),2&o.valid&&4&o.valid)break}else o.comments+=l+"\n";return 2&o.valid||t(3,"missing format specifier"),4&o.valid||t(3,"missing image size specifier"),o}(a),o=s.width,l=s.height,c=function(e,n,i){const r=n;if(r<8||r>32767||2!==e[0]||2!==e[1]||128&e[2])return new Uint8Array(e);r!==(e[2]<<8|e[3])&&t(3,"wrong scanline width");const a=new Uint8Array(4*n*i);a.length||t(4,"unable to allocate buffer space");let s=0,o=0;const l=4*r,c=new Uint8Array(4),h=new Uint8Array(l);let d=i;for(;d>0&&oe.byteLength&&t(1),c[0]=e[o++],c[1]=e[o++],c[2]=e[o++],c[3]=e[o++],2==c[0]&&2==c[1]&&(c[2]<<8|c[3])==r||t(3,"bad rgbe scanline format");let n,i=0;for(;i128;if(r&&(n-=128),(0===n||i+n>l)&&t(3,"bad scanline data"),r){const t=e[o++];for(let e=0;e0?this.environmentName:r),s=this.currentEnvironment!==a;return this.showBackground=null!==(i=null==t?void 0:t.showEnvironment)&&void 0!==i&&i,this.currentEnvironment=a,this.currentEnvironment&&(null==t?void 0:t.environmentRotation)&&(this.currentEnvironment.rotation=t.environmentRotation),this.currentEnvironment&&(null==t?void 0:t.environmentIntensity)&&(this.currentEnvironment.intensity=t.environmentIntensity),e.userData.showEnvironmentBackground=this.showBackground,e.userData.environmentDefinition=this.currentEnvironment,s}loadDefaultEnvironment(e,t,n){var i;const r=null!=n?n:"room environment",a=null!==(i=t&&t())&&void 0!==i?i:new vd;this.environemtMap.set(r,new Nh(a)),e&&(this.environmentName=r),this.updateUI()}loadEnvmap(e,t,n){this.loadAndSetCubeTexture((t=>{this.environemtMap.set(e,new Nh(t)),n&&(this.environmentName=e),this.updateUI()}),t)}loadExr(e,t,n){this.loadExrAndSetTexture(((t,i)=>{this.environemtMap.set(e,new Nh(t,{textureData:i})),n&&(this.environmentName=e),this.updateUI()}),t)}loadHdr(e,t,n){this.loadHdrAndSetTexture(((t,i)=>{this.environemtMap.set(e,new Nh(t,{textureData:i})),n&&(this.environmentName=e),this.updateUI()}),t)}loadAndSetCubeTexture(e,t){t&&(this.envMapReader||(this.envMapReader=new Fh),this.envMapReader.load(t).then((t=>{t&&e(t)})))}loadExrAndSetTexture(e,t){t&&(this.exrLoader||(this.exrLoader=new md),this.exrLoader.load(t,((t,n)=>{e(t,n)})))}loadHdrAndSetTexture(e,t){t&&(this.rgbeLoader||(this.rgbeLoader=new gd),this.rgbeLoader.load(t,((t,n)=>{e(t,n)})))}addGUI(e){this.uiFolder=e,this.updateUI()}updateUI(){if(this.uiFolder){const e=Array.from(this.environemtMap.keys());if(this.environmentController){let t="";e.forEach((e=>{t+=``})),this.environmentController.domElement.children[0].innerHTML=t,this.environmentController.setValue(this.environmentName),this.environmentController.updateDisplay()}else this.environmentController=this.uiFolder.add(this,"environmentName",e)}}}class xd extends Zi{constructor(){const e=xd.SkyShader,t=new nr({name:e.name,uniforms:tr.clone(e.uniforms),vertexShader:e.vertexShader,fragmentShader:e.fragmentShader,side:1,depthWrite:!1});super(new Ji(1,1,1),t),this.isSky=!0}}xd.SkyShader={name:"SkyShader",uniforms:{turbidity:{value:2},rayleigh:{value:1},mieCoefficient:{value:.005},mieDirectionalG:{value:.8},sunPosition:{value:new Yt},up:{value:new Yt(0,1,0)}},vertexShader:"\n\t\tuniform vec3 sunPosition;\n\t\tuniform float rayleigh;\n\t\tuniform float turbidity;\n\t\tuniform float mieCoefficient;\n\t\tuniform vec3 up;\n\n\t\tvarying vec3 vWorldPosition;\n\t\tvarying vec3 vSunDirection;\n\t\tvarying float vSunfade;\n\t\tvarying vec3 vBetaR;\n\t\tvarying vec3 vBetaM;\n\t\tvarying float vSunE;\n\n\t\t// constants for atmospheric scattering\n\t\tconst float e = 2.71828182845904523536028747135266249775724709369995957;\n\t\tconst float pi = 3.141592653589793238462643383279502884197169;\n\n\t\t// wavelength of used primaries, according to preetham\n\t\tconst vec3 lambda = vec3( 680E-9, 550E-9, 450E-9 );\n\t\t// this pre-calcuation replaces older TotalRayleigh(vec3 lambda) function:\n\t\t// (8.0 * pow(pi, 3.0) * pow(pow(n, 2.0) - 1.0, 2.0) * (6.0 + 3.0 * pn)) / (3.0 * N * pow(lambda, vec3(4.0)) * (6.0 - 7.0 * pn))\n\t\tconst vec3 totalRayleigh = vec3( 5.804542996261093E-6, 1.3562911419845635E-5, 3.0265902468824876E-5 );\n\n\t\t// mie stuff\n\t\t// K coefficient for the primaries\n\t\tconst float v = 4.0;\n\t\tconst vec3 K = vec3( 0.686, 0.678, 0.666 );\n\t\t// MieConst = pi * pow( ( 2.0 * pi ) / lambda, vec3( v - 2.0 ) ) * K\n\t\tconst vec3 MieConst = vec3( 1.8399918514433978E14, 2.7798023919660528E14, 4.0790479543861094E14 );\n\n\t\t// earth shadow hack\n\t\t// cutoffAngle = pi / 1.95;\n\t\tconst float cutoffAngle = 1.6110731556870734;\n\t\tconst float steepness = 1.5;\n\t\tconst float EE = 1000.0;\n\n\t\tfloat sunIntensity( float zenithAngleCos ) {\n\t\t\tzenithAngleCos = clamp( zenithAngleCos, -1.0, 1.0 );\n\t\t\treturn EE * max( 0.0, 1.0 - pow( e, -( ( cutoffAngle - acos( zenithAngleCos ) ) / steepness ) ) );\n\t\t}\n\n\t\tvec3 totalMie( float T ) {\n\t\t\tfloat c = ( 0.2 * T ) * 10E-18;\n\t\t\treturn 0.434 * c * MieConst;\n\t\t}\n\n\t\tvoid main() {\n\n\t\t\tvec4 worldPosition = modelMatrix * vec4( position, 1.0 );\n\t\t\tvWorldPosition = worldPosition.xyz;\n\n\t\t\tgl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n\t\t\tgl_Position.z = gl_Position.w; // set z to camera.far\n\n\t\t\tvSunDirection = normalize( sunPosition );\n\n\t\t\tvSunE = sunIntensity( dot( vSunDirection, up ) );\n\n\t\t\tvSunfade = 1.0 - clamp( 1.0 - exp( ( sunPosition.y / 450000.0 ) ), 0.0, 1.0 );\n\n\t\t\tfloat rayleighCoefficient = rayleigh - ( 1.0 * ( 1.0 - vSunfade ) );\n\n\t\t\t// extinction (absorbtion + out scattering)\n\t\t\t// rayleigh coefficients\n\t\t\tvBetaR = totalRayleigh * rayleighCoefficient;\n\n\t\t\t// mie coefficients\n\t\t\tvBetaM = totalMie( turbidity ) * mieCoefficient;\n\n\t\t}",fragmentShader:"\n\t\tvarying vec3 vWorldPosition;\n\t\tvarying vec3 vSunDirection;\n\t\tvarying float vSunfade;\n\t\tvarying vec3 vBetaR;\n\t\tvarying vec3 vBetaM;\n\t\tvarying float vSunE;\n\n\t\tuniform float mieDirectionalG;\n\t\tuniform vec3 up;\n\n\t\t// constants for atmospheric scattering\n\t\tconst float pi = 3.141592653589793238462643383279502884197169;\n\n\t\tconst float n = 1.0003; // refractive index of air\n\t\tconst float N = 2.545E25; // number of molecules per unit volume for air at 288.15K and 1013mb (sea level -45 celsius)\n\n\t\t// optical length at zenith for molecules\n\t\tconst float rayleighZenithLength = 8.4E3;\n\t\tconst float mieZenithLength = 1.25E3;\n\t\t// 66 arc seconds -> degrees, and the cosine of that\n\t\tconst float sunAngularDiameterCos = 0.999956676946448443553574619906976478926848692873900859324;\n\n\t\t// 3.0 / ( 16.0 * pi )\n\t\tconst float THREE_OVER_SIXTEENPI = 0.05968310365946075;\n\t\t// 1.0 / ( 4.0 * pi )\n\t\tconst float ONE_OVER_FOURPI = 0.07957747154594767;\n\n\t\tfloat rayleighPhase( float cosTheta ) {\n\t\t\treturn THREE_OVER_SIXTEENPI * ( 1.0 + pow( cosTheta, 2.0 ) );\n\t\t}\n\n\t\tfloat hgPhase( float cosTheta, float g ) {\n\t\t\tfloat g2 = pow( g, 2.0 );\n\t\t\tfloat inverse = 1.0 / pow( 1.0 - 2.0 * g * cosTheta + g2, 1.5 );\n\t\t\treturn ONE_OVER_FOURPI * ( ( 1.0 - g2 ) * inverse );\n\t\t}\n\n\t\tvoid main() {\n\n\t\t\tvec3 direction = normalize( vWorldPosition - cameraPosition );\n\n\t\t\t// optical length\n\t\t\t// cutoff angle at 90 to avoid singularity in next formula.\n\t\t\tfloat zenithAngle = acos( max( 0.0, dot( up, direction ) ) );\n\t\t\tfloat inverse = 1.0 / ( cos( zenithAngle ) + 0.15 * pow( 93.885 - ( ( zenithAngle * 180.0 ) / pi ), -1.253 ) );\n\t\t\tfloat sR = rayleighZenithLength * inverse;\n\t\t\tfloat sM = mieZenithLength * inverse;\n\n\t\t\t// combined extinction factor\n\t\t\tvec3 Fex = exp( -( vBetaR * sR + vBetaM * sM ) );\n\n\t\t\t// in scattering\n\t\t\tfloat cosTheta = dot( direction, vSunDirection );\n\n\t\t\tfloat rPhase = rayleighPhase( cosTheta * 0.5 + 0.5 );\n\t\t\tvec3 betaRTheta = vBetaR * rPhase;\n\n\t\t\tfloat mPhase = hgPhase( cosTheta, mieDirectionalG );\n\t\t\tvec3 betaMTheta = vBetaM * mPhase;\n\n\t\t\tvec3 Lin = pow( vSunE * ( ( betaRTheta + betaMTheta ) / ( vBetaR + vBetaM ) ) * ( 1.0 - Fex ), vec3( 1.5 ) );\n\t\t\tLin *= mix( vec3( 1.0 ), pow( vSunE * ( ( betaRTheta + betaMTheta ) / ( vBetaR + vBetaM ) ) * Fex, vec3( 1.0 / 2.0 ) ), clamp( pow( 1.0 - dot( up, vSunDirection ), 5.0 ), 0.0, 1.0 ) );\n\n\t\t\t// nightsky\n\t\t\tfloat theta = acos( direction.y ); // elevation --\x3e y-axis, [-pi/2, pi/2]\n\t\t\tfloat phi = atan( direction.z, direction.x ); // azimuth --\x3e x-axis [-pi/2, pi/2]\n\t\t\tvec2 uv = vec2( phi, theta ) / vec2( 2.0 * pi, pi ) + vec2( 0.5, 0.0 );\n\t\t\tvec3 L0 = vec3( 0.1 ) * Fex;\n\n\t\t\t// composition + solar disc\n\t\t\tfloat sundisk = smoothstep( sunAngularDiameterCos, sunAngularDiameterCos + 0.00002, cosTheta );\n\t\t\tL0 += ( vSunE * 19000.0 * Fex ) * sundisk;\n\n\t\t\tvec3 texColor = ( Lin + L0 ) * 0.04 + vec3( 0.0, 0.0003, 0.00075 );\n\n\t\t\tvec3 retColor = pow( texColor, vec3( 1.0 / ( 1.2 + ( 1.2 * vSunfade ) ) ) );\n\n\t\t\tgl_FragColor = vec4( retColor, 1.0 );\n\n\t\t\t#include \n\t\t\t#include \n\n\t\t}"};class yd{constructor(e){this.sky=new xd,this.sky.name="Sky",this.parameters=Object.assign({visible:!0,distance:4e5,turbidity:10,rayleigh:2,mieCoefficient:.005,mieDirectionalG:.8,inclination:.6,azimuth:0},e),this.updateSky()}updateParameters(e){for(const t in e)this.parameters.hasOwnProperty(t)&&(this.parameters[t]=e[t])}updateSky(){this.sky.scale.setScalar(45e4),this.sky.frustumCulled=!1,this.sky.material.uniforms.turbidity.value=this.parameters.turbidity,this.sky.material.uniforms.rayleigh.value=this.parameters.rayleigh,this.sky.material.uniforms.mieCoefficient.value=this.parameters.mieCoefficient,this.sky.material.uniforms.mieDirectionalG.value=this.parameters.mieDirectionalG;const e=(t=this.parameters.distance,n=this.parameters.azimuth,i=this.parameters.inclination,(new Yt).setFromSphericalCoords(t,Math.PI*(1-i),2*Math.PI*(1-n)));var t,n,i;this.sky.material.uniforms.sunPosition.value.copy(e),this.sky.visible=this.parameters.visible}addToScene(e){e.add(this.sky)}changeVisibility(e){this.parameters.visible!==e&&(this.updateParameters({visible:e}),this.updateSky())}}const Sd="None",wd="GridPaper",bd="Concrete",Md="Marble",Td="Granite",Ed="VorocracksMarble",Ad="Kraft",Pd="Line",Rd="Test";class Cd{get isSet(){return this.parameters.backgroundType!==Sd}constructor(e){this._materialMap=new Map;const t=new Fi;t.setAttribute("position",new Ri([-1,3,0,-1,-1,0,3,-1,0],3)),t.setAttribute("uv",new Ri([0,2,0,0,2,0],2)),this.backgroundMesh=new Zi(t),this.backgroundMesh.name="Background",this.parameters=Object.assign({visible:!1,backgroundType:Sd},e),this.updateBackground()}_updateParameters(e){for(const t in e)this.parameters.hasOwnProperty(t)&&(this.parameters[t]=e[t])}updateBackground(){this.backgroundMesh.visible=this.parameters.backgroundType!==Sd,this.backgroundMaterial=this._getMaterial(),this.backgroundMesh.material=this.backgroundMaterial}update(e,t,n){this.backgroundMesh.visible&&this.backgroundMaterial&&(this.backgroundMaterial.uniforms.viewMatrixInverse.value.copy(n.matrixWorld),this.backgroundMaterial.uniforms.projectionMatrixInverse.value.copy(n.projectionMatrixInverse),this.backgroundMaterial.uniforms.iResolution.value.set(e,t))}addToScene(e){this.backgroundMesh!==e&&e.add(this.backgroundMesh)}hideBackground(){this.parameters.backgroundType!==Sd&&(this.parameters.backgroundType=Sd,this.updateBackground())}_getMaterial(){let e=this._materialMap.get(this.parameters.backgroundType);if(e)return e;let t=Ld,n={};switch(this.parameters.backgroundType){default:break;case Rd:t=Ld;break;case wd:t=Id;break;case bd:t=Ud,n={patternChoice:1};break;case Md:t=Ud,n={patternChoice:3};break;case Td:t=Ud,n={patternChoice:6};break;case Ed:t=Od;break;case Ad:t=Nd;break;case Pd:t=Fd}return e=new nr({name:"BackgroundShader",vertexShader:Dd,fragmentShader:t,defines:n,uniforms:{viewMatrixInverse:{value:new Mn},projectionMatrixInverse:{value:new Mn},scale:{value:8},iResolution:{value:new _t(1024,1024)}},side:2,depthWrite:!1}),this._materialMap.set(this.parameters.backgroundType,e),e}}const Dd="varying vec2 vertexUv;\nuniform mat4 viewMatrixInverse;\nuniform mat4 projectionMatrixInverse;\nuniform float scale;\n\nvoid main() {\n vec4 p = viewMatrixInverse * projectionMatrixInverse * vec4(position.xy, 0.0, 1.0);\n vertexUv = (p.xz / p.w * 0.5 + 0.5) / scale; \n gl_Position = vec4(position.xy, 1.0, 1.0);\n}",Ld="varying vec2 vertexUv;\nvoid main() {\n vec2 uv = fract(vertexUv);\n gl_FragColor = vec4(uv.x, uv.y, (1.0-uv.x) * (1.0 - uv.y), 1.0);\n}",Id="varying vec2 vertexUv;\nuniform vec2 iResolution;\nfloat nsin(float a)\n{\n return (sin(a)+1.)/2.;\n}\nfloat rand(float n)\n{\n \treturn fract(cos(n*89.42)*343.42);\n}\nvec2 rand(vec2 n)\n{\n \treturn vec2(rand(n.x*23.62-300.0+n.y*34.35),rand(n.x*45.13+256.0+n.y*38.89)); \n}\n\n// returns (dx, dy, distance)\nvec3 worley(vec2 n,float s)\n{\n vec3 ret = vec3(s * 10.);\n // look in 9 cells (n, plus 8 surrounding)\n for(int x = -1;x<2;x++)\n {\n for(int y = -1;y<2;y++)\n {\n vec2 xy = vec2(x,y);// xy can be thought of as both # of cells distance to n, and \n vec2 cellIndex = floor(n/s) + xy;\n vec2 worleyPoint = rand(cellIndex);// random point in this cell (0-1)\n worleyPoint += xy - fract(n/s);// turn it into distance to n. ;\n float d = length(worleyPoint) * s;\n if(d < ret.z)\n ret = vec3(worleyPoint, d);\n }\n }\n return ret;\n}\n\nvec2 mouse = vec2(1.);// how do i initialize this??\n\nvec4 applyLighting(vec4 inpColor, vec2 uv, vec3 normal, vec3 LightPos, vec4 LightColor, vec4 AmbientColor)\n{\n // if(distance(uv.xy, LightPos.xy) < 0.01) return vec4(1.,0.,0.,1.);\n vec3 LightDir = vec3(LightPos.xy - uv, LightPos.z);\n vec3 N = normalize(normal);\n vec3 L = normalize(LightDir);\n vec3 Diffuse = (LightColor.rgb * LightColor.a) * max(dot(N, L), 0.0);\n vec3 Ambient = AmbientColor.rgb * AmbientColor.a;\n vec3 Intensity = Ambient + Diffuse;\n vec3 FinalColor = inpColor.rgb * Intensity;\n return vec4(FinalColor, inpColor.a);\n}\n\n// convert distance to alpha value (see https://www.shadertoy.com/view/ltBGzt)\nfloat dtoa(float d)\n{\n const float amount = 800.0;\n return clamp(1.0 / (clamp(d, 1.0/amount, 1.0)*amount), 0.,1.);\n}\n\n// distance to edge of grid line. real distance, and centered over its position.\nfloat grid_d(vec2 uv, vec2 gridSize, float gridLineWidth)\n{\n uv += gridLineWidth / 2.0;\n uv = mod(uv, gridSize);\n vec2 halfRemainingSpace = (gridSize - gridLineWidth) / 2.0;\n uv -= halfRemainingSpace + gridLineWidth;\n uv = abs(uv);\n uv = -(uv - halfRemainingSpace);\n return min(uv.x, uv.y);\n}\n// centered over lineposy\nfloat hline_d(vec2 uv, float lineposy, float lineWidth)\n{\n\treturn distance(uv.y, lineposy) - (lineWidth / 2.0);\n}\n// centered over lineposx\nfloat vline_d(vec2 uv, float lineposx, float lineWidth)\n{\n\treturn distance(uv.x, lineposx) - (lineWidth / 2.0);\n}\nfloat circle_d(vec2 uv, vec2 center, float radius)\n{\n\treturn length(uv - center) - radius;\n}\n\n// not exactly perfectly perfect, but darn close\nfloat pointRectDist(vec2 p, vec2 rectTL, vec2 rectBR)\n{\n float dx = max(max(rectTL.x - p.x, 0.), p.x - rectBR.x);\n float dy = max(max(rectTL.y - p.y, 0.), p.y - rectBR.y);\n return max(dx, dy);\n}\n\n\nvec2 getuv(vec2 fragCoord, vec2 newTL, vec2 newSize, out float distanceToVisibleArea, out float vignetteAmt)\n{\n vec2 ret = vec2(fragCoord.x / iResolution.x, (iResolution.y - fragCoord.y) / iResolution.y);// ret is now 0-1 in both dimensions\n \n // warp\n //ret = tvWarp(ret / 2.) * 2.;// scale it by 2.\n distanceToVisibleArea = pointRectDist(ret, vec2(0.0), vec2(1.));\n\n // vignette\n vec2 vignetteCenter = vec2(0.5, 0.5);\n\tvignetteAmt = 1.0 - distance(ret, vignetteCenter);\n vignetteAmt = 0.03 + pow(vignetteAmt, .25);// strength\n vignetteAmt = clamp(vignetteAmt, 0.,1.);\n \n \n ret *= newSize;// scale up to new dimensions\n float aspect = iResolution.x / iResolution.y;\n ret.x *= aspect;// orig aspect ratio\n float newWidth = newSize.x * aspect;\n return ret + vec2(newTL.x - (newWidth - newSize.x) / 2.0, newTL.y);\n}\n\nvec4 drawHole(vec4 inpColor, vec2 uv, vec2 pos)\n{\n vec4 circleWhiteColor = vec4(vec3(0.95), 1.);\n\tfloat d = circle_d(uv, pos, 0.055);\n return vec4(mix(inpColor.rgb, circleWhiteColor.rgb, circleWhiteColor.a * dtoa(d)), 1.);\n}\n\nvoid main()\n{\n vec4 fragColor;\n vec2 fragCoord = vertexUv.xy * iResolution.yy;\n float distanceToVisibleArea;\n float vignetteAmt;\n\tvec2 uv = getuv(fragCoord, vec2(-1.,1.), vec2(2., -2.), distanceToVisibleArea, vignetteAmt);\n float throwaway;\n //mouse = getuv(iMouse.xy, vec2(-1.,1.), vec2(2., -2.), throwaway, throwaway);\n\n fragColor = vec4(0.94, 0.96, 0.78, 1.0);// background\n float d;\n \n // grid\n vec4 gridColor = vec4(0.2,0.4,.9, 0.35);\n\td = grid_d(uv, vec2(0.10), 0.001);\n\tfragColor = vec4(mix(fragColor.rgb, gridColor.rgb, gridColor.a * dtoa(d)), 1.);\n \n // red h line\n //vec4 hlineColor = vec4(0.8,0.,.2, 0.55);\n\t//d = hline_d(uv, 0.60, 0.003);\n\t//fragColor = vec4(mix(fragColor.rgb, hlineColor.rgb, hlineColor.a * dtoa(d)), 1.);\n \n // red v line\n //vec4 vlineColor = vec4(0.8,0.,.2, 0.55);\n\t//d = vline_d(uv, -1.40, 0.003);\n\t//fragColor = vec4(mix(fragColor.rgb, vlineColor.rgb, vlineColor.a * dtoa(d)), 1.);\n\n \n // fractal worley crumpled paper effect\n float wsize = 0.8;\n const int iterationCount = 6;\n vec2 normal = vec2(0.);\n float influenceFactor = 1.0;\n for(int i = 0; i < iterationCount; ++ i)\n {\n vec3 w = worley(uv, wsize);\n\t\tnormal.xy += influenceFactor * w.xy;\n wsize *= 0.5;\n influenceFactor *= 0.9;\n }\n \n // lighting\n //vec3 lightPos = vec3(mouse, 8.);\n //vec4 lightColor = vec4(vec3(0.99),0.6);\n //vec4 ambientColor = vec4(vec3(0.99),0.5);\n\t//fragColor = applyLighting(fragColor, uv, vec3(normal, 4.0), lightPos, lightColor, ambientColor);\n\n // white circles\n //fragColor = drawHole(fragColor, uv, vec2(-1.6, 0.2));\n\t//fragColor = drawHole(fragColor, uv, vec2(-1.6, -.7));\n \n // post effects\n\t//fragColor.rgb *= vignetteAmt;\n gl_FragColor = fragColor;\n}",Ud="varying vec2 vertexUv;\nuniform vec2 iResolution;\nuniform float iTime;\n\n// Solid Colors\nvec3 red = vec3(1.0,0.0,0.0);\nvec3 green = vec3(0.0,1.0,0.0);\nvec3 blue = vec3(0.0,0.0,1.0);\nvec3 black = vec3(0.0,0.0,0.0);\nvec3 white = vec3(1.0,1.0,1.0);\n// Concrete\nvec3 concreteLite = vec3(0.909, 0.905, 0.917);\nvec3 concreteDark = vec3(0.760, 0.729, 0.647);\n// Lava\nvec3 lavaLite = vec3(0.686, 0.203, 0.160);\nvec3 lavaDark = vec3(0.580, 0.176, 0.117);\n// Marble\nvec3 marbleLite = vec3(0.988, 0.988, 0.988);\nvec3 marbleStainBlue1 = vec3(0.690, 0.760, 0.811);\nvec3 marbleStainBlue2 = vec3(0.647, 0.745, 0.803);\nvec3 marbleStainBlue3 = vec3(0.654, 0.756, 0.772);\n// Lava Lamp\nvec3 lavaLampBG = vec3(0.462, 0.266, 0.6);\nvec3 lavaLampLava = vec3(0.929, 0.203, 0.572);\n// Clouds\nvec3 sky = vec3(0.541, 0.729, 0.827);\nvec3 cloud = vec3(0.941, 0.945, 0.941);\n// Granite\nvec3 graniteBG = vec3(0.956, 0.952, 0.976);\nvec3 graniteGray = vec3(0.478, 0.474, 0.494);\nvec3 graniteBrown = vec3(0.4, 0.356, 0.341);\nvec3 graniteBlack = vec3(0.105, 0.121, 0.160);\n\n// Tartan\nvec3 tar1Blue = vec3(0.074, 0.349, 0.505);\nvec3 tar1Green = vec3(0.286, 0.541, 0.341);\nvec3 tar1White = vec3(1.0,1.0,1.0);\nvec3 tar1Black = vec3(0.0,0.0,0.0);\nvec3 tar1BG = vec3(0.062, 0.274, 0.109);\n\n// Tartan 2\nvec3 tar2BG = vec3(0.152, 0.160, 0.156);\nvec3 tar2Blue = vec3(0.176, 0.501, 0.674);\nvec3 tar2Orange = vec3(0.603, 0.407, 0.309);\n\n// Art Installation\nvec3 violet = vec3(0.662, 0.407, 0.870);\nvec3 yellow = vec3(0.968, 0.752, 0.556);\n\n\nfloat random (in vec2 uv) {\n return fract(sin(dot(uv.xy,\n vec2(12.9898,78.233)))*\n 43758.5453123);\n}\n\n// Based on Morgan McGuire @morgan3d\n// https://www.shadertoy.com/view/4dS3Wd\nfloat noise (in vec2 uv) {\n vec2 i = floor(uv);\n vec2 f = fract(uv);\n\n // Four corners in 2D of a tile\n float a = random(i);\n float b = random(i + vec2(1.0, 0.0));\n float c = random(i + vec2(0.0, 1.0));\n float d = random(i + vec2(1.0, 1.0));\n\n vec2 u = f * f * (3.0 - 2.0 * f);\n\n return mix(a, b, u.x) +\n (c - a)* u.y * (1.0 - u.x) +\n (d - b) * u.x * u.y;\n}\n\n#define OCTAVES 6\nfloat fbm (in vec2 uv) {\n // Initial values\n float value = 0.0;\n float amplitud = .5;\n float frequency = 0.;\n //\n // Loop of octaves\n for (int i = 0; i < OCTAVES; i++) {\n value += amplitud * noise(uv);\n uv *= 2.;\n amplitud *= .5;\n }\n return value;\n}\n\n// Simplex noise\nvec3 mod289(vec3 x) { return x - floor(x * (1.0 / 289.0)) * 289.0; }\nvec2 mod289(vec2 x) { return x - floor(x * (1.0 / 289.0)) * 289.0; }\nvec3 permute(vec3 x) { return mod289(((x*34.0)+1.0)*x); }\n\nfloat snoise(vec2 v) {\n const vec4 C = vec4(0.211324865405187, // (3.0-sqrt(3.0))/6.0\n 0.366025403784439, // 0.5*(sqrt(3.0)-1.0)\n -0.577350269189626, // -1.0 + 2.0 * C.x\n 0.024390243902439); // 1.0 / 41.0\n vec2 i = floor(v + dot(v, C.yy) );\n vec2 x0 = v - i + dot(i, C.xx);\n vec2 i1;\n i1 = (x0.x > x0.y) ? vec2(1.0, 0.0) : vec2(0.0, 1.0);\n vec4 x12 = x0.xyxy + C.xxzz;\n x12.xy -= i1;\n i = mod289(i); // Avoid truncation effects in permutation\n vec3 p = permute( permute( i.y + vec3(0.0, i1.y, 1.0 ))\n + i.x + vec3(0.0, i1.x, 1.0 ));\n\n vec3 m = max(0.5 - vec3(dot(x0,x0), dot(x12.xy,x12.xy), dot(x12.zw,x12.zw)), 0.0);\n m = m*m ;\n m = m*m ;\n vec3 x = 2.0 * fract(p * C.www) - 1.0;\n vec3 h = abs(x) - 0.5;\n vec3 ox = floor(x + 0.5);\n vec3 a0 = x - ox;\n m *= 1.79284291400159 - 0.85373472095314 * ( a0*a0 + h*h );\n vec3 g;\n g.x = a0.x * x0.x + h.x * x0.y;\n g.yz = a0.yz * x12.xz + h.yz * x12.yw;\n return 130.0 * dot(m, g);\n}\n\nfloat lavaLamp(vec2 uv,vec2 shapePos, float times){\n shapePos = vec2(shapePos.x*1.5,shapePos.y*0.3);\n uv -= shapePos;\n \n float angle = atan(uv.y,uv.x);\n float radius = cos(times*angle*0.5);\n return radius;\n}\n\nvec4 rectangle(vec2 uv, vec2 pos, float width, float height, vec3 color) {\n\tfloat t = 0.0;\n\tif ((uv.x > pos.x - width / 2.0) && (uv.x < pos.x + width / 2.0)\n\t\t&& (uv.y > pos.y - height / 2.0) && (uv.y < pos.y + height / 2.0)) {\n\t\tt = 1.0;\n\t}\n\treturn vec4(color, t);\n}\n\nvoid main()\n{\n vec4 fragColor;\n vec2 fragCoord = vertexUv.xy * iResolution.yy;\n\tvec2 uv = fragCoord.xy / iResolution.xy;\n\tfloat ratio = iResolution.x/iResolution.y;\n uv.x *= ratio;\n \n if (patternChoice == 1) // Concrete\n {\n vec3 value = concreteLite;\n \n value = mix(value, concreteDark,random(uv)*0.6);\n value = mix(value, black, random(uv)*0.35);\n \n vec3 stains = vec3(fbm((uv*5.)*2.))*.12;\n \n value = mix(value, concreteLite,(smoothstep(0.03,.12,stains) - smoothstep(.2,.3,stains))*0.3);\n \n\t fragColor = vec4(value, 1.0);\n }\n \n else if (patternChoice == 2) // Lava\n {\n\t\tvec3 value = black;\n \n vec3 stains = vec3(fbm((uv*1.7)*25.))*.75;\n \n float fade = sin(iTime * 5.)+2.5;\n \n value = mix(value, lavaLite, (smoothstep(0.05,0.1,stains) - smoothstep(.17, .22,stains) * fade));\n \n fragColor = vec4(value,1.0);\n }\n \n else if (patternChoice == 3) // Marble\n {\n vec3 value = marbleLite;\n \n vec3 stains = vec3(fbm((uv*1.2)*18.))*.113;\n vec3 stains2 = vec3(fbm((uv*5.)*1.5))*.12;\n \n vec3 stains3 = vec3(fbm((uv)*5.))*.12;\n vec3 stains4 = vec3(fbm((uv*2.)*2.5))*.12;\n \n value = mix(value, marbleStainBlue1,(smoothstep(0.065,0.1,stains) - smoothstep(0.1, 0.8,stains)));\n //value = mix(value, marbleStainBlue2,(smoothstep(0.065,0.1,stains2) - smoothstep(0.1, 0.8,stains2)));\n //value = mix(value, marbleStainBlue3,(smoothstep(0.09,0.1,stains2) - smoothstep(0.2, 0.5,stains2)));\n //value = mix(value, marbleStainBlue2,(smoothstep(0.07,0.1,stains3) - smoothstep(0.1, 0.8,stains3)));\n \n fragColor = vec4(value, 1.0);\n }\n \n else if (patternChoice == 4) // Lava Lamp\n {\n //float value = lavaLamp(uv,vec2(0.,0.5), 3.);\n //vec2 value = vec2(snoise(uv*3.-iTime));\n \t//vec3 color = red*vec3(value, 1.0);\n \n vec3 value = lavaLampBG;\n float lava = lavaLamp(uv*0.5,vec2(snoise(uv*4.-iTime)), 1.);\n \n vec3 color = lavaLampLava*lava;\n value += color;\n \n \n fragColor = vec4(value, 1.0);\n }\n \t\n else if (patternChoice == 5) // Clouds\n {\n uv *= 0.5;\n vec3 value = sky;\n \n vec3 clouds = vec3(fbm((uv*sin(iTime*0.25))*20.))*.12;\n \n value = mix(value, cloud,(smoothstep(0.05,0.1,clouds) - smoothstep(0.1, 0.2,clouds)));\n \n fragColor = vec4(value, 1.0);\n }\n \n else if (patternChoice == 6) // Granite\n {\n \tvec3 value = graniteBG;\n \n uv *= 2.;\n uv += 2.3;\n vec3 layer1 = vec3(fbm((uv*0.6)*18.))*.113;\n uv *= 0.2;\n uv += 0.5;\n vec3 layer2 = vec3(fbm((uv*0.8)*30.))*.117;\n uv *= 2.2;\n uv += 2.5;\n vec3 layer3 = vec3(fbm((uv*0.4)*15.))*.12;\n \n value = mix(value, graniteBlack,(smoothstep(0.04,0.1,layer1) - smoothstep(0.1, 0.8,layer1)));\n value = mix(value, graniteBrown,(smoothstep(0.04,0.1,layer2) - smoothstep(0.1, 0.8,layer2)));\n value = mix(value, graniteGray,(smoothstep(0.072,0.1,layer3) - smoothstep(0.1, 0.8,layer3)));\n \n fragColor = vec4(value, 1.0);\n }\n \n else if (patternChoice == 7) // Scottish Tartan 1\n {\n vec3 value = tar1BG; \n \n uv *= 2.;\n \tuv = fract(uv);\n \n float blackTile = 0.;\n float greenTile = 0.;\n float blueTile = 0.;\n float whiteTile = 0.;\n \n // Blue blocks\n // Horizontal\n \tblueTile += step(0.15, uv.x) - step(0.35, uv.x);\n \tblueTile += step(0.65, uv.x) - step(0.85, uv.x);\n // Vertical\n blueTile += step(0.15, uv.y) - step(0.35, uv.y);\n blueTile += step(0.68, uv.y) - step(0.85, uv.y);\n \n // White lines\n // Vertical\n whiteTile += step(0.0001, uv.x) - step(0.02, uv.x);\n whiteTile += step(0.49, uv.x) - step(0.51, uv.x);\n // Horizontal\n whiteTile += step(0.220, uv.y) - step(0.245, uv.y);\n \twhiteTile += step(0.755, uv.y) - step(0.775, uv.y);\n \n // Black lines\n // Vertical\n blackTile += step(0.10, uv.x) - step(0.11, uv.x);\n blackTile += step(0.12, uv.x) - step(0.13, uv.x);\n blackTile += step(0.14, uv.x) - step(0.15, uv.x);\n blackTile += step(0.18, uv.x) - step(0.19, uv.x);\n blackTile += step(0.2, uv.x) - step(0.21, uv.x);\n blackTile += step(0.29, uv.x) - step(0.3, uv.x);\n blackTile += step(0.31, uv.x) - step(0.32, uv.x);\n blackTile += step(0.35, uv.x) - step(0.36, uv.x);\n blackTile += step(0.37, uv.x) - step(0.38, uv.x);\n blackTile += step(0.39, uv.x) - step(0.4, uv.x);\n blackTile += step(0.59, uv.x) - step(0.6, uv.x);\n blackTile += step(0.61, uv.x) - step(0.62, uv.x);\n blackTile += step(0.63, uv.x) - step(0.64, uv.x);\n blackTile += step(0.68, uv.x) - step(0.69, uv.x);\n blackTile += step(0.7, uv.x) - step(0.71, uv.x);\n blackTile += step(0.77, uv.x) - step(0.78, uv.x);\n blackTile += step(0.8, uv.x) - step(0.81, uv.x);\n blackTile += step(0.85, uv.x) - step(0.86, uv.x);\n blackTile += step(0.87, uv.x) - step(0.88, uv.x);\n blackTile += step(0.89, uv.x) - step(0.9, uv.x);\n // Horizontal\n blackTile += step(0.07, uv.y) - step(0.08, uv.y);\n blackTile += step(0.05, uv.y) - step(0.06, uv.y);\n blackTile += step(0.39, uv.y) - step(0.4, uv.y);\n blackTile += step(0.41, uv.y) - step(0.42, uv.y);\n blackTile += step(0.59, uv.y) - step(0.6, uv.y);\n blackTile += step(0.61, uv.y) - step(0.62, uv.y);\n blackTile += step(0.90, uv.y) - step(0.91, uv.y);\n blackTile += step(0.92, uv.y) - step(0.93, uv.y);\n \n // Apply\n value = mix(value, tar1Blue, vec3(blueTile * noise(uv* 1000.)));\n value = mix(value, tar1White, vec3(whiteTile * noise(uv * 200.)));\n value = mix(value, tar1Black, vec3(blackTile * noise(uv * 200.)));\n \n fragColor = vec4(value, 1.0);\n }\n \n else if (patternChoice == 8) // Scottish Tartan 2\n {\n vec3 value = tar2BG; \n \n uv *= 2.;\n \tuv = fract(uv);\n \n float blackTile = 0.;\n float greenTile = 0.;\n float blueTile = 0.;\n float orangeTile = 0.;\n \n // Blue blocks\n // Horizontal\n \tblueTile += step(0.15, uv.x) - step(0.35, uv.x);\n \tblueTile += step(0.65, uv.x) - step(0.85, uv.x);\n // Vertical\n blueTile += step(0.15, uv.y) - step(0.35, uv.y);\n blueTile += step(0.68, uv.y) - step(0.85, uv.y);\n \n // Orange lines\n // Vertical\n orangeTile += step(0.0001, uv.x) - step(0.02, uv.x);\n orangeTile += step(0.49, uv.x) - step(0.51, uv.x);\n orangeTile += step(0.04, uv.x) - step(0.05, uv.x);\n orangeTile += step(0.97, uv.x) - step(0.98, uv.x);\n orangeTile += step(0.46, uv.x) - step(0.47, uv.x);\n orangeTile += step(0.53, uv.x) - step(0.54, uv.x);\n // Horizontal\n orangeTile += step(0.220, uv.y) - step(0.245, uv.y);\n \torangeTile += step(0.755, uv.y) - step(0.775, uv.y);\n orangeTile += step(0.200, uv.y) - step(0.210, uv.y);\n orangeTile += step(0.255, uv.y) - step(0.265, uv.y);\n orangeTile += step(0.730, uv.y) - step(0.740, uv.y);\n orangeTile += step(0.79, uv.y) - step(0.8, uv.y);\n \n // Apply\n value = mix(value, tar2Blue, vec3(blueTile * noise(uv* 1200.)));\n value = mix(value, tar2Orange, vec3(orangeTile * noise(uv * 200.)));\n \n fragColor = vec4(value, 1.0);\n }\n \n else if (patternChoice == 9) // Art Installation\n {\n vec2 uv2 = fragCoord.xy/iResolution.xy;\n uv2 -= 0.5;\n uv2.x *= 1.6;\n uv2.y *= 1.9;\n \n float dist = length(uv2);\n \n vec2 fragCo = fragCoord.xy;\n vec2 center = iResolution.xy * 0.5;\n float width = iResolution.x * 0.4;\n float height = iResolution.x * 0.2;\n \n vec3 value = mix(violet, yellow, dist);\n \n vec4 finalVal = vec4(value, 1.0);\n \n vec4 rect = rectangle(fragCo, center, width, height, violet);\n \n fragColor = mix(finalVal,rect,rect.a);\n fragColor = finalVal;\n }\n gl_FragColor = fragColor;\n}",Od="varying vec2 vertexUv;\nuniform vec2 iResolution;\nuniform float iTime;\n// variant of Vorocracks: https://shadertoy.com/view/lsVyRy\n// integrated with cracks here: https://www.shadertoy.com/view/Xd3fRN\n\n#define MM 0\n\n#define VARIANT 1 // 1: amplifies Voronoi cell jittering\n#if VARIANT\n float ofs = .5; // jitter Voronoi centers in -ofs ... 1.+ofs\n#else\n float ofs = 0.;\n#endif\n \n//int FAULT = 1; // 0: crest 1: fault\n\nfloat RATIO = 1., // stone length/width ratio\n /* STONE_slope = .3, // 0. .3 .3 -.3\n STONE_height = 1., // 1. 1. .6 .7\n profile = 1., // z = height + slope * dist ^ prof\n */ \n CRACK_depth = 3.,\n CRACK_zebra_scale = 1., // fractal shape of the fault zebra\n CRACK_zebra_amp = .67,\n CRACK_profile = 1., // fault vertical shape 1. .2 \n CRACK_slope = 50., // 10. 1.4\n CRACK_width = .0;\n \n\n// std int hash, inspired from https://www.shadertoy.com/view/XlXcW4\nvec3 hash3( uvec3 x ) \n{\n# define scramble x = ( (x>>8U) ^ x.yzx ) * 1103515245U // GLIB-C const\n scramble; scramble; scramble; \n return vec3(x) / float(0xffffffffU) + 1e-30; // <- eps to fix a windows/angle bug\n}\n\n// === Voronoi =====================================================\n// --- Base Voronoi. inspired by https://www.shadertoy.com/view/MslGD8\n\n#define hash22(p) fract( 18.5453 * sin( p * mat2(127.1,311.7,269.5,183.3)) )\n#define disp(p) ( -ofs + (1.+2.*ofs) * hash22(p) )\n\nvec3 voronoi( vec2 u ) // returns len + id\n{\n vec2 iu = floor(u), v;\n\tfloat m = 1e9,d;\n#if VARIANT\n for( int k=0; k < 25; k++ ) {\n vec2 p = iu + vec2(k%5-2,k/5-2),\n#else\n for( int k=0; k < 9; k++ ) {\n vec2 p = iu + vec2(k%3-1,k/3-1),\n#endif\n o = disp(p),\n \t r = p - u + o;\n\t\td = dot(r,r);\n if( d < m ) m = d, v = r;\n }\n\n return vec3( sqrt(m), v+u );\n}\n\n// --- Voronoi distance to borders. inspired by https://www.shadertoy.com/view/ldl3W8\nvec3 voronoiB( vec2 u ) // returns len + id\n{\n vec2 iu = floor(u), C, P;\n\tfloat m = 1e9,d;\n#if VARIANT\n for( int k=0; k < 25; k++ ) {\n vec2 p = iu + vec2(k%5-2,k/5-2),\n#else\n for( int k=0; k < 9; k++ ) {\n vec2 p = iu + vec2(k%3-1,k/3-1),\n#endif\n o = disp(p),\n \t r = p - u + o;\n\t\td = dot(r,r);\n if( d < m ) m = d, C = p-iu, P = r;\n }\n\n m = 1e9;\n \n for( int k=0; k < 25; k++ ) {\n vec2 p = iu+C + vec2(k%5-2,k/5-2),\n\t\t o = disp(p),\n r = p-u + o;\n\n if( dot(P-r,P-r)>1e-5 )\n m = min( m, .5*dot( (P+r), normalize(r-P) ) );\n }\n\n return vec3( m, P+u );\n}\n\n// === pseudo Perlin noise =============================================\n#define rot(a) mat2(cos(a),-sin(a),sin(a),cos(a))\nint MOD = 1; // type of Perlin noise\n \n// --- 2D\n#define hash21(p) fract(sin(dot(p,vec2(127.1,311.7)))*43758.5453123)\nfloat noise2(vec2 p) {\n vec2 i = floor(p);\n vec2 f = fract(p); f = f*f*(3.-2.*f); // smoothstep\n\n float v= mix( mix(hash21(i+vec2(0,0)),hash21(i+vec2(1,0)),f.x),\n mix(hash21(i+vec2(0,1)),hash21(i+vec2(1,1)),f.x), f.y);\n\treturn MOD==0 ? v\n\t : MOD==1 ? 2.*v-1.\n : MOD==2 ? abs(2.*v-1.)\n : 1.-abs(2.*v-1.);\n}\n\nfloat fbm2(vec2 p) {\n float v = 0., a = .5;\n mat2 R = rot(.37);\n\n for (int i = 0; i < 9; i++, p*=2.,a/=2.) \n p *= R,\n v += a * noise2(p);\n\n return v;\n}\n#define noise22(p) vec2(noise2(p),noise2(p+17.7))\nvec2 fbm22(vec2 p) {\n vec2 v = vec2(0);\n float a = .5;\n mat2 R = rot(.37);\n\n for (int i = 0; i < 6; i++, p*=2.,a/=2.) \n p *= R,\n v += a * noise22(p);\n\n return v;\n}\nvec2 mfbm22(vec2 p) { // multifractal fbm \n vec2 v = vec2(1);\n float a = .5;\n mat2 R = rot(.37);\n\n for (int i = 0; i < 6; i++, p*=2.,a/=2.) \n p *= R,\n //v *= 1.+noise22(p);\n v += v * a * noise22(p);\n\n return v-1.;\n}\n\n/*\n// --- 3D \n#define hash31(p) fract(sin(dot(p,vec3(127.1,311.7, 74.7)))*43758.5453123)\nfloat noise3(vec3 p) {\n vec3 i = floor(p);\n vec3 f = fract(p); f = f*f*(3.-2.*f); // smoothstep\n\n float v= mix( mix( mix(hash31(i+vec3(0,0,0)),hash31(i+vec3(1,0,0)),f.x),\n mix(hash31(i+vec3(0,1,0)),hash31(i+vec3(1,1,0)),f.x), f.y), \n mix( mix(hash31(i+vec3(0,0,1)),hash31(i+vec3(1,0,1)),f.x),\n mix(hash31(i+vec3(0,1,1)),hash31(i+vec3(1,1,1)),f.x), f.y), f.z);\n\treturn MOD==0 ? v\n\t : MOD==1 ? 2.*v-1.\n : MOD==2 ? abs(2.*v-1.)\n : 1.-abs(2.*v-1.);\n}\n\nfloat fbm3(vec3 p) {\n float v = 0., a = .5;\n mat2 R = rot(.37);\n\n for (int i = 0; i < 9; i++, p*=2.,a/=2.) \n p.xy *= R, p.yz *= R,\n v += a * noise3(p);\n\n return v;\n}\n*/\n \n// ======================================================\n\nvoid main()\n{\n vec4 O;\n vec2 U = vertexUv.xy * iResolution.yy;\n U *= 4./iResolution.y;\n U.x += iTime; // for demo\n // O = vec4( 1.-voronoiB(U).x,voronoi(U).x, 0,0 ); // for tests\n vec2 I = floor(U/2.); \n bool vert = mod(I.x+I.y,2.)==0.; //if (vert) U = U.yx;\n vec3 H0;\n O-=O;\n\n for(float i=0.; i{this.parse(e,t,i)}),n,i)}parse(e,t,n=()=>{}){this.decodeDracoFile(e,t,null,null,Ge,n).catch(n)}decodeDracoFile(e,t,n,i,r=We,a=()=>{}){const s={attributeIDs:n||this.defaultAttributeIDs,attributeTypes:i||this.defaultAttributeTypes,useUniqueIDs:!!n,vertexColorSpace:r};return this.decodeGeometry(e,s).then(t).catch(a)}decodeGeometry(e,t){const n=JSON.stringify(t);if(Bd.has(e)){const t=Bd.get(e);if(t.key===n)return t.promise;if(0===e.byteLength)throw new Error("THREE.DRACOLoader: Unable to re-decode a buffer with different settings. Buffer has already been transferred.")}let i;const r=this.workerNextTaskID++,a=e.byteLength,s=this._getWorker(r,a).then((n=>(i=n,new Promise(((n,a)=>{i._callbacks[r]={resolve:n,reject:a},i.postMessage({type:"decode",id:r,taskConfig:t,buffer:e},[e])}))))).then((e=>this._createGeometry(e.geometry)));return s.catch((()=>!0)).then((()=>{i&&r&&this._releaseTask(i,r)})),Bd.set(e,{key:n,promise:s}),s}_createGeometry(e){const t=new Fi;e.index&&t.setIndex(new Ei(e.index.array,1));for(let n=0;n{n.load(e,t,void 0,i)}))}preload(){return this._initDecoder(),this}_initDecoder(){if(this.decoderPending)return this.decoderPending;const e="object"!=typeof WebAssembly||"js"===this.decoderConfig.type,t=[];return e?t.push(this._loadLibrary("draco_decoder.js","text")):(t.push(this._loadLibrary("draco_wasm_wrapper.js","text")),t.push(this._loadLibrary("draco_decoder.wasm","arraybuffer"))),this.decoderPending=Promise.all(t).then((t=>{const n=t[0];e||(this.decoderConfig.wasmBinary=t[1]);const i=kd.toString(),r=["/* draco decoder */",n,"","/* worker */",i.substring(i.indexOf("{")+1,i.lastIndexOf("}"))].join("\n");this.workerSourceURL=URL.createObjectURL(new Blob([r]))})),this.decoderPending}_getWorker(e,t){return this._initDecoder().then((()=>{if(this.workerPool.lengtht._taskLoad?-1:1}));const n=this.workerPool[this.workerPool.length-1];return n._taskCosts[e]=t,n._taskLoad+=t,n}))}_releaseTask(e,t){e._taskLoad-=e._taskCosts[t],delete e._callbacks[t],delete e._taskCosts[t]}debug(){console.log("Task load: ",this.workerPool.map((e=>e._taskLoad)))}dispose(){for(let e=0;e{const t=e.draco,s=new t.Decoder;try{const e=function(e,t,i,r){const a=r.attributeIDs,s=r.attributeTypes;let o,l;const c=t.GetEncodedGeometryType(i);if(c===e.TRIANGULAR_MESH)o=new e.Mesh,l=t.DecodeArrayToMesh(i,i.byteLength,o);else{if(c!==e.POINT_CLOUD)throw new Error("THREE.DRACOLoader: Unexpected geometry type.");o=new e.PointCloud,l=t.DecodeArrayToPointCloud(i,i.byteLength,o)}if(!l.ok()||0===o.ptr)throw new Error("THREE.DRACOLoader: Decoding failed: "+l.error_msg());const h={index:null,attributes:[]};for(const i in a){const l=self[s[i]];let c,d;if(r.useUniqueIDs)d=a[i],c=t.GetAttributeByUniqueId(o,d);else{if(d=t.GetAttributeId(o,e[a[i]]),-1===d)continue;c=t.GetAttribute(o,d)}const u=n(e,t,o,i,l,c);"color"===i&&(u.vertexColorSpace=r.vertexColorSpace),h.attributes.push(u)}return c===e.TRIANGULAR_MESH&&(h.index=function(e,t,n){const i=3*n.num_faces(),r=4*i,a=e._malloc(r);t.GetTrianglesUInt32Array(n,r,a);const s=new Uint32Array(e.HEAPF32.buffer,a,i).slice();return e._free(a),{array:s,itemSize:1}}(e,t,o)),e.destroy(o),h}(t,s,new Int8Array(i),a),o=e.attributes.map((e=>e.array.buffer));e.index&&o.push(e.index.array.buffer),self.postMessage({type:"decode",id:r.id,geometry:e},o)}catch(e){console.error(e),self.postMessage({type:"error",id:r.id,error:e.message})}finally{t.destroy(s)}}))}}}function Hd(e,t){if(0===t)return console.warn("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Geometry already defined as triangles."),e;if(2===t||1===t){let n=e.getIndex();if(null===n){const t=[],i=e.getAttribute("position");if(void 0===i)return console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Undefined position attribute. Processing not possible."),e;for(let e=0;e=2.0 are supported.")));const l=new Lu(r,{path:t||this.resourcePath||"",crossOrigin:this.crossOrigin,requestHeader:this.requestHeader,manager:this.manager,ktx2Loader:this.ktx2Loader,meshoptDecoder:this.meshoptDecoder});l.fileLoader.setRequestHeader(this.requestHeader);for(let e=0;e=0&&void 0===s[t]&&console.warn('THREE.GLTFLoader: Unknown extension "'+t+'".')}}l.setExtensions(a),l.setPlugins(s),l.parse(n,i)}parseAsync(e,t){const n=this;return new Promise((function(i,r){n.parse(e,t,i,r)}))}}function Gd(){let e={};return{get:function(t){return e[t]},add:function(t,n){e[t]=n},remove:function(t){delete e[t]},removeAll:function(){e={}}}}const Wd={KHR_BINARY_GLTF:"KHR_binary_glTF",KHR_DRACO_MESH_COMPRESSION:"KHR_draco_mesh_compression",KHR_LIGHTS_PUNCTUAL:"KHR_lights_punctual",KHR_MATERIALS_CLEARCOAT:"KHR_materials_clearcoat",KHR_MATERIALS_DISPERSION:"KHR_materials_dispersion",KHR_MATERIALS_IOR:"KHR_materials_ior",KHR_MATERIALS_SHEEN:"KHR_materials_sheen",KHR_MATERIALS_SPECULAR:"KHR_materials_specular",KHR_MATERIALS_TRANSMISSION:"KHR_materials_transmission",KHR_MATERIALS_IRIDESCENCE:"KHR_materials_iridescence",KHR_MATERIALS_ANISOTROPY:"KHR_materials_anisotropy",KHR_MATERIALS_UNLIT:"KHR_materials_unlit",KHR_MATERIALS_VOLUME:"KHR_materials_volume",KHR_TEXTURE_BASISU:"KHR_texture_basisu",KHR_TEXTURE_TRANSFORM:"KHR_texture_transform",KHR_MESH_QUANTIZATION:"KHR_mesh_quantization",KHR_MATERIALS_EMISSIVE_STRENGTH:"KHR_materials_emissive_strength",EXT_MATERIALS_BUMP:"EXT_materials_bump",EXT_TEXTURE_WEBP:"EXT_texture_webp",EXT_TEXTURE_AVIF:"EXT_texture_avif",EXT_MESHOPT_COMPRESSION:"EXT_meshopt_compression",EXT_MESH_GPU_INSTANCING:"EXT_mesh_gpu_instancing"};class jd{constructor(e){this.parser=e,this.name=Wd.KHR_LIGHTS_PUNCTUAL,this.cache={refs:{},uses:{}}}_markDefs(){const e=this.parser,t=this.parser.json.nodes||[];for(let n=0,i=t.length;n=0)throw new Error("THREE.GLTFLoader: setKTX2Loader must be called before loading KTX2 textures");return null}return t.loadTextureImage(e,r.source,a)}}class au{constructor(e){this.parser=e,this.name=Wd.EXT_TEXTURE_WEBP,this.isSupported=null}loadTexture(e){const t=this.name,n=this.parser,i=n.json,r=i.textures[e];if(!r.extensions||!r.extensions[t])return null;const a=r.extensions[t],s=i.images[a.source];let o=n.textureLoader;if(s.uri){const e=n.options.manager.getHandler(s.uri);null!==e&&(o=e)}return this.detectSupport().then((function(r){if(r)return n.loadTextureImage(e,a.source,o);if(i.extensionsRequired&&i.extensionsRequired.indexOf(t)>=0)throw new Error("THREE.GLTFLoader: WebP required by asset but unsupported.");return n.loadTexture(e)}))}detectSupport(){return this.isSupported||(this.isSupported=new Promise((function(e){const t=new Image;t.src="data:image/webp;base64,UklGRiIAAABXRUJQVlA4IBYAAAAwAQCdASoBAAEADsD+JaQAA3AAAAAA",t.onload=t.onerror=function(){e(1===t.height)}}))),this.isSupported}}class su{constructor(e){this.parser=e,this.name=Wd.EXT_TEXTURE_AVIF,this.isSupported=null}loadTexture(e){const t=this.name,n=this.parser,i=n.json,r=i.textures[e];if(!r.extensions||!r.extensions[t])return null;const a=r.extensions[t],s=i.images[a.source];let o=n.textureLoader;if(s.uri){const e=n.options.manager.getHandler(s.uri);null!==e&&(o=e)}return this.detectSupport().then((function(r){if(r)return n.loadTextureImage(e,a.source,o);if(i.extensionsRequired&&i.extensionsRequired.indexOf(t)>=0)throw new Error("THREE.GLTFLoader: AVIF required by asset but unsupported.");return n.loadTexture(e)}))}detectSupport(){return this.isSupported||(this.isSupported=new Promise((function(e){const t=new Image;t.src="data:image/avif;base64,AAAAIGZ0eXBhdmlmAAAAAGF2aWZtaWYxbWlhZk1BMUIAAADybWV0YQAAAAAAAAAoaGRscgAAAAAAAAAAcGljdAAAAAAAAAAAAAAAAGxpYmF2aWYAAAAADnBpdG0AAAAAAAEAAAAeaWxvYwAAAABEAAABAAEAAAABAAABGgAAABcAAAAoaWluZgAAAAAAAQAAABppbmZlAgAAAAABAABhdjAxQ29sb3IAAAAAamlwcnAAAABLaXBjbwAAABRpc3BlAAAAAAAAAAEAAAABAAAAEHBpeGkAAAAAAwgICAAAAAxhdjFDgQAMAAAAABNjb2xybmNseAACAAIABoAAAAAXaXBtYQAAAAAAAAABAAEEAQKDBAAAAB9tZGF0EgAKCBgABogQEDQgMgkQAAAAB8dSLfI=",t.onload=t.onerror=function(){e(1===t.height)}}))),this.isSupported}}class ou{constructor(e){this.name=Wd.EXT_MESHOPT_COMPRESSION,this.parser=e}loadBufferView(e){const t=this.parser.json,n=t.bufferViews[e];if(n.extensions&&n.extensions[this.name]){const e=n.extensions[this.name],i=this.parser.getDependency("buffer",e.buffer),r=this.parser.options.meshoptDecoder;if(!r||!r.supported){if(t.extensionsRequired&&t.extensionsRequired.indexOf(this.name)>=0)throw new Error("THREE.GLTFLoader: setMeshoptDecoder must be called before loading compressed files");return null}return i.then((function(t){const n=e.byteOffset||0,i=e.byteLength||0,a=e.count,s=e.byteStride,o=new Uint8Array(t,n,i);return r.decodeGltfBufferAsync?r.decodeGltfBufferAsync(a,s,o,e.mode,e.filter).then((function(e){return e.buffer})):r.ready.then((function(){const t=new ArrayBuffer(a*s);return r.decodeGltfBuffer(new Uint8Array(t),a,s,o,e.mode,e.filter),t}))}))}return null}}class lu{constructor(e){this.name=Wd.EXT_MESH_GPU_INSTANCING,this.parser=e}createNodeMesh(e){const t=this.parser.json,n=t.nodes[e];if(!n.extensions||!n.extensions[this.name]||void 0===n.mesh)return null;const i=t.meshes[n.mesh];for(const e of i.primitives)if(e.mode!==vu.TRIANGLES&&e.mode!==vu.TRIANGLE_STRIP&&e.mode!==vu.TRIANGLE_FAN&&void 0!==e.mode)return null;const r=n.extensions[this.name].attributes,a=[],s={};for(const e in r)a.push(this.parser.getDependency("accessor",r[e]).then((t=>(s[e]=t,s[e]))));return a.length<1?null:(a.push(this.parser.createNodeMesh(e)),Promise.all(a).then((e=>{const t=e.pop(),n=t.isGroup?t.children:[t],i=e[0].count,r=[];for(const e of n){const t=new Mn,n=new Yt,a=new Xt,o=new Yt(1,1,1),l=new Oo(e.geometry,e.material,i);for(let e=0;e-1,a=r?e.match(/Firefox\/([0-9]+)\./)[1]:-1}"undefined"==typeof createImageBitmap||n&&i<17||r&&a<98?this.textureLoader=new ic(this.options.manager):this.textureLoader=new Sc(this.options.manager),this.textureLoader.setCrossOrigin(this.options.crossOrigin),this.textureLoader.setRequestHeader(this.options.requestHeader),this.fileLoader=new ec(this.options.manager),this.fileLoader.setResponseType("arraybuffer"),"use-credentials"===this.options.crossOrigin&&this.fileLoader.setWithCredentials(!0)}setExtensions(e){this.extensions=e}setPlugins(e){this.plugins=e}parse(e,t){const n=this,i=this.json,r=this.extensions;this.cache.removeAll(),this.nodeCache={},this._invokeAll((function(e){return e._markDefs&&e._markDefs()})),Promise.all(this._invokeAll((function(e){return e.beforeRoot&&e.beforeRoot()}))).then((function(){return Promise.all([n.getDependencies("scene"),n.getDependencies("animation"),n.getDependencies("camera")])})).then((function(t){const a={scene:t[0][i.scene||0],scenes:t[0],animations:t[1],cameras:t[2],asset:i.asset,parser:n,userData:{}};return Tu(r,a,i),Eu(a,i),Promise.all(n._invokeAll((function(e){return e.afterRoot&&e.afterRoot(a)}))).then((function(){for(const e of a.scenes)e.updateMatrixWorld();e(a)}))})).catch(t)}_markDefs(){const e=this.json.nodes||[],t=this.json.skins||[],n=this.json.meshes||[];for(let n=0,i=t.length;n{const n=this.associations.get(e);null!=n&&this.associations.set(t,n);for(const[n,i]of e.children.entries())r(i,t.children[n])};return r(n,i),i.name+="_instance_"+e.uses[t]++,i}_invokeOne(e){const t=Object.values(this.plugins);t.push(this);for(let n=0;n=2&&p.setY(t,h[e*a+1]),a>=3&&p.setZ(t,h[e*a+2]),a>=4&&p.setW(t,h[e*a+3]),a>=5)throw new Error("THREE.GLTFLoader: Unsupported itemSize in sparse BufferAttribute.")}p.normalized=d}return p}))}loadTexture(e){const t=this.json,n=this.options,i=t.textures[e].source,r=t.images[i];let a=this.textureLoader;if(r.uri){const e=n.manager.getHandler(r.uri);null!==e&&(a=e)}return this.loadTextureImage(e,i,a)}loadTextureImage(e,t,n){const i=this,r=this.json,a=r.textures[e],s=r.images[t],o=(s.uri||s.bufferView)+":"+a.sampler;if(this.textureCache[o])return this.textureCache[o];const l=this.loadImageSource(t,n).then((function(t){t.flipY=!1,t.name=a.name||s.name||"",""===t.name&&"string"==typeof s.uri&&!1===s.uri.startsWith("data:image/")&&(t.name=s.uri);const n=(r.samplers||{})[a.sampler]||{};return t.magFilter=xu[n.magFilter]||V,t.minFilter=xu[n.minFilter]||W,t.wrapS=yu[n.wrapS]||N,t.wrapT=yu[n.wrapT]||N,t.generateMipmaps=!t.isCompressedTexture&&t.minFilter!==z&&t.minFilter!==V,i.associations.set(t,{textures:e}),t})).catch((function(){return null}));return this.textureCache[o]=l,l}loadImageSource(e,t){const n=this.json,i=this.options;if(void 0!==this.sourceCache[e])return this.sourceCache[e].then((e=>e.clone()));const r=n.images[e],a=self.URL||self.webkitURL;let s=r.uri||"",o=!1;if(void 0!==r.bufferView)s=this.getDependency("bufferView",r.bufferView).then((function(e){o=!0;const t=new Blob([e],{type:r.mimeType});return s=a.createObjectURL(t),s}));else if(void 0===r.uri)throw new Error("THREE.GLTFLoader: Image "+e+" is missing URI and bufferView");const l=Promise.resolve(s).then((function(e){return new Promise((function(n,r){let a=n;!0===t.isImageBitmapLoader&&(a=function(e){const t=new kt(e);t.needsUpdate=!0,n(t)}),t.load(yc.resolveURL(e,i.path),a,void 0,r)}))})).then((function(e){var t;return!0===o&&a.revokeObjectURL(s),Eu(e,r),e.userData.mimeType=r.mimeType||((t=r.uri).search(/\.jpe?g($|\?)/i)>0||0===t.search(/^data\:image\/jpeg/)?"image/jpeg":t.search(/\.webp($|\?)/i)>0||0===t.search(/^data\:image\/webp/)?"image/webp":t.search(/\.ktx2($|\?)/i)>0||0===t.search(/^data\:image\/ktx2/)?"image/ktx2":"image/png"),e})).catch((function(e){throw console.error("THREE.GLTFLoader: Couldn't load texture",s),e}));return this.sourceCache[e]=l,l}assignTexture(e,t,n,i){const r=this;return this.getDependency("texture",n.index).then((function(a){if(!a)return null;if(void 0!==n.texCoord&&n.texCoord>0&&((a=a.clone()).channel=n.texCoord),r.extensions[Wd.KHR_TEXTURE_TRANSFORM]){const e=void 0!==n.extensions?n.extensions[Wd.KHR_TEXTURE_TRANSFORM]:void 0;if(e){const t=r.associations.get(a);a=r.extensions[Wd.KHR_TEXTURE_TRANSFORM].extendTexture(a,e),r.associations.set(a,t)}}return void 0!==i&&(a.colorSpace=i),e[t]=a,a}))}assignFinalMaterial(e){const t=e.geometry;let n=e.material;const i=void 0===t.attributes.tangent,r=void 0!==t.attributes.color,a=void 0===t.attributes.normal;if(e.isPoints){const e="PointsMaterial:"+n.uuid;let t=this.cache.get(e);t||(t=new Ko,xi.prototype.copy.call(t,n),t.color.copy(n.color),t.map=n.map,t.sizeAttenuation=!1,this.cache.add(e,t)),n=t}else if(e.isLine){const e="LineBasicMaterial:"+n.uuid;let t=this.cache.get(e);t||(t=new No,xi.prototype.copy.call(t,n),t.color.copy(n.color),t.map=n.map,this.cache.add(e,t)),n=t}if(i||r||a){let e="ClonedMaterial:"+n.uuid+":";i&&(e+="derivative-tangents:"),r&&(e+="vertex-colors:"),a&&(e+="flat-shading:");let t=this.cache.get(e);t||(t=n.clone(),r&&(t.vertexColors=!0),a&&(t.flatShading=!0),i&&(t.normalScale&&(t.normalScale.y*=-1),t.clearcoatNormalScale&&(t.clearcoatNormalScale.y*=-1)),this.cache.add(e,t),this.associations.set(t,this.associations.get(n))),n=t}e.material=n}getMaterialType(){return Tl}loadMaterial(e){const t=this,n=this.json,i=this.extensions,r=n.materials[e];let a;const s={},o=[];if((r.extensions||{})[Wd.KHR_MATERIALS_UNLIT]){const e=i[Wd.KHR_MATERIALS_UNLIT];a=e.getMaterialType(),o.push(e.extendParams(s,r,t))}else{const n=r.pbrMetallicRoughness||{};if(s.color=new gi(1,1,1),s.opacity=1,Array.isArray(n.baseColorFactor)){const e=n.baseColorFactor;s.color.setRGB(e[0],e[1],e[2],We),s.opacity=e[3]}void 0!==n.baseColorTexture&&o.push(t.assignTexture(s,"map",n.baseColorTexture,Ge)),s.metalness=void 0!==n.metallicFactor?n.metallicFactor:1,s.roughness=void 0!==n.roughnessFactor?n.roughnessFactor:1,void 0!==n.metallicRoughnessTexture&&(o.push(t.assignTexture(s,"metalnessMap",n.metallicRoughnessTexture)),o.push(t.assignTexture(s,"roughnessMap",n.metallicRoughnessTexture))),a=this._invokeOne((function(t){return t.getMaterialType&&t.getMaterialType(e)})),o.push(Promise.all(this._invokeAll((function(t){return t.extendMaterialParams&&t.extendMaterialParams(e,s)}))))}!0===r.doubleSided&&(s.side=2);const l=r.alphaMode||"OPAQUE";if("BLEND"===l?(s.transparent=!0,s.depthWrite=!1):(s.transparent=!1,"MASK"===l&&(s.alphaTest=void 0!==r.alphaCutoff?r.alphaCutoff:.5)),void 0!==r.normalTexture&&a!==yi&&(o.push(t.assignTexture(s,"normalMap",r.normalTexture)),s.normalScale=new _t(1,1),void 0!==r.normalTexture.scale)){const e=r.normalTexture.scale;s.normalScale.set(e,e)}if(void 0!==r.occlusionTexture&&a!==yi&&(o.push(t.assignTexture(s,"aoMap",r.occlusionTexture)),void 0!==r.occlusionTexture.strength&&(s.aoMapIntensity=r.occlusionTexture.strength)),void 0!==r.emissiveFactor&&a!==yi){const e=r.emissiveFactor;s.emissive=(new gi).setRGB(e[0],e[1],e[2],We)}return void 0!==r.emissiveTexture&&a!==yi&&o.push(t.assignTexture(s,"emissiveMap",r.emissiveTexture,Ge)),Promise.all(o).then((function(){const n=new a(s);return r.name&&(n.name=r.name),Eu(n,r),t.associations.set(n,{materials:e}),r.extensions&&Tu(i,n,r),n}))}createUniqueName(e){const t=Pc.sanitizeNodeName(e||"");return t in this.nodeNamesUsed?t+"_"+ ++this.nodeNamesUsed[t]:(this.nodeNamesUsed[t]=0,t)}loadGeometries(e){const t=this,n=this.extensions,i=this.primitiveCache;function r(e){return n[Wd.KHR_DRACO_MESH_COMPRESSION].decodePrimitive(e,t).then((function(n){return Iu(n,e,t)}))}const a=[];for(let n=0,s=e.length;n0&&Au(d,r),d.name=t.createUniqueName(r.name||"mesh_"+e),Eu(d,r),h.extensions&&Tu(i,d,h),t.assignFinalMaterial(d),l.push(d)}for(let n=0,i=l.length;n1?new Qs:1===t.length?t[0]:new Jn,s!==t[0])for(let e=0,n=t.length;e{const t=new Map;for(const[e,n]of i.associations)(e instanceof xi||e instanceof kt)&&t.set(e,n);return e.traverse((e=>{const n=i.associations.get(e);null!=n&&t.set(e,n)})),t})(r),r}))}_createAnimationTracks(e,t,n,i,r){const a=[],s=e.name?e.name:e.uuid,o=[];let l;switch(bu[r.path]===bu.weights?e.traverse((function(e){e.morphTargetInfluences&&o.push(e.name?e.name:e.uuid)})):o.push(s),bu[r.path]){case bu.weights:l=Hl;break;case bu.rotation:l=Gl;break;case bu.position:case bu.scale:l=jl;break;default:l=1===n.itemSize?Hl:jl}const c=void 0!==i.interpolation?Mu[i.interpolation]:ke,h=this._getArrayFromAccessor(n);for(let e=0,n=o.length;eMath.PI&&(n-=Hu),i<-Math.PI?i+=Hu:i>Math.PI&&(i-=Hu),this._spherical.theta=n<=i?Math.max(n,Math.min(i,this._spherical.theta)):this._spherical.theta>(n+i)/2?Math.max(n,this._spherical.theta):Math.min(i,this._spherical.theta)),this._spherical.phi=Math.max(this.minPolarAngle,Math.min(this.maxPolarAngle,this._spherical.phi)),this._spherical.makeSafe(),!0===this.enableDamping?this.target.addScaledVector(this._panOffset,this.dampingFactor):this.target.add(this._panOffset),this.target.sub(this.cursor),this.target.clampLength(this.minTargetRadius,this.maxTargetRadius),this.target.add(this.cursor);let r=!1;if(this.zoomToCursor&&this._performCursorZoom||this.object.isOrthographicCamera)this._spherical.radius=this._clampDistance(this._spherical.radius);else{const e=this._spherical.radius;this._spherical.radius=this._clampDistance(this._spherical.radius*this._scale),r=e!=this._spherical.radius}if(ku.setFromSpherical(this._spherical),ku.applyQuaternion(this._quatInverse),t.copy(this.target).add(ku),this.object.lookAt(this.target),!0===this.enableDamping?(this._sphericalDelta.theta*=1-this.dampingFactor,this._sphericalDelta.phi*=1-this.dampingFactor,this._panOffset.multiplyScalar(1-this.dampingFactor)):(this._sphericalDelta.set(0,0,0),this._panOffset.set(0,0,0)),this.zoomToCursor&&this._performCursorZoom){let e=null;if(this.object.isPerspectiveCamera){const t=ku.length();e=this._clampDistance(t*this._scale);const n=t-e;this.object.position.addScaledVector(this._dollyDirection,n),this.object.updateMatrixWorld(),r=!!n}else if(this.object.isOrthographicCamera){const t=new Yt(this._mouse.x,this._mouse.y,0);t.unproject(this.object);const n=this.object.zoom;this.object.zoom=Math.max(this.minZoom,Math.min(this.maxZoom,this.object.zoom/this._scale)),this.object.updateProjectionMatrix(),r=n!==this.object.zoom;const i=new Yt(this._mouse.x,this._mouse.y,0);i.unproject(this.object),this.object.position.sub(i).add(t),this.object.updateMatrixWorld(),e=ku.length()}else console.warn("WARNING: OrbitControls.js encountered an unknown camera type - zoom to cursor disabled."),this.zoomToCursor=!1;null!==e&&(this.screenSpacePanning?this.target.set(0,0,-1).transformDirection(this.object.matrix).multiplyScalar(e).add(this.object.position):(Fu.origin.copy(this.object.position),Fu.direction.set(0,0,-1).transformDirection(this.object.matrix),Math.abs(this.object.up.dot(Fu.direction))Gu||8*(1-this._lastQuaternion.dot(this.object.quaternion))>Gu||this._lastTargetPosition.distanceToSquared(this.target)>Gu)&&(this.dispatchEvent(Uu),this._lastPosition.copy(this.object.position),this._lastQuaternion.copy(this.object.quaternion),this._lastTargetPosition.copy(this.target),!0)}_getAutoRotationAngle(e){return null!==e?Hu/60*this.autoRotateSpeed*e:Hu/60/60*this.autoRotateSpeed}_getZoomScale(e){const t=Math.abs(.01*e);return Math.pow(.95,this.zoomSpeed*t)}_rotateLeft(e){this._sphericalDelta.theta-=e}_rotateUp(e){this._sphericalDelta.phi-=e}_panLeft(e,t){ku.setFromMatrixColumn(t,0),ku.multiplyScalar(-e),this._panOffset.add(ku)}_panUp(e,t){!0===this.screenSpacePanning?ku.setFromMatrixColumn(t,1):(ku.setFromMatrixColumn(t,0),ku.crossVectors(this.object.up,ku)),ku.multiplyScalar(e),this._panOffset.add(ku)}_pan(e,t){const n=this.domElement;if(this.object.isPerspectiveCamera){const i=this.object.position;ku.copy(i).sub(this.target);let r=ku.length();r*=Math.tan(this.object.fov/2*Math.PI/180),this._panLeft(2*e*r/n.clientHeight,this.object.matrix),this._panUp(2*t*r/n.clientHeight,this.object.matrix)}else this.object.isOrthographicCamera?(this._panLeft(e*(this.object.right-this.object.left)/this.object.zoom/n.clientWidth,this.object.matrix),this._panUp(t*(this.object.top-this.object.bottom)/this.object.zoom/n.clientHeight,this.object.matrix)):(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - pan disabled."),this.enablePan=!1)}_dollyOut(e){this.object.isPerspectiveCamera||this.object.isOrthographicCamera?this._scale/=e:(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled."),this.enableZoom=!1)}_dollyIn(e){this.object.isPerspectiveCamera||this.object.isOrthographicCamera?this._scale*=e:(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled."),this.enableZoom=!1)}_updateZoomParameters(e,t){if(!this.zoomToCursor)return;this._performCursorZoom=!0;const n=this.domElement.getBoundingClientRect(),i=e-n.left,r=t-n.top,a=n.width,s=n.height;this._mouse.x=i/a*2-1,this._mouse.y=-r/s*2+1,this._dollyDirection.set(this._mouse.x,this._mouse.y,1).unproject(this.object).sub(this.object.position).normalize()}_clampDistance(e){return Math.max(this.minDistance,Math.min(this.maxDistance,e))}_handleMouseDownRotate(e){this._rotateStart.set(e.clientX,e.clientY)}_handleMouseDownDolly(e){this._updateZoomParameters(e.clientX,e.clientX),this._dollyStart.set(e.clientX,e.clientY)}_handleMouseDownPan(e){this._panStart.set(e.clientX,e.clientY)}_handleMouseMoveRotate(e){this._rotateEnd.set(e.clientX,e.clientY),this._rotateDelta.subVectors(this._rotateEnd,this._rotateStart).multiplyScalar(this.rotateSpeed);const t=this.domElement;this._rotateLeft(Hu*this._rotateDelta.x/t.clientHeight),this._rotateUp(Hu*this._rotateDelta.y/t.clientHeight),this._rotateStart.copy(this._rotateEnd),this.update()}_handleMouseMoveDolly(e){this._dollyEnd.set(e.clientX,e.clientY),this._dollyDelta.subVectors(this._dollyEnd,this._dollyStart),this._dollyDelta.y>0?this._dollyOut(this._getZoomScale(this._dollyDelta.y)):this._dollyDelta.y<0&&this._dollyIn(this._getZoomScale(this._dollyDelta.y)),this._dollyStart.copy(this._dollyEnd),this.update()}_handleMouseMovePan(e){this._panEnd.set(e.clientX,e.clientY),this._panDelta.subVectors(this._panEnd,this._panStart).multiplyScalar(this.panSpeed),this._pan(this._panDelta.x,this._panDelta.y),this._panStart.copy(this._panEnd),this.update()}_handleMouseWheel(e){this._updateZoomParameters(e.clientX,e.clientY),e.deltaY<0?this._dollyIn(this._getZoomScale(e.deltaY)):e.deltaY>0&&this._dollyOut(this._getZoomScale(e.deltaY)),this.update()}_handleKeyDown(e){let t=!1;switch(e.code){case this.keys.UP:e.ctrlKey||e.metaKey||e.shiftKey?this._rotateUp(Hu*this.rotateSpeed/this.domElement.clientHeight):this._pan(0,this.keyPanSpeed),t=!0;break;case this.keys.BOTTOM:e.ctrlKey||e.metaKey||e.shiftKey?this._rotateUp(-Hu*this.rotateSpeed/this.domElement.clientHeight):this._pan(0,-this.keyPanSpeed),t=!0;break;case this.keys.LEFT:e.ctrlKey||e.metaKey||e.shiftKey?this._rotateLeft(Hu*this.rotateSpeed/this.domElement.clientHeight):this._pan(this.keyPanSpeed,0),t=!0;break;case this.keys.RIGHT:e.ctrlKey||e.metaKey||e.shiftKey?this._rotateLeft(-Hu*this.rotateSpeed/this.domElement.clientHeight):this._pan(-this.keyPanSpeed,0),t=!0}t&&(e.preventDefault(),this.update())}_handleTouchStartRotate(e){if(1===this._pointers.length)this._rotateStart.set(e.pageX,e.pageY);else{const t=this._getSecondPointerPosition(e),n=.5*(e.pageX+t.x),i=.5*(e.pageY+t.y);this._rotateStart.set(n,i)}}_handleTouchStartPan(e){if(1===this._pointers.length)this._panStart.set(e.pageX,e.pageY);else{const t=this._getSecondPointerPosition(e),n=.5*(e.pageX+t.x),i=.5*(e.pageY+t.y);this._panStart.set(n,i)}}_handleTouchStartDolly(e){const t=this._getSecondPointerPosition(e),n=e.pageX-t.x,i=e.pageY-t.y,r=Math.sqrt(n*n+i*i);this._dollyStart.set(0,r)}_handleTouchStartDollyPan(e){this.enableZoom&&this._handleTouchStartDolly(e),this.enablePan&&this._handleTouchStartPan(e)}_handleTouchStartDollyRotate(e){this.enableZoom&&this._handleTouchStartDolly(e),this.enableRotate&&this._handleTouchStartRotate(e)}_handleTouchMoveRotate(e){if(1==this._pointers.length)this._rotateEnd.set(e.pageX,e.pageY);else{const t=this._getSecondPointerPosition(e),n=.5*(e.pageX+t.x),i=.5*(e.pageY+t.y);this._rotateEnd.set(n,i)}this._rotateDelta.subVectors(this._rotateEnd,this._rotateStart).multiplyScalar(this.rotateSpeed);const t=this.domElement;this._rotateLeft(Hu*this._rotateDelta.x/t.clientHeight),this._rotateUp(Hu*this._rotateDelta.y/t.clientHeight),this._rotateStart.copy(this._rotateEnd)}_handleTouchMovePan(e){if(1===this._pointers.length)this._panEnd.set(e.pageX,e.pageY);else{const t=this._getSecondPointerPosition(e),n=.5*(e.pageX+t.x),i=.5*(e.pageY+t.y);this._panEnd.set(n,i)}this._panDelta.subVectors(this._panEnd,this._panStart).multiplyScalar(this.panSpeed),this._pan(this._panDelta.x,this._panDelta.y),this._panStart.copy(this._panEnd)}_handleTouchMoveDolly(e){const t=this._getSecondPointerPosition(e),n=e.pageX-t.x,i=e.pageY-t.y,r=Math.sqrt(n*n+i*i);this._dollyEnd.set(0,r),this._dollyDelta.set(0,Math.pow(this._dollyEnd.y/this._dollyStart.y,this.zoomSpeed)),this._dollyOut(this._dollyDelta.y),this._dollyStart.copy(this._dollyEnd);const a=.5*(e.pageX+t.x),s=.5*(e.pageY+t.y);this._updateZoomParameters(a,s)}_handleTouchMoveDollyPan(e){this.enableZoom&&this._handleTouchMoveDolly(e),this.enablePan&&this._handleTouchMovePan(e)}_handleTouchMoveDollyRotate(e){this.enableZoom&&this._handleTouchMoveDolly(e),this.enableRotate&&this._handleTouchMoveRotate(e)}_addPointer(e){this._pointers.push(e.pointerId)}_removePointer(e){delete this._pointerPositions[e.pointerId];for(let t=0;te&&(i.scale.set(1e-10,1e-10,1e-10),i.visible=!1),"Y"===i.name&&Math.abs(yp.copy(Pp).applyQuaternion(t).dot(this.eye))>e&&(i.scale.set(1e-10,1e-10,1e-10),i.visible=!1),"Z"===i.name&&Math.abs(yp.copy(Rp).applyQuaternion(t).dot(this.eye))>e&&(i.scale.set(1e-10,1e-10,1e-10),i.visible=!1),"XY"===i.name&&Math.abs(yp.copy(Rp).applyQuaternion(t).dot(this.eye)).9&&(i.visible=!1)),"Y"===this.axis&&(sp.setFromEuler(xp.set(0,0,Math.PI/2)),i.quaternion.copy(t).multiply(sp),Math.abs(yp.copy(Pp).applyQuaternion(t).dot(this.eye))>.9&&(i.visible=!1)),"Z"===this.axis&&(sp.setFromEuler(xp.set(0,Math.PI/2,0)),i.quaternion.copy(t).multiply(sp),Math.abs(yp.copy(Rp).applyQuaternion(t).dot(this.eye))>.9&&(i.visible=!1)),"XYZE"===this.axis&&(sp.setFromEuler(xp.set(0,Math.PI/2,0)),yp.copy(this.rotationAxis),i.quaternion.setFromRotationMatrix(wp.lookAt(Sp,yp,Pp)),i.quaternion.multiply(sp),i.visible=this.dragging),"E"===this.axis&&(i.visible=!1)):"START"===i.name?(i.position.copy(this.worldPositionStart),i.visible=this.dragging):"END"===i.name?(i.position.copy(this.worldPosition),i.visible=this.dragging):"DELTA"===i.name?(i.position.copy(this.worldPositionStart),i.quaternion.copy(this.worldQuaternionStart),rp.set(1e-10,1e-10,1e-10).add(this.worldPositionStart).sub(this.worldPosition).multiplyScalar(-1),rp.applyQuaternion(this.worldQuaternionStart.clone().invert()),i.scale.copy(rp),i.visible=this.dragging):(i.quaternion.copy(t),this.dragging?i.position.copy(this.worldPositionStart):i.position.copy(this.worldPosition),this.axis&&(i.visible=-1!==this.axis.search(i.name)))}super.updateMatrixWorld(e)}}class Op extends Zi{constructor(){super(new Sr(1e5,1e5,2,2),new yi({visible:!1,wireframe:!0,side:2,transparent:!0,opacity:.1,toneMapped:!1})),this.isTransformControlsPlane=!0,this.type="TransformControlsPlane"}updateMatrixWorld(e){let t=this.space;switch(this.position.copy(this.worldPosition),"scale"===this.mode&&(t="local"),Cp.copy(Ap).applyQuaternion("local"===t?this.worldQuaternion:Mp),Dp.copy(Pp).applyQuaternion("local"===t?this.worldQuaternion:Mp),Lp.copy(Rp).applyQuaternion("local"===t?this.worldQuaternion:Mp),yp.copy(Dp),this.mode){case"translate":case"scale":switch(this.axis){case"X":yp.copy(this.eye).cross(Cp),Tp.copy(Cp).cross(yp);break;case"Y":yp.copy(this.eye).cross(Dp),Tp.copy(Dp).cross(yp);break;case"Z":yp.copy(this.eye).cross(Lp),Tp.copy(Lp).cross(yp);break;case"XY":Tp.copy(Lp);break;case"YZ":Tp.copy(Cp);break;case"XZ":yp.copy(Lp),Tp.copy(Dp);break;case"XYZ":case"E":Tp.set(0,0,0)}break;default:Tp.set(0,0,0)}0===Tp.length()?this.quaternion.copy(this.cameraQuaternion):(Ep.lookAt(rp.set(0,0,0),Tp,yp),this.quaternion.setFromRotationMatrix(Ep)),super.updateMatrixWorld(e)}}class Np{constructor(e,t,n){this.renderer=e,this.canvas=n||this.renderer.domElement,this.camera=t,this.orbitControls=new Wu(t,this.canvas)}addTransformControl(e,t){const n=new up(this.camera,this.canvas);return n.addEventListener("dragging-changed",(e=>{this.orbitControls.enabled=!e.value})),n.attach(e),t.add(n.getHelper()),n}update(){this.orbitControls.update()}}class Fp extends Zi{constructor(e,t){super(new Sr(1,1,10,10),new El({color:Fp.alphaMap?0:16777215,transparent:!0,depthWrite:!1,polygonOffset:!0,name:"ShadowGroundPlaneMaterial"})),this.name="ShadowGroundPlane",this.userData.isFloor=!0,this.renderOrder=1,this.receiveShadow=!1,this.layers.disableAll(),t&&this.updateMaterial(t),this.setShadowMap(e)}setVisibility(e){this.visible=e,this.setVisibilityLayers(e)}setVisibilityLayers(e){e?this.layers.enableAll():this.layers.disableAll()}setDepthWrite(e){const t=this.material;t.depthWrite=e,t.transparent=!e,t.needsUpdate=!0,this.setVisibility(e)}setReceiveShadow(e){this.receiveShadow=e,this.setVisibility(e)}setShadowMap(e){const t=this.material;Fp.alphaMap?(t.alphaMap=e,t.map=null,t.color.set(0)):(t.alphaMap=null,t.map=e,t.color.set(16777215)),t.needsUpdate=!0}updateMaterial(e){const t=this.material;e.opacity&&t.opacity!==e.opacity&&(t.opacity=e.opacity),e.polygonOffset&&t.polygonOffsetFactor!==e.polygonOffset&&(t.polygonOffset=!0,t.polygonOffsetFactor=e.polygonOffset,t.polygonOffsetUnits=e.polygonOffset),t.needsUpdate=!0}}Fp.alphaMap=!0;class Bp extends eh{get renderPassManager(){return this._renderPassManager}get renderCacheManager(){return this._renderPassManager.renderCacheManager}get scene(){return this._renderPassManager.scene}get camera(){return this._renderPassManager.camera}get gBufferTextures(){return this._renderPassManager.gBufferRenderPass}get passRenderer(){return this._renderPassManager.passRenderer}constructor(e){super(),this._renderPassManager=e}render(e,t,n,i,r){this.renderPass(e)}}const zp="inputRgbNormal",kp="floatBufferNormal",Hp="separateBuffer",Vp="normalVectorAlpha",Gp=(e,t)=>{const n=Wp(e,t);let i="vec4[SAMPLES](";for(let t=0;t{const n=[];for(let i=0;i\n\t\t#include \n\n\t\t#ifndef FRAGMENT_OUTPUT\n\t\t#define FRAGMENT_OUTPUT vec4(vec3(ao), 1.)\n\t\t#endif\n\n\t\tconst vec4 sampleKernel[SAMPLES] = SAMPLE_VECTORS;\n\n\t\tvec3 getViewPosition(const in vec2 screenPosition, const in float depth) {\n\t\t\tvec4 clipSpacePosition = vec4(vec3(screenPosition, depth) * 2.0 - 1.0, 1.0);\n\t\t\tvec4 viewSpacePosition = cameraProjectionMatrixInverse * clipSpacePosition;\n\t\t\treturn viewSpacePosition.xyz / viewSpacePosition.w;\n\t\t}\n\n\t\tfloat getDepth(const vec2 uv) { \n\t\t\t#if DEPTH_BUFFER_ANTIALIAS == 1\n\t\t\t\tvec2 size = vec2(textureSize(tDepth, 0));\n\t\t\t\tivec2 p = ivec2(uv * size);\n\t\t\t\tfloat d0 = texelFetch(tDepth, p, 0).DEPTH_SWIZZLING;\n\t\t\t\tvec2 depth = vec2(d0, 1.0);\n\t\t\t\tfloat d1 = texelFetch(tDepth, p + ivec2(1, 0), 0).DEPTH_SWIZZLING;\n\t\t\t\tdepth += vec2(d1, 1.0) * step(abs(d1 - d0), 0.1);\n\t\t\t\tfloat d2 = texelFetch(tDepth, p - ivec2(1, 0), 0).DEPTH_SWIZZLING;\n\t\t\t\tdepth += vec2(d2, 1.0) * step(abs(d2 - d0), 0.1);\n\t\t\t\tfloat d3 = texelFetch(tDepth, p + ivec2(0, 1), 0).DEPTH_SWIZZLING;\n\t\t\t\tdepth += vec2(d3, 1.0) * step(abs(d3 - d0), 0.1);\n\t\t\t\tfloat d4 = texelFetch(tDepth, p - ivec2(0, 1), 0).DEPTH_SWIZZLING;\n\t\t\t\tdepth += vec2(d4, 1.0) * step(abs(d4 - d0), 0.1);\n\t\t\t\treturn depth.x / depth.y;\n \t#else\n \treturn textureLod(tDepth, uv.xy, 0.0).DEPTH_SWIZZLING;\n \t#endif\n\t\t}\n\n\t\tfloat fetchDepth(const ivec2 uv) { \n\t\t\treturn texelFetch(tDepth, uv.xy, 0).DEPTH_SWIZZLING;\n\t\t}\n\n\t\tfloat getViewZ(const in float depth) {\n\t\t\t#if PERSPECTIVE_CAMERA == 1\n\t\t\t\treturn perspectiveDepthToViewZ(depth, cameraNear, cameraFar);\n\t\t\t#else\n\t\t\t\treturn orthographicDepthToViewZ(depth, cameraNear, cameraFar);\n\t\t\t#endif\n\t\t}\n\n\t\tvec3 computeNormalFromDepth(const vec2 uv) {\n vec2 size = vec2(textureSize(tDepth, 0));\n ivec2 p = ivec2(uv * size);\n float c0 = fetchDepth(p);\n float l2 = fetchDepth(p - ivec2(2, 0));\n float l1 = fetchDepth(p - ivec2(1, 0));\n float r1 = fetchDepth(p + ivec2(1, 0));\n float r2 = fetchDepth(p + ivec2(2, 0));\n float b2 = fetchDepth(p - ivec2(0, 2));\n float b1 = fetchDepth(p - ivec2(0, 1));\n float t1 = fetchDepth(p + ivec2(0, 1));\n float t2 = fetchDepth(p + ivec2(0, 2));\n float dl = abs((2.0 * l1 - l2) - c0);\n float dr = abs((2.0 * r1 - r2) - c0);\n float db = abs((2.0 * b1 - b2) - c0);\n float dt = abs((2.0 * t1 - t2) - c0);\n vec3 ce = getViewPosition(uv, c0).xyz;\n vec3 dpdx = (dl < dr) ? ce - getViewPosition((uv - vec2(1.0 / size.x, 0.0)), l1).xyz\n : -ce + getViewPosition((uv + vec2(1.0 / size.x, 0.0)), r1).xyz;\n vec3 dpdy = (db < dt) ? ce - getViewPosition((uv - vec2(0.0, 1.0 / size.y)), b1).xyz\n : -ce + getViewPosition((uv + vec2(0.0, 1.0 / size.y)), t1).xyz;\n return normalize(cross(dpdx, dpdy));\n\t\t}\n\n\t\tvec3 getViewNormal(const vec2 uv) {\n\t\t\t#if NORMAL_VECTOR_TYPE == 2\n\t\t\t\treturn normalize(textureLod(tNormal, uv, 0.).rgb);\n\t\t\t#elif NORMAL_VECTOR_TYPE == 1\n\t\t\t\treturn unpackRGBToNormal(textureLod(tNormal, uv, 0.).rgb);\n\t\t\t#else\n\t\t\t\treturn computeNormalFromDepth(uv);\n\t\t\t#endif\n\t\t}\n\n\t\tvec3 getAntiAliasedViewNormal(const in vec2 screenPosition) {\n\t\t\t#if NORMAL_VECTOR_TYPE == 2\n\t\t\t\t#if NORMAL_VECTOR_ANTIALIAS == 1\n\t\t\t\t\tvec2 uv = screenPosition;\n\t\t\t\t\tvec2 size = vec2(textureSize(tNormal, 0));\n\t\t\t\t\tivec2 p = ivec2(screenPosition * size);\n\t\t\t\t\tfloat c0 = texelFetch(tNormal, p, 0).a;\n\t\t\t\t\tfloat l2 = texelFetch(tNormal, p - ivec2(2, 0), 0).a;\n\t\t\t\t\tfloat l1 = texelFetch(tNormal, p - ivec2(1, 0), 0).a;\n\t\t\t\t\tfloat r1 = texelFetch(tNormal, p + ivec2(1, 0), 0).a;\n\t\t\t\t\tfloat r2 = texelFetch(tNormal, p + ivec2(2, 0), 0).a;\n\t\t\t\t\tfloat b2 = texelFetch(tNormal, p - ivec2(0, 2), 0).a;\n\t\t\t\t\tfloat b1 = texelFetch(tNormal, p - ivec2(0, 1), 0).a;\n\t\t\t\t\tfloat t1 = texelFetch(tNormal, p + ivec2(0, 1), 0).a;\n\t\t\t\t\tfloat t2 = texelFetch(tNormal, p + ivec2(0, 2), 0).a;\n\t\t\t\t\tfloat dl = abs((2.0 * l1 - l2) - c0);\n\t\t\t\t\tfloat dr = abs((2.0 * r1 - r2) - c0);\n\t\t\t\t\tfloat db = abs((2.0 * b1 - b2) - c0);\n\t\t\t\t\tfloat dt = abs((2.0 * t1 - t2) - c0);\n\t\t\t\t\tvec3 ce = getViewPosition(uv, c0).xyz;\n\t\t\t\t\tvec3 dpdx = (dl < dr) ? ce - getViewPosition((uv - vec2(1.0 / size.x, 0.0)), l1).xyz\n\t\t\t\t\t\t\t\t\t\t : -ce + getViewPosition((uv + vec2(1.0 / size.x, 0.0)), r1).xyz;\n\t\t\t\t\tvec3 dpdy = (db < dt) ? ce - getViewPosition((uv - vec2(0.0, 1.0 / size.y)), b1).xyz\n\t\t\t\t\t\t\t\t\t\t : -ce + getViewPosition((uv + vec2(0.0, 1.0 / size.y)), t1).xyz;\n\t\t\t\t\treturn normalize(cross(dpdx, dpdy));\n\t\t\t\t#elif NORMAL_VECTOR_ANTIALIAS == 2\n\t\t\t\t\tvec2 size = vec2(textureSize(tNormal, 0));\n\t\t\t\t\tivec2 p = ivec2(screenPosition * size);\n\t\t\t\t\tvec3 normalVector = texelFetch(tNormal, p, 0).xyz;\n\t\t\t\t\tnormalVector += texelFetch(tNormal, p + ivec2(1, 0), 0).xyz;\n\t\t\t\t\tnormalVector += texelFetch(tNormal, p - ivec2(1, 0), 0).xyz;\n\t\t\t\t\tnormalVector += texelFetch(tNormal, p + ivec2(0, 1), 0).xyz;\n\t\t\t\t\tnormalVector += texelFetch(tNormal, p - ivec2(0, 1), 0).xyz;\n\t\t\t\t\treturn normalize(normalVector);\n\t\t\t\t#else\n\t\t\t\t\treturn texture2D(tNormal, screenPosition).xyz;\n\t\t\t\t#endif\n\t\t\t#elif NORMAL_VECTOR_TYPE == 1\n\t\t\t\treturn unpackRGBToNormal(textureLod(tNormal, screenPosition, 0.).rgb);\n\t\t\t#else\n\t\t\t\treturn computeNormalFromDepth(screenPosition);\n\t\t\t#endif\n\t\t }\n\n\t\tvec3 getSceneUvAndDepth(vec3 sampleViewPos) {\n\t\t\tvec4 sampleClipPos = cameraProjectionMatrix * vec4(sampleViewPos, 1.);\n\t\t\tvec2 sampleUv = sampleClipPos.xy / sampleClipPos.w * 0.5 + 0.5;\n\t\t\tfloat sampleSceneDepth = getDepth(sampleUv);\n\t\t\treturn vec3(sampleUv, sampleSceneDepth);\n\t\t}\n\n\t\tfloat sinusToPlane(vec3 pointOnPlane, vec3 planeNormal, vec3 point) {\n\t\t\tvec3 delta = point - pointOnPlane;\n\t\t\tfloat sinV = dot(planeNormal, normalize(delta));\n\t\t\treturn sinV;\n\t\t}\n\n\t\tfloat getFallOff(float delta, float falloffDistance) {\n\t\t\tfloat fallOff = smoothstep(0., 1., 1. - distanceFallOff * abs(delta) / falloffDistance);\n\t\t\treturn fallOff;\n\t\t}\n\t\t\n\t\tvoid main() {\n\t\t\tfloat depth = getDepth(vUv.xy);\n\t\t\tif (depth >= 1.0) {\n\t\t\t\tdiscard;\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tvec3 viewPos = getViewPosition(vUv, depth);\n\t\t\tvec3 viewNormal = getAntiAliasedViewNormal(vUv);\n\n\t\t\tfloat radiusToUse = radius;\n\t\t\tfloat distanceFalloffToUse = thickness;\n\t\t\t#if SCREEN_SPACE_RADIUS == 1\n\t\t\t float radiusScale = getViewPosition(vec2(0.5 + float(SCREEN_SPACE_RADIUS_SCALE) / resolution.x, 0.0), depth).x;\n\t\t\t\tradiusToUse *= radiusScale;\n\t\t\t\tdistanceFalloffToUse *= radiusScale;\n\t\t\t#endif\n\n\t\t\t#if SCENE_CLIP_BOX == 1\n\t\t\t\tvec3 worldPos = (cameraWorldMatrix * vec4(viewPos, 1.0)).xyz;\n \t\t\tfloat boxDistance = length(max(vec3(0.0), max(sceneBoxMin - worldPos, worldPos - sceneBoxMax)));\n\t\t\t\tif (boxDistance > radiusToUse) {\n\t\t\t\t\tdiscard;\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t#endif\n\t\t\t\n\t\t\tvec2 noiseResolution = vec2(textureSize(tNoise, 0));\n\t\t\tvec2 noiseUv = vUv * resolution / noiseResolution;\n\t\t\tvec4 noiseTexel = textureLod(tNoise, noiseUv, 0.0);\n\t\t\tvec3 randomVec = noiseTexel.xyz * 2.0 - 1.0;\n\n\t\t\t#if NV_ALIGNED_SAMPLES == 1\n \t\t\t\tvec3 tangent = normalize(randomVec - viewNormal * dot(randomVec, viewNormal));\n \t\t\tvec3 bitangent = cross(viewNormal, tangent);\n \t\t\tmat3 kernelMatrix = mat3(tangent, bitangent, viewNormal);\n\t\t\t#else\n\t\t\t\tvec3 tangent = normalize(vec3(randomVec.xy, 0.));\n\t\t\t\tvec3 bitangent = vec3(-tangent.y, tangent.x, 0.);\n\t\t\t\tmat3 kernelMatrix = mat3(tangent, bitangent, vec3(0., 0., 1.));\n\t\t\t#endif\n\n\t\t#if AO_ALGORITHM == 4\n\t\t\tconst int DIRECTIONS = SAMPLES < 30 ? 3 : 5;\n\t\t\tconst int STEPS = (SAMPLES + DIRECTIONS - 1) / DIRECTIONS;\n\t\t#elif AO_ALGORITHM == 3\n\t\t\tconst int DIRECTIONS = SAMPLES < 16 ? 3 : 5;\n\t\t\tconst int STEPS = (SAMPLES + DIRECTIONS - 1) / DIRECTIONS;\n\t\t#else\n\t\t\tconst int DIRECTIONS = SAMPLES;\n\t\t\tconst int STEPS = 1;\n\t\t#endif\n\n\t\t\tfloat ao = 0.0, totalWeight = 0.0;\n\t\t\tfor (int i = 0; i < DIRECTIONS; ++i) {\n\n\t\t\t#if AO_ALGORITHM == 4\n\t\t\t\tfloat angle = float(i) / float(DIRECTIONS) * PI;\n\t\t\t\tvec4 sampleDir = vec4(cos(angle), sin(angle), 0., 0.5 + 0.5 * noiseTexel.w); \n\t\t\t#elif AO_ALGORITHM == 3\n\t\t\t\tfloat angle = float(i) / float(DIRECTIONS) * 2. * PI;\n\t\t\t\tvec4 sampleDir = vec4(cos(angle), sin(angle), 0., 0.5 + 0.5 * noiseTexel.w); \n\t\t\t#else\n\t\t\t\tvec4 sampleDir = sampleKernel[i];\n\t\t\t#endif\n\t\t\t\tsampleDir.xyz = normalize(kernelMatrix * sampleDir.xyz);\n\n\t\t\t\tvec3 viewDir = normalize(-viewPos.xyz);\n\t\t\t\tvec3 sliceBitangent = normalize(cross(sampleDir.xyz, viewDir));\n\t\t\t\tvec3 sliceTangent = cross(sliceBitangent, viewDir);\n\t\t\t\tvec3 normalInSlice = normalize(viewNormal - sliceBitangent * dot(viewNormal, sliceBitangent));\n\t\t\t\t\n\t\t\t#if (AO_ALGORITHM == 3 || AO_ALGORITHM == 4)\n\t\t\t\tvec3 tangentToNormalInSlice = cross(normalInSlice, sliceBitangent);\n\t\t\t\t#if AO_ALGORITHM == 4\n\t\t\t\t\tvec2 cosHorizons = vec2(dot(viewDir, tangentToNormalInSlice), dot(viewDir, -tangentToNormalInSlice));\n\t\t\t\t#else\n\t\t\t\t\tvec2 cosHorizons = vec2(dot(viewDir, tangentToNormalInSlice));\n\t\t\t\t#endif\n\t\t\t\tfor (int j = 0; j < STEPS; ++j) {\n\t\t\t\t\tvec3 sampleViewOffset = sampleDir.xyz * radiusToUse * sampleDir.w * pow(float(j + 1) / float(STEPS), distanceExponent);\n\t\t\t\t\tvec3 sampleViewPos = viewPos + sampleViewOffset;\n\t\t\t#else\n\t\t\t\t\tvec3 sampleViewPos = viewPos + sampleDir.xyz * radiusToUse * pow(sampleDir.w, distanceExponent);\n\t\t\t#endif\t\n\n\t\t\t\t\tvec3 sampleSceneUvDepth = getSceneUvAndDepth(sampleViewPos);\n\t\t\t\t\tvec3 sampleSceneViewPos = getViewPosition(sampleSceneUvDepth.xy, sampleSceneUvDepth.z);\n\t\t\t\t\tfloat sceneSampleDist = abs(sampleSceneViewPos.z);\n\t\t\t\t\tfloat sampleDist = abs(sampleViewPos.z);\n\t\t\t\t\t\n\t\t\t\t#if (AO_ALGORITHM == 3 || AO_ALGORITHM == 4)\n\t\t\t\t\t// HBAO || GTAO\n\t\t\t\t\tvec3 viewDelta = sampleSceneViewPos - viewPos;\n\t\t\t\t\tif (abs(viewDelta.z) < thickness) {\n\t\t\t\t\t\tvec2 clipRangeCheck = step(0., sampleSceneUvDepth.xy) * step(sampleSceneUvDepth.xy, vec2(1.));\n\t\t\t\t\t\tfloat sampleCosHorizon = dot(viewDir, normalize(viewDelta));\n\t\t\t\t\t\tcosHorizons.x += max(0., (sampleCosHorizon - cosHorizons.x) * mix(1., 2. / float(j + 2), distanceFallOff) * clipRangeCheck.x * clipRangeCheck.y);\n\t\t\t\t\t}\t\t\n\t\t\t\t\t#if AO_ALGORITHM == 4\n\t\t\t\t\t\tsampleSceneUvDepth = getSceneUvAndDepth(viewPos - sampleViewOffset);\n\t\t\t\t\t\tsampleSceneViewPos = getViewPosition(sampleSceneUvDepth.xy, sampleSceneUvDepth.z);\n\t\t\t\t\t\tviewDelta = sampleSceneViewPos - viewPos;\n\t\t\t\t\t\tif (abs(viewDelta.z) < thickness) {\n\t\t\t\t\t\t\tvec2 clipRangeCheck = step(0., sampleSceneUvDepth.xy) * step(sampleSceneUvDepth.xy, vec2(1.));\n\t\t\t\t\t\t\tfloat sampleCosHorizon = dot(viewDir, normalize(viewDelta));\n\t\t\t\t\t\t\tcosHorizons.y += max(0., (sampleCosHorizon - cosHorizons.y) * mix(1., 2. / float(j + 2), distanceFallOff) * clipRangeCheck.x * clipRangeCheck.y);\t\n\t\t\t\t\t\t}\n\t\t\t\t\t#endif\n\t\t\t\t#elif AO_ALGORITHM == 2\n\t\t\t\t\t// N8AO\n\t\t\t\t\tfloat weight = dot(viewNormal, sampleDir.xyz);\n\t\t\t\t\tfloat occlusion = weight * step(sceneSampleDist + bias, sampleDist);\n\t\t\t\t#elif AO_ALGORITHM == 1\n\t\t\t\t\t// SAO\n\t\t\t\t\tvec3 viewDelta = sampleSceneViewPos - viewPos;\n\t\t\t\t\tfloat minResolution = 0.; // ?\n\t\t\t\t\tfloat scaledViewDist = length( viewDelta ) / scale;\n\t\t\t\t\tfloat weight = 1.;\n\t\t\t\t\tfloat occlusion = max(0., (dot(viewNormal, viewDelta) - minResolution) / scaledViewDist - bias) / (1. + scaledViewDist * scaledViewDist );\n\t\t\t\t#else\n\t\t\t\t\t// SSAO\n\t\t\t\t\tfloat weight = 1.;\n\t\t\t\t\tfloat occlusion = step(sceneSampleDist + bias, sampleDist);\n\t\t\t\t#endif\n\n\t\t#if AO_ALGORITHM == 4\t\n\t\t\t\t}\n\t\t\t\t// GTAO\n\t\t\t\tvec2 sinHorizons = sqrt(1. - cosHorizons * cosHorizons);\n\t\t\t\tfloat nx = dot(normalInSlice, sliceTangent);\n\t\t\t\tfloat ny = dot(normalInSlice, viewDir);\n\t\t\t\tfloat nxb = 1. / 2. * (acos(cosHorizons.y) - acos(cosHorizons.x) + sinHorizons.x * cosHorizons.x - sinHorizons.y * cosHorizons.y);\n\t\t\t\tfloat nyb = 1. / 2. * (2. - cosHorizons.x * cosHorizons.x - cosHorizons.y * cosHorizons.y);\n\t\t\t\tfloat occlusion = nx * nxb + ny * nyb;\n\t\t\t\tao += occlusion;\n\t\t\t}\n\t\t\tao = clamp(ao / float(DIRECTIONS), 0., 1.);\t\n\t\t#elif AO_ALGORITHM == 3\n\t\t\t\t}\n\t\t\t\ttotalWeight += 1.;\n\t\t\t\tao += max(0., cosHorizons.x - max(0., cosHorizons.y));\n\t\t\t}\n\t\t\tao /= totalWeight + 1. - step(0., totalWeight);\n\t\t\tao = clamp(1. - ao, 0., 1.);\n\t\t#else\n\n\t\t\t\tfloat fallOff = getFallOff(sceneSampleDist - sampleDist, distanceFalloffToUse);\n\t\t\t\tocclusion *= fallOff;\n\t\t\t\tvec2 diff = (vUv - sampleSceneUvDepth.xy) * resolution;\n\t\t\t\tocclusion *= step(1., dot(diff, diff));\n\t\t\t\tvec2 clipRangeCheck = step(0., sampleSceneUvDepth.xy) * step(sampleSceneUvDepth.xy, vec2(1.));\n\t\t\t\tocclusion *= clipRangeCheck.x * clipRangeCheck.y;\n\t\t\t\tweight *= clipRangeCheck.x * clipRangeCheck.y;\n\t\t\t\ttotalWeight += weight;\n\t\t\t\tao += occlusion;\n\t\t\t}\n\t\t\tao /= totalWeight + 1. - step(0., totalWeight);\n\t\t\tao = clamp(1. - ao, 0., 1.);\n\t\t#endif\t\n\n\t\t#if SCENE_CLIP_BOX == 1\n\t\t\tao = mix(ao, 1., smoothstep(0., radiusToUse, boxDistance));\n\t\t#endif\n\t\t#if AO_ALGORITHM != 1\n\t\t\tao = pow(ao, scale);\n\t\t#endif\n\t\t\tgl_FragColor = FRAGMENT_OUTPUT;\n\t\t}"},Xp={resolutionScale:1,algorithm:0,samples:32,radius:.25,distanceExponent:2,thickness:.5,distanceFallOff:.5,scale:1,bias:.01,screenSpaceRadius:!1};class Yp{get texture(){var e;return this._renderTarget?null===(e=this._renderTarget)||void 0===e?void 0:e.texture:null}constructor(e,t,n,i,r){this.needsUpdate=!0,this.parameters=Object.assign({},Xp),this._width=0,this._height=0,this._samples=0,this._gBufferAntiAliasing=!1,this._normalVectorSourceType=kp,this._depthValueSourceType=Vp,this._modulateRedChannel=!1,this.depthTexture=null,this.normalTexture=null,this._noiseTexture=null,this._renderTarget=null,this._passRenderer=new dh,this._sceneClipBox=new Kt(new Yt(-1,-1,-1),new Yt(1,1,1)),this._sceneScale=1,this._width=e,this._height=t,this._samples=n,this._gBufferAntiAliasing=i,this._normalVectorSourceType=(null==r?void 0:r.normalVectorSourceType)||kp,this._depthValueSourceType=(null==r?void 0:r.depthValueSourceType)||Vp,this._modulateRedChannel=(null==r?void 0:r.modulateRedChannel)||!1,(null==r?void 0:r.aoParameters)&&(this.parameters=r.aoParameters),r&&this.updateTextures(r)}_getNoiseTexture(e=64){if(!this._noiseTexture){const t=new rh,n=new Uint8Array(e*e*4);for(let i=0;i{const t=new rh,n=Math.floor(e)%2==0?Math.floor(e)+1:Math.floor(e),i=(e=>{const t=Math.floor(e)%2==0?Math.floor(e)+1:Math.floor(e),n=t*t,i=Array(n).fill(0);let r=Math.floor(t/2),a=t-1;for(let e=1;e<=n;)-1===r&&a===t?(a=t-2,r=0):(a===t&&(a=0),r<0&&(r=t-1)),0===i[r*t+a]?(i[r*t+a]=e++,a++,r--):(a-=2,r++);return i})(n),r=i.length,a=new Uint8Array(4*r);for(let n=0;n{const r=Jp(e,t,n,i);let a="vec3[SAMPLES](";for(let t=0;t{const r=[];for(let a=0;a\n#include \n\n#if LUMINANCE_WEIGHTED == 1 \n\n#ifndef LUMINANCE_TYPE\n#define LUMINANCE_TYPE float\n#endif\n#ifndef SAMPLE_LUMINANCE\n#define SAMPLE_LUMINANCE dot(vec3(0.2125, 0.7154, 0.0721), a)\n#endif\n#define WEIGHT_TYPE LUMINANCE_TYPE\n\n#else\n#define WEIGHT_TYPE float\n#endif\n\n#ifndef FRAGMENT_OUTPUT\n#define FRAGMENT_OUTPUT vec4(vec3(denoised), 1.)\n#endif\n\nLUMINANCE_TYPE getLuminance(const in vec3 a) {\n return SAMPLE_LUMINANCE;\n}\n\nconst vec3 poissonDisk[SAMPLES] = SAMPLE_VECTORS;\n\nvec3 getViewPosition(const in vec2 screenPosition, const in float depth) {\n vec4 clipSpacePosition = vec4(vec3(screenPosition, depth) * 2.0 - 1.0, 1.0);\n vec4 viewSpacePosition = cameraProjectionMatrixInverse * clipSpacePosition;\n return viewSpacePosition.xyz / viewSpacePosition.w;\n}\n\nfloat getDepth(const vec2 uv) {\n#if DEPTH_VALUE_SOURCE == 1 \n return textureLod(tDepth, uv.xy, 0.0).a;\n#else\n return textureLod(tDepth, uv.xy, 0.0).r;\n#endif\n}\n\nfloat fetchDepth(const ivec2 uv) {\n#if DEPTH_VALUE_SOURCE == 1 \n return texelFetch(tDepth, uv.xy, 0).a;\n#else\n return texelFetch(tDepth, uv.xy, 0).r;\n#endif\n}\n\nvec3 computeNormalFromDepth(const vec2 uv) {\n vec2 size = vec2(textureSize(tDepth, 0));\n ivec2 p = ivec2(uv * size);\n float c0 = fetchDepth(p);\n float l2 = fetchDepth(p - ivec2(2, 0));\n float l1 = fetchDepth(p - ivec2(1, 0));\n float r1 = fetchDepth(p + ivec2(1, 0));\n float r2 = fetchDepth(p + ivec2(2, 0));\n float b2 = fetchDepth(p - ivec2(0, 2));\n float b1 = fetchDepth(p - ivec2(0, 1));\n float t1 = fetchDepth(p + ivec2(0, 1));\n float t2 = fetchDepth(p + ivec2(0, 2));\n float dl = abs((2.0 * l1 - l2) - c0);\n float dr = abs((2.0 * r1 - r2) - c0);\n float db = abs((2.0 * b1 - b2) - c0);\n float dt = abs((2.0 * t1 - t2) - c0);\n vec3 ce = getViewPosition(uv, c0).xyz;\n vec3 dpdx = (dl < dr) ? ce - getViewPosition((uv - vec2(1.0 / size.x, 0.0)), l1).xyz\n : -ce + getViewPosition((uv + vec2(1.0 / size.x, 0.0)), r1).xyz;\n vec3 dpdy = (db < dt) ? ce - getViewPosition((uv - vec2(0.0, 1.0 / size.y)), b1).xyz\n : -ce + getViewPosition((uv + vec2(0.0, 1.0 / size.y)), t1).xyz;\n return normalize(cross(dpdx, dpdy));\n}\n\nvec3 getViewNormal(const vec2 uv) {\n#if NORMAL_VECTOR_TYPE == 2\n return normalize(textureLod(tNormal, uv, 0.).rgb);\n#elif NORMAL_VECTOR_TYPE == 1\n return unpackRGBToNormal(textureLod(tNormal, uv, 0.).rgb);\n#else\n return computeNormalFromDepth(uv);\n#endif\n}\n\nvoid denoiseSample(in vec3 center, in vec3 viewNormal, in vec3 viewPos, in vec2 sampleUv, inout vec3 denoised, inout WEIGHT_TYPE totalWeight) {\n vec4 sampleTexel = textureLod(tDiffuse, sampleUv, 0.0);\n float sampleDepth = getDepth(sampleUv);\n vec3 sampleNormal = getViewNormal(sampleUv);\n vec3 neighborColor = sampleTexel.rgb;\n vec3 viewPosSample = getViewPosition(sampleUv, sampleDepth);\n \n float normalDiff = dot(viewNormal, sampleNormal);\n float normalSimilarity = pow(max(normalDiff, 0.), normalPhi);\n float depthDiff = abs(dot(normalize(viewPos - viewPosSample), viewNormal));\n float depthSimilarity = max(1. - depthDiff / depthPhi, 0.);\n #if LUMINANCE_WEIGHTED == 1 \n LUMINANCE_TYPE lumaDiff = abs(getLuminance(neighborColor) - getLuminance(center));\n LUMINANCE_TYPE lumaSimilarity = max(1. - lumaDiff / lumaPhi, 0.);\n LUMINANCE_TYPE w = lumaSimilarity * depthSimilarity * normalSimilarity;\n #else\n WEIGHT_TYPE w = depthSimilarity * normalSimilarity;\n #endif\n\n denoised += w * neighborColor;\n totalWeight += w;\n}\n\nvoid main() {\n float depth = fetchDepth(ivec2(vec2(textureSize(tDepth, 0)) * vUv.xy));\t\n vec3 viewNormal = getViewNormal(vUv);\t\n if (depth == 1. || dot(viewNormal, viewNormal) == 0.) {\n discard;\n return;\n }\n vec4 texel = textureLod(tDiffuse, vUv, 0.0);\n vec3 center = texel.rgb;\n vec3 viewPos = getViewPosition(vUv, depth);\n\n #if SCENE_CLIP_BOX == 1\n vec3 worldPos = (cameraWorldMatrix * vec4(viewPos, 1.0)).xyz;\n float boxDistance = length(max(vec3(0.0), max(sceneBoxMin - worldPos, worldPos - sceneBoxMax)));\n if (boxDistance > radius * 2.) {\n discard;\n return;\n }\n\t\t#endif\n\n vec2 noiseResolution = vec2(textureSize(tNoise, 0));\n vec2 noiseUv = vUv * resolution / noiseResolution;\n vec4 noiseTexel = textureLod(tNoise, noiseUv, 0.0);\n vec2 noiseVec = vec2(sin(noiseTexel[iteration % 4] * 2. * PI), cos(noiseTexel[iteration % 4] * 2. * PI));\n #if SAMPLE_DISTRIBUTION == 1\n vec3 randomVec = normalize(vec3(noiseVec.xy, 0.));\n vec3 tangent = normalize(randomVec - viewNormal * dot(randomVec, viewNormal));\n vec3 bitangent = cross(viewNormal, tangent);\n mat3 kernelMatrix = mat3(tangent, bitangent, viewNormal);\n #else\n mat2 rotationMatrix = mat2(noiseVec.x, -noiseVec.y, noiseVec.x, noiseVec.y);\n #endif\n\n WEIGHT_TYPE totalWeight = WEIGHT_TYPE(1.);\n vec3 denoised = texel.rgb;\n for (int i = 0; i < SAMPLES; i++) {\n vec3 sampleDir = poissonDisk[i];\n #if SAMPLE_DISTRIBUTION == 1\n vec3 offsetViewPos = viewPos + normalize(kernelMatrix * vec3(sampleDir.xy, 0.)) * sampleDir.z * radius * radius;\n vec4 samplePointNDC = cameraProjectionMatrix * vec4(offsetViewPos, 1.0); \n vec2 sampleUv = (samplePointNDC.xy / samplePointNDC.w * 0.5 + 0.5);\n #else\n vec2 offset = rotationMatrix * sampleDir.xy * (1. + sampleDir.z * (radius - 1.));\n offset *= mix(vec2(1.0), sqrt(1.0 - viewNormal.xy * viewNormal.xy), float(iteration) / float(noOfIterations-1));\n offset *= max(1.0, 1.0 / length(offset));\n vec2 sampleUv = vUv + offset / resolution;\n #endif\n denoiseSample(center, viewNormal, viewPos, sampleUv, denoised, totalWeight);\n }\n\n denoised /= totalWeight + 1.0 - step(0.0, totalWeight);\n gl_FragColor = FRAGMENT_OUTPUT;\n}"},$p={iterations:2,samples:16,rings:2.89,radiusExponent:1.3,radius:4,lumaPhi:10,depthPhi:2.5,normalPhi:.5,nvOrientatedSamples:!1};class ef{get texture(){return this.parameters.iterations>0&&this._renderTargets.length>0?this._renderTargets[this._outputRenderTargetIndex].texture:this._inputTexture}set inputTexture(e){this._inputTexture=e}constructor(e,t,n,i){this.needsUpdate=!0,this.parameters=Object.assign({},$p),this._width=0,this._height=0,this._samples=0,this._normalVectorSourceType=kp,this._depthValueSourceType=Vp,this._inputTexture=null,this.depthTexture=null,this.normalTexture=null,this._noiseTexture=null,this._renderTargets=[],this._outputRenderTargetIndex=0,this._passRenderer=new dh,this._rgInputTexture=!1,this._luminanceWeighted=!0,this._width=e,this._height=t,this._samples=n,this._normalVectorSourceType=(null==i?void 0:i.normalVectorSourceType)||kp,this._depthValueSourceType=(null==i?void 0:i.depthValueSourceType)||Vp,this._inputTexture=(null==i?void 0:i.inputTexture)||null,this.depthTexture=(null==i?void 0:i.depthTexture)||null,this.normalTexture=(null==i?void 0:i.normalTexture)||null,this._rgInputTexture=(null==i?void 0:i.rgInputTexture)||!1,this._luminanceWeighted=!0===(null==i?void 0:i.luminanceWeighted),this._luminanceType=(null==i?void 0:i.luminanceType)||"vec3",this._sampleLuminance=(null==i?void 0:i.sampleLuminance)||"a",this._fragmentOutput=(null==i?void 0:i.fragmentOutput)||"vec4(denoised.xyz, 1.)",(null==i?void 0:i.poissonDenoisePassParameters)&&(this.parameters=i.poissonDenoisePassParameters),i&&this.updateTextures(i)}_getNoiseTexture(e=64){if(!this._noiseTexture){const t=new rh,n=new Uint8Array(e*e*4);for(let i=0;ie.dispose()))}setSize(e,t){this._width=e,this._height=t,this._renderTargets.forEach((n=>n.setSize(e,t))),this.needsUpdate=!0}updateBounds(e){this._sceneClipBox=(new Kt).copy(e),this.needsUpdate=!0}updateParameters(e){for(const t in e)this.parameters.hasOwnProperty(t)&&(this.parameters[t]=e[t],this.needsUpdate=!0)}updateTextures(e){e.inputTexture&&(this._inputTexture=e.inputTexture,this.needsUpdate=!0),e.depthTexture&&(this.depthTexture=e.depthTexture,this.needsUpdate=!0),e.normalTexture&&(this.normalTexture=e.normalTexture,this.needsUpdate=!0)}render(e,t){const n=this._getMaterial(t,this.needsUpdate);this.needsUpdate=!1;const i=this._getRenderTargets();n.uniforms.iteration.value=this.parameters.iterations;for(let t=0;t.001,r=e===nf&&t>.001&&t<.999;return{fadeInPoissonShadow:i,fadeInHardShadow:r,onlyHardShadow:e===nf&&!r,progressiveDenoise:!i&&!r&&n>1&&n<=this.parameters.progressiveDenoiseIterations+1}}renderPass(e){if(!this._setRenderState())return;const t=this._getRenderConditions(this.shadowAndAoPassSettings.shadowFadeInBlurType,this.shadowAndAoPassSettings.shadowFadeInMix,this.shadowAndAoPassSettings.noOStaticFrames);let n=!1;!t.onlyHardShadow&&this.shadowAndAoPassSettings.shadowBlurType===af&&this._evaluateIfUpdateIsNeeded(this.camera)&&(this._renderShadowAndAo(e,this.scene,this.camera,this.shadowAndAoPassSettings.shadowMapTexture),n=!0);let i=t.onlyHardShadow?this.shadowAndAoPassSettings.shadowMapTexture:this.denoiseRenderTargetTexture;t.fadeInPoissonShadow&&(i=this._renderDynamicShadow(e,this.aoAndSoftShadowRenderTarget.texture,this.shadowAndAoPassSettings.shadowMapTexture,this.shadowAndAoPassSettings.shadowFadeInMix),n=!0),n?i=this._renderDenoise(e,this.camera,t.fadeInPoissonShadow,!1):t.progressiveDenoise&&(i=this._renderDenoise(e,this.camera,!1,!0)),t.fadeInHardShadow&&(i=this._renderDynamicShadow(e,this.denoiseRenderTargetTexture,this.shadowAndAoPassSettings.shadowMapTexture,this.shadowAndAoPassSettings.shadowFadeInMix)),this._finalTexture=i,this._onlyHardShadow=t.onlyHardShadow,this.renderToRenderTarget&&this.renderToTarget(e)}_setRenderState(){return!(!this.parameters.enabled||!(null!==this.parameters.ao.algorithm||this.parameters.shadowIntensity>=.01)||(this.needsUpdate&&(this._aoPass&&(this._aoPass.needsUpdate=!0),this._poissonDenoisePass&&(this._poissonDenoisePass.needsUpdate=!0)),0))}_evaluateIfUpdateIsNeeded(e){e.updateProjectionMatrix();const t=this.parameters.alwaysUpdate||this.needsUpdate||null!=e&&this._cameraUpdate.changed(e);return this.needsUpdate=!1,t}_renderShadowAndAo(e,t,n,i){var r;const a=null!==this.parameters.ao.algorithm&&this.parameters.aoIntensity>.01;a||null===(r=this._aoPass)||void 0===r||r.clear(e,this.aoAndSoftShadowRenderTarget),this._renderSoftShadow(e,n,i),a&&this._renderAo(e,t,n)}_renderAo(e,t,n){const i=this.gBufferTextures.depthBufferTexture,r=this.gBufferTextures.gBufferTexture,a=this._aoAndSoftShadowRenderTarget,s=e.autoClear;e.autoClear=!1;const o=this.aoRenderPass;o.depthTexture=i,o.normalTexture=r,o.render(e,n,t,a),e.autoClear=s}_renderSoftShadow(e,t,n){const i=this.softShadowPass;i.parameters.radius=this.parameters.shadow.shadowRadius,i.inputTexture=n,this.softShadowPass.renderToTarget(e,t,this.aoAndSoftShadowRenderTarget)}_renderDynamicShadow(e,t,n,i=1){const r=i<.999;return r&&(this._copyMaterial.update({texture:t,blending:0,colorTransform:Hc,colorBase:Xc,multiplyChannels:0}),this.passRenderer.renderScreenSpace(e,this._copyMaterial,this.fadeRenderTarget)),i>.001&&(this._blendMaterial.update({texture:n,blending:r?5:0,colorTransform:(new Mn).set(0,0,0,1,1,0,0,0,0,0,0,1,0,0,0,r?i:1),multiplyChannels:0}),this.passRenderer.renderScreenSpace(e,this._blendMaterial,this.fadeRenderTarget)),this.fadeRenderTarget.texture}_renderDenoise(e,t,n,i){const r=this.denoisePass;return r.inputTexture=n?this.fadeRenderTarget.texture:i?r.texture:this.aoAndSoftShadowRenderTarget.texture,r.render(e,t),r.texture}renderToTarget(e){const t=this._onlyHardShadow?this.parameters.shadowIntensity:this.parameters.aoIntensity,n=this._onlyHardShadow?0:this.parameters.shadowIntensity;this.passRenderer.renderScreenSpace(e,this._blendAoAndShadowMaterial.update({texture:this._finalTexture,blending:5,aoIntensity:t,shadowIntensity:n}),e.getRenderTarget())}}of.shadowTransform=(new Mn).set(0,1,0,0,0,1,0,0,0,1,0,0,0,0,0,1);class lf{get isOutlinePassActivated(){return this.outlinePassActivated}get outlinePass(){return this._renderPassManager.outlinePass}constructor(e,t,n){this._effectComposer=null,this.outlinePassActivated=!1,this._renderPassManager=e,this._effectComposer=t,this.parameters=Object.assign({enabled:!0,edgeStrength:2,edgeGlow:1,edgeThickness:2,pulsePeriod:0,usePatternTexture:!1,visibleEdgeColor:16777215,hiddenEdgeColor:16777215},n)}updateParameters(e){for(const t in e)this.parameters.hasOwnProperty(t)&&(this.parameters[t]=e[t])}applyParameters(){this.outlinePass&&(this.outlinePass.edgeStrength=this.parameters.edgeStrength,this.outlinePass.edgeGlow=this.parameters.edgeGlow,this.outlinePass.edgeThickness=this.parameters.edgeThickness,this.outlinePass.pulsePeriod=this.parameters.pulsePeriod,this.outlinePass.usePatternTexture=this.parameters.usePatternTexture,this.outlinePass.visibleEdgeColor.set(this.parameters.visibleEdgeColor),this.outlinePass.hiddenEdgeColor.set(this.parameters.hiddenEdgeColor))}activateOutline(e,t){var n;if(!this.parameters.enabled)return void this.deactivateOutline();const i=(null===(n=this.outlinePass)||void 0===n?void 0:n.renderCamera)&&t.isPerspectiveCamera!==this.outlinePass.renderCamera.isPerspectiveCamera;this.outlinePass&&(this.outlinePass.renderScene=e,this.outlinePass.renderCamera=t),!i&&this.outlinePassActivated||(!i&&this.outlinePass||this._renderPassManager.createOutlinePass(),this.applyParameters(),this._effectComposer&&this._effectComposer.addPass(this.outlinePass),this.outlinePassActivated=!0)}deactivateOutline(){this.outlinePassActivated&&(this.outlinePass&&this._effectComposer&&this._effectComposer.removePass(this.outlinePass),this.outlinePassActivated=!1)}updateOutline(e,t,n){n.length>0?(this.activateOutline(e,t),this.outlinePass&&(this.outlinePass.selectedObjects=n)):this.deactivateOutline()}}const cf=(e,t)=>{for(const n in t)try{t[n].constructor===Object?e[n]=cf(e[n],t[n]):e[n]=t[n]}catch(i){e[n]=t[n]}return e},hf="default",df={shadowType:"PCFSoftShadowMap",shAndAoPassParameters:{aoIntensity:.3,shadow:{shadowRadius:.1},ao:{algorithm:0,samples:32,radius:.02,distanceExponent:2,thickness:.1,distanceFallOff:1,bias:.01},poissonDenoise:{iterations:2,samples:16,rings:2.89,radius:4,radiusExponent:1.3,depthPhi:2.5,normalPhi:.5}},groundReflectionParameters:{brightness:.5}},uf=e=>Math.max(0,Math.min(1,e));class pf{constructor(e){this.needsUpdate=!0,this._cache=null,this._cache=e}dispose(){var e;null===(e=this._cache)||void 0===e||e.dispose()}clear(){var e;null===(e=this._cache)||void 0===e||e.clear(),this.needsUpdate=!0}update(e){this.needsUpdate&&this._cache&&(e.traverse((e=>{var t,n,i;e.isLine||e.isPoints?null===(t=this._cache)||void 0===t||t.addLineOrPoint(e):e.isMesh?null===(n=this._cache)||void 0===n||n.addMesh(e):null===(i=this._cache)||void 0===i||i.addObject(e)})),this.needsUpdate=!1)}onBeforeRender(){var e;null===(e=this._cache)||void 0===e||e.onBeforeRender()}onAfterRender(){var e;null===(e=this._cache)||void 0===e||e.onAfterRender()}}class ff{constructor(){this._cacheMap=new Map}dispose(){this._cacheMap.forEach((e=>{e.dispose()}))}registerCache(e,t){this._cacheMap.set(e,new pf(t))}clearCache(){this._cacheMap.forEach((e=>{e.clear()}))}clearObjectCache(e){const t=this._cacheMap.get(e);t&&t.clear()}onBeforeRender(e,t){const n=this._cacheMap.get(e);n&&(n.update(t),n.onBeforeRender())}onAfterRender(e){const t=this._cacheMap.get(e);t&&t.onAfterRender()}render(e,t,n){const i=this._cacheMap.get(e);i&&(i.update(t),i.onBeforeRender()),n(),i&&i.onAfterRender()}}class mf{constructor(e){this._visibilityCache=new Map,this._isObjectInvisible=e}dispose(){this._visibilityCache.clear()}clear(){this._visibilityCache.clear()}addLineOrPoint(e){this._visibilityCache.set(e,e.visible)}addMesh(e){this._isObjectInvisible&&this._isObjectInvisible(e)&&this._visibilityCache.set(e,e.visible)}addObject(e){this._isObjectInvisible&&this._isObjectInvisible(e)&&this._visibilityCache.set(e,e.visible)}onBeforeRender(){this._visibilityCache.forEach(((e,t)=>{t.visible=!1}))}onAfterRender(){this._visibilityCache.forEach(((e,t)=>{t.visible=e}))}}class gf{constructor(e){this._depthWriteCache=new Set,this._doNotWriteDepth=e}dispose(){this._depthWriteCache.clear()}clear(){this._depthWriteCache.clear()}addLineOrPoint(e){}addObject(e){}addMesh(e){this._doNotWriteDepth&&this._doNotWriteDepth(e)&&e.material instanceof Tl&&e.material.depthWrite&&this._depthWriteCache.add(e.material)}onBeforeRender(){this._depthWriteCache.forEach((e=>{e.depthWrite=!1}))}onAfterRender(){this._depthWriteCache.forEach((e=>{e.depthWrite=!0}))}}class vf{constructor(){this._objectCache=new Map}clear(){this._objectCache.clear()}onBeforeRender(){this._objectCache.forEach(((e,t)=>{t instanceof Zi&&(t.material!==e.originalObjectData.material&&t.material!==e.updateObjectData.material&&(e.originalObjectData.material=t.material),t.receiveShadow!==e.originalObjectData.receiveShadow&&(e.originalObjectData.receiveShadow=t.receiveShadow),t.castShadow!==e.originalObjectData.castShadow&&(e.originalObjectData.castShadow=t.castShadow),t.visible!==e.originalObjectData.visible&&(e.originalObjectData.visible=t.visible)),this._updateObject(t,e.updateObjectData)}))}onAfterRender(){this._objectCache.forEach(((e,t)=>{this._updateObject(t,e.originalObjectData)}))}addToCache(e,t){this._objectCache.set(e,{originalObjectData:{visible:e.visible,castShadow:e.castShadow,receiveShadow:e instanceof Zi?e.receiveShadow:void 0,material:e instanceof Zi?e.material:void 0},updateObjectData:t})}_updateObject(e,t){void 0!==t.visible&&(e.visible=t.visible),void 0!==t.castShadow&&(e.castShadow=t.castShadow),e instanceof Zi&&void 0!==t.receiveShadow&&(e.receiveShadow=t.receiveShadow),e instanceof Zi&&void 0!==t.material&&(e.material=t.material)}}class _f extends Bp{get shadowGroundPlane(){var e;let t=this._sharedShadowGroundPlane;return t||(null!==(e=this._shadowGroundPlane)&&void 0!==e||(this._shadowGroundPlane=new Fp(this.renderTarget.texture,this.parameters)),t=this._shadowGroundPlane),t.parent!==this._groundGroup&&this._groundGroup.add(t),t}constructor(e,t,n,i){var r,a;super(e),this.limitPlaneSize=!0,this.needsUpdate=!0,this.noNeedOfUpdateCount=0,this._blurScale=1,this._shadowScale=1,this._groundGroup=n,this.shadowMapSize=null!==(r=i.shadowMapSize)&&void 0!==r?r:2048,this.parameters=this._getDefaultParameters(i),this._groundShadowFar=this.parameters.cameraFar,this._renderer=t,null===(a=this.renderCacheManager)||void 0===a||a.registerCache(this,new mf((e=>e.isMesh&&!(e=>{var t;if(!e.isMesh)return!1;if(!e.castShadow&&!(null===(t=e.userData)||void 0===t?void 0:t.meshId))return!1;const n=e.material;return!n.transparent||n.opacity>.5})(e)||void 0!==e.name&&["Ground","Floor"].includes(e.name)))),this.renderTarget=new Gt(this.shadowMapSize,this.shadowMapSize),this.renderTarget.texture.generateMipmaps=!1,this._renderTargetBlur=new Gt(this.shadowMapSize,this.shadowMapSize),this._renderTargetBlur.texture.generateMipmaps=!1,this._sharedShadowGroundPlane=null==i?void 0:i.sharedShadowGroundPlane,this.shadowGroundPlane.setShadowMap(this.renderTarget.texture),this.shadowGroundPlane.updateMaterial(this.parameters),this._groundContactCamera=new xf,this._groundGroup.add(this._groundContactCamera),this._depthMaterial=new Gs,this._depthMaterial.userData.fadeoutBias={value:this.parameters.fadeoutBias},this._depthMaterial.userData.fadeoutFalloff={value:this.parameters.fadeoutFalloff},this._depthMaterial.onBeforeCompile=e=>{e.uniforms.fadeoutBias=this._depthMaterial.userData.fadeoutBias,e.uniforms.fadeoutFalloff=this._depthMaterial.userData.fadeoutFalloff,e.fragmentShader=`\n uniform float fadeoutBias;\n uniform float fadeoutFalloff;\n ${e.fragmentShader.replace("gl_FragColor = vec4( vec3( 1.0 - fragCoordZ ), opacity );",Fp.alphaMap?"gl_FragColor = vec4(clamp(pow(1.0 + fadeoutBias - fragCoordZ, 1.0/(1.0-fadeoutFalloff)), 0.0, 1.0));":"gl_FragColor = vec4(vec3(0.0), clamp(pow(1.0 + fadeoutBias - fragCoordZ, 1.0/(1.0-fadeoutFalloff)), 0.0, 1.0));")}\n `},this._depthMaterial.side=2,this._depthMaterial.depthTest=!0,this._depthMaterial.depthWrite=!0,this._blurPass=new uh(Qc,Object.assign(Object.assign({},i),{passRenderer:this.renderPassManager.passRenderer})),this.updatePlaneAndShadowCamera()}_getDefaultParameters(e){return Object.assign({enabled:!0,cameraHelper:!1,alwaysUpdate:!1,fadeIn:!1,blurMin:.001,blurMax:.1,fadeoutFalloff:.9,fadeoutBias:.03,opacity:.5,maximumPlaneSize:40,planeSize:10,cameraFar:3,hardLayers:null,softLayers:null,polygonOffset:2,excludeGroundObjects:!0},e)}dispose(){this.renderTarget.dispose(),this._renderTargetBlur.dispose(),this._blurPass.dispose(),this._depthMaterial.dispose()}updateParameters(e){for(const t in e)this.parameters.hasOwnProperty(t)&&(this.parameters[t]=e[t]);void 0!==e.cameraFar&&(this._groundShadowFar=this.parameters.cameraFar)}applyParameters(){this.shadowGroundPlane.updateMaterial(this.parameters),this._groundContactCamera.updateCameraHelper(this.parameters.cameraHelper),this._groundContactCamera.far!==this.parameters.cameraFar&&this.updatePlaneAndShadowCamera();const e=this.parameters.fadeoutFalloff;this._depthMaterial.userData.fadeoutFalloff.value!==e&&(this._depthMaterial.userData.fadeoutFalloff.value=this.parameters.fadeoutFalloff);const t=this.parameters.fadeoutBias/this._groundContactCamera.far;this._depthMaterial.userData.fadeoutBias.value!==t&&(this._depthMaterial.userData.fadeoutBias.value=t),this.needsUpdate=!0}setScale(e,t){this._blurScale=e,this._shadowScale=null!=t?t:e,this.needsUpdate=!0}updateBounds(e,t){var n;this._groundShadowFar=this.parameters.cameraFar,this._groundShadowFarthis.parameters.maximumPlaneSize?(this.parameters.planeSize=this.parameters.maximumPlaneSize,this._groundGroup.position.set(0,null!=t?t:0,0)):this._groundGroup.position.set(e.center.x,null!=t?t:0,e.center.z),this._groundGroup.updateMatrixWorld(),this.updatePlaneAndShadowCamera()}updatePlaneAndShadowCamera(){const e=this.parameters.planeSize;this.shadowGroundPlane.scale.x=e,this.shadowGroundPlane.scale.y=e,this._groundContactCamera.updateCameraFormPlaneSize(e,this._groundShadowFar),this.needsUpdate=!0}setGroundVisibilityLayers(e){this.shadowGroundPlane.setVisibilityLayers(e)}renderPass(e){if(this._groundContactCamera.updateCameraHelper(this.parameters.cameraHelper,this.scene),!this.parameters.enabled)return void(this.needsUpdate&&(this.needsUpdate=!1,this.passRenderer.clear(e,this.renderTarget,0,1)));if(this.shadowGroundPlane.visible=this.parameters.enabled,this.parameters.alwaysUpdate||this.needsUpdate)this.noNeedOfUpdateCount=0;else if(this.noNeedOfUpdateCount++,this.noNeedOfUpdateCount>=10)return;this.needsUpdate=!1,this.shadowGroundPlane.material.opacity=this.parameters.alwaysUpdate||!this.parameters.fadeIn?this.parameters.opacity:this.parameters.opacity*(this.noNeedOfUpdateCount+2)/12;const t=this._renderer.getClearAlpha();this._renderer.setClearAlpha(0),this._groundGroup.visible=!1,this.shadowGroundPlane.visible=!1,this._groundContactCamera.setCameraHelperVisibility(!1),0===this.noNeedOfUpdateCount?(this._renderGroundContact(this.scene),this._renderBlur()):1===this.noNeedOfUpdateCount&&this._renderBlur(),this._renderReduceBandingBlur(),this._renderer.setRenderTarget(null),this._renderer.setClearAlpha(t),this._groundGroup.visible=!0,this.shadowGroundPlane.visible=this.parameters.enabled,this._groundContactCamera.setCameraHelperVisibility(this.parameters.cameraHelper)}_renderGroundContact(e){const t=e.background;e.background=null,e.overrideMaterial=this._depthMaterial,this._renderer.setRenderTarget(this.renderTarget),this._renderer.clear();const n=this._renderer.autoClear;this._renderer.autoClear=!1,this.parameters.hardLayers&&(this._groundContactCamera.layers.mask=this.parameters.hardLayers.mask,this._groundContactCamera.updateCameraFarPlane(10),this._depthMaterial.userData.fadeoutBias.value=.99,this._renderer.render(e,this._groundContactCamera),this._groundContactCamera.updateCameraFarPlane(this._groundShadowFar),this._depthMaterial.userData.fadeoutBias.value=this.parameters.fadeoutBias/this._groundShadowFar),this._groundContactCamera.layers.enableAll(),this.parameters.softLayers&&(this._groundContactCamera.layers.mask=this.parameters.softLayers.mask),this.renderCacheManager?this.renderCacheManager.render(this,e,(()=>{this._renderer.render(e,this._groundContactCamera)})):this._renderer.render(e,this._groundContactCamera),this._renderer.autoClear=n,e.overrideMaterial=null,e.background=t}_renderBlur(){this._renderBlurPass(this._blurScale*this.parameters.blurMin/this.parameters.planeSize,this._blurScale*this.parameters.blurMax/this.parameters.planeSize)}_renderReduceBandingBlur(){const e=.01*this._blurScale/this.parameters.planeSize;this._renderBlurPass(e,e)}_renderBlurPass(e,t){this._blurPass.render(this._renderer,[this.renderTarget,this._renderTargetBlur,this.renderTarget],[e,e],[t,t])}}_f.addTestMesh=!1;class xf extends Ur{constructor(){super(-1,1,-1,1,-1,1),this.rotation.x=Math.PI}updateCameraFormPlaneSize(e,t){var n;this.left=-e/2,this.right=e/2,this.top=-e/2,this.bottom=e/2,this.near=0,this.far=t,this.updateProjectionMatrix(),null===(n=this.cameraHelper)||void 0===n||n.update()}updateCameraFarPlane(e){var t;this.far=e,this.updateProjectionMatrix(),null===(t=this.cameraHelper)||void 0===t||t.update()}updateCameraHelper(e,t){var n,i,r;e?(this.cameraHelper=null!==(n=this.cameraHelper)&&void 0!==n?n:new Nc(this),this.cameraHelper.visible=!0,null==t||t.add(this.cameraHelper)):(null===(i=this.cameraHelper)||void 0===i?void 0:i.parent)&&(null===(r=this.cameraHelper)||void 0===r||r.removeFromParent())}setCameraHelperVisibility(e){this.cameraHelper&&(this.cameraHelper.visible=e)}}class yf extends nr{constructor(e){var t;super({defines:Object.assign(Object.assign(Object.assign({},yf._normalAndDepthShader.defines),{FLOAT_BUFFER:(null==e?void 0:e.floatBufferType)?1:0,LINEAR_DEPTH:(null==e?void 0:e.linearDepth)?1:0})),uniforms:tr.clone(yf._normalAndDepthShader.uniforms),vertexShader:yf._normalAndDepthShader.vertexShader,fragmentShader:yf._normalAndDepthShader.fragmentShader,blending:null!==(t=null==e?void 0:e.blending)&&void 0!==t?t:0}),this.update(e)}update(e){if(void 0!==(null==e?void 0:e.camera)){const t=(null==e?void 0:e.camera)||(null==e?void 0:e.camera);this.uniforms.cameraNear.value=t.near,this.uniforms.cameraFar.value=t.far}return this}}yf._normalAndDepthShader={uniforms:{cameraNear:{value:.1},cameraFar:{value:1}},defines:{FLOAT_BUFFER:0,LINEAR_DEPTH:0},vertexShader:"varying vec3 vNormal;\n#if LINEAR_DEPTH == 1\n varying float vZ; \n#endif\n\n void main() {\n vNormal = normalMatrix * normal;\n vec4 viewPosition = modelViewMatrix * vec4(position, 1.0);\n #if LINEAR_DEPTH == 1\n vZ = viewPosition.z; \n #endif\n gl_Position = projectionMatrix * viewPosition;\n }",fragmentShader:"varying vec3 vNormal;\n#if LINEAR_DEPTH == 1\n varying float vZ; \n uniform float cameraNear;\n uniform float cameraFar;\n#endif\n\n void main() {\n #if FLOAT_BUFFER == 1\n vec3 normal = normalize(vNormal);\n #else\n vec3 normal = normalize(vNormal) * 0.5 + 0.5;\n #endif\n #if LINEAR_DEPTH == 1\n float depth = (-vZ - cameraNear) / (cameraFar - cameraNear);\n #else\n float depth = gl_FragCoord.z;\n #endif\n gl_FragColor = vec4(normal, depth);\n }"};class Sf extends Bp{set groundDepthWrite(e){this._gBufferMaterialCache&&(this._gBufferMaterialCache.groundDepthWrite=e)}get isFloatGBufferWithRgbNormalAlphaDepth(){return this.floatRgbNormalAlphaDepth}get gBufferTexture(){return this.depthNormalRenderTarget.texture}get depthBufferTexture(){return this.copyToSeparateDepthBuffer&&this.floatRgbNormalAlphaDepth?this.separateDeptRenderTarget.texture:this.depthNormalRenderTarget.depthTexture}get textureWithDepthValue(){return this.floatRgbNormalAlphaDepth?this.depthNormalRenderTarget.texture:this.depthNormalRenderTarget.depthTexture}updateGBufferRenderMaterial(e){var t;return this._gBufferRenderMaterial=null!==(t=this._gBufferRenderMaterial)&&void 0!==t?t:this.floatRgbNormalAlphaDepth?new yf({blending:0,floatBufferType:!0,linearDepth:!1}):new Pl({blending:0}),this._gBufferRenderMaterial instanceof yf&&this._gBufferRenderMaterial.update({camera:e}),this._gBufferRenderMaterial}get depthNormalRenderTarget(){if(!this._depthNormalRenderTarget)if(this.floatRgbNormalAlphaDepth)this._depthNormalRenderTarget=new Gt(this._width*this.parameters.depthNormalScale,this._height*this.parameters.depthNormalScale,{minFilter:this._targetMinificationTextureFilter,magFilter:this._targetMagnificationTextureFilter,type:Z,samples:this._samples});else{const e=new ia(this._width*this.parameters.depthNormalScale,this._height*this.parameters.depthNormalScale);e.format=ne,e.type=$,this._depthNormalRenderTarget=new Gt(this._width*this.parameters.depthNormalScale,this._height*this.parameters.depthNormalScale,{minFilter:this._targetMinificationTextureFilter,magFilter:this._targetMagnificationTextureFilter,depthTexture:e})}return this._depthNormalRenderTarget}get separateDeptRenderTarget(){return this._separateDeptRenderTarget||(this._separateDeptRenderTarget=new Gt(this._width*this.parameters.depthNormalScale,this._height*this.parameters.depthNormalScale,{minFilter:this._targetMinificationTextureFilter,magFilter:this._targetMagnificationTextureFilter,type:Z,samples:0})),this._separateDeptRenderTarget}constructor(e,t){var n,i,r,a,s,o,l,c,h;super(e),this.floatRgbNormalAlphaDepth=!1,this.linearDepth=!1,this.copyToSeparateDepthBuffer=!1,this.needsUpdate=!0,this.drawGround=!0,this.floatRgbNormalAlphaDepth=null!==(i=null===(n=null==t?void 0:t.capabilities)||void 0===n?void 0:n.isWebGL2)&&void 0!==i&&i,this.renderCacheManager&&(this._gBufferMaterialCache=new wf,this.renderCacheManager.registerCache(this,this._gBufferMaterialCache)),this.parameters={depthNormalScale:null!==(r=null==t?void 0:t.depthNormalScale)&&void 0!==r?r:1},this._targetMinificationTextureFilter=null!==(a=null==t?void 0:t.textureMinificationFilter)&&void 0!==a?a:z,this._targetMagnificationTextureFilter=null!==(s=null==t?void 0:t.textureMagnificationFilter)&&void 0!==s?s:z,this._width=null!==(o=null==t?void 0:t.width)&&void 0!==o?o:1024,this._height=null!==(l=null==t?void 0:t.height)&&void 0!==l?l:1024,this._samples=null!==(c=null==t?void 0:t.samples)&&void 0!==c?c:0,this._shared=null!==(h=null==t?void 0:t.shared)&&void 0!==h&&h}dispose(){var e,t;super.dispose(),null===(e=this._gBufferRenderMaterial)||void 0===e||e.dispose(),null===(t=this._depthNormalRenderTarget)||void 0===t||t.dispose()}setSize(e,t){var n;this._width=e,this._height=t,null===(n=this._depthNormalRenderTarget)||void 0===n||n.setSize(this._width*this.parameters.depthNormalScale,this._height*this.parameters.depthNormalScale)}renderPass(e){this._shared&&!this.needsUpdate||(this.needsUpdate=!1,this.renderPassManager.setGroundVisibility(this.drawGround),this.renderCacheManager?this.renderCacheManager.render(this,this.scene,(()=>{this._renderGBuffer(e,this.scene,this.camera)})):this._renderGBuffer(e,this.scene,this.camera),this.renderPassManager.setGroundVisibility(!1),this.floatRgbNormalAlphaDepth&&this.copyToSeparateDepthBuffer&&this._copyDepthToSeparateDepthTexture(e,this.depthNormalRenderTarget))}_renderGBuffer(e,t,n){this.passRenderer.renderWithOverrideMaterial(e,t,n,this.updateGBufferRenderMaterial(n),this.depthNormalRenderTarget,7829503,1)}getCopyMaterial(e){var t;return null!==(t=this._copyMaterial)&&void 0!==t||(this._copyMaterial=new Jc),this._copyMaterial.update(e)}_copyDepthToSeparateDepthTexture(e,t){this.passRenderer.renderScreenSpace(e,this.getCopyMaterial({texture:t.texture,blending:0,colorTransform:Gc,colorBase:Yc,multiplyChannels:0,uvTransform:qc}),this.separateDeptRenderTarget)}}class wf extends vf{set groundDepthWrite(e){this._groundDepthWrite=e}constructor(){super(),this._groundDepthWrite=!0}dispose(){}addLineOrPoint(e){this.addToCache(e,{visible:!1})}addMesh(e){e.userData.isFloor?this.addToCache(e,{visible:this._groundDepthWrite}):e.visible&&(e.material instanceof xi&&(e.material.transparent&&e.material.opacity<.7||e.material.alphaTest>0)||e.material instanceof El&&e.material.transmission>0)&&this.addToCache(e,{visible:!1})}addObject(e){}}class bf extends Bp{get reflectionRenderTarget(){var e;return this._reflectionRenderTarget=null!==(e=this._reflectionRenderTarget)&&void 0!==e?e:this._newRenderTarget(!0),this._reflectionRenderTarget}get intensityRenderTarget(){var e;return this._intensityRenderTarget=null!==(e=this._intensityRenderTarget)&&void 0!==e?e:this._newRenderTarget(!1),this._intensityRenderTarget}get blurRenderTarget(){var e;return this._blurRenderTarget=null!==(e=this._blurRenderTarget)&&void 0!==e?e:this._newRenderTarget(!1),this._blurRenderTarget}constructor(e,t,n,i,r){super(e),this.reflectionFadeInScale=1,this._width=t,this._height=n,this._samples=null!=i?i:1,this.parameters=Object.assign({enabled:!1,intensity:.25,fadeOutDistance:1,fadeOutExponent:4,brightness:1,blurHorizontal:3,blurVertical:6,blurAscent:0,groundLevel:0,groundReflectionScale:1,renderTargetDownScale:4},r),this._copyMaterial=new Jc({},Kc,!0,!0),this._updateCopyMaterial(null),this._reflectionIntensityMaterial=new Mf({width:this._width/this.parameters.renderTargetDownScale,height:this._height/this.parameters.renderTargetDownScale}),this._blurPass=new uh(Qc,Object.assign(Object.assign({},r),{passRenderer:this.renderPassManager.passRenderer}))}_newRenderTarget(e){const t=this._width/this.parameters.renderTargetDownScale,n=this._height/this.parameters.renderTargetDownScale,i={};if(e){const e=new ia(t,n);i.depthTexture=e,i.samples=this._samples}else i.samples=1;return new Gt(t,n,Object.assign({format:ee},i))}dispose(){var e,t,n;super.dispose(),null===(e=this._reflectionRenderTarget)||void 0===e||e.dispose(),null===(t=this._intensityRenderTarget)||void 0===t||t.dispose(),null===(n=this._blurRenderTarget)||void 0===n||n.dispose(),this._copyMaterial.dispose()}setSize(e,t){var n,i,r,a;this._width=e,this._height=t,null===(n=this._reflectionRenderTarget)||void 0===n||n.setSize(this._width/this.parameters.renderTargetDownScale,this._height/this.parameters.renderTargetDownScale),null===(i=this._intensityRenderTarget)||void 0===i||i.setSize(this._width/this.parameters.renderTargetDownScale,this._height/this.parameters.renderTargetDownScale),null===(r=this._blurRenderTarget)||void 0===r||r.setSize(this._width/this.parameters.renderTargetDownScale,this._height/this.parameters.renderTargetDownScale),null===(a=this._reflectionIntensityMaterial)||void 0===a||a.update({width:this._width/this.parameters.renderTargetDownScale,height:this._height/this.parameters.renderTargetDownScale})}updateParameters(e){for(const t in e)this.parameters.hasOwnProperty(t)&&(this.parameters[t]=e[t])}updateBounds(e,t){this.parameters.groundLevel=e,this.parameters.groundReflectionScale=t}_updateCopyMaterial(e,t=1){var n;const i=this.parameters.intensity*t,r=this.parameters.brightness;this._copyMaterial.update({texture:null!==(n=null==e?void 0:e.texture)&&void 0!==n?n:void 0,colorTransform:(new Mn).set(r,0,0,0,0,r,0,0,0,0,r,0,0,0,0,i),multiplyChannels:0,uvTransform:Zc}),this._copyMaterial.depthTest=!0,this._copyMaterial.depthWrite=!1}renderPass(e){if(!(this.parameters.enabled&&this.camera instanceof or))return;const t=this._createGroundReflectionCamera(this.camera);this.renderCacheManager.render("inivisibleGround",this.scene,(()=>{this._renderGroundReflection(e,this.scene,t,this.reflectionRenderTarget)})),this._renderGroundReflectionIntensity(e,t,this.intensityRenderTarget),(this.parameters.blurHorizontal>0||this.parameters.blurVertical>0)&&this.blurReflection(e,this.camera,[this.intensityRenderTarget,this.blurRenderTarget,this.intensityRenderTarget]),this._updateCopyMaterial(this.intensityRenderTarget,this.reflectionFadeInScale),this.passRenderer.renderScreenSpace(e,this._copyMaterial,e.getRenderTarget())}_renderGroundReflection(e,t,n,i){const r=e.getRenderTarget();i&&(e.setRenderTarget(i),this.passRenderer.clear(e,i,0,0)),e.render(t,n),i&&e.setRenderTarget(r)}_renderGroundReflectionIntensity(e,t,n){const i=e.getRenderTarget();e.setRenderTarget(n),this.passRenderer.renderScreenSpace(e,this._reflectionIntensityMaterial.update({texture:this.reflectionRenderTarget.texture,depthTexture:this.reflectionRenderTarget.depthTexture,camera:t,groundLevel:this.parameters.groundLevel,fadeOutDistance:this.parameters.fadeOutDistance*this.parameters.groundReflectionScale,fadeOutExponent:this.parameters.fadeOutExponent}),e.getRenderTarget()),e.setRenderTarget(i)}blurReflection(e,t,n){const i=new Yt(t.matrixWorld.elements[4],t.matrixWorld.elements[5],t.matrixWorld.elements[6]),r=this.parameters.blurHorizontal/this._width,a=this.parameters.blurVertical/this._height*Math.abs(i.dot(new Yt(0,0,1)));this._blurPass.render(e,n,[4*r,4*a],[4*r*(1+this.parameters.blurAscent),4*a*(1+this.parameters.blurAscent)])}_createGroundReflectionCamera(e){const t=e.clone(),n=t;return n._offset&&(n._offset={left:n._offset.left,top:1-n._offset.bottom,right:n._offset.right,bottom:1-n._offset.top}),t.position.set(e.position.x,-e.position.y+2*this.parameters.groundLevel,e.position.z),t.rotation.set(-e.rotation.x,e.rotation.y,-e.rotation.z),t.updateMatrixWorld(),t.updateProjectionMatrix(),t}}class Mf extends nr{constructor(e){super({defines:Object.assign({},Mf.shader.defines),uniforms:tr.clone(Mf.shader.uniforms),vertexShader:Mf.shader.vertexShader,fragmentShader:Mf.shader.fragmentShader,blending:0}),this.update(e)}update(e){var t,n;if(void 0!==(null==e?void 0:e.texture)&&(this.uniforms.tDiffuse.value=null==e?void 0:e.texture),void 0!==(null==e?void 0:e.depthTexture)&&(this.uniforms.tDepth.value=null==e?void 0:e.depthTexture),(null==e?void 0:e.width)||(null==e?void 0:e.height)){const i=null!==(t=null==e?void 0:e.width)&&void 0!==t?t:this.uniforms.resolution.value.x,r=null!==(n=null==e?void 0:e.height)&&void 0!==n?n:this.uniforms.resolution.value.y;this.uniforms.resolution.value.set(i,r)}if(void 0!==(null==e?void 0:e.camera)){const t=(null==e?void 0:e.camera)||(null==e?void 0:e.camera);this.uniforms.cameraNear.value=t.near,this.uniforms.cameraFar.value=t.far,this.uniforms.cameraProjectionMatrix.value.copy(t.projectionMatrix),this.uniforms.cameraInverseProjectionMatrix.value.copy(t.projectionMatrixInverse),this.uniforms.inverseViewMatrix.value.copy(t.matrixWorld)}return void 0!==(null==e?void 0:e.groundLevel)&&(this.uniforms.groundLevel.value=null==e?void 0:e.groundLevel),void 0!==(null==e?void 0:e.fadeOutDistance)&&(this.uniforms.fadeOutDistance.value=null==e?void 0:e.fadeOutDistance),void 0!==(null==e?void 0:e.fadeOutExponent)&&(this.uniforms.fadeOutExponent.value=null==e?void 0:e.fadeOutExponent),this}}Mf.shader={uniforms:{tDiffuse:{value:null},tDepth:{value:null},resolution:{value:new _t},cameraNear:{value:.1},cameraFar:{value:1},cameraProjectionMatrix:{value:new Mn},cameraInverseProjectionMatrix:{value:new Mn},inverseViewMatrix:{value:new Mn},groundLevel:{value:0},fadeOutDistance:{value:1},fadeOutExponent:{value:1}},defines:{PERSPECTIVE_CAMERA:1,LINEAR_TO_SRGB:0,PREMULTIPLIED_ALPHA:1},vertexShader:"\n varying vec2 vUv;\n void main() {\n vUv = uv;\n gl_Position = projectionMatrix * modelViewMatrix * vec4(position, 1.0);\n }",fragmentShader:"\n uniform sampler2D tDiffuse;\n uniform sampler2D tDepth;\n uniform vec2 resolution;\n uniform float cameraNear;\n uniform float cameraFar;\n uniform mat4 cameraProjectionMatrix;\n uniform mat4 cameraInverseProjectionMatrix;\n uniform mat4 inverseViewMatrix;\n uniform float groundLevel;\n uniform float fadeOutDistance;\n uniform float fadeOutExponent;\n varying vec2 vUv;\n\n #include \n\n float getDepth(const in vec2 screenPosition) {\n return texture2D(tDepth, screenPosition).x;\n }\n\n float getLinearDepth(const in vec2 screenPosition) {\n #if PERSPECTIVE_CAMERA == 1\n float fragCoordZ = texture2D(tDepth, screenPosition).x;\n float viewZ = perspectiveDepthToViewZ(fragCoordZ, cameraNear, cameraFar);\n return viewZToOrthographicDepth(viewZ, cameraNear, cameraFar);\n #else\n return texture2D(tDepth, screenPosition).x;\n #endif\n }\n\n float getViewZ(const in float depth) {\n #if PERSPECTIVE_CAMERA == 1\n return perspectiveDepthToViewZ(depth, cameraNear, cameraFar);\n #else\n return 0.0;//orthographicDepthToViewZ(depth, cameraNear, cameraFar);\n #endif\n }\n\n vec3 getViewPosition(const in vec2 screenPosition, const in float depth, const in float viewZ ) {\n float clipW = cameraProjectionMatrix[2][3] * viewZ + cameraProjectionMatrix[3][3];\n vec4 clipPosition = vec4((vec3(screenPosition, depth) - 0.5) * 2.0, 1.0);\n clipPosition *= clipW;\n return (cameraInverseProjectionMatrix * clipPosition).xyz;\n }\n\n void main() {\n float verticalBias = 1.5 / resolution.y;\n vec2 uv = vUv.xy + vec2(0.0, verticalBias);\n float depth = getDepth(uv);\n float viewZ = getViewZ(depth);\n vec4 worldPosition = inverseViewMatrix * vec4(getViewPosition(uv, depth, viewZ), 1.0);\n float distance = worldPosition.y - groundLevel;\n vec2 diffuseTextureSize = vec2(textureSize(tDiffuse, 0 ));\n vec4 fragColor = texelFetch(tDiffuse, ivec2(uv * diffuseTextureSize), 0).rgba;\n #if LINEAR_TO_SRGB == 1\n fragColor.rgb = mix(fragColor.rgb * 12.92, 1.055 * pow(fragColor.rgb, vec3(0.41666)) - 0.055, step(0.0031308, fragColor.rgb));\n #endif\n float fadeOutAlpha = pow(clamp(1.0 - distance / fadeOutDistance, 0.0, 1.0), fadeOutExponent);\n fragColor.a *= fadeOutAlpha * step(depth, 0.9999);\n #if PREMULTIPLIED_ALPHA == 1\n gl_FragColor = vec4(fragColor.rgb * fragColor.a, fragColor.a);\n #else\n gl_FragColor = fragColor;\n #endif\n }"};class Tf extends Wo{constructor(e,t){const n=new Fi;n.setAttribute("position",new Ri([1,1,0,-1,1,0,-1,-1,0,1,-1,0,1,1,0],3)),n.computeBoundingSphere(),super(n,new No({fog:!1})),this.light=e,this.color=t,this.type="RectAreaLightHelper";const i=new Fi;i.setAttribute("position",new Ri([1,1,0,-1,1,0,-1,-1,0,1,1,0,-1,-1,0,1,-1,0],3)),i.computeBoundingSphere(),this.add(new Zi(i,new yi({side:1,fog:!1})))}updateMatrixWorld(){if(this.scale.set(.5*this.light.width,.5*this.light.height,1),void 0!==this.color)this.material.color.set(this.color),this.children[0].material.color.set(this.color);else{this.material.color.copy(this.light.color).multiplyScalar(this.light.intensity);const e=this.material.color,t=Math.max(e.r,e.g,e.b);t>1&&e.multiplyScalar(1/t),this.children[0].material.color.copy(this.material.color)}this.matrixWorld.extractRotation(this.light.matrixWorld).scale(this.scale).copyPosition(this.light.matrixWorld),this.children[0].matrixWorld.copy(this.matrixWorld)}dispose(){this.geometry.dispose(),this.material.dispose(),this.children[0].geometry.dispose(),this.children[0].material.dispose()}}class Ef extends Rl{constructor(e){super(e),this.customProgramCacheKey=this._customProgramCacheKey,this.onBeforeCompile=this._onBeforeCompile}static setShadowParameters(e,t,n,i,r,a,s){this._enableGroundBoundary=e,Ef._distributionProperties.set(t,n,i,r),Ef._shadowFadeOut.set(a,s)}static setBoundingBox(e){Ef._sceneBoxMin.copy(e.min),Ef._sceneBoxMax.copy(e.max)}_customProgramCacheKey(){return Ef._enableGroundBoundary?"GROUND_BOUNDARY":"NO_GROUND_BOUNDARY"}_onBeforeCompile(e,t){e.vertexShader=Af,e.fragmentShader=Pf,e.defines=Object.assign(Object.assign(Object.assign({},e.defines),{DYNAMIC_SHADOW_RADIUS:"",GROUND_BOUNDARY:Ef._enableGroundBoundary?1:0}));const n=e.uniforms;n&&(n.distributionProperties={value:Ef._distributionProperties},n.shadowFadeOut={value:Ef._shadowFadeOut},n.sceneBoxMin={value:Ef._sceneBoxMin},n.sceneBoxMax={value:Ef._sceneBoxMax})}}Ef._enableGroundBoundary=!1,Ef._shadowFadeOut=new _t(.1,20),Ef._sceneBoxMin=new Yt(-1,-1,-1),Ef._sceneBoxMax=new Yt(1,1,1),Ef._distributionProperties=new Ht(1,1,1,1);const Af="\n#define LAMBERT\n\nvarying vec3 vViewPosition;\nvarying vec3 vWorldPosition;\n\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n\nvoid main() {\n #include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\n\tvViewPosition = - mvPosition.xyz;\n\n\t#include \n\t#include \n\n#if defined( USE_ENVMAP ) || defined( DISTANCE ) || defined ( USE_SHADOWMAP ) || defined ( USE_TRANSMISSION ) || NUM_SPOT_LIGHT_COORDS > 0\n vWorldPosition = worldPosition.xyz;\n#else\n vWorldPosition = (modelMatrix * vec4(transformed, 1.)).xyz;\n#endif\n}\n",Pf="\n#define LAMBERT\n\nuniform vec3 diffuse;\nuniform float opacity;\n\nvarying vec3 vViewPosition;\nvarying vec3 vWorldPosition;\n\n#ifdef DYNAMIC_SHADOW_RADIUS\n uniform vec2 shadowFadeOut;\n #define fadeOutDistance shadowFadeOut.x\n #define fadeOutBlur shadowFadeOut.y\n uniform vec3 sceneBoxMin;\n uniform vec3 sceneBoxMax;\n#endif\nuniform vec4 distributionProperties;\n#define directionalDependency distributionProperties.x\n#define directionalExponent distributionProperties.y\n#define groundBoundary distributionProperties.z\n#define groundMapScale distributionProperties.w\n\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n\nvec2 getShadowDynamicScale() {\n vec2 dynamicScale = vec2(0.0, 1.0);\n#ifdef DYNAMIC_SHADOW_RADIUS\n if (fadeOutDistance > 0.0) {\n vec3 boxDistanceVec = max(vec3(0.0), max(sceneBoxMin - vWorldPosition, vWorldPosition - sceneBoxMax));\n float boxDistance = length(boxDistanceVec);\n float shadowBase = clamp(boxDistance / fadeOutDistance, 0.0, 1.0);\n dynamicScale = vec2(shadowBase, 1.0 - shadowBase);\n }\n#endif\n return dynamicScale;\n}\n\nfloat getShadowDynamicRadius(sampler2D shadowMap, float shadowBias, float shadowRadius, vec4 shadowCoord, vec2 shadowScale) {\n float dynamicRadius = shadowRadius;\n#ifdef DYNAMIC_SHADOW_RADIUS\n shadowCoord.xyz /= shadowCoord.w;\n shadowCoord.z += shadowBias;\n bool inFrustum = shadowCoord.x >= 0.0 && shadowCoord.x <= 1.0 && shadowCoord.y >= 0.0 && shadowCoord.y <= 1.0;\n bool frustumTest = inFrustum && shadowCoord.z <= 1.0;\n if (frustumTest && fadeOutDistance > 0.0) {\n dynamicRadius = shadowRadius + fadeOutBlur * max(0.0, shadowScale.x);\n }\n#endif\n return dynamicRadius;\n}\n\nvoid main() {\n\n\t#include \n\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\n\t// accumulation\n\n\tvec3 geometryPosition = - vViewPosition;\n vec3 geometryNormal = normal;\n vec3 geometryViewDir = ( isOrthographic ) ? vec3( 0, 0, 1 ) : normalize( vViewPosition );\n\n vec3 accumulatedShadowLight = vec3(0.0);\n vec3 directionDependentShadowLight = vec3(1.0);\n float groundDistance = clamp((vWorldPosition.y - sceneBoxMin.y) * 100.0, 0.0, 1.0);\n vec2 dynamicScale = getShadowDynamicScale();\n\n #if ( NUM_DIR_LIGHTS > 0 )\n DirectionalLight directionalLight;\n #if defined( USE_SHADOWMAP ) && NUM_DIR_LIGHT_SHADOWS > 0\n DirectionalLightShadow directionalLightShadow;\n #endif\n\n IncidentLight directLight;\n vec3 incidentLightSum = vec3(0.0);\n vec3 incidentShadowLight = vec3(0.0);\n float groundShadowFactor = 1.;\n float shadowFactor;\n float dynamicRadius;\n float dotNL;\n\n #pragma unroll_loop_start\n for ( int i = 0 ; i < NUM_DIR_LIGHTS; i ++ ) {\n directionalLight = directionalLights[ i ];\n getDirectionalLightInfo( directionalLight, directLight );\n\n #if defined( USE_SHADOWMAP ) && ( GROUND_BOUNDARY == 1 && UNROLLED_LOOP_INDEX == 0 )\n\n directionalLightShadow = directionalLightShadows[ i ];\n dynamicRadius = fadeOutDistance * groundMapScale;\n groundShadowFactor = groundDistance < 0.5 ? getShadow( directionalShadowMap[ i ], directionalLightShadow.shadowMapSize, directionalLightShadow.shadowIntensity, directionalLightShadow.shadowBias, dynamicRadius, vDirectionalShadowCoord[ i ] ) : 1.0;\n\n #elif defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_DIR_LIGHT_SHADOWS )\n\n directionalLightShadow = directionalLightShadows[ i ];\n dynamicRadius = getShadowDynamicRadius(directionalShadowMap[i], directionalLightShadow.shadowBias, directionalLightShadow.shadowRadius, vDirectionalShadowCoord[i], dynamicScale);\n shadowFactor = ( directLight.visible && receiveShadow ) ? getShadow( directionalShadowMap[ i ], directionalLightShadow.shadowMapSize, directionalLightShadow.shadowIntensity, directionalLightShadow.shadowBias, dynamicRadius, vDirectionalShadowCoord[ i ] ) : 1.0; \n accumulatedShadowLight += directLight.color * shadowFactor * saturate(min(dotNL * 10.0 + 0.9, 1.0));\n dotNL = dot(dot(geometryNormal, geometryPosition) >= 0.0 ? -geometryNormal : geometryNormal, directLight.direction);\n incidentLightSum += directLight.color;\n incidentShadowLight += directLight.color * mix(1.0, shadowFactor, pow(clamp(dotNL, 0.0, 1.0), directionalExponent));\n \n #endif\n }\n #pragma unroll_loop_end\n\n directionDependentShadowLight = incidentShadowLight / ( incidentLightSum + 1. - step(0., incidentLightSum) );\n #else\n accumulatedShadowLight = vec3(1.0);\n #endif \n\n\t// modulation\n\n\tvec3 outgoingLight = mix(accumulatedShadowLight, directionDependentShadowLight, max(directionalDependency, 1.0 - groundDistance));\n #if GROUND_BOUNDARY == 1\n float groundWeight = 1. - groundShadowFactor + groundDistance - (1. - groundShadowFactor) * groundDistance;\n outgoingLight = mix(vec3(1.), outgoingLight, mix(dynamicScale.y, groundWeight, groundBoundary));\n #else\n outgoingLight = mix(vec3(1.), outgoingLight, dynamicScale.y);\n #endif\n\n\t#include \n\t#include \n}\n",Rf="DirectionalLightShadow",Cf={alwaysUpdate:!1,enableShadowMap:!0,enableGroundBoundary:!0,layers:null,shadowLightSourceType:Rf,maximumNumberOfLightSources:-1,directionalDependency:1,directionalExponent:1,groundBoundary:1,fadeOutDistance:.1,fadeOutBlur:5};class Df extends Bp{get shadowTexture(){return this._shadowRenderTarget.texture}set shadowOnGround(e){this._shadowMapPassOverrideMaterialCache.shadowOnGround=e}constructor(e,t,n){var i,r,a;super(e),this.needsUpdate=!1,this.drawGround=!0,this.shadowTypeNeedsUpdate=!0,this.shadowConfiguration=new Nf,this._shadowLightSources=[],this._shadowScale=1,this._groundMapScale=1,this._cameraUpdate=new hh,this._viewportSize=new _t(t.x,t.y),this._samples=null!==(i=null==n?void 0:n.samples)&&void 0!==i?i:0,this._shadowMapSize=null!==(r=null==n?void 0:n.shadowMapSize)&&void 0!==r?r:1024,this.parameters=this._getScreenSpaceShadowMapParameters(n),this.castShadow=this.parameters.enableShadowMap,this._shadowMapPassOverrideMaterialCache=new Of,null===(a=this.renderCacheManager)||void 0===a||a.registerCache(this,this._shadowMapPassOverrideMaterialCache);const s=this._samples;this._shadowRenderTarget=new Gt(this._viewportSize.x,this._viewportSize.y,{samples:s,format:ie,magFilter:z,minFilter:z})}_getScreenSpaceShadowMapParameters(e){return Object.assign(Object.assign({},Cf),e)}dispose(){super.dispose(),this._shadowLightSources.forEach((e=>e.dispose())),this._shadowRenderTarget.dispose(),this._shadowMapPassOverrideMaterialCache.dispose()}updateParameters(e){for(const t in e)this.parameters.hasOwnProperty(t)&&(this.parameters[t]=e[t])}updateBounds(e,t){var n;const i=this._shadowScale;if(this._shadowScale=t,Math.abs(i-this._shadowScale)>1e-5&&(this.shadowTypeNeedsUpdate=!0),this._shadowLightSources.forEach((t=>t.updateBounds(e))),this._shadowLightSources.length>0){const e=null===(n=this._shadowLightSources[0].getShadowLight().shadow)||void 0===n?void 0:n.camera;e instanceof Ur&&(this._groundMapScale=2*this._shadowMapSize/(Math.abs(e.right-e.left)+Math.abs(e.top-e.bottom)))}else this._groundMapScale=1;this._shadowMapPassOverrideMaterialCache.setBoundingBox(e.bounds)}forceShadowUpdate(){this._shadowLightSources.forEach((e=>e.forceShadowUpdate())),this.needsUpdate=!0}getShadowLightSources(){return this._shadowLightSources.map((e=>e.getShadowLight()))}findShadowLightSource(e){var t;return null===(t=this._shadowLightSources.find((t=>t.getOriginalLight()===e)))||void 0===t?void 0:t.getShadowLight()}addRectAreaLight(e,t){const n=new Bf(e,{shadowMapSize:this._shadowMapSize,shadowLightSourceType:this.parameters.shadowLightSourceType});this._shadowLightSources.push(n),n.addTo(t),n.updatePositionAndTarget(),this.needsUpdate=!0}updateRectAreaLights(e,t){const n=this._shadowLightSources;this._shadowLightSources=this._createShadowLightSourceArray(!1);for(const i of n){if(i instanceof Bf){const t=i.getRectAreaLight();e.includes(t)&&(i.updatePositionAndTarget(),this._shadowLightSources.push(i))}i.removeFrom(t),i.dispose()}e.forEach((e=>{this._shadowLightSources.find((t=>t instanceof Bf&&t.getRectAreaLight()===e))||this.addRectAreaLight(e,t)})),this.needsUpdate=!0,this.shadowTypeNeedsUpdate=!0}createShadowFromLightSources(e,t){for(const t of this._shadowLightSources)t.removeFrom(e),t.dispose();this._shadowLightSources=this._createShadowLightSourceArray(!0);const n=1/(t.length>0?Math.max(...t.map((e=>e.maxIntensity))):1);this._addShadowFromLightSources(t,n),this._shadowLightSources.forEach((t=>{t.addTo(e),t.updatePositionAndTarget()})),this.needsUpdate=!0,this.shadowTypeNeedsUpdate=!0}_addShadowFromLightSources(e,t){e.forEach((e=>{const n=e.maxIntensity*t;if(n>=.1&&e.position.z>=0){const t=new Yt(e.position.x,e.position.z,e.position.y).multiplyScalar(7),i=new zf(t,n,{shadowMapSize:this._shadowMapSize,shadowLightSourceType:this.parameters.shadowLightSourceType});this._shadowLightSources.push(i)}}))}_createShadowLightSourceArray(e){const t=[];if(e){const e=new kf(new Yt(0,7,0),{shadowMapSize:this._shadowMapSize});t.push(e)}return this.parameters.enableGroundBoundary=e,t}setSize(e,t){this._viewportSize=new _t(e,t),this._shadowRenderTarget.setSize(this._viewportSize.x,this._viewportSize.y)}updatePositionAndTarget(){this._shadowLightSources.forEach((e=>e.updatePositionAndTarget()))}renderPass(e){if(!(this.needsUpdate||this.parameters.alwaysUpdate||this._cameraUpdate.changed(this.camera)))return;this.needsUpdate=!1,this.shadowTypeNeedsUpdate&&(this.shadowTypeNeedsUpdate=!1,this.needsUpdate=!0,this._updateShadowType(e));const t=this.scene.background,n=this.scene.environment,i=this.camera.layers.mask;this.scene.environment=null,this.scene.background=null,this.parameters.layers&&(this.camera.layers.mask=this.parameters.layers.mask),this.renderPassManager.setGroundVisibility(this.drawGround),this._renderSimpleShadowMapFromShadowLightSources(e,this.scene,this.camera),this.renderPassManager.setGroundVisibility(!1),this.camera.layers.mask=i,this.scene.environment=n,this.scene.background=t}_renderSimpleShadowMapFromShadowLightSources(e,t,n){var i;this._shadowMapPassOverrideMaterialCache.setShadowParameters(this.parameters.enableGroundBoundary,this.parameters.directionalDependency,this.parameters.directionalExponent,this.parameters.groundBoundary,this._groundMapScale,this.parameters.fadeOutDistance*this._shadowScale,this.parameters.fadeOutBlur);const r=this._getSortedShadowLightSources();0===r.length?this.passRenderer.clear(e,this._shadowRenderTarget,16777215,1):(this._setShadowLightSourcesIntensity(r),null===(i=this.renderCacheManager)||void 0===i||i.render(this,t,(()=>{this.passRenderer.render(e,t,n,this._shadowRenderTarget,16777215,1)})),this._shadowLightSources.forEach((e=>e.finishRenderShadow())))}_getSortedShadowLightSources(){const e=[];return this._shadowLightSources.forEach((t=>e.push(...t.prepareRenderShadow()))),e.sort(((e,t)=>e.light.castShadow&&!t.light.castShadow||e.groundShadow&&!t.groundShadow?-1:!e.light.castShadow&&t.light.castShadow||!e.groundShadow&&t.groundShadow?1:t.intensity-e.intensity)),e}_setShadowLightSourcesIntensity(e){let t=0;const n=this.parameters.maximumNumberOfLightSources;let i=0;e.forEach((e=>{(n<0||i{var r;!this.parameters.enableGroundBoundary&&e.groundShadow||!(n<0||ie._updateShadowType(this.shadowConfiguration.currentConfiguration,this._shadowScale)))}switchType(e){return!!this.shadowConfiguration.switchType(e)&&(this.needsUpdate=!0,this.shadowTypeNeedsUpdate=!0,!0)}}const Lf="unlit",If="emissive",Uf="shadow";class Of extends vf{set shadowOnGround(e){this._shadowOnGround=e}constructor(){super(),this._boundingBoxSet=!1,this._shadowOnGround=!0,this._shadowObjectMaterial=this._createShadowMaterial("default"),this._unlitMaterial=this._createShadowMaterial(Lf),this._emissiveMaterial=this._createShadowMaterial(If),this._receiveShadowMaterial=this._createShadowMaterial(Uf)}dispose(){this._shadowObjectMaterial.dispose(),this._unlitMaterial.dispose(),this._emissiveMaterial.dispose(),this._receiveShadowMaterial.dispose()}setShadowParameters(e,t,n,i,r,a,s){Ef.setShadowParameters(e,t,n,i,r,a,s)}setBoundingBox(e){this._boundingBoxSet=!0,Ef.setBoundingBox(e)}_createShadowMaterial(e){let t;return t=e===If||e===Lf?new yi({color:16777215,side:2}):e===Uf?new Ml({side:2}):Of.useModifiedMaterial?this._createCustomerShadowMaterial():new Al({color:16777215,shininess:0,polygonOffsetFactor:0,polygonOffsetUnits:0,side:2}),t}_createCustomerShadowMaterial(){return new Ef({side:2})}addLineOrPoint(e){this.addToCache(e,{visible:!1})}addMesh(e){e.visible&&this._setMeshMaterialAndVisibility(e)}addObject(e){e.isLight&&!e.userData.shadowLightSource&&this.addToCache(e,{visible:!1})}_setMeshMaterialAndVisibility(e){e.userData.isFloor?this._setMeshShadowFloorMaterial(e):!e.material||!e.receiveShadow||Array.isArray(e.material)||!0===e.material.transparent&&e.material.opacity<.9?e.material&&e.material.transparent&&e.material.opacity<.9?this.addToCache(e,{visible:!1}):e.receiveShadow?this.addToCache(e,{castShadow:!1,material:this._receiveShadowMaterial}):this.addToCache(e,{visible:!1}):this._setShadowMaterialForOpaqueObject(e)}_setShadowMaterialForOpaqueObject(e){const t=e.material;t instanceof No||t instanceof yi?this.addToCache(e,{material:this._unlitMaterial}):t instanceof Tl?this._setMeshShadowStandardMaterial(e,t):this.addToCache(e,{material:e.receiveShadow?this._shadowObjectMaterial:this._unlitMaterial})}_setMeshShadowStandardMaterial(e,t){const n=t.emissiveIntensity>0&&(t.emissive.r>0||t.emissive.g>0||t.emissive.b>0);this.addToCache(e,{castShadow:!n&&e.castShadow,material:n?this._emissiveMaterial:e.receiveShadow?this._shadowObjectMaterial:this._unlitMaterial})}_setMeshShadowFloorMaterial(e){this._boundingBoxSet&&this._shadowOnGround?this.addToCache(e,{visible:!0,castShadow:!1,receiveShadow:!0,material:this._shadowObjectMaterial}):this.addToCache(e,{visible:!1})}}Of.useModifiedMaterial=!0;class Nf{constructor(){var e;this.types=new Map([["off",Nf._noShadow],["BasicShadowMap",Nf._basicShadow],["PCFShadowMap",Nf._pcfShadow],["PCFSoftShadowMap",Nf._pcfSoftShadow],["VSMShadowMap",Nf._vcmShadow]]),this.shadowType="PCFShadowMap",this.currentConfiguration=null!==(e=this.types.get(this.shadowType))&&void 0!==e?e:Nf._defaultType}switchType(e){var t;return!!this.types.has(e)&&(this.currentConfiguration=null!==(t=this.types.get(e))&&void 0!==t?t:Nf._defaultType,!0)}}Nf._noShadow={castShadow:!1,type:1,bias:0,normalBias:0,radius:0},Nf._basicShadow={castShadow:!0,type:0,bias:-5e-5,normalBias:.005,radius:0},Nf._pcfShadow={castShadow:!0,type:1,bias:-5e-5,normalBias:.01,radius:4},Nf._pcfSoftShadow={castShadow:!0,type:2,bias:-5e-5,normalBias:.01,radius:1},Nf._vcmShadow={castShadow:!0,type:3,bias:1e-4,normalBias:0,radius:15},Nf._defaultType=Nf._pcfShadow;class Ff{constructor(e,t){var n,i;this._isVisibleBackup=!0,this._castShadowBackup=!0,this._shadowMapSize=null!==(n=null==t?void 0:t.shadowMapSize)&&void 0!==n?n:1024,this._blurSamples=null!==(i=null==t?void 0:t.blurSamples)&&void 0!==i?i:8,this._shadowLightSource=e,this._shadowLightSource.visible=!1,this._shadowLightSource.castShadow=!0,this._shadowLightSource.shadow&&(this._shadowLightSource.shadow.mapSize=new _t(this._shadowMapSize,this._shadowMapSize),this._shadowLightSource.shadow.blurSamples=this._blurSamples,this._shadowLightSource.shadow.autoUpdate=!1),this._shadowLightSource.userData.shadowLightSource=this}getPosition(){return this._shadowLightSource.position}getShadowLight(){return this._shadowLightSource}getOriginalLight(){return null}dispose(){this._shadowLightSource.dispose()}addTo(e){e.add(this._shadowLightSource)}removeFrom(e){e.remove(this._shadowLightSource)}updatePositionAndTarget(){this._updateShadowPositionAndTarget(this.getPosition(),new Yt(0,0,0))}updateBounds(e){if(this._shadowLightSource instanceof hc){const t=this._shadowLightSource.shadow.camera,n=e.bounds.clone().applyMatrix4(t.matrixWorldInverse),i=Math.max(.001,Math.min(-n.min.z,-n.max.z)),r=Math.max(-n.min.z,-n.max.z),a=Math.max(Math.abs(n.min.x),Math.abs(n.max.x)),s=Math.max(Math.abs(n.min.y),Math.abs(n.max.y)),o=Math.atan2(1.05*Math.hypot(s,a),i);t.aspect=1,t.near=i,t.far=r,this._shadowLightSource.angle=o}else if(this._shadowLightSource.shadow){const t=this._shadowLightSource.shadow.camera;e.updateCameraViewVolumeFromBounds(t);const n=t;n.far+=n.far-n.near,n.updateProjectionMatrix()}this._shadowLightSource.shadow&&(this._shadowLightSource.shadow.needsUpdate=!0)}forceShadowUpdate(){this._shadowLightSource.shadow&&(this._shadowLightSource.shadow.needsUpdate=!0)}_updateShadowPositionAndTarget(e,t){var n,i,r;if(this._shadowLightSource instanceof hc){const n=t.clone().sub(e),i=n.length();n.normalize();const r=t.clone().sub(n.clone().multiplyScalar(4*i));this._shadowLightSource.shadow.camera.position.copy(r),this._shadowLightSource.shadow.camera.position.copy(r),this._shadowLightSource.shadow.camera.lookAt(t),this._shadowLightSource.position.copy(r),this._shadowLightSource.lookAt(t)}else this._shadowLightSource.position.copy(e),this._shadowLightSource.lookAt(t),null===(n=this._shadowLightSource.shadow)||void 0===n||n.camera.position.copy(e),null===(i=this._shadowLightSource.shadow)||void 0===i||i.camera.lookAt(t);null===(r=this._shadowLightSource.shadow)||void 0===r||r.camera.updateMatrixWorld(),this._shadowLightSource.updateMatrixWorld()}_updateShadowType(e,t){const n=this._shadowLightSource.shadow;n&&(n.bias=e.bias,n.normalBias=e.normalBias*t,n.radius=e.radius,n.needsUpdate=!0)}prepareRenderShadow(){return[]}finishRenderShadow(){}}class Bf extends Ff{constructor(e,t){let n;switch(null==t?void 0:t.shadowLightSourceType){default:case Rf:n=new vc(16777215,1);break;case"SpotLightShadow":n=new hc(16777215,1,0,Math.PI/4,0)}n.position.copy(e.position),n.lookAt(0,0,0),super(n,t),this._rectAreaLight=e,this._rectAreaLight.userData.shadowLightSource=this,(null==t?void 0:t.addHelper)&&(this._rectLightHelper=new Tf(this._rectAreaLight),this._rectLightHelper.material.depthWrite=!1,this._rectAreaLight.add(this._rectLightHelper))}getPosition(){return this._rectAreaLight.position}getRectAreaLight(){return this._rectAreaLight}getOriginalLight(){return this._rectAreaLight}prepareRenderShadow(){return this._isVisibleBackup=this._rectAreaLight.visible,this._castShadowBackup=this._shadowLightSource.castShadow,this._shadowLightSource.visible=this._rectAreaLight.visible,this._rectAreaLight.visible=!1,this._shadowLightSource.visible?[{light:this._shadowLightSource,intensity:this._rectAreaLight.intensity,groundShadow:!1}]:[]}finishRenderShadow(){this._shadowLightSource.visible=!1,this._shadowLightSource.castShadow=this._castShadowBackup,this._rectAreaLight.visible=this._isVisibleBackup}}class zf extends Ff{constructor(e,t,n){const i=new vc(16777215,t);i.position.copy(e),i.lookAt(0,0,0),i.updateMatrix(),i.castShadow=!0,super(i,n),this._position=e.clone(),this._intensity=t}getPosition(){return this._position}prepareRenderShadow(){return this._castShadowBackup=this._shadowLightSource.castShadow,this._shadowLightSource.visible=!0,[{light:this._shadowLightSource,intensity:this._intensity,groundShadow:!1}]}finishRenderShadow(){this._shadowLightSource.castShadow=this._castShadowBackup,this._shadowLightSource.visible=!1}}class kf extends Ff{constructor(e,t){const n=new vc(16777215,1);n.position.copy(e),n.lookAt(0,0,0),n.updateMatrix(),n.castShadow=!0,super(n,t),this._position=e.clone()}getPosition(){return this._position}prepareRenderShadow(){return this._castShadowBackup=this._shadowLightSource.castShadow,this._shadowLightSource.visible=!0,[{light:this._shadowLightSource,intensity:1,groundShadow:!0}]}finishRenderShadow(){this._shadowLightSource.castShadow=this._castShadowBackup,this._shadowLightSource.visible=!1}}const Hf={name:"CopyShader",uniforms:{tDiffuse:{value:null},opacity:{value:1}},vertexShader:"\n\n\t\tvarying vec2 vUv;\n\n\t\tvoid main() {\n\n\t\t\tvUv = uv;\n\t\t\tgl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n\n\t\t}",fragmentShader:"\n\n\t\tuniform float opacity;\n\n\t\tuniform sampler2D tDiffuse;\n\n\t\tvarying vec2 vUv;\n\n\t\tvoid main() {\n\n\t\t\tvec4 texel = texture2D( tDiffuse, vUv );\n\t\t\tgl_FragColor = opacity * texel;\n\n\n\t\t}"},Vf={name:"FXAAShader",uniforms:{tDiffuse:{value:null},resolution:{value:new _t(1/1024,1/512)}},vertexShader:"\n\n\t\tvarying vec2 vUv;\n\n\t\tvoid main() {\n\n\t\t\tvUv = uv;\n\t\t\tgl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n\n\t\t}",fragmentShader:"\n\n\t\t// FXAA algorithm from NVIDIA, C# implementation by Jasper Flick, GLSL port by Dave Hoskins\n\t\t// http://developer.download.nvidia.com/assets/gamedev/files/sdk/11/FXAA_WhitePaper.pdf\n\t\t// https://catlikecoding.com/unity/tutorials/advanced-rendering/fxaa/\n\n\t\tuniform sampler2D tDiffuse;\n\t\tuniform vec2 resolution;\n\t\tvarying vec2 vUv;\n\n\t\t#define EDGE_STEP_COUNT 6\n\t\t#define EDGE_GUESS 8.0\n\t\t#define EDGE_STEPS 1.0, 1.5, 2.0, 2.0, 2.0, 4.0\n\t\tconst float edgeSteps[EDGE_STEP_COUNT] = float[EDGE_STEP_COUNT]( EDGE_STEPS );\n\n\t\tfloat _ContrastThreshold = 0.0312;\n\t\tfloat _RelativeThreshold = 0.063;\n\t\tfloat _SubpixelBlending = 1.0;\n\n\t\tvec4 Sample( sampler2D tex2D, vec2 uv ) {\n\n\t\t\treturn texture( tex2D, uv );\n\n\t\t}\n\n\t\tfloat SampleLuminance( sampler2D tex2D, vec2 uv ) {\n\n\t\t\treturn dot( Sample( tex2D, uv ).rgb, vec3( 0.3, 0.59, 0.11 ) );\n\n\t\t}\n\n\t\tfloat SampleLuminance( sampler2D tex2D, vec2 texSize, vec2 uv, float uOffset, float vOffset ) {\n\n\t\t\tuv += texSize * vec2(uOffset, vOffset);\n\t\t\treturn SampleLuminance(tex2D, uv);\n\n\t\t}\n\n\t\tstruct LuminanceData {\n\n\t\t\tfloat m, n, e, s, w;\n\t\t\tfloat ne, nw, se, sw;\n\t\t\tfloat highest, lowest, contrast;\n\n\t\t};\n\n\t\tLuminanceData SampleLuminanceNeighborhood( sampler2D tex2D, vec2 texSize, vec2 uv ) {\n\n\t\t\tLuminanceData l;\n\t\t\tl.m = SampleLuminance( tex2D, uv );\n\t\t\tl.n = SampleLuminance( tex2D, texSize, uv, 0.0, 1.0 );\n\t\t\tl.e = SampleLuminance( tex2D, texSize, uv, 1.0, 0.0 );\n\t\t\tl.s = SampleLuminance( tex2D, texSize, uv, 0.0, -1.0 );\n\t\t\tl.w = SampleLuminance( tex2D, texSize, uv, -1.0, 0.0 );\n\n\t\t\tl.ne = SampleLuminance( tex2D, texSize, uv, 1.0, 1.0 );\n\t\t\tl.nw = SampleLuminance( tex2D, texSize, uv, -1.0, 1.0 );\n\t\t\tl.se = SampleLuminance( tex2D, texSize, uv, 1.0, -1.0 );\n\t\t\tl.sw = SampleLuminance( tex2D, texSize, uv, -1.0, -1.0 );\n\n\t\t\tl.highest = max( max( max( max( l.n, l.e ), l.s ), l.w ), l.m );\n\t\t\tl.lowest = min( min( min( min( l.n, l.e ), l.s ), l.w ), l.m );\n\t\t\tl.contrast = l.highest - l.lowest;\n\t\t\treturn l;\n\n\t\t}\n\n\t\tbool ShouldSkipPixel( LuminanceData l ) {\n\n\t\t\tfloat threshold = max( _ContrastThreshold, _RelativeThreshold * l.highest );\n\t\t\treturn l.contrast < threshold;\n\n\t\t}\n\n\t\tfloat DeterminePixelBlendFactor( LuminanceData l ) {\n\n\t\t\tfloat f = 2.0 * ( l.n + l.e + l.s + l.w );\n\t\t\tf += l.ne + l.nw + l.se + l.sw;\n\t\t\tf *= 1.0 / 12.0;\n\t\t\tf = abs( f - l.m );\n\t\t\tf = clamp( f / l.contrast, 0.0, 1.0 );\n\n\t\t\tfloat blendFactor = smoothstep( 0.0, 1.0, f );\n\t\t\treturn blendFactor * blendFactor * _SubpixelBlending;\n\n\t\t}\n\n\t\tstruct EdgeData {\n\n\t\t\tbool isHorizontal;\n\t\t\tfloat pixelStep;\n\t\t\tfloat oppositeLuminance, gradient;\n\n\t\t};\n\n\t\tEdgeData DetermineEdge( vec2 texSize, LuminanceData l ) {\n\n\t\t\tEdgeData e;\n\t\t\tfloat horizontal =\n\t\t\t\tabs( l.n + l.s - 2.0 * l.m ) * 2.0 +\n\t\t\t\tabs( l.ne + l.se - 2.0 * l.e ) +\n\t\t\t\tabs( l.nw + l.sw - 2.0 * l.w );\n\t\t\tfloat vertical =\n\t\t\t\tabs( l.e + l.w - 2.0 * l.m ) * 2.0 +\n\t\t\t\tabs( l.ne + l.nw - 2.0 * l.n ) +\n\t\t\t\tabs( l.se + l.sw - 2.0 * l.s );\n\t\t\te.isHorizontal = horizontal >= vertical;\n\n\t\t\tfloat pLuminance = e.isHorizontal ? l.n : l.e;\n\t\t\tfloat nLuminance = e.isHorizontal ? l.s : l.w;\n\t\t\tfloat pGradient = abs( pLuminance - l.m );\n\t\t\tfloat nGradient = abs( nLuminance - l.m );\n\n\t\t\te.pixelStep = e.isHorizontal ? texSize.y : texSize.x;\n\t\t\t\n\t\t\tif (pGradient < nGradient) {\n\n\t\t\t\te.pixelStep = -e.pixelStep;\n\t\t\t\te.oppositeLuminance = nLuminance;\n\t\t\t\te.gradient = nGradient;\n\n\t\t\t} else {\n\n\t\t\t\te.oppositeLuminance = pLuminance;\n\t\t\t\te.gradient = pGradient;\n\n\t\t\t}\n\n\t\t\treturn e;\n\n\t\t}\n\n\t\tfloat DetermineEdgeBlendFactor( sampler2D tex2D, vec2 texSize, LuminanceData l, EdgeData e, vec2 uv ) {\n\n\t\t\tvec2 uvEdge = uv;\n\t\t\tvec2 edgeStep;\n\t\t\tif (e.isHorizontal) {\n\n\t\t\t\tuvEdge.y += e.pixelStep * 0.5;\n\t\t\t\tedgeStep = vec2( texSize.x, 0.0 );\n\n\t\t\t} else {\n\n\t\t\t\tuvEdge.x += e.pixelStep * 0.5;\n\t\t\t\tedgeStep = vec2( 0.0, texSize.y );\n\n\t\t\t}\n\n\t\t\tfloat edgeLuminance = ( l.m + e.oppositeLuminance ) * 0.5;\n\t\t\tfloat gradientThreshold = e.gradient * 0.25;\n\n\t\t\tvec2 puv = uvEdge + edgeStep * edgeSteps[0];\n\t\t\tfloat pLuminanceDelta = SampleLuminance( tex2D, puv ) - edgeLuminance;\n\t\t\tbool pAtEnd = abs( pLuminanceDelta ) >= gradientThreshold;\n\n\t\t\tfor ( int i = 1; i < EDGE_STEP_COUNT && !pAtEnd; i++ ) {\n\n\t\t\t\tpuv += edgeStep * edgeSteps[i];\n\t\t\t\tpLuminanceDelta = SampleLuminance( tex2D, puv ) - edgeLuminance;\n\t\t\t\tpAtEnd = abs( pLuminanceDelta ) >= gradientThreshold;\n\n\t\t\t}\n\n\t\t\tif ( !pAtEnd ) {\n\n\t\t\t\tpuv += edgeStep * EDGE_GUESS;\n\n\t\t\t}\n\n\t\t\tvec2 nuv = uvEdge - edgeStep * edgeSteps[0];\n\t\t\tfloat nLuminanceDelta = SampleLuminance( tex2D, nuv ) - edgeLuminance;\n\t\t\tbool nAtEnd = abs( nLuminanceDelta ) >= gradientThreshold;\n\n\t\t\tfor ( int i = 1; i < EDGE_STEP_COUNT && !nAtEnd; i++ ) {\n\n\t\t\t\tnuv -= edgeStep * edgeSteps[i];\n\t\t\t\tnLuminanceDelta = SampleLuminance( tex2D, nuv ) - edgeLuminance;\n\t\t\t\tnAtEnd = abs( nLuminanceDelta ) >= gradientThreshold;\n\n\t\t\t}\n\n\t\t\tif ( !nAtEnd ) {\n\n\t\t\t\tnuv -= edgeStep * EDGE_GUESS;\n\n\t\t\t}\n\n\t\t\tfloat pDistance, nDistance;\n\t\t\tif ( e.isHorizontal ) {\n\n\t\t\t\tpDistance = puv.x - uv.x;\n\t\t\t\tnDistance = uv.x - nuv.x;\n\n\t\t\t} else {\n\t\t\t\t\n\t\t\t\tpDistance = puv.y - uv.y;\n\t\t\t\tnDistance = uv.y - nuv.y;\n\n\t\t\t}\n\n\t\t\tfloat shortestDistance;\n\t\t\tbool deltaSign;\n\t\t\tif ( pDistance <= nDistance ) {\n\n\t\t\t\tshortestDistance = pDistance;\n\t\t\t\tdeltaSign = pLuminanceDelta >= 0.0;\n\n\t\t\t} else {\n\n\t\t\t\tshortestDistance = nDistance;\n\t\t\t\tdeltaSign = nLuminanceDelta >= 0.0;\n\n\t\t\t}\n\n\t\t\tif ( deltaSign == ( l.m - edgeLuminance >= 0.0 ) ) {\n\n\t\t\t\treturn 0.0;\n\n\t\t\t}\n\n\t\t\treturn 0.5 - shortestDistance / ( pDistance + nDistance );\n\n\t\t}\n\n\t\tvec4 ApplyFXAA( sampler2D tex2D, vec2 texSize, vec2 uv ) {\n\n\t\t\tLuminanceData luminance = SampleLuminanceNeighborhood( tex2D, texSize, uv );\n\t\t\tif ( ShouldSkipPixel( luminance ) ) {\n\n\t\t\t\treturn Sample( tex2D, uv );\n\n\t\t\t}\n\n\t\t\tfloat pixelBlend = DeterminePixelBlendFactor( luminance );\n\t\t\tEdgeData edge = DetermineEdge( texSize, luminance );\n\t\t\tfloat edgeBlend = DetermineEdgeBlendFactor( tex2D, texSize, luminance, edge, uv );\n\t\t\tfloat finalBlend = max( pixelBlend, edgeBlend );\n\n\t\t\tif (edge.isHorizontal) {\n\n\t\t\t\tuv.y += edge.pixelStep * finalBlend;\n\n\t\t\t} else {\n\n\t\t\t\tuv.x += edge.pixelStep * finalBlend;\n\n\t\t\t}\n\n\t\t\treturn Sample( tex2D, uv );\n\n\t\t}\n\n\t\tvoid main() {\n\n\t\t\tgl_FragColor = ApplyFXAA( tDiffuse, resolution.xy, vUv );\n\t\t\t\n\t\t}"};class Gf extends Bp{constructor(e,t,n,i,r,a){var s;super(e),this.patternTexture=null,this.clearBackground=!1,this.renderScene=n,this.renderCamera=i,this.selectedObjects=void 0!==r?r:[],this.visibleEdgeColor=new gi(1,1,1),this.hiddenEdgeColor=new gi(.1,.04,.02),this.edgeGlow=0,this.usePatternTexture=!1,this.edgeThickness=1,this.edgeStrength=3,this.downSampleRatio=(null==a?void 0:a.downSampleRatio)||2,this.pulsePeriod=0,this.edgeDetectionFxaa=(null==a?void 0:a.edgeDetectionFxaa)||!1,this._visibilityCache=new Map,this.resolution=void 0!==t?new _t(t.x,t.y):new _t(256,256);const o=Math.round(this.resolution.x/this.downSampleRatio),l=Math.round(this.resolution.y/this.downSampleRatio);this.renderTargetMaskBuffer=new Gt(this.resolution.x,this.resolution.y),this.renderTargetMaskBuffer.texture.name="OutlinePass.mask",this.renderTargetMaskBuffer.texture.generateMipmaps=!1,this.prepareMaskMaterial=this._getPrepareMaskMaterial(null===(s=this.gBufferTextures)||void 0===s?void 0:s.isFloatGBufferWithRgbNormalAlphaDepth),this.prepareMaskMaterial.side=2,this.prepareMaskMaterial.fragmentShader=function(e,t){const n=t.isPerspectiveCamera?"perspective":"orthographic";return e.replace(/DEPTH_TO_VIEW_Z/g,n+"DepthToViewZ")}(this.prepareMaskMaterial.fragmentShader,this.renderCamera),this.edgeDetectionFxaa&&(this.fxaaRenderMaterial=new nr(Vf),this.fxaaRenderMaterial.uniforms.tDiffuse.value=this.renderTargetMaskBuffer.texture,this.fxaaRenderMaterial.uniforms.resolution.value.set(1/this.resolution.x,1/this.resolution.y),this.renderTargetFxaaBuffer=new Gt(this.resolution.x,this.resolution.y),this.renderTargetFxaaBuffer.texture.name="OutlinePass.fxaa",this.renderTargetFxaaBuffer.texture.generateMipmaps=!1),this.renderTargetMaskDownSampleBuffer=new Gt(o,l),this.renderTargetMaskDownSampleBuffer.texture.name="OutlinePass.depthDownSample",this.renderTargetMaskDownSampleBuffer.texture.generateMipmaps=!1,this.renderTargetBlurBuffer1=new Gt(o,l),this.renderTargetBlurBuffer1.texture.name="OutlinePass.blur1",this.renderTargetBlurBuffer1.texture.generateMipmaps=!1,this.renderTargetBlurBuffer2=new Gt(Math.round(o/2),Math.round(l/2)),this.renderTargetBlurBuffer2.texture.name="OutlinePass.blur2",this.renderTargetBlurBuffer2.texture.generateMipmaps=!1,this.edgeDetectionMaterial=this._getEdgeDetectionMaterial(),this.renderTargetEdgeBuffer1=new Gt(o,l),this.renderTargetEdgeBuffer1.texture.name="OutlinePass.edge1",this.renderTargetEdgeBuffer1.texture.generateMipmaps=!1,this.renderTargetEdgeBuffer2=new Gt(Math.round(o/2),Math.round(l/2)),this.renderTargetEdgeBuffer2.texture.name="OutlinePass.edge2",this.renderTargetEdgeBuffer2.texture.generateMipmaps=!1,this.separableBlurMaterial1=this._getSeperableBlurMaterial(4),this.separableBlurMaterial1.uniforms.texSize.value.set(o,l),this.separableBlurMaterial1.uniforms.kernelRadius.value=1,this.separableBlurMaterial2=this._getSeperableBlurMaterial(4),this.separableBlurMaterial2.uniforms.texSize.value.set(Math.round(o/2),Math.round(l/2)),this.separableBlurMaterial2.uniforms.kernelRadius.value=4,this.overlayMaterial=this._getOverlayMaterial();const c=Hf;this.copyUniforms=tr.clone(c.uniforms),this.copyUniforms.opacity.value=1,this.materialCopy=new nr({uniforms:this.copyUniforms,vertexShader:c.vertexShader,fragmentShader:c.fragmentShader,blending:0,depthTest:!1,depthWrite:!1,transparent:!0}),this.enabled=!0,this.needsSwap=!1,this.oldClearColor=new gi,this.oldClearAlpha=1,this.fsQuad=new ih(void 0),this.tempPulseColor1=new gi,this.tempPulseColor2=new gi,this.textureMatrix=new Mn}dispose(){var e,t;super.dispose(),this.renderTargetMaskBuffer.dispose(),null===(e=this.renderTargetFxaaBuffer)||void 0===e||e.dispose(),this.renderTargetMaskDownSampleBuffer.dispose(),this.renderTargetBlurBuffer1.dispose(),this.renderTargetBlurBuffer2.dispose(),this.renderTargetEdgeBuffer1.dispose(),this.renderTargetEdgeBuffer2.dispose(),this.prepareMaskMaterial.dispose(),null===(t=this.fxaaRenderMaterial)||void 0===t||t.dispose(),this.edgeDetectionMaterial.dispose(),this.separableBlurMaterial1.dispose(),this.separableBlurMaterial2.dispose(),this.overlayMaterial.dispose(),this.materialCopy.dispose(),this.fsQuad.dispose()}setSize(e,t){var n,i;this.renderTargetMaskBuffer.setSize(e,t);let r=Math.round(e/this.downSampleRatio),a=Math.round(t/this.downSampleRatio);this.renderTargetMaskDownSampleBuffer.setSize(r,a),this.renderTargetBlurBuffer1.setSize(r,a),this.renderTargetEdgeBuffer1.setSize(r,a),this.separableBlurMaterial1.uniforms.texSize.value.set(r,a),r=Math.round(r/2),a=Math.round(a/2),this.renderTargetBlurBuffer2.setSize(r,a),this.renderTargetEdgeBuffer2.setSize(r,a),this.separableBlurMaterial2.uniforms.texSize.value.set(r,a),null===(n=this.fxaaRenderMaterial)||void 0===n||n.uniforms.resolution.value.set(1/this.resolution.x,1/this.resolution.y),null===(i=this.renderTargetFxaaBuffer)||void 0===i||i.setSize(e,t)}_canBeHighlighted(e){return e.isMesh||Gf.highlightLines&&e.isLine}_changeVisibilityOfSelectedObjects(e){const t=this._visibilityCache;this.selectedObjects.forEach((n=>n.traverse((n=>{this._canBeHighlighted(n)&&(!0===e?n.visible=t.get(n):(t.set(n,n.visible),n.visible=e))}))))}_changeVisibilityOfNonSelectedObjects(e){const t=this._visibilityCache,n=[];this.selectedObjects.forEach((e=>e.traverse((e=>{this._canBeHighlighted(e)&&n.push(e)})))),this.renderScene.traverse((i=>{if(this._canBeHighlighted(i)||i.isSprite){if(!1===n.some((e=>e.id===i.id))){const n=i.visible;!1!==e&&!0!==t.get(i)||(i.visible=e),t.set(i,n)}}else i.isPoints&&(!0===e?i.visible=t.get(i):(t.set(i,i.visible),i.visible=e))}))}_updateTextureMatrix(){this.textureMatrix.set(.5,0,0,.5,0,.5,0,.5,0,0,.5,.5,0,0,0,1),this.textureMatrix.multiply(this.renderCamera.projectionMatrix),this.textureMatrix.multiply(this.renderCamera.matrixWorldInverse)}render(e,t,n,i,r){if(this.selectedObjects.length>0){e.getClearColor(this.oldClearColor),this.oldClearAlpha=e.getClearAlpha();const t=e.autoClear;this.clearBackground&&(e.setClearColor(0,255),e.clear(!0,!1,!1)),e.autoClear=!1,r&&e.state.buffers.stencil.setTest(!1),e.setClearColor(16777215,1),this._changeVisibilityOfSelectedObjects(!1);const i=this.renderScene.background;this.renderScene.background=null,this._changeVisibilityOfSelectedObjects(!0),this._visibilityCache.clear(),this._updateTextureMatrix(),this._changeVisibilityOfNonSelectedObjects(!1),this.renderScene.overrideMaterial=this.prepareMaskMaterial,this.prepareMaskMaterial.uniforms.cameraNearFar.value.set(this.renderCamera.near,this.renderCamera.far),this.prepareMaskMaterial.uniforms.depthTexture.value=this.gBufferTextures.textureWithDepthValue,this.prepareMaskMaterial.uniforms.textureMatrix.value=this.textureMatrix,e.setRenderTarget(this.renderTargetMaskBuffer),e.clear(),e.render(this.renderScene,this.renderCamera),this.renderScene.overrideMaterial=null,this._changeVisibilityOfNonSelectedObjects(!0),this._visibilityCache.clear(),this.renderScene.background=i;let a=this.renderTargetMaskBuffer;if(this.edgeDetectionFxaa&&this.fxaaRenderMaterial&&this.renderTargetFxaaBuffer&&(this.fxaaRenderMaterial.uniforms.tDiffuse.value=this.renderTargetMaskBuffer.texture,this.fsQuad.material=this.fxaaRenderMaterial,e.setRenderTarget(this.renderTargetFxaaBuffer),e.clear(),this.fsQuad.render(e),a=this.renderTargetFxaaBuffer),this.fsQuad.material=this.materialCopy,this.copyUniforms.tDiffuse.value=a.texture,e.setRenderTarget(this.renderTargetMaskDownSampleBuffer),e.clear(),this.fsQuad.render(e),this.tempPulseColor1.copy(this.visibleEdgeColor),this.tempPulseColor2.copy(this.hiddenEdgeColor),this.pulsePeriod>0){const e=.625+.75*Math.cos(.01*performance.now()/this.pulsePeriod)/2;this.tempPulseColor1.multiplyScalar(e),this.tempPulseColor2.multiplyScalar(e)}this.fsQuad.material=this.edgeDetectionMaterial,this.edgeDetectionMaterial.uniforms.maskTexture.value=this.renderTargetMaskDownSampleBuffer.texture,this.edgeDetectionMaterial.uniforms.texSize.value.set(this.renderTargetMaskDownSampleBuffer.width,this.renderTargetMaskDownSampleBuffer.height),this.edgeDetectionMaterial.uniforms.visibleEdgeColor.value=this.tempPulseColor1,this.edgeDetectionMaterial.uniforms.hiddenEdgeColor.value=this.tempPulseColor2,e.setRenderTarget(this.renderTargetEdgeBuffer1),e.clear(),this.fsQuad.render(e),this.fsQuad.material=this.separableBlurMaterial1,this.separableBlurMaterial1.uniforms.colorTexture.value=this.renderTargetEdgeBuffer1.texture,this.separableBlurMaterial1.uniforms.direction.value=Gf.BlurDirectionX,this.separableBlurMaterial1.uniforms.kernelRadius.value=this.edgeThickness,e.setRenderTarget(this.renderTargetBlurBuffer1),e.clear(),this.fsQuad.render(e),this.separableBlurMaterial1.uniforms.colorTexture.value=this.renderTargetBlurBuffer1.texture,this.separableBlurMaterial1.uniforms.direction.value=Gf.BlurDirectionY,e.setRenderTarget(this.renderTargetEdgeBuffer1),e.clear(),this.fsQuad.render(e),this.fsQuad.material=this.separableBlurMaterial2,this.separableBlurMaterial2.uniforms.colorTexture.value=this.renderTargetEdgeBuffer1.texture,this.separableBlurMaterial2.uniforms.direction.value=Gf.BlurDirectionX,e.setRenderTarget(this.renderTargetBlurBuffer2),e.clear(),this.fsQuad.render(e),this.separableBlurMaterial2.uniforms.colorTexture.value=this.renderTargetBlurBuffer2.texture,this.separableBlurMaterial2.uniforms.direction.value=Gf.BlurDirectionY,e.setRenderTarget(this.renderTargetEdgeBuffer2),e.clear(),this.fsQuad.render(e),this.fsQuad.material=this.overlayMaterial,this.overlayMaterial.uniforms.maskTexture.value=a.texture,this.overlayMaterial.uniforms.edgeTexture1.value=this.renderTargetEdgeBuffer1.texture,this.overlayMaterial.uniforms.edgeTexture2.value=this.renderTargetEdgeBuffer2.texture,this.overlayMaterial.uniforms.patternTexture.value=this.patternTexture,this.overlayMaterial.uniforms.edgeStrength.value=this.edgeStrength,this.overlayMaterial.uniforms.edgeGlow.value=this.edgeGlow,this.overlayMaterial.uniforms.usePatternTexture.value=this.usePatternTexture,r&&e.state.buffers.stencil.setTest(!0),e.setRenderTarget(n),this.fsQuad.render(e),e.setClearColor(this.oldClearColor,this.oldClearAlpha),e.autoClear=t}this.renderToScreen&&n&&(this.fsQuad.material=this.materialCopy,this.copyUniforms.tDiffuse.value=n.texture,e.setRenderTarget(null),this.fsQuad.render(e))}renderPass(e){this.render(e,null,null,0,!1)}_getPrepareMaskMaterial(e){return new nr({uniforms:{depthTexture:{value:null},cameraNearFar:{value:new _t(.5,.5)},textureMatrix:{value:null}},defines:{FLOAT_ALPHA_DEPTH:e?1:0},vertexShader:"#include \n\t\t\t\t#include \n\n\t\t\t\tvarying vec4 projTexCoord;\n\t\t\t\tvarying vec4 vPosition;\n\t\t\t\tuniform mat4 textureMatrix;\n\n\t\t\t\tvoid main() {\n\n\t\t\t\t\t#include \n\t\t\t\t\t#include \n\t\t\t\t\t#include \n\t\t\t\t\t#include \n\t\t\t\t\t#include \n\n\t\t\t\t\tvPosition = mvPosition;\n\n\t\t\t\t\tvec4 worldPosition = vec4( transformed, 1.0 );\n\n\t\t\t\t\t#ifdef USE_INSTANCING\n\n\t\t\t\t\t\tworldPosition = instanceMatrix * worldPosition;\n\n\t\t\t\t\t#endif\n\t\t\t\t\t\n\t\t\t\t\tworldPosition = modelMatrix * worldPosition;\n\n\t\t\t\t\tprojTexCoord = textureMatrix * worldPosition;\n\n\t\t\t\t}",fragmentShader:"#include \n\t\t\t\tvarying vec4 vPosition;\n\t\t\t\tvarying vec4 projTexCoord;\n\t\t\t\tuniform sampler2D depthTexture;\n\t\t\t\tuniform vec2 cameraNearFar;\n\n\t\t\t\tvoid main() {\n\n #if FLOAT_ALPHA_DEPTH == 1\n\t\t\t\t\t float depth = texture2DProj( depthTexture, projTexCoord ).w;\n #else\n float depth = unpackRGBAToDepth(texture2DProj( depthTexture, projTexCoord ));\n #endif\n\t\t\t\t\tfloat viewZ = - DEPTH_TO_VIEW_Z( depth, cameraNearFar.x, cameraNearFar.y );\n\t\t\t\t\tfloat depthTest = (-vPosition.z > viewZ) ? 1.0 : 0.0;\n\t\t\t\t\tgl_FragColor = vec4(0.0, depthTest, 1.0, 1.0);\n\n\t\t\t\t}"})}_getEdgeDetectionMaterial(){return new nr({uniforms:{maskTexture:{value:null},texSize:{value:new _t(.5,.5)},visibleEdgeColor:{value:new Yt(1,1,1)},hiddenEdgeColor:{value:new Yt(1,1,1)}},vertexShader:"varying vec2 vUv;\n\n\t\t\t\tvoid main() {\n\t\t\t\t\tvUv = uv;\n\t\t\t\t\tgl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n\t\t\t\t}",fragmentShader:"varying vec2 vUv;\n\n\t\t\t\tuniform sampler2D maskTexture;\n\t\t\t\tuniform vec2 texSize;\n\t\t\t\tuniform vec3 visibleEdgeColor;\n\t\t\t\tuniform vec3 hiddenEdgeColor;\n\n\t\t\t\tvoid main() {\n\t\t\t\t\tvec2 invSize = 1.0 / texSize;\n\t\t\t\t\tvec4 uvOffset = vec4(1.0, 0.0, 0.0, 1.0) * vec4(invSize, invSize);\n\t\t\t\t\tvec4 c1 = texture2D( maskTexture, vUv + uvOffset.xy);\n\t\t\t\t\tvec4 c2 = texture2D( maskTexture, vUv - uvOffset.xy);\n\t\t\t\t\tvec4 c3 = texture2D( maskTexture, vUv + uvOffset.yw);\n\t\t\t\t\tvec4 c4 = texture2D( maskTexture, vUv - uvOffset.yw);\n\t\t\t\t\tfloat diff1 = (c1.r - c2.r)*0.5;\n\t\t\t\t\tfloat diff2 = (c3.r - c4.r)*0.5;\n\t\t\t\t\tfloat d = length( vec2(diff1, diff2) );\n\t\t\t\t\tfloat a1 = min(c1.g, c2.g);\n\t\t\t\t\tfloat a2 = min(c3.g, c4.g);\n\t\t\t\t\tfloat visibilityFactor = min(a1, a2);\n\t\t\t\t\tvec3 edgeColor = 1.0 - visibilityFactor > 0.001 ? visibleEdgeColor : hiddenEdgeColor;\n\t\t\t\t\tgl_FragColor = vec4(edgeColor, 1.0) * vec4(d);\n\t\t\t\t}"})}_getSeperableBlurMaterial(e){return new nr({defines:{MAX_RADIUS:e},uniforms:{colorTexture:{value:null},texSize:{value:new _t(.5,.5)},direction:{value:new _t(.5,.5)},kernelRadius:{value:1}},vertexShader:"varying vec2 vUv;\n\n\t\t\t\tvoid main() {\n\t\t\t\t\tvUv = uv;\n\t\t\t\t\tgl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n\t\t\t\t}",fragmentShader:"#include \n\t\t\t\tvarying vec2 vUv;\n\t\t\t\tuniform sampler2D colorTexture;\n\t\t\t\tuniform vec2 texSize;\n\t\t\t\tuniform vec2 direction;\n\t\t\t\tuniform float kernelRadius;\n\n\t\t\t\tfloat gaussianPdf(in float x, in float sigma) {\n\t\t\t\t\treturn 0.39894 * exp( -0.5 * x * x/( sigma * sigma))/sigma;\n\t\t\t\t}\n\n\t\t\t\tvoid main() {\n\t\t\t\t\tvec2 invSize = 1.0 / texSize;\n\t\t\t\t\tfloat sigma = kernelRadius/2.0;\n\t\t\t\t\tfloat weightSum = gaussianPdf(0.0, sigma);\n\t\t\t\t\tvec4 diffuseSum = texture2D( colorTexture, vUv) * weightSum;\n\t\t\t\t\tvec2 delta = direction * invSize * kernelRadius/float(MAX_RADIUS);\n\t\t\t\t\tvec2 uvOffset = delta;\n\t\t\t\t\tfor( int i = 1; i <= MAX_RADIUS; i ++ ) {\n\t\t\t\t\t\tfloat x = kernelRadius * float(i) / float(MAX_RADIUS);\n\t\t\t\t\t\tfloat w = gaussianPdf(x, sigma);\n\t\t\t\t\t\tvec4 sample1 = texture2D( colorTexture, vUv + uvOffset);\n\t\t\t\t\t\tvec4 sample2 = texture2D( colorTexture, vUv - uvOffset);\n\t\t\t\t\t\tdiffuseSum += ((sample1 + sample2) * w);\n\t\t\t\t\t\tweightSum += (2.0 * w);\n\t\t\t\t\t\tuvOffset += delta;\n\t\t\t\t\t}\n\t\t\t\t\tgl_FragColor = diffuseSum/weightSum;\n\t\t\t\t}"})}_getOverlayMaterial(){return new nr({uniforms:{maskTexture:{value:null},edgeTexture1:{value:null},edgeTexture2:{value:null},patternTexture:{value:null},edgeStrength:{value:1},edgeGlow:{value:1},usePatternTexture:{value:0}},vertexShader:"varying vec2 vUv;\n\n\t\t\t\tvoid main() {\n\t\t\t\t\tvUv = uv;\n\t\t\t\t\tgl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n\t\t\t\t}",fragmentShader:"varying vec2 vUv;\n\n\t\t\t\tuniform sampler2D maskTexture;\n\t\t\t\tuniform sampler2D edgeTexture1;\n\t\t\t\tuniform sampler2D edgeTexture2;\n\t\t\t\tuniform sampler2D patternTexture;\n\t\t\t\tuniform float edgeStrength;\n\t\t\t\tuniform float edgeGlow;\n\t\t\t\tuniform bool usePatternTexture;\n\n\t\t\t\tvoid main() {\n\t\t\t\t\tvec4 edgeValue1 = texture2D(edgeTexture1, vUv);\n\t\t\t\t\tvec4 edgeValue2 = texture2D(edgeTexture2, vUv);\n\t\t\t\t\tvec4 maskColor = texture2D(maskTexture, vUv);\n\t\t\t\t\tvec4 patternColor = texture2D(patternTexture, 6.0 * vUv);\n\t\t\t\t\tfloat visibilityFactor = 1.0 - maskColor.g > 0.0 ? 1.0 : 0.5;\n\t\t\t\t\tvec4 edgeValue = edgeValue1 + edgeValue2 * edgeGlow;\n\t\t\t\t\tvec4 finalColor = edgeStrength * maskColor.r * edgeValue;\n\t\t\t\t\tif(usePatternTexture)\n\t\t\t\t\t\tfinalColor += + visibilityFactor * (1.0 - maskColor.r) * (1.0 - patternColor.r);\n\t\t\t\t\tgl_FragColor = finalColor;\n }",blending:2,depthTest:!1,depthWrite:!1,transparent:!0})}}Gf.BlurDirectionX=new _t(1,0),Gf.BlurDirectionY=new _t(0,1),Gf.highlightLines=!0;const Wf={tDiffuse:{value:null}},jf="\n varying vec2 vUv;\n \n void main() {\n vUv = uv;\n gl_Position = (projectionMatrix * modelViewMatrix * vec4(position, 1.0)).xyww;\n }",Xf="\n uniform highp sampler2D tDiffuse;\n varying vec2 vUv;\n \n void main() {\n vec4 textureColor = texture2D(tDiffuse, vUv);\n float aoPassDepth = dot(textureColor.wz, vec2(1.0/1024.0));\n gl_FragColor = vec4(vec3(aoPassDepth * aoPassDepth), 1.0);\n }";class Yf extends nr{constructor(e){super({uniforms:tr.clone(Wf),vertexShader:jf,fragmentShader:Xf,transparent:!0,depthTest:!1,depthWrite:!1,blendSrc:v,blendDst:c,blendEquation:s,blendSrcAlpha:m,blendDstAlpha:c,blendEquationAlpha:s}),this._intensity=new _t(1,1),this.update(e)}update(e){return void 0!==(null==e?void 0:e.texture)&&(this.uniforms.tDiffuse.value=e.texture),void 0!==(null==e?void 0:e.blending)&&(this.blending=e.blending),this}}class qf extends Bp{constructor(e){super(e),this.debugOutput="",this._environmentMapDecodeMaterial=new Eh(!0,!1),this._environmentMapDecodeMaterial.blending=0,this._environmentMapDecodeMaterial.depthTest=!1}dispose(){var e,t,n;null===(e=this._depthRenderMaterial)||void 0===e||e.dispose(),null===(t=this._copyMaterial)||void 0===t||t.dispose(),null===(n=this._srgbToLinearCopyMaterial)||void 0===n||n.dispose()}getCopyMaterial(e){var t;return this._copyMaterial=null!==(t=this._copyMaterial)&&void 0!==t?t:new Jc,this._copyMaterial.update(e)}getBlendAoAndShadowMaterial(e){var t;return this._blendAoAndShadowMaterial=null!==(t=this._blendAoAndShadowMaterial)&&void 0!==t?t:new Zp({blending:0}),this._blendAoAndShadowMaterial.update(e)}getBlendAoPassDepthMaterial(e){var t;return this._blendAoPassDepthMaterial=null!==(t=this._blendAoPassDepthMaterial)&&void 0!==t?t:new Yf({blending:0}),this._blendAoPassDepthMaterial.update(e)}getSrgbToLinearCopyMaterial(e){var t;return this._srgbToLinearCopyMaterial=null!==(t=this._copyMaterial)&&void 0!==t?t:new Jc({},Kc,!0,!0),this._srgbToLinearCopyMaterial.update(e)}_getDepthRenderMaterial(e){var t;return this._depthRenderMaterial=null!==(t=this._depthRenderMaterial)&&void 0!==t?t:new $c({depthTexture:this.gBufferTextures.textureWithDepthValue,depthFilter:this.gBufferTextures.isFloatGBufferWithRgbNormalAlphaDepth?new Ht(0,0,0,1):new Ht(1,0,0,0)}),this._depthRenderMaterial.update({camera:e})}renderPass(e){var t,n,i,r,a,s;switch(this.debugOutput){default:break;case"lineardepth":this.passRenderer.renderScreenSpace(e,this._getDepthRenderMaterial(this.camera),null);break;case"g-normal":this.gBufferTextures.isFloatGBufferWithRgbNormalAlphaDepth?this.passRenderer.renderScreenSpace(e,this.getCopyMaterial({texture:null===(t=this.gBufferTextures)||void 0===t?void 0:t.gBufferTexture,blending:0,colorTransform:(new Mn).set(.5,0,0,0,0,.5,0,0,0,0,.5,0,0,0,0,0),colorBase:new Ht(.5,.5,.5,1),multiplyChannels:0,uvTransform:qc}),null):this.passRenderer.renderScreenSpace(e,this.getCopyMaterial({texture:null===(n=this.gBufferTextures)||void 0===n?void 0:n.gBufferTexture,blending:0,colorTransform:Vc,colorBase:Yc,multiplyChannels:0,uvTransform:qc}),null);break;case"g-depth":this.gBufferTextures.isFloatGBufferWithRgbNormalAlphaDepth?this.passRenderer.renderScreenSpace(e,this.getCopyMaterial({texture:null===(i=this.gBufferTextures)||void 0===i?void 0:i.gBufferTexture,blending:0,colorTransform:Gc,colorBase:Yc,multiplyChannels:0,uvTransform:qc}),null):this.passRenderer.renderScreenSpace(e,this.getCopyMaterial({texture:null===(r=this.gBufferTextures)||void 0===r?void 0:r.depthBufferTexture,blending:0,colorTransform:Wc,colorBase:Yc,multiplyChannels:0,uvTransform:qc}),null);break;case"ssao":this.passRenderer.renderScreenSpace(e,this.getCopyMaterial({texture:this.renderPassManager.shadowAndAoPass.aoAndSoftShadowRenderTarget.texture,blending:0,colorTransform:jc,colorBase:Xc,multiplyChannels:0,uvTransform:qc}),null);break;case"ssaodenoise":this.passRenderer.renderScreenSpace(e,this.getCopyMaterial({texture:this.renderPassManager.shadowAndAoPass.denoiseRenderTargetTexture,blending:0,colorTransform:jc,colorBase:Xc,multiplyChannels:0,uvTransform:qc}),null);break;case"shadowmap":this.passRenderer.renderScreenSpace(e,this.getCopyMaterial({texture:this.renderPassManager.screenSpaceShadowMapPass.shadowTexture,blending:0,colorTransform:jc,colorBase:Xc,multiplyChannels:0,uvTransform:qc}),null);break;case"shadowsoft":this.passRenderer.renderScreenSpace(e,this.getCopyMaterial({texture:this.renderPassManager.shadowAndAoPass.aoAndSoftShadowRenderTarget.texture,blending:0,colorTransform:of.shadowTransform,colorBase:Xc,multiplyChannels:0,uvTransform:qc}),null);break;case"shadowdenoise":this.passRenderer.renderScreenSpace(e,this.getCopyMaterial({texture:this.renderPassManager.shadowAndAoPass.denoiseRenderTargetTexture,blending:0,colorTransform:of.shadowTransform,colorBase:Xc,multiplyChannels:0,uvTransform:qc}),null);break;case"shadowfadein":this.passRenderer.renderScreenSpace(e,this.getCopyMaterial({texture:this.renderPassManager.shadowAndAoPass.fadeRenderTarget.texture,blending:0,colorTransform:of.shadowTransform,colorBase:Xc,multiplyChannels:0,uvTransform:qc}),null);break;case"shadowandao":this.passRenderer.renderScreenSpace(e,this.getBlendAoAndShadowMaterial({texture:this.renderPassManager.shadowAndAoPass.denoiseRenderTargetTexture,blending:0,aoIntensity:this.renderPassManager.shadowAndAoPass.parameters.aoIntensity,shadowIntensity:this.renderPassManager.shadowAndAoPass.parameters.shadowIntensity}),null);break;case"shadowandaodepth":this.passRenderer.renderScreenSpace(e,this.getBlendAoPassDepthMaterial({texture:this.renderPassManager.shadowAndAoPass.denoiseRenderTargetTexture,blending:0}),null);break;case"materialao":this.passRenderer.renderScreenSpace(e,this.getCopyMaterial({texture:this.renderPassManager.aoPassMapTexture,blending:0,colorTransform:Hc,colorBase:Xc,multiplyChannels:0,uvTransform:qc}),null);break;case"groundreflection":this.passRenderer.renderScreenSpace(e,this.getSrgbToLinearCopyMaterial({texture:this.renderPassManager.groundReflectionPass.reflectionRenderTarget.texture,blending:0,colorTransform:Hc,colorBase:Xc,multiplyChannels:0,uvTransform:Zc}),null);break;case"groundreflectionfinal":this.passRenderer.renderScreenSpace(e,this.getSrgbToLinearCopyMaterial({texture:this.renderPassManager.groundReflectionPass.intensityRenderTarget.texture,blending:0,colorTransform:Hc,colorBase:Xc,multiplyChannels:0,uvTransform:Zc}),null);break;case"bakedgroundshadow":this.passRenderer.renderScreenSpace(e,this.getCopyMaterial({texture:this.renderPassManager.bakedGroundContactShadowPass.renderTarget.texture,blending:0,colorTransform:Hc,colorBase:Xc,multiplyChannels:0,uvTransform:qc}),null);break;case"environmentmap":this._environmentMapDecodeMaterial.setSourceTexture(this.scene.environment),this.passRenderer.renderScreenSpace(e,this._environmentMapDecodeMaterial,null);break;case"lightsourcedetection":if(null===(a=this.scene.userData)||void 0===a?void 0:a.environmentDefinition){const t=this.renderPassManager.aspect,n=new Ur(-1,1,1/t,-1/t,-1,1),i=null===(s=this.scene.userData)||void 0===s?void 0:s.environmentDefinition.createDebugScene(e,this.scene,this.renderPassManager.screenSpaceShadowMapPass.parameters.maximumNumberOfLightSources);i.background=new gi(16777215),e.render(i,n)}}}}class Zf extends Bp{constructor(e){super(e),this.drawGround=!0,this.drawWithDebugMaterial=!1,this.grayDebugMaterial=new Tl({color:12632256,side:2,envMapIntensity:.4})}dispose(){super.dispose(),this.grayDebugMaterial.dispose()}renderPass(e){this.renderCacheManager.onBeforeRender("floorDepthWrite",this.scene),this.renderPassManager.setGroundVisibility(this.drawGround),this.drawWithDebugMaterial?this.renderCacheManager.render("debug",this.scene,(()=>{this.passRenderer.renderWithOverrideMaterial(e,this.scene,this.camera,this.grayDebugMaterial,null,0,1)})):e.render(this.scene,this.camera),this.renderPassManager.setGroundVisibility(!1),this.renderCacheManager.onAfterRender("floorDepthWrite")}}class Kf{constructor(){this.weightedAoPassAntiAliasing=!1,this.applyAoAndShadowToAlpha=!1,this._aoPassMapUniform={value:null},this._aoPassMapScaleUniform={value:1},this._aoPassMapIntensityUniform={value:1},this._shPassMapIntensityUniform={value:1},this._reflectionPassMapUniform={value:null},this._reflectionPassMapScaleUniform={value:1},this._reflectionPassMapIntensityUniform={value:0},this.applyReflectionPassMap=!1}set aoPassMap(e){this._aoPassMapUniform.value=e}set aoPassMapScale(e){this._aoPassMapScaleUniform.value=e}set aoPassMapIntensity(e){this._aoPassMapIntensityUniform.value=e}set shPassMapIntensity(e){this._shPassMapIntensityUniform.value=e}set reflectionPassMap(e){this._reflectionPassMapUniform.value=e}set reflectionPassMapScale(e){this._reflectionPassMapScaleUniform.value=e}set reflectionPassMapIntensity(e){this._reflectionPassMapIntensityUniform.value=e}static addPlugin(e){if(void 0!==e.userData.postProcessingMaterialPlugin)return e.userData.postProcessingMaterialPlugin instanceof Kf?e.userData.postProcessingMaterialPlugin:null;const t=new Kf;return e.userData.postProcessingMaterialPlugin=t,e.onBeforeCompile=(e,n)=>t._onBeforeCompile(e,n),e.customProgramCacheKey=()=>t._customProgramCacheKey(),t}_isEnabled(){return void 0!==this._aoPassMapUniform.value&&null!==this._aoPassMapUniform.value}_customProgramCacheKey(){let e="";return this._isEnabled()&&(e+="aoPassMap"+(this.applyAoAndShadowToAlpha?"Alpha":"")),this.applyReflectionPassMap&&(e+="reflectionPassMap"),e}_onBeforeCompile(e,t){if(this._isEnabled()||this.applyReflectionPassMap){let t=this.applyAoAndShadowToAlpha?"#define USE_APPLY_AO_AND_SHADOW_TO_ALPHA\n":"";t+=this.applyReflectionPassMap?"#define USE_REFLECTION_PASS_MAP\n":"",t+=this.weightedAoPassAntiAliasing?"#define WEIGHTED_AO_PASS_ANTIALIASING\n":"",t+=Jf,e.fragmentShader=e.fragmentShader.replace("#include ",t),e.fragmentShader=e.fragmentShader.replace("#include ",Qf),this._initUniforms(e)}}_initUniforms(e){e&&(e.uniforms.tAoPassMap=this._aoPassMapUniform,e.uniforms.aoPassMapScale=this._aoPassMapScaleUniform,e.uniforms.aoPassMapIntensity=this._aoPassMapIntensityUniform,e.uniforms.shPassMapIntensity=this._shPassMapIntensityUniform,e.uniforms.tReflectionPassMap=this._reflectionPassMapUniform,e.uniforms.reflectionPassMapScale=this._reflectionPassMapScaleUniform,e.uniforms.reflectionPassMapIntensity=this._reflectionPassMapIntensityUniform)}}const Jf="\n#ifdef USE_AOMAP\n\n\tuniform sampler2D aoMap;\n\tuniform float aoMapIntensity;\n\n#endif\n\n\tuniform highp sampler2D tAoPassMap;\n uniform float aoPassMapScale;\n uniform float aoPassMapIntensity;\n uniform float shPassMapIntensity;\n uniform sampler2D tReflectionPassMap;\n uniform float reflectionPassMapScale;\n uniform float reflectionPassMapIntensity;\n",Qf="\n#ifndef AOPASSMAP_SWIZZLE\n\t#define AOPASSMAP_SWIZZLE rg\n#endif\n\nfloat ambientOcclusion = 1.0;\nfloat shadowValue = 1.0;\n\t\n#ifdef USE_AOMAP\n\n\t// reads channel R, compatible with a combined OcclusionRoughnessMetallic (RGB) texture\n\tambientOcclusion = texture2D( aoMap, vAoMapUv ).r;\n ambientOcclusion = ( ambientOcclusion - 1.0 ) * aoMapIntensity + 1.0;\n\n#endif\n\n vec4 aoAndShadowMap = texelFetch( tAoPassMap, ivec2( gl_FragCoord.xy * aoPassMapScale ), 0 );\n vec2 aoAndShadow = aoAndShadowMap.rg;\n float depthDelta = abs( dot(aoAndShadowMap.wz, vec2(1.0/1024.0)) - gl_FragCoord.z );\n const ivec2 aoOffsetArray[8] = ivec2[8](\n ivec2(1, 0), ivec2(-1, 0), ivec2(0, 1), ivec2(0, -1), ivec2(1, 1), ivec2(-1, 1), ivec2(1, -1), ivec2(-1, -1));\n #ifdef WEIGHTED_AO_PASS_ANTIALIASING \n aoAndShadow *= 100.0;\n float deltaAoPassWeight = 100.0; \n for (int aoOffsetI = 0; aoOffsetI < 8; aoOffsetI++) {\n aoAndShadowMap = texelFetch( tAoPassMap, ivec2( gl_FragCoord.xy * aoPassMapScale ) + aoOffsetArray[aoOffsetI], 0 );\n float testDepthDelta = abs( dot(aoAndShadowMap.wz, vec2(1.0/1024.0)) - gl_FragCoord.z );\n float aoPassSampleWeight = (depthDelta * 100.0 + 0.01) / (testDepthDelta * 100.0 + 0.01);\n deltaAoPassWeight += aoPassSampleWeight;\n aoAndShadow += aoAndShadowMap.rg * aoPassSampleWeight;\n }\n aoAndShadow /= deltaAoPassWeight;\n #else\n for (int aoOffsetI = 0; aoOffsetI < 8; aoOffsetI++) {\n aoAndShadowMap = texelFetch( tAoPassMap, ivec2( gl_FragCoord.xy * aoPassMapScale ) + aoOffsetArray[aoOffsetI], 0 );\n float testDepthDelta = abs( dot(aoAndShadowMap.wz, vec2(1.0/1024.0)) - gl_FragCoord.z );\n if (testDepthDelta < depthDelta) {\n aoAndShadow = aoAndShadowMap.rg;\n depthDelta = testDepthDelta;\n }\n }\n #endif \n \n float aoPassMapValue = aoPassMapIntensity < 0.0 ? 1.0 : max(0.0, (aoAndShadow.r - 1.0) * aoPassMapIntensity + 1.0);\n shadowValue = shPassMapIntensity < 0.0 ? 1.0 : max(0.0, (aoAndShadow.g - 1.0) * shPassMapIntensity + 1.0);\n\n #ifdef USE_REFLECTION_PASS_MAP\n\n ivec2 reflectionPassMapSize = textureSize( tReflectionPassMap, 0 );\n vec2 reflectionPassMapUv = vec2( gl_FragCoord.x * reflectionPassMapScale, float(reflectionPassMapSize.y) - gl_FragCoord.y * reflectionPassMapScale );\n vec4 reflectionPassMapColor = texture2D( tReflectionPassMap, reflectionPassMapUv / vec2(reflectionPassMapSize) );\n if (reflectionPassMapColor.a > 0.0) reflectionPassMapColor.rgb /= reflectionPassMapColor.a;\n vec3 diffuseReflectionPassMapColor = reflectionPassMapColor.rgb * material.diffuseColor;\n reflectedLight.indirectDiffuse += diffuseReflectionPassMapColor * reflectionPassMapColor.a * reflectionPassMapIntensity;\n //reflectedLight.indirectDiffuse = mix(reflectedLight.indirectDiffuse, diffuseReflectionPassMapColor, reflectionPassMapColor.a * reflectionPassMapIntensity);\n\n #endif\n\n #if defined ( USE_APPLY_AO_AND_SHADOW_TO_ALPHA )\n diffuseColor.a = 1.0 - (1.0 - diffuseColor.a) * aoPassMapValue * shadowValue;\n #else\n ambientOcclusion = min( ambientOcclusion, aoPassMapValue );\n #endif\n\n\treflectedLight.indirectDiffuse *= ambientOcclusion * shadowValue;\n \n\t#if defined( USE_CLEARCOAT ) \n\t\tclearcoatSpecularIndirect *= ambientOcclusion * shadowValue;\n\t#endif\n\n\t#if defined( USE_SHEEN ) \n\t\tsheenSpecularIndirect *= ambientOcclusion * shadowValue;\n\t#endif\n\n\t#if defined( USE_ENVMAP ) && defined( STANDARD )\n\n\t\tfloat dotNV = saturate( dot( geometryNormal, geometryViewDir ) );\n \n float specularOcclusion = computeSpecularOcclusion( dotNV, ambientOcclusion * shadowValue, material.roughness );\n\t\treflectedLight.indirectSpecular *= specularOcclusion;\n\n #ifdef USE_REFLECTION_PASS_MAP\n reflectedLight.indirectSpecular += material.specularColor * reflectionPassMapColor.rgb * reflectionPassMapColor.a * reflectionPassMapIntensity * specularOcclusion;\n #endif \n \n\t#endif\n";class $f{get passRenderer(){return this._passRenderer}get scene(){return this._scene}get camera(){return this._camera}get aspect(){return this._sceneRenderer.width/this._sceneRenderer.height}get cameraChanged(){return this._cameraChanged}get noOStaticFrames(){return this._noOStaticFrames}get renderCacheManager(){return this._sceneRenderer.renderCacheManager}get parameters(){return this._sceneRenderer.parameters}get sceneRenderPass(){return this._sceneRenderPass}get bakedGroundContactShadowPass(){return this._bakedGroundContactShadowPass}get gBufferRenderPass(){return this._gBufferRenderPass}get groundReflectionPass(){return this._groundReflectionPass}get screenSpaceShadowMapPass(){return this._screenSpaceShadowMapPass}get shadowAndAoPass(){return this._shadowAndAoPass}get outlinePass(){return this._outlinePass}get outlineRenderer(){return this._sceneRenderer.outlineRenderer}get debugPass(){var e;return null!==(e=this._debugPass)&&void 0!==e||(this._debugPass=new qf(this)),this._debugPass}get debugOutput(){return this._sceneRenderer.debugOutput}constructor(e){this.materialsNeedUpdate=!0,this._passRenderer=new dh,this._outlinePass=null,this._debugPass=null,this._cameraUpdate=new hh,this._cameraChanged=!0,this._noUpdateNeededCount=0,this._noOStaticFrames=0,this._maxSamples=1,this._passUpdateStates={updateGroundReflection:!1,updateGBuffer:!1,updateScreenSpaceShadow:!1,updateShadowAndAoPass:!1,updateOutlinePass:!1,updateDebugPass:!1},this.aoPassMapTexture=null,this._sceneRenderer=e,this._maxSamples=ch(this._sceneRenderer.renderer),this._sceneRenderPass=new Zf(this),this._bakedGroundContactShadowPass=new _f(this,this._sceneRenderer.renderer,this._sceneRenderer.groundGroup,{sharedShadowGroundPlane:this._sceneRenderer.shadowAndAoGroundPlane}),this._gBufferRenderPass=new Sf(this,{shared:!0,capabilities:this._sceneRenderer.renderer.capabilities,width:this._sceneRenderer.width,height:this._sceneRenderer.height,samples:1}),this._groundReflectionPass=new bf(this,this._sceneRenderer.width,this._sceneRenderer.height,this._maxSamples,{}),this._screenSpaceShadowMapPass=new Df(this,new _t(this._sceneRenderer.width,this._sceneRenderer.height),{samples:1,alwaysUpdate:!1}),this._shadowAndAoPass=new of(this,this._sceneRenderer.width,this._sceneRenderer.height,1)}dispose(){var e;this._sceneRenderPass.dispose(),this._bakedGroundContactShadowPass.dispose(),this._gBufferRenderPass.dispose(),this._groundReflectionPass.dispose(),this._screenSpaceShadowMapPass.dispose(),this._shadowAndAoPass.dispose(),null===(e=this._outlinePass)||void 0===e||e.dispose()}setSize(e,t){var n;this._gBufferRenderPass.setSize(e,t),this._groundReflectionPass.setSize(e,t),this._screenSpaceShadowMapPass.setSize(e,t),this._shadowAndAoPass.setSize(e,t),null===(n=this._outlinePass)||void 0===n||n.setSize(e,t)}createOutlinePass(){return this._outlinePass||(this._outlinePass=new Gf(this,new _t(this._sceneRenderer.width,this._sceneRenderer.height),this.scene,this.camera,[],{downSampleRatio:2,edgeDetectionFxaa:!0})),this._outlinePass}setGroundVisibility(e){this._sceneRenderer.shadowAndAoGroundPlane.setVisibility(e)}updatePasses(e,t,n){this._scene=t,this._camera=n,this._cameraChanged=this._cameraUpdate.changed(n);const i=this._evaluateIfShadowAndAoUpdateIsNeeded();this._updateSceneRenderPass(),this._updateBakedGroundContactShadowPass(),this._updateGBufferPass(i),this._updateGroundReflectionPass(i),this._updateScreenSpaceShadowPass(i),this._updateShadowAndAoPass(i),this._updateOutlinePass(),this._updateDebugPass()}_evaluateIfShadowAndAoUpdateIsNeeded(){const e=this._shadowAndAoPass.parameters.alwaysUpdate||this._screenSpaceShadowMapPass.needsUpdate||this._screenSpaceShadowMapPass.shadowTypeNeedsUpdate;let t=(this._shadowAndAoPass.parameters.enabled||this._groundReflectionPass.parameters.enabled)&&this._cameraChanged,n=1;return t&&(this._noUpdateNeededCount=0,this._noOStaticFrames=0),e||(this._noUpdateNeededCount++,t=this._noUpdateNeededCount>=this.parameters.effectSuspendFrames,n=Math.max(0,Math.min(1,(this._noUpdateNeededCount-this.parameters.effectSuspendFrames)/this.parameters.effectFadeInFrames))),e||1!==n||this._noOStaticFrames++,t=e||t,{needsUpdate:t,shadowOnCameraChange:!t||n<.99?this.parameters.shadowOnCameraChange:tf,intensityScale:n}}_dynamicChanges(e){return e.needsUpdate||e.shadowOnCameraChange!==tf}_updateSceneRenderPass(){this._sceneRenderPass.drawWithDebugMaterial=!1}_updateBakedGroundContactShadowPass(){const e=this._bakedGroundContactShadowPass.limitPlaneSize;this._bakedGroundContactShadowPass.limitPlaneSize=this._bakedGroundContactShadowPass.parameters.enabled,(e!==this._bakedGroundContactShadowPass.limitPlaneSize||this._bakedGroundContactShadowPass.needsUpdate)&&this._bakedGroundContactShadowPass.updateBounds(this._sceneRenderer.boundingVolume,this._sceneRenderer.groundLevel),this._sceneRenderPass.drawGround=this._bakedGroundContactShadowPass.parameters.enabled||this._shadowAndAoPass.parameters.applyToMaterial}_updateGBufferPass(e){this._passUpdateStates.updateGBuffer=!1,this._gBufferRenderPass.needsUpdate=e.needsUpdate||e.shadowOnCameraChange===rf,this.gBufferRenderPass.drawGround=this._sceneRenderer.boundingVolumeSet&&this._shadowAndAoPass.parameters.aoOnGround}_updateGroundReflectionPass(e){this._passUpdateStates.updateGroundReflection=!1,this._groundReflectionPass.parameters.enabled&&this._dynamicChanges(e)&&(!this.parameters.suspendGroundReflection||e.needsUpdate)&&(this._groundReflectionPass.reflectionFadeInScale=this.parameters.suspendGroundReflection?e.intensityScale:1,this._passUpdateStates.updateGroundReflection=!0)}_updateScreenSpaceShadowPass(e){this._dynamicChanges(e)?(this._screenSpaceShadowMapPass.parameters.alwaysUpdate=this._shadowAndAoPass.parameters.alwaysUpdate,this._screenSpaceShadowMapPass.drawGround=this._shadowAndAoPass.parameters.shadowOnGround,this._passUpdateStates.updateScreenSpaceShadow=this._shadowAndAoPass.parameters.shadowIntensity>0,this._passUpdateStates.updateScreenSpaceShadow=!0,this._passUpdateStates.updateGBuffer=!0):this._passUpdateStates.updateScreenSpaceShadow=!1}_updateShadowAndAoPass(e){this._dynamicChanges(e)?(this._shadowAndAoPass.shadowAndAoPassSettings={shadowMapTexture:this._screenSpaceShadowMapPass.shadowTexture,shadowBlurType:e.needsUpdate?af:e.shadowOnCameraChange,shadowFadeInBlurType:e.shadowOnCameraChange,shadowFadeInMix:1-e.intensityScale,noOStaticFrames:this.noOStaticFrames},this._passUpdateStates.updateShadowAndAoPass=!0,this._passUpdateStates.updateGBuffer=!0):this._passUpdateStates.updateShadowAndAoPass=!1}_updateOutlinePass(){this.outlineRenderer.outlinePassActivated&&this.outlineRenderer.outlinePass?(this.outlineRenderer.outlinePass.renderToScreen=!1,this.outlineRenderer.outlinePass.clearBackground=!1,this._passUpdateStates.updateOutlinePass=!0,this._passUpdateStates.updateGBuffer=!0):this._passUpdateStates.updateOutlinePass=!1}_updateDebugPass(){if(this.debugOutput&&""!==this.debugOutput&&"off"!==this.debugOutput){if("outline"===this.debugOutput&&this.outlineRenderer.outlinePass)return this.outlineRenderer.outlinePass.clearBackground=!0,void(this._passUpdateStates.updateDebugPass=!1);if("color"===this.debugOutput||"grayscale"===this.debugOutput)return this._passUpdateStates.updateGroundReflection=!1,this._passUpdateStates.updateGBuffer=!1,this._passUpdateStates.updateScreenSpaceShadow=!1,this._passUpdateStates.updateShadowAndAoPass=!1,this._passUpdateStates.updateOutlinePass=!1,this._passUpdateStates.updateDebugPass=!1,void(this._sceneRenderPass.drawWithDebugMaterial="grayscale"===this.debugOutput);this.debugPass.debugOutput=this.debugOutput,this._passUpdateStates.updateDebugPass=!0}else this._passUpdateStates.updateDebugPass=!1}_updateMaterials(e,t){if(!this.materialsNeedUpdate||!this._shadowAndAoPass.parameters.applyToMaterial)return;this.aoPassMapTexture=this._shadowAndAoPass.denoiseRenderTargetTexture;const n=e.getPixelRatio();this.materialsNeedUpdate=!1,t.traverse((e=>{if(e.isMesh){const t=e.material;t instanceof Tl&&this._updateMaterial(e,t,n)}}))}_updateMaterial(e,t,n){const i=Kf.addPlugin(t);i&&(this._updatePlugInAo(i,e,t,n),this._updatePlugInReflection(i,e),t.needsUpdate=!1)}_updatePlugInAo(e,t,n,i){const r=this._shadowAndAoPass.parameters.enabled&&this._shadowAndAoPass.parameters.applyToMaterial&&null!==this.aoPassMapTexture&&("ShadowGroundPlaneMaterial"===n.name||t.receiveShadow&&(!n.transparent||n.alphaTest>=.9)),a=r&&this._shadowAndAoPass.parameters.aoIntensity>.01,s=r&&this._screenSpaceShadowMapPass.enabled&&this._shadowAndAoPass.parameters.shadowIntensity>.01;e.applyAoAndShadowToAlpha="ShadowGroundPlaneMaterial"===n.name,e.aoPassMapIntensity=a?2*this._shadowAndAoPass.parameters.aoIntensity:-1,e.shPassMapIntensity=s?2*this._shadowAndAoPass.parameters.shadowIntensity:-1,e.aoPassMapScale=1/i,e.aoPassMap=this.aoPassMapTexture}_updatePlugInReflection(e,t){const n=this._groundReflectionPass.intensityRenderTarget.texture,i=t.userData.isPlanFloor&&this._groundReflectionPass.parameters.enabled&&(null!==n||void 0!==n),r=this._groundReflectionPass.parameters.intensity;e.applyReflectionPassMap=i,e.reflectionPassMapIntensity=i?Math.pow(r,.25):0,e.reflectionPassMapScale=1/(this._groundReflectionPass.parameters.renderTargetDownScale*devicePixelRatio),e.reflectionPassMap=i?n:null}renderPasses(e,t){var n,i;e.setRenderTarget(null),this._bakedGroundContactShadowPass.renderPass(e),this._passUpdateStates.updateGBuffer&&this._gBufferRenderPass.renderPass(e),this._passUpdateStates.updateScreenSpaceShadow&&this._screenSpaceShadowMapPass.renderPass(e),this._passUpdateStates.updateShadowAndAoPass&&this._shadowAndAoPass.renderPass(e),this._updateMaterials(e,t),this._sceneRenderPass.renderPass(e),this._passUpdateStates.updateGroundReflection&&this._groundReflectionPass.renderPass(e),this._passUpdateStates.updateShadowAndAoPass&&!this._shadowAndAoPass.parameters.applyToMaterial&&this._shadowAndAoPass.renderToTarget(e),this._passUpdateStates.updateOutlinePass&&(null===(n=this._outlinePass)||void 0===n||n.renderPass(e)),this._passUpdateStates.updateDebugPass&&(null===(i=this._debugPass)||void 0===i||i.renderPass(e))}}const em="highest",tm="high",nm="medium";class im{get sceneRenderPass(){return this._renderPassManager.sceneRenderPass}get bakedGroundContactShadowPass(){return this._renderPassManager.bakedGroundContactShadowPass}get gBufferRenderPass(){return this._renderPassManager.gBufferRenderPass}get groundReflectionPass(){return this._renderPassManager.groundReflectionPass}get screenSpaceShadowMapPass(){return this._renderPassManager.screenSpaceShadowMapPass}get shadowAndAoPass(){return this._renderPassManager.shadowAndAoPass}get debugPass(){return this._renderPassManager.debugPass}get shadowAndAoGroundPlane(){return this._shadowAndAoGroundPlane}constructor(e,t,n){this.debugOutput="off",this.outputColorSpace="",this.toneMapping="",this.environmentLights=!1,this.enableObjectSelection=!0,this.groundLevel=0,this.uiInteractionMode=!1,this.width=0,this.height=0,this.boundingVolume=new lh,this.boundingVolumeSet=!1,this.renderCacheManager=new ff,this.selectedObjects=[],this.groundGroup=new Qs,this._shadingType=hf,this._qualityLevel=em,this._qualityMap=new Map,this._customShadingParameters=null,this.width=t,this.height=n,this.renderer=e,this.renderCacheManager.registerCache("inivisibleGround",new mf((e=>e===this.groundGroup))),this.renderCacheManager.registerCache("debug",new mf),this.renderCacheManager.registerCache("floorDepthWrite",new gf((e=>{var t;return null===(t=e.userData)||void 0===t?void 0:t.isFloor}))),this._shadowAndAoGroundPlane=new Fp(null),this.groundGroup.rotateX(-Math.PI/2),this._renderPassManager=new $f(this),this.outlineRenderer=new lf(this._renderPassManager,null,{}),this.parameters={gBufferRenderTargetParameters:this.gBufferRenderPass.parameters,bakedGroundContactShadowParameters:this.bakedGroundContactShadowPass.parameters,screenSpaceShadowMapParameters:this.screenSpaceShadowMapPass.parameters,shAndAoPassParameters:this.shadowAndAoPass.parameters,groundReflectionParameters:this.groundReflectionPass.parameters,outlineParameters:this.outlineRenderer.parameters,effectSuspendFrames:0,effectFadeInFrames:0,suspendGroundReflection:!1,shadowOnCameraChange:tf},this._addEventListeners(this.renderer)}_addEventListeners(e){e.domElement.addEventListener("webglcontextlost",(()=>{console.log("webglcontextlost")})),e.domElement.addEventListener("webglcontextrestored",(()=>{console.log("webglcontextrestored"),this._forceEnvironmentMapUpdate(this.renderer)}))}dispose(){var e;null===(e=this._copyMaterial)||void 0===e||e.dispose(),this._renderPassManager.dispose(),this.renderer.dispose()}setSize(e,t){this.width=e,this.height=t,this._renderPassManager.setSize(e,t),this.renderer.setSize(e,t)}getQualityLevel(){return this._qualityLevel}setShadingType(e){this._shadingType!==e&&(this._shadingType=e,this.applyCurrentParameters())}setQualityLevel(e){this._qualityLevel!==e&&(this._qualityMap.has(this._qualityLevel)&&(this._qualityLevel=e),this.applyCurrentParameters())}setQualityMap(e){this._qualityMap=e,this.applyCurrentParameters()}setCustomShadingParameters(e){this._customShadingParameters=e,this.applyCurrentParameters(),this.requestUpdateOfPasses()}setQualityMapAndShadingParameters(e,t){this._qualityMap=e,this._customShadingParameters=t,this.applyCurrentParameters(),this.requestUpdateOfPasses()}applyCurrentParameters(){const e=[];this._qualityMap.has(this._qualityLevel)&&e.push(this._qualityMap.get(this._qualityLevel));const t=(n=this._shadingType)&&n!==hf&&"bright"===n?df:null;var n;t&&e.push(t);const i=this.uiInteractionMode?{groundReflectionParameters:{enabled:!1}}:null;if(i&&e.push(i),this._customShadingParameters&&e.push((e=>{const t={shAndAoPassParameters:{ao:{},shadow:{}},groundReflectionParameters:{},bakedGroundContactShadowParameters:{}};return((e,t)=>{void 0!==t.aoIntensity&&(e.shAndAoPassParameters.aoIntensity=uf(t.aoIntensity)),void 0!==t.aoExtent&&(e.shAndAoPassParameters.ao.radius=.3*uf(t.aoExtent),e.shAndAoPassParameters.ao.thickness=.1+.2*uf(t.aoExtent))})(t,e),((e,t)=>{t.shBakedOnGround?(e.bakedGroundContactShadowParameters.enabled=!0,e.shAndAoPassParameters.shadowIntensity=0,void 0!==t.shadowIntensity&&(e.bakedGroundContactShadowParameters.opacity=uf(t.shadowIntensity)),void 0!==t.shadowIntensity&&(e.bakedGroundContactShadowParameters.blurMax=.1*uf(t.shadowIntensity),e.bakedGroundContactShadowParameters.blurMin=.01*e.bakedGroundContactShadowParameters.blurMax)):(void 0!==t.shBakedOnGround&&(e.bakedGroundContactShadowParameters.enabled=!1),void 0!==t.shadowIntensity&&(e.shAndAoPassParameters.shadowIntensity=uf(t.shadowIntensity)),void 0!==t.shadowSoftening&&(e.shAndAoPassParameters.shadow.shadowRadius=.001+.2*uf(t.shadowSoftening)))})(t,e),((e,t)=>{void 0!==t.grReflectIntensity&&(e.groundReflectionParameters.enabled=t.grReflectIntensity>0,e.groundReflectionParameters.intensity=uf(t.grReflectIntensity)),void 0!==t.grReflectFadeOut&&(e.groundReflectionParameters.fadeOutDistance=4*(1-uf(t.grReflectFadeOut)))})(t,e),t})(this._customShadingParameters)),e.length>0){const t=((...e)=>{if(0===e.length)return null;if(1===e.length)return e[0];let t=e[0];for(let n=1;n0&&(this.environmentLights=!1),this.screenSpaceShadowMapPass.updateRectAreaLights(e,t),this.shadowAndAoPass.needsUpdate=!0}createShadowFromLightSources(e,t){this.environmentLights=!0,this.screenSpaceShadowMapPass.createShadowFromLightSources(e,t),this.shadowAndAoPass.needsUpdate=!0}selectObjects(e){this.selectedObjects=e}updateBounds(e,t){this.clearCache();const n=e.clone();n.min.y>this.groundLevel&&(n.min.y=this.groundLevel),this.boundingVolumeSet=!0,this.gBufferRenderPass.groundDepthWrite=this.shadowAndAoPass.parameters.aoOnGround,this.boundingVolume.updateFromBox(n);const i=this.boundingVolume.size,r=(i.x+i.y+i.z)/3,a=Math.min(i.x,i.y,i.z),s=Math.max(i.x,i.y,i.z),o=a<.5?a/.5:i.z>5?i.z/5:1;this.bakedGroundContactShadowPass.setScale(t?r:o,r),this.groundReflectionPass.updateBounds(this.groundLevel,Math.min(1,s)),this.screenSpaceShadowMapPass.updateBounds(this.boundingVolume,r),this.shadowAndAoPass.updateBounds(this.boundingVolume,t?r:Math.min(1,2*s))}updateNearAndFarPlaneOfPerspectiveCamera(e,t){const n=this.boundingVolume.getNearAndFarForPerspectiveCamera(e.position,3);e.near=Math.max(1e-5,.9*n[0]),e.far=Math.max(null!=t?t:e.near,n[1]),e.updateProjectionMatrix()}_forceEnvironmentMapUpdate(e){const t=e.userData;if(null==t?void 0:t.environmentTexture){const e=t.environmentTexture;t.environmentTexture=void 0,e.dispose()}}_updateEnvironment(e,t){var n,i;if(!(null===(n=t.userData)||void 0===n?void 0:n.environmentDefinition))return;e.userData||(e.userData={});const r=e.userData;if(r&&((null===(i=t.userData)||void 0===i?void 0:i.environmentDefinition.needsUpdate)||!r.environmentTexture||r.environmentDefinition!==t.userData.environmentDefinition)){const n=t.userData.environmentDefinition;if(r.environmentDefinition=n,r.environmentTexture=n.createNewEnvironment(e),t.userData.shadowFromEnvironment){const e=n.maxNoOfLightSources;void 0!==e&&(this.screenSpaceShadowMapPass.parameters.maximumNumberOfLightSources=e),this.createShadowFromLightSources(t,n.lightSources)}}t.environment=null==r?void 0:r.environmentTexture,t.userData.showEnvironmentBackground?t.background=t.environment:t.background===t.environment&&(t.background=null)}render(e,t){e.add(this.groundGroup),this._updateEnvironment(this.renderer,e),this.outlineRenderer.updateOutline(e,t,this.enableObjectSelection?this.selectedObjects:[]),this._renderPassManager.updatePasses(this.renderer,e,t),this._renderPassManager.renderPasses(this.renderer,e),e.remove(this.groundGroup)}}class rm extends Jn{constructor(e=document.createElement("div")){super(),this.isCSS2DObject=!0,this.element=e,this.element.style.position="absolute",this.element.style.userSelect="none",this.element.setAttribute("draggable",!1),this.center=new _t(.5,.5),this.addEventListener("removed",(function(){this.traverse((function(e){e.element instanceof e.element.ownerDocument.defaultView.Element&&null!==e.element.parentNode&&e.element.remove()}))}))}copy(e,t){return super.copy(e,t),this.element=e.element.cloneNode(!0),this.center=e.center,this}}const am=new Yt,sm=new Mn,om=new Mn,lm=new Yt,cm=new Yt;class hm extends Qs{constructor(e,t,n){super(),this.arrowNeedsUpdate=!0,this.labelTextClientWidth=0,this.startPosition=e.clone(),this.endPosition=t.clone(),this.parameters=Object.assign({shaftPixelWidth:10,shaftPixelOffset:3,arrowPixelWidth:30,arrowPixelHeight:50,color:0,labelClass:"label",deviceRatio:1,autoLabelTextUpdate:!0,autoLabelRotationUpdate:!0},n),this.startShaftMaterial=new dm,this.startShaft=new Zi(new Sr(2,1).translate(0,.5,0),this.startShaftMaterial),this.startShaft.onBeforeRender=(e,t,n,i,r,a)=>{this.updateShaftMaterial(!0,e,n,r)},this.add(this.startShaft),this.endShaftMaterial=new dm,this.endShaft=new Zi(new Sr(2,1).translate(0,.5,0),this.endShaftMaterial),this.endShaft.onBeforeRender=(e,t,n,i,r,a)=>{this.updateShaftMaterial(!1,e,n,r)},this.add(this.endShaft),this.startArrowMaterial=new um,this.startArrow=new Zi(new Sr(2,1).translate(0,.5,0),this.startArrowMaterial),this.startArrow.onBeforeRender=(e,t,n,i,r,a)=>{this.updateArrowMaterial(!0,e,n,r)},this.add(this.startArrow),this.endArrowMaterial=new um,this.endArrow=new Zi(new Sr(2,1).translate(0,.5,0),this.endArrowMaterial),this.endArrow.onBeforeRender=(e,t,n,i,r,a)=>{this.updateArrowMaterial(!1,e,n,r)},this.add(this.endArrow),this.arrowLabel=this.createArrowLabel("0.000",this.parameters),this.add(this.arrowLabel),this.updateArrow()}createArrowLabel(e,t){var n,i,r,a,s,o;const l=document.createElement("div"),c=document.createElement("div");l.appendChild(c),c.className=null!==(n=t.labelClass)&&void 0!==n?n:"",c.textContent=e,c.style.backgroundColor="transparent",c.style.color=new gi(null!==(i=t.color)&&void 0!==i?i:0).getStyle();const h=new rm(l);return h.position.set(0,0,0),h.center.set(null!==(a=null===(r=t.origin)||void 0===r?void 0:r.x)&&void 0!==a?a:.5,null!==(o=null===(s=t.origin)||void 0===s?void 0:s.y)&&void 0!==o?o:.5),h.layers.set(0),h}setPosition(e,t,n=0,i=0){const r=t.clone().sub(e).normalize();this.startPosition.copy(e.clone().add(r.clone().multiplyScalar(n))),this.endPosition.copy(t.clone().add(r.clone().multiplyScalar(-i))),this.arrowNeedsUpdate=!0}setAngle(e){const t=`${e.toFixed(0)}deg`;this.arrowLabel.element.children[0].style.rotate=t}setLabel(e){const t=this.arrowLabel.element.children[0];t.textContent=e,this.labelTextClientWidth=t.clientWidth*this.parameters.deviceRatio}updateArrow(){const e=this.startPosition.clone().applyMatrix4(this.matrixWorld),t=this.endPosition.clone().applyMatrix4(this.matrixWorld),n=t.clone().sub(e),i=n.length();n.multiplyScalar(1/i);const r=new Yt(0,1,0).cross(n),a=Math.acos(new Yt(0,1,0).dot(n));this.setModelMatrix(this.startShaft,e,i,r,a),this.setModelMatrix(this.endShaft,t,i,r,a),this.setModelMatrix(this.startArrow,e,1,r,a),this.setModelMatrix(this.endArrow,t,1,r,a+Math.PI)}updateArrowLabel(e,t){var n,i;const r=this.startPosition.distanceTo(this.endPosition).toFixed(3),a=this.startPosition.clone().applyMatrix4(this.matrixWorld).applyMatrix4(t.matrixWorldInverse).applyMatrix4(t.projectionMatrix),s=this.endPosition.clone().applyMatrix4(this.matrixWorld).applyMatrix4(t.matrixWorldInverse).applyMatrix4(t.projectionMatrix),o=s.clone().add(a).multiplyScalar(.5).applyMatrix4(t.projectionMatrixInverse).applyMatrix4(t.matrixWorld);this.arrowLabel.position.copy(o);const l=e.getRenderTarget(),c=null!==(n=null==l?void 0:l.width)&&void 0!==n?n:e.domElement.clientWidth,h=null!==(i=null==l?void 0:l.height)&&void 0!==i?i:e.domElement.clientHeight,d=s.clone().sub(a),u=180*Math.atan2(-d.y,d.x*c/h)/Math.PI;this.parameters.autoLabelRotationUpdate&&this.setAngle(u),this.parameters.autoLabelTextUpdate&&this.setLabel(r)}setModelMatrix(e,t,n,i,r){e.scale.set(1,1,1),e.rotation.set(0,0,0),e.position.set(0,0,0),e.applyMatrix4((new Mn).makeScale(1,.5*n,1)),e.applyMatrix4((new Mn).makeRotationAxis(i,r)),e.applyMatrix4((new Mn).makeTranslation(t.x,t.y,t.z))}updateShaftMaterial(e,t,n,i){var r,a;if(this.updateMatrixWorld(),i instanceof dm){const s=t.getRenderTarget(),o=new _t;t.getSize(o);const l=null!==(r=null==s?void 0:s.width)&&void 0!==r?r:o.x,c=null!==(a=null==s?void 0:s.height)&&void 0!==a?a:o.y,h=this.startPosition.clone().applyMatrix4(this.matrixWorld),d=this.endPosition.clone().applyMatrix4(this.matrixWorld);i.update({width:l,height:c,camera:n,start:e?h:d,end:e?d:h,shaftPixelWidth:this.parameters.shaftPixelWidth,shaftPixelOffset:this.parameters.shaftPixelOffset,arrowPixelSize:new _t(this.parameters.arrowPixelWidth,this.parameters.arrowPixelHeight),labelPixelWidth:this.labelTextClientWidth,color:this.parameters.color})}this.arrowNeedsUpdate&&(this.arrowNeedsUpdate=!1,this.updateArrowLabel(t,n),this.updateArrow())}updateArrowMaterial(e,t,n,i){var r,a;if(this.updateMatrixWorld(),i instanceof um){const s=t.getRenderTarget(),o=null!==(r=null==s?void 0:s.width)&&void 0!==r?r:t.domElement.clientWidth,l=null!==(a=null==s?void 0:s.height)&&void 0!==a?a:t.domElement.clientHeight,c=this.startPosition.clone().applyMatrix4(this.matrixWorld),h=this.endPosition.clone().applyMatrix4(this.matrixWorld);i.update({width:o,height:l,camera:n,start:e?c:h,end:e?h:c,arrowPixelSize:new _t(this.parameters.arrowPixelWidth,this.parameters.arrowPixelHeight),color:this.parameters.color})}this.arrowNeedsUpdate&&(this.arrowNeedsUpdate=!1,this.updateArrowLabel(t,n),this.updateArrow())}}class dm extends nr{constructor(e){super({defines:Object.assign({},dm.shader.defines),uniforms:tr.clone(dm.shader.uniforms),vertexShader:dm.shader.vertexShader,fragmentShader:dm.shader.fragmentShader,side:2,blending:0}),this.update(e)}update(e){var t,n;if((null==e?void 0:e.width)||(null==e?void 0:e.height)){const i=null!==(t=null==e?void 0:e.width)&&void 0!==t?t:this.uniforms.resolution.value.x,r=null!==(n=null==e?void 0:e.height)&&void 0!==n?n:this.uniforms.resolution.value.y;this.uniforms.resolution.value.set(i,r)}return void 0!==(null==e?void 0:e.start)&&this.uniforms.start.value.copy(e.start),void 0!==(null==e?void 0:e.end)&&this.uniforms.end.value.copy(e.end),void 0!==(null==e?void 0:e.shaftPixelWidth)&&(this.uniforms.shaftPixelWidth.value=e.shaftPixelWidth),void 0!==(null==e?void 0:e.shaftPixelOffset)&&(this.uniforms.shaftPixelOffset.value=e.shaftPixelOffset),void 0!==(null==e?void 0:e.arrowPixelSize)&&this.uniforms.arrowPixelSize.value.copy(e.arrowPixelSize),void 0!==(null==e?void 0:e.labelPixelWidth)&&(this.uniforms.labelPixelWidth.value=e.labelPixelWidth),void 0!==(null==e?void 0:e.color)&&(this.uniforms.color.value=new gi(e.color)),this}}dm.shader={uniforms:{resolution:{value:new _t},start:{value:new Yt},end:{value:new Yt},shaftPixelWidth:{value:10},shaftPixelOffset:{value:10},arrowPixelSize:{value:new _t},labelPixelWidth:{value:0},color:{value:new gi}},defines:{RADIUS_RATIO:.5},vertexShader:"varying vec2 centerPixel;\nvarying vec2 posPixel;\nvarying vec2 arrowDir;\n\nuniform vec2 resolution;\nuniform vec3 start;\nuniform vec3 end;\nuniform float shaftPixelWidth;\nuniform float shaftPixelOffset;\nuniform vec2 arrowPixelSize;\nuniform float labelPixelWidth;\n\nvec2 pixelToNdcScale(vec4 hVec) {\n return vec2(2.0 * hVec.w) / resolution.xy;\n}\n\nvoid main() {\n vec4 viewPos = modelViewMatrix * vec4(0.0, 0.0, position.z, 1.0);\n gl_Position = projectionMatrix * viewPos;\n vec4 clipStart = projectionMatrix * viewMatrix * vec4(start, 1.0);\n vec4 clipEnd = projectionMatrix * viewMatrix * vec4(end, 1.0);\n vec2 clipDir = normalize((clipEnd.xy / clipEnd.w - clipStart.xy / clipStart.w) * resolution.xy);\n vec4 shaftEnd = vec4(clipEnd.xy / clipEnd.w * clipStart.w, clipStart.zw);\n shaftEnd.xy -= clipDir * (labelPixelWidth * 0.5 + shaftPixelOffset) * pixelToNdcScale(gl_Position);\n gl_Position.xy = mix(clipStart.xy / clipStart.w, shaftEnd.xy / shaftEnd.w, position.y * 0.5) * gl_Position.w;\n gl_Position.xy += vec2(-clipDir.y, clipDir.x) * position.x * shaftPixelWidth * 0.5 * pixelToNdcScale(gl_Position);\n\n vec4 clipCenter = clipStart;\n float d = arrowPixelSize.y * (1.0 + RADIUS_RATIO) - length(arrowPixelSize * vec2(0.5, RADIUS_RATIO));\n clipCenter.xy += clipDir * (d + shaftPixelOffset + shaftPixelWidth * 0.5) * pixelToNdcScale(gl_Position);\n centerPixel = (clipCenter.xy / gl_Position.w * 0.5 + 0.5) * resolution;\n posPixel = (gl_Position.xy / gl_Position.w * 0.5 + 0.5) * resolution;\n arrowDir = clipDir;\n}",fragmentShader:"varying vec2 centerPixel;\nvarying vec2 posPixel;\nvarying vec2 arrowDir;\n\nuniform float shaftPixelWidth;\nuniform vec3 color;\n\nvoid main() {\n if (dot(arrowDir, posPixel - centerPixel) < 0.0 && length(posPixel - centerPixel) > shaftPixelWidth * 0.5)\n discard;\n gl_FragColor = vec4(color, 1.0);\n}"};class um extends nr{constructor(e){super({defines:Object.assign({},um.shader.defines),uniforms:tr.clone(um.shader.uniforms),vertexShader:um.shader.vertexShader,fragmentShader:um.shader.fragmentShader,side:2,blending:0}),this.update(e)}update(e){var t,n;if((null==e?void 0:e.width)||(null==e?void 0:e.height)){const i=null!==(t=null==e?void 0:e.width)&&void 0!==t?t:this.uniforms.resolution.value.x,r=null!==(n=null==e?void 0:e.height)&&void 0!==n?n:this.uniforms.resolution.value.y;this.uniforms.resolution.value.set(i,r)}return void 0!==(null==e?void 0:e.start)&&this.uniforms.start.value.copy(e.start),void 0!==(null==e?void 0:e.end)&&this.uniforms.end.value.copy(e.end),void 0!==(null==e?void 0:e.arrowPixelSize)&&this.uniforms.arrowPixelSize.value.copy(e.arrowPixelSize),void 0!==(null==e?void 0:e.color)&&(this.uniforms.color.value=new gi(e.color)),this}}um.shader={uniforms:{resolution:{value:new _t},start:{value:new Yt},end:{value:new Yt},arrowPixelSize:{value:new _t},color:{value:new gi}},defines:{RADIUS_RATIO:.5},vertexShader:"varying vec2 arrowUv;\nvarying vec2 centerPixel;\nvarying vec2 posPixel;\n\nuniform vec2 resolution;\nuniform vec3 start;\nuniform vec3 end;\nuniform vec2 arrowPixelSize;\n\nvec2 pixelToNdcScale(vec4 hVec) {\n return vec2(2.0 * hVec.w) / resolution.xy;\n}\n\nvoid main() {\n vec4 viewPos = modelViewMatrix * vec4(0.0, 0.0, position.z, 1.0);\n gl_Position = projectionMatrix * viewPos;\n vec4 clipStart = projectionMatrix * viewMatrix * vec4(start, 1.0);\n vec4 clipEnd = projectionMatrix * viewMatrix * vec4(end, 1.0);\n vec2 clipDir = normalize((clipEnd.xy / clipEnd.w - clipStart.xy / clipStart.w) * resolution.xy);\n gl_Position.xy += clipDir * position.y * arrowPixelSize.y * pixelToNdcScale(gl_Position);\n gl_Position.xy += vec2(-clipDir.y, clipDir.x) * position.x * arrowPixelSize.x * 0.5 * pixelToNdcScale(gl_Position);\n\n arrowUv = position.xy;\n\n vec4 clipCenter = clipStart;\n clipCenter.xy += clipDir * arrowPixelSize.y * (1.0 + RADIUS_RATIO) * pixelToNdcScale(gl_Position);\n centerPixel = (clipCenter.xy / gl_Position.w * 0.5 + 0.5) * resolution;\n posPixel = (gl_Position.xy / gl_Position.w * 0.5 + 0.5) * resolution;\n}",fragmentShader:"varying vec2 arrowUv;\nvarying vec2 centerPixel;\nvarying vec2 posPixel;\n\nuniform vec2 resolution;\nuniform vec2 arrowPixelSize;\nuniform vec3 color;\n\nvoid main() {\n if (abs(arrowUv.x) > abs(arrowUv.y))\n discard;\n if (length(posPixel - centerPixel) < length(arrowPixelSize * vec2(0.5, RADIUS_RATIO)))\n discard;\n gl_FragColor = vec4(color, 1.0);\n}"};const pm="all_around",fm="front";class mm extends Oh{constructor(e={}){super(),this._parameters={},this._parameters=e}generateScene(e,t){const n=new gm(Object.assign(Object.assign({},this._parameters),{lightIntensity:e*(this._parameters.lightIntensity||1),topLightIntensity:e*(this._parameters.topLightIntensity||1),sidLightIntensity:e*(this._parameters.sidLightIntensity||1)}));return n.rotation.y=t,n}}class gm extends oo{constructor(e={}){var t;super(),this._type=null!==(t=null==e?void 0:e.type)&&void 0!==t?t:pm,this._topLightIntensity=(null==e?void 0:e.topLightIntensity)||(null==e?void 0:e.lightIntensity)||1,this._sideLightIntensity=(null==e?void 0:e.sidLightIntensity)||(null==e?void 0:e.lightIntensity)||1,this._sideReflectorIntensity=(null==e?void 0:e.sidLightIntensity)||(null==e?void 0:e.lightIntensity)||1;const n=this._type===fm?.3:0;this._ambientLightIntensity=(null==e?void 0:e.ambientLightIntensity)||n,this._colorVariation=(null==e?void 0:e.colorVariation)||.5,this._lightGeometry=new Ji,this._lightGeometry.deleteAttribute("uv"),this._reflectorLightGeometry=new vl(.7,.4,2,32),this._reflectorLightGeometry.deleteAttribute("uv"),this.generateScene(this)}generateScene(e){switch(this._type){default:case pm:this._createAllAroundSceneLight(e);break;case fm:this._createFrontSceneLight(e)}}dispose(){const e=new Set;this.traverse((t=>{t.isMesh&&(e.add(t.geometry),e.add(t.material))}));for(const t of e)t.dispose()}_createAllAroundSceneLight(e){const t=this._ambientLightIntensity;this.background=new gi(t,t,t),this._createTopLight(e,6,1);for(let t=0;t<6;t++){const n=t*Math.PI*2/6,i=Math.sin(n),r=Math.cos(n);t%2==0?this._createReflector(e,new _t(i,r),3,1,.8,.2):this._createSideLight(e,new _t(i,r),(t-1)/2,15,1.1,.33,1)}}_createFrontSceneLight(e){const t=this._ambientLightIntensity;this.background=new gi(t,t,t),this._createTopLight(e,6,.7);for(let t=0;t<6;t++){const n=t*Math.PI*2/6,i=Math.sin(n),r=Math.cos(n);if(0===t){this._createReflector(e,new _t(i,r),1.1,.6,.8,-.4);for(let n=0;n<2;n++){const i=(t-.3+.6*n)*Math.PI*2/6,r=Math.sin(i),a=Math.cos(i);this._createSideLight(e,new _t(r,a),(t-1)/2,50,1.2,.7,.8)}}else this._createReflector(e,new _t(i,r),1.1,.7,1.4,0)}}_createAreaLightMaterial(e,t,n){const i=new yi;return i.color.set(e,null!=t?t:e,null!=n?n:e),i}_createTopLight(e,t,n){const i=new Zi(this._lightGeometry,this._createAreaLightMaterial(t*this._topLightIntensity));i.position.set(0,20,0),i.scale.set(5*n,.1,5*n),e.add(i)}_createSideLight(e,t,n,i,r,a,s){for(let o=0;o<3;o++){const l=i*this._sideLightIntensity,c=new Zi(this._lightGeometry,this._createAreaLightMaterial((o+n)%3==0?l:l*(1-this._colorVariation),(o+n)%3==1?l:l*(1-this._colorVariation),(o+n)%3==2?l:l*(1-this._colorVariation))),h=(1===o?-t.y:2===o?t.y:0)/Math.sqrt(2),d=0===o?0:1,u=(1===o?t.x:2===o?-t.x:0)/Math.sqrt(2);c.position.set(t.x*s*15+1.1*h*r,15*a+1.1*d*r,t.y*s*15+1.1*u*r),c.rotation.set(0,Math.atan2(t.x,t.y),0),c.scale.setScalar(r),e.add(c)}}_createReflector(e,t,n,i,r,a){const s=new Zi(this._reflectorLightGeometry,this._createAreaLightMaterial(n*this._sideReflectorIntensity));s.position.set(15*t.x,10*a,15*t.y),s.scale.set(10*i,10*r,10*i),e.add(s)}}const vm={effectSuspendFrames:0,effectFadeInFrames:0,suspendGroundReflection:!1,shadowOnCameraChange:af},_m={effectSuspendFrames:5,effectFadeInFrames:5,suspendGroundReflection:!1,shadowOnCameraChange:rf},xm={effectSuspendFrames:5,effectFadeInFrames:5,suspendGroundReflection:!0,shadowOnCameraChange:nf},ym={enabled:!0,aoOnGround:!0,shadowOnGround:!0,aoIntensity:1,shadowIntensity:1,ao:{algorithm:4,samples:16,radius:.5,distanceExponent:2,thickness:1,distanceFallOff:1,scale:1,bias:.01,screenSpaceRadius:!1}},Sm={enableGroundBoundary:!1,directionalDependency:1,directionalExponent:1,groundBoundary:1,fadeOutDistance:.2,fadeOutBlur:5},wm=new Map([[em,Object.assign(Object.assign({},vm),{shAndAoPassParameters:ym,screenSpaceShadowMapParameters:Sm,groundReflectionParameters:{enabled:!0},bakedGroundContactShadowParameters:{enabled:!1}})],[tm,Object.assign(Object.assign({},_m),{shAndAoPassParameters:ym,screenSpaceShadowMapParameters:Sm,groundReflectionParameters:{enabled:!0},bakedGroundContactShadowParameters:{enabled:!1}})],[nm,Object.assign(Object.assign({},xm),{shAndAoPassParameters:ym,screenSpaceShadowMapParameters:Sm,groundReflectionParameters:{enabled:!1},bakedGroundContactShadowParameters:{enabled:!1}})],["low",{shAndAoPassParameters:{enabled:!1,aoOnGround:!1,shadowOnGround:!1},groundReflectionParameters:{enabled:!1},bakedGroundContactShadowParameters:{enabled:!0}}]]);class bm extends Zi{constructor(e,t,n,i=128){if(t<=0||n<=0||i<=0)throw new Error("GroundedSkybox height, radius, and resolution must be positive.");const r=new Sl(n,2*i,i);r.scale(1,1,-1);const a=r.getAttribute("position"),s=new Yt;for(let e=0;e{const t=e.materialId;return{materialId:e.materialId,name:t}})),a=Object.assign({},...r.map((e=>({[e.name]:e.materialId}))));this.materialFolder.add(this,"materialId",a).onChange((e=>this.updateMaterialPropertiesUI(e))),this.updateMaterialPropertiesUI(this.materialId)}updateMaterialPropertiesUI(e){var t,n,i,r,a,s,o,l,c,h;if(this.materialId=e,!this.materialFolder)return;this.materialProperties&&(this.materialFolder.removeFolder(this.materialProperties),this.materialProperties=void 0);const d=this.materials.find((t=>t.materialId===e));if(!d)return;const u=d.material;if(!u)return;const p={color:null!==(n=null===(t=u.color)||void 0===t?void 0:t.getHex())&&void 0!==n?n:16777215,specularColor:null!==(r=null===(i=u.color)||void 0===i?void 0:i.getHex())&&void 0!==r?r:16777215,emissive:null!==(s=null===(a=u.emissive)||void 0===a?void 0:a.getHex())&&void 0!==s?s:16777215,sheenColor:null!==(l=null===(o=u.emissive)||void 0===o?void 0:o.getHex())&&void 0!==l?l:16777215,attenuationColor:null!==(h=null===(c=u.emissive)||void 0===c?void 0:c.getHex())&&void 0!==h?h:16777215};let f="properties";d.material.userData&&(d.material.userData.diffuseMap&&(f+=d.material.userData.diffuseMapHasAlpha?" RGBA":" RGB"),d.material.userData.normalMap&&(f+=" XYZ"),d.material.userData.ormMap&&(f+=" ORM")),this.materialProperties=this.materialFolder.addFolder(f),this.materialProperties.addColor(p,"color").onChange(Em.handleColorChange(u.color,!0)),this.materialProperties.add(u,"opacity",0,1).onChange((e=>{const t=e<1;t!==u.transparent&&(u.transparent=t,u.needsUpdate=!0)}));try{this.materialProperties.add(u,"metalness",0,1),this.materialProperties.add(u,"roughness",0,1),this.materialProperties.add(u,"transmission",0,1),this.materialProperties.add(u,"ior",1,2.333),this.materialProperties.add(u,"specularIntensity",0,1),this.materialProperties.addColor(p,"specularColor").onChange(Em.handleColorChange(u.specularColor,!0)),this.materialProperties.add(u,"reflectivity",0,1),this.materialProperties.add(u,"clearcoat",0,1),this.materialProperties.add(u,"clearcoatRoughness",0,1),this.materialProperties.add(u,"sheen",0,1),this.materialProperties.add(u,"sheenRoughness",0,1),this.materialProperties.addColor(p,"sheenColor").onChange(Em.handleColorChange(u.sheenColor,!0)),this.materialProperties.add(u,"emissiveIntensity",0,1),this.materialProperties.addColor(p,"emissive").onChange(Em.handleColorChange(u.emissive,!0)),this.materialProperties.add(u,"attenuationDistance",0,50),this.materialProperties.addColor(p,"attenuationColor").onChange(Em.handleColorChange(u.attenuationColor,!0)),this.materialProperties.add(u,"thickness",0,50)}catch(e){console.log(e)}}static handleColorChange(e,t=!1){return n=>{"string"==typeof n&&(n=n.replace("#","0x")),e.setHex(n),!0===t&&e.convertSRGBToLinear()}}}var Am=function(){var e=0,t=document.createElement("div");function n(e){return t.appendChild(e.dom),e}function i(n){for(var i=0;i=a+1e3&&(o.update(1e3*s/(e-a),100),a=e,s=0,c)){var t=performance.memory;c.update(t.usedJSHeapSize/1048576,t.jsHeapSizeLimit/1048576)}return e},update:function(){r=this.end()},domElement:t,setMode:i}};Am.Panel=function(e,t,n){var i=1/0,r=0,a=Math.round,s=a(window.devicePixelRatio||1),o=80*s,l=48*s,c=3*s,h=2*s,d=3*s,u=15*s,p=74*s,f=30*s,m=document.createElement("canvas");m.width=o,m.height=l,m.style.cssText="width:80px;height:48px";var g=m.getContext("2d");return g.font="bold "+9*s+"px Helvetica,Arial,sans-serif",g.textBaseline="top",g.fillStyle=n,g.fillRect(0,0,o,l),g.fillStyle=t,g.fillText(e,c,h),g.fillRect(d,u,p,f),g.fillStyle=n,g.globalAlpha=.9,g.fillRect(d,u,p,f),{dom:m,update:function(l,v){i=Math.min(i,l),r=Math.max(r,l),g.fillStyle=n,g.globalAlpha=1,g.fillRect(0,0,o,u),g.fillStyle=t,g.fillText(a(l)+" "+e+" ("+a(i)+"-"+a(r)+")",c,h),g.drawImage(m,d+s,u,p-s,f,d,u,p-s,f),g.fillRect(d+p-s,u,s,f),g.fillStyle=n,g.globalAlpha=.9,g.fillRect(d+p-s,u,s,a((1-l/v)*f))}}};const Pm=Am;function Rm(e,t){var n=e.__state.conversionName.toString(),i=Math.round(e.r),r=Math.round(e.g),a=Math.round(e.b),s=e.a,o=Math.round(e.h),l=e.s.toFixed(1),c=e.v.toFixed(1);if(t||"THREE_CHAR_HEX"===n||"SIX_CHAR_HEX"===n){for(var h=e.hex.toString(16);h.length<6;)h="0"+h;return"#"+h}return"CSS_RGB"===n?"rgb("+i+","+r+","+a+")":"CSS_RGBA"===n?"rgba("+i+","+r+","+a+","+s+")":"HEX"===n?"0x"+e.hex.toString(16):"RGB_ARRAY"===n?"["+i+","+r+","+a+"]":"RGBA_ARRAY"===n?"["+i+","+r+","+a+","+s+"]":"RGB_OBJ"===n?"{r:"+i+",g:"+r+",b:"+a+"}":"RGBA_OBJ"===n?"{r:"+i+",g:"+r+",b:"+a+",a:"+s+"}":"HSV_OBJ"===n?"{h:"+o+",s:"+l+",v:"+c+"}":"HSVA_OBJ"===n?"{h:"+o+",s:"+l+",v:"+c+",a:"+s+"}":"unknown format"}var Cm=Array.prototype.forEach,Dm=Array.prototype.slice,Lm={BREAK:{},extend:function(e){return this.each(Dm.call(arguments,1),(function(t){(this.isObject(t)?Object.keys(t):[]).forEach(function(n){this.isUndefined(t[n])||(e[n]=t[n])}.bind(this))}),this),e},defaults:function(e){return this.each(Dm.call(arguments,1),(function(t){(this.isObject(t)?Object.keys(t):[]).forEach(function(n){this.isUndefined(e[n])&&(e[n]=t[n])}.bind(this))}),this),e},compose:function(){var e=Dm.call(arguments);return function(){for(var t=Dm.call(arguments),n=e.length-1;n>=0;n--)t=[e[n].apply(this,t)];return t[0]}},each:function(e,t,n){if(e)if(Cm&&e.forEach&&e.forEach===Cm)e.forEach(t,n);else if(e.length===e.length+0){var i,r=void 0;for(r=0,i=e.length;r1?Lm.toArray(arguments):arguments[0];return Lm.each(Im,(function(t){if(t.litmus(e))return Lm.each(t.conversions,(function(t,n){if(Um=t.read(e),!1===Om&&!1!==Um)return Om=Um,Um.conversionName=n,Um.conversion=t,Lm.BREAK})),Lm.BREAK})),Om},Fm=void 0,Bm={hsv_to_rgb:function(e,t,n){var i=Math.floor(e/60)%6,r=e/60-Math.floor(e/60),a=n*(1-t),s=n*(1-r*t),o=n*(1-(1-r)*t),l=[[n,o,a],[s,n,a],[a,n,o],[a,s,n],[o,a,n],[n,a,s]][i];return{r:255*l[0],g:255*l[1],b:255*l[2]}},rgb_to_hsv:function(e,t,n){var i=Math.min(e,t,n),r=Math.max(e,t,n),a=r-i,s=void 0;return 0===r?{h:NaN,s:0,v:0}:(s=e===r?(t-n)/a:t===r?2+(n-e)/a:4+(e-t)/a,(s/=6)<0&&(s+=1),{h:360*s,s:a/r,v:r/255})},rgb_to_hex:function(e,t,n){var i=this.hex_with_component(0,2,e);return i=this.hex_with_component(i,1,t),this.hex_with_component(i,0,n)},component_from_hex:function(e,t){return e>>8*t&255},hex_with_component:function(e,t,n){return n<<(Fm=8*t)|e&~(255<-1?t.length-t.indexOf(".")-1:0}var ig=function(e){function t(e,n,i){km(this,t);var r=Wm(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,e,n)),a=i||{};return r.__min=a.min,r.__max=a.max,r.__step=a.step,Lm.isUndefined(r.__step)?0===r.initialValue?r.__impliedStep=1:r.__impliedStep=Math.pow(10,Math.floor(Math.log(Math.abs(r.initialValue))/Math.LN10))/10:r.__impliedStep=r.__step,r.__precision=ng(r.__impliedStep),r}return Gm(t,e),Hm(t,[{key:"setValue",value:function(e){var n=e;return void 0!==this.__min&&nthis.__max&&(n=this.__max),void 0!==this.__step&&n%this.__step!=0&&(n=Math.round(n/this.__step)*this.__step),Vm(t.prototype.__proto__||Object.getPrototypeOf(t.prototype),"setValue",this).call(this,n)}},{key:"min",value:function(e){return this.__min=e,this}},{key:"max",value:function(e){return this.__max=e,this}},{key:"step",value:function(e){return this.__step=e,this.__impliedStep=e,this.__precision=ng(e),this}}]),t}(qm),rg=function(e){function t(e,n,i){km(this,t);var r=Wm(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,e,n,i));r.__truncationSuspended=!1;var a=r,s=void 0;function o(){a.__onFinishChange&&a.__onFinishChange.call(a,a.getValue())}function l(e){var t=s-e.clientY;a.setValue(a.getValue()+t*a.__impliedStep),s=e.clientY}function c(){Qm.unbind(window,"mousemove",l),Qm.unbind(window,"mouseup",c),o()}return r.__input=document.createElement("input"),r.__input.setAttribute("type","text"),Qm.bind(r.__input,"change",(function(){var e=parseFloat(a.__input.value);Lm.isNaN(e)||a.setValue(e)})),Qm.bind(r.__input,"blur",(function(){o()})),Qm.bind(r.__input,"mousedown",(function(e){Qm.bind(window,"mousemove",l),Qm.bind(window,"mouseup",c),s=e.clientY})),Qm.bind(r.__input,"keydown",(function(e){13===e.keyCode&&(a.__truncationSuspended=!0,this.blur(),a.__truncationSuspended=!1,o())})),r.updateDisplay(),r.domElement.appendChild(r.__input),r}return Gm(t,e),Hm(t,[{key:"updateDisplay",value:function(){var e,n,i;return this.__input.value=this.__truncationSuspended?this.getValue():(e=this.getValue(),n=this.__precision,i=Math.pow(10,n),Math.round(e*i)/i),Vm(t.prototype.__proto__||Object.getPrototypeOf(t.prototype),"updateDisplay",this).call(this)}}]),t}(ig);function ag(e,t,n,i,r){return i+(e-t)/(n-t)*(r-i)}var sg=function(e){function t(e,n,i,r,a){km(this,t);var s=Wm(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,e,n,{min:i,max:r,step:a})),o=s;function l(e){e.preventDefault();var t=o.__background.getBoundingClientRect();return o.setValue(ag(e.clientX,t.left,t.right,o.__min,o.__max)),!1}function c(){Qm.unbind(window,"mousemove",l),Qm.unbind(window,"mouseup",c),o.__onFinishChange&&o.__onFinishChange.call(o,o.getValue())}function h(e){var t=e.touches[0].clientX,n=o.__background.getBoundingClientRect();o.setValue(ag(t,n.left,n.right,o.__min,o.__max))}function d(){Qm.unbind(window,"touchmove",h),Qm.unbind(window,"touchend",d),o.__onFinishChange&&o.__onFinishChange.call(o,o.getValue())}return s.__background=document.createElement("div"),s.__foreground=document.createElement("div"),Qm.bind(s.__background,"mousedown",(function(e){document.activeElement.blur(),Qm.bind(window,"mousemove",l),Qm.bind(window,"mouseup",c),l(e)})),Qm.bind(s.__background,"touchstart",(function(e){1===e.touches.length&&(Qm.bind(window,"touchmove",h),Qm.bind(window,"touchend",d),h(e))})),Qm.addClass(s.__background,"slider"),Qm.addClass(s.__foreground,"slider-fg"),s.updateDisplay(),s.__background.appendChild(s.__foreground),s.domElement.appendChild(s.__background),s}return Gm(t,e),Hm(t,[{key:"updateDisplay",value:function(){var e=(this.getValue()-this.__min)/(this.__max-this.__min);return this.__foreground.style.width=100*e+"%",Vm(t.prototype.__proto__||Object.getPrototypeOf(t.prototype),"updateDisplay",this).call(this)}}]),t}(ig),og=function(e){function t(e,n,i){km(this,t);var r=Wm(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,e,n)),a=r;return r.__button=document.createElement("div"),r.__button.innerHTML=void 0===i?"Fire":i,Qm.bind(r.__button,"click",(function(e){return e.preventDefault(),a.fire(),!1})),Qm.addClass(r.__button,"button"),r.domElement.appendChild(r.__button),r}return Gm(t,e),Hm(t,[{key:"fire",value:function(){this.__onChange&&this.__onChange.call(this),this.getValue().call(this.object),this.__onFinishChange&&this.__onFinishChange.call(this,this.getValue())}}]),t}(qm),lg=function(e){function t(e,n){km(this,t);var i=Wm(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,e,n));i.__color=new jm(i.getValue()),i.__temp=new jm(0);var r=i;i.domElement=document.createElement("div"),Qm.makeSelectable(i.domElement,!1),i.__selector=document.createElement("div"),i.__selector.className="selector",i.__saturation_field=document.createElement("div"),i.__saturation_field.className="saturation-field",i.__field_knob=document.createElement("div"),i.__field_knob.className="field-knob",i.__field_knob_border="2px solid ",i.__hue_knob=document.createElement("div"),i.__hue_knob.className="hue-knob",i.__hue_field=document.createElement("div"),i.__hue_field.className="hue-field",i.__input=document.createElement("input"),i.__input.type="text",i.__input_textShadow="0 1px 1px ",Qm.bind(i.__input,"keydown",(function(e){13===e.keyCode&&d.call(this)})),Qm.bind(i.__input,"blur",d),Qm.bind(i.__selector,"mousedown",(function(){Qm.addClass(this,"drag").bind(window,"mouseup",(function(){Qm.removeClass(r.__selector,"drag")}))})),Qm.bind(i.__selector,"touchstart",(function(){Qm.addClass(this,"drag").bind(window,"touchend",(function(){Qm.removeClass(r.__selector,"drag")}))}));var a,s=document.createElement("div");function o(e){p(e),Qm.bind(window,"mousemove",p),Qm.bind(window,"touchmove",p),Qm.bind(window,"mouseup",c),Qm.bind(window,"touchend",c)}function l(e){f(e),Qm.bind(window,"mousemove",f),Qm.bind(window,"touchmove",f),Qm.bind(window,"mouseup",h),Qm.bind(window,"touchend",h)}function c(){Qm.unbind(window,"mousemove",p),Qm.unbind(window,"touchmove",p),Qm.unbind(window,"mouseup",c),Qm.unbind(window,"touchend",c),u()}function h(){Qm.unbind(window,"mousemove",f),Qm.unbind(window,"touchmove",f),Qm.unbind(window,"mouseup",h),Qm.unbind(window,"touchend",h),u()}function d(){var e=Nm(this.value);!1!==e?(r.__color.__state=e,r.setValue(r.__color.toOriginal())):this.value=r.__color.toString()}function u(){r.__onFinishChange&&r.__onFinishChange.call(r,r.__color.toOriginal())}function p(e){-1===e.type.indexOf("touch")&&e.preventDefault();var t=r.__saturation_field.getBoundingClientRect(),n=e.touches&&e.touches[0]||e,i=n.clientX,a=n.clientY,s=(i-t.left)/(t.right-t.left),o=1-(a-t.top)/(t.bottom-t.top);return o>1?o=1:o<0&&(o=0),s>1?s=1:s<0&&(s=0),r.__color.v=o,r.__color.s=s,r.setValue(r.__color.toOriginal()),!1}function f(e){-1===e.type.indexOf("touch")&&e.preventDefault();var t=r.__hue_field.getBoundingClientRect(),n=1-((e.touches&&e.touches[0]||e).clientY-t.top)/(t.bottom-t.top);return n>1?n=1:n<0&&(n=0),r.__color.h=360*n,r.setValue(r.__color.toOriginal()),!1}return Lm.extend(i.__selector.style,{width:"122px",height:"102px",padding:"3px",backgroundColor:"#222",boxShadow:"0px 1px 3px rgba(0,0,0,0.3)"}),Lm.extend(i.__field_knob.style,{position:"absolute",width:"12px",height:"12px",border:i.__field_knob_border+(i.__color.v<.5?"#fff":"#000"),boxShadow:"0px 1px 3px rgba(0,0,0,0.5)",borderRadius:"12px",zIndex:1}),Lm.extend(i.__hue_knob.style,{position:"absolute",width:"15px",height:"2px",borderRight:"4px solid #fff",zIndex:1}),Lm.extend(i.__saturation_field.style,{width:"100px",height:"100px",border:"1px solid #555",marginRight:"3px",display:"inline-block",cursor:"pointer"}),Lm.extend(s.style,{width:"100%",height:"100%",background:"none"}),hg(s,"top","rgba(0,0,0,0)","#000"),Lm.extend(i.__hue_field.style,{width:"15px",height:"100px",border:"1px solid #555",cursor:"ns-resize",position:"absolute",top:"3px",right:"3px"}),(a=i.__hue_field).style.background="",a.style.cssText+="background: -moz-linear-gradient(top, #ff0000 0%, #ff00ff 17%, #0000ff 34%, #00ffff 50%, #00ff00 67%, #ffff00 84%, #ff0000 100%);",a.style.cssText+="background: -webkit-linear-gradient(top, #ff0000 0%,#ff00ff 17%,#0000ff 34%,#00ffff 50%,#00ff00 67%,#ffff00 84%,#ff0000 100%);",a.style.cssText+="background: -o-linear-gradient(top, #ff0000 0%,#ff00ff 17%,#0000ff 34%,#00ffff 50%,#00ff00 67%,#ffff00 84%,#ff0000 100%);",a.style.cssText+="background: -ms-linear-gradient(top, #ff0000 0%,#ff00ff 17%,#0000ff 34%,#00ffff 50%,#00ff00 67%,#ffff00 84%,#ff0000 100%);",a.style.cssText+="background: linear-gradient(top, #ff0000 0%,#ff00ff 17%,#0000ff 34%,#00ffff 50%,#00ff00 67%,#ffff00 84%,#ff0000 100%);",Lm.extend(i.__input.style,{outline:"none",textAlign:"center",color:"#fff",border:0,fontWeight:"bold",textShadow:i.__input_textShadow+"rgba(0,0,0,0.7)"}),Qm.bind(i.__saturation_field,"mousedown",o),Qm.bind(i.__saturation_field,"touchstart",o),Qm.bind(i.__field_knob,"mousedown",o),Qm.bind(i.__field_knob,"touchstart",o),Qm.bind(i.__hue_field,"mousedown",l),Qm.bind(i.__hue_field,"touchstart",l),i.__saturation_field.appendChild(s),i.__selector.appendChild(i.__field_knob),i.__selector.appendChild(i.__saturation_field),i.__selector.appendChild(i.__hue_field),i.__hue_field.appendChild(i.__hue_knob),i.domElement.appendChild(i.__input),i.domElement.appendChild(i.__selector),i.updateDisplay(),i}return Gm(t,e),Hm(t,[{key:"updateDisplay",value:function(){var e=Nm(this.getValue());if(!1!==e){var t=!1;Lm.each(jm.COMPONENTS,(function(n){if(!Lm.isUndefined(e[n])&&!Lm.isUndefined(this.__color.__state[n])&&e[n]!==this.__color.__state[n])return t=!0,{}}),this),t&&Lm.extend(this.__color.__state,e)}Lm.extend(this.__temp.__state,this.__color.__state),this.__temp.a=1;var n=this.__color.v<.5||this.__color.s>.5?255:0,i=255-n;Lm.extend(this.__field_knob.style,{marginLeft:100*this.__color.s-7+"px",marginTop:100*(1-this.__color.v)-7+"px",backgroundColor:this.__temp.toHexString(),border:this.__field_knob_border+"rgb("+n+","+n+","+n+")"}),this.__hue_knob.style.marginTop=100*(1-this.__color.h/360)+"px",this.__temp.s=1,this.__temp.v=1,hg(this.__saturation_field,"left","#fff",this.__temp.toHexString()),this.__input.value=this.__color.toString(),Lm.extend(this.__input.style,{backgroundColor:this.__color.toHexString(),color:"rgb("+n+","+n+","+n+")",textShadow:this.__input_textShadow+"rgba("+i+","+i+","+i+",.7)"})}}]),t}(qm),cg=["-moz-","-o-","-webkit-","-ms-",""];function hg(e,t,n,i){e.style.background="",Lm.each(cg,(function(r){e.style.cssText+="background: "+r+"linear-gradient("+t+", "+n+" 0%, "+i+" 100%); "}))}var dg=function(e,t){var n=e[t];return Lm.isArray(arguments[2])||Lm.isObject(arguments[2])?new eg(e,t,arguments[2]):Lm.isNumber(n)?Lm.isNumber(arguments[2])&&Lm.isNumber(arguments[3])?Lm.isNumber(arguments[4])?new sg(e,t,arguments[2],arguments[3],arguments[4]):new sg(e,t,arguments[2],arguments[3]):Lm.isNumber(arguments[4])?new rg(e,t,{min:arguments[2],max:arguments[3],step:arguments[4]}):new rg(e,t,{min:arguments[2],max:arguments[3]}):Lm.isString(n)?new tg(e,t):Lm.isFunction(n)?new og(e,t,""):Lm.isBoolean(n)?new $m(e,t):null},ug=window.requestAnimationFrame||window.webkitRequestAnimationFrame||window.mozRequestAnimationFrame||window.oRequestAnimationFrame||window.msRequestAnimationFrame||function(e){setTimeout(e,1e3/60)},pg=function(){function e(){km(this,e),this.backgroundElement=document.createElement("div"),Lm.extend(this.backgroundElement.style,{backgroundColor:"rgba(0,0,0,0.8)",top:0,left:0,display:"none",zIndex:"1000",opacity:0,WebkitTransition:"opacity 0.2s linear",transition:"opacity 0.2s linear"}),Qm.makeFullscreen(this.backgroundElement),this.backgroundElement.style.position="fixed",this.domElement=document.createElement("div"),Lm.extend(this.domElement.style,{position:"fixed",display:"none",zIndex:"1001",opacity:0,WebkitTransition:"-webkit-transform 0.2s ease-out, opacity 0.2s linear",transition:"transform 0.2s ease-out, opacity 0.2s linear"}),document.body.appendChild(this.backgroundElement),document.body.appendChild(this.domElement);var t=this;Qm.bind(this.backgroundElement,"click",(function(){t.hide()}))}return Hm(e,[{key:"show",value:function(){var e=this;this.backgroundElement.style.display="block",this.domElement.style.display="block",this.domElement.style.opacity=0,this.domElement.style.webkitTransform="scale(1.1)",this.layout(),Lm.defer((function(){e.backgroundElement.style.opacity=1,e.domElement.style.opacity=1,e.domElement.style.webkitTransform="scale(1)"}))}},{key:"hide",value:function(){var e=this,t=function t(){e.domElement.style.display="none",e.backgroundElement.style.display="none",Qm.unbind(e.domElement,"webkitTransitionEnd",t),Qm.unbind(e.domElement,"transitionend",t),Qm.unbind(e.domElement,"oTransitionEnd",t)};Qm.bind(this.domElement,"webkitTransitionEnd",t),Qm.bind(this.domElement,"transitionend",t),Qm.bind(this.domElement,"oTransitionEnd",t),this.backgroundElement.style.opacity=0,this.domElement.style.opacity=0,this.domElement.style.webkitTransform="scale(1.1)"}},{key:"layout",value:function(){this.domElement.style.left=window.innerWidth/2-Qm.getWidth(this.domElement)/2+"px",this.domElement.style.top=window.innerHeight/2-Qm.getHeight(this.domElement)/2+"px"}}]),e}();!function(e,t){var n=t||document,i=document.createElement("style");i.type="text/css",i.innerHTML=e;var r=n.getElementsByTagName("head")[0];try{r.appendChild(i)}catch(e){}}(function(e){if(e&&"undefined"!=typeof window){var t=document.createElement("style");return t.setAttribute("type","text/css"),t.innerHTML=e,document.head.appendChild(t),e}}(".dg ul{list-style:none;margin:0;padding:0;width:100%;clear:both}.dg.ac{position:fixed;top:0;left:0;right:0;height:0;z-index:0}.dg:not(.ac) .main{overflow:hidden}.dg.main{-webkit-transition:opacity .1s linear;-o-transition:opacity .1s linear;-moz-transition:opacity .1s linear;transition:opacity .1s linear}.dg.main.taller-than-window{overflow-y:auto}.dg.main.taller-than-window .close-button{opacity:1;margin-top:-1px;border-top:1px solid #2c2c2c}.dg.main ul.closed .close-button{opacity:1 !important}.dg.main:hover .close-button,.dg.main .close-button.drag{opacity:1}.dg.main .close-button{-webkit-transition:opacity .1s linear;-o-transition:opacity .1s linear;-moz-transition:opacity .1s linear;transition:opacity .1s linear;border:0;line-height:19px;height:20px;cursor:pointer;text-align:center;background-color:#000}.dg.main .close-button.close-top{position:relative}.dg.main .close-button.close-bottom{position:absolute}.dg.main .close-button:hover{background-color:#111}.dg.a{float:right;margin-right:15px;overflow-y:visible}.dg.a.has-save>ul.close-top{margin-top:0}.dg.a.has-save>ul.close-bottom{margin-top:27px}.dg.a.has-save>ul.closed{margin-top:0}.dg.a .save-row{top:0;z-index:1002}.dg.a .save-row.close-top{position:relative}.dg.a .save-row.close-bottom{position:fixed}.dg li{-webkit-transition:height .1s ease-out;-o-transition:height .1s ease-out;-moz-transition:height .1s ease-out;transition:height .1s ease-out;-webkit-transition:overflow .1s linear;-o-transition:overflow .1s linear;-moz-transition:overflow .1s linear;transition:overflow .1s linear}.dg li:not(.folder){cursor:auto;height:27px;line-height:27px;padding:0 4px 0 5px}.dg li.folder{padding:0;border-left:4px solid rgba(0,0,0,0)}.dg li.title{cursor:pointer;margin-left:-4px}.dg .closed li:not(.title),.dg .closed ul li,.dg .closed ul li>*{height:0;overflow:hidden;border:0}.dg .cr{clear:both;padding-left:3px;height:27px;overflow:hidden}.dg .property-name{cursor:default;float:left;clear:left;width:40%;overflow:hidden;text-overflow:ellipsis}.dg .cr.function .property-name{width:100%}.dg .c{float:left;width:60%;position:relative}.dg .c input[type=text]{border:0;margin-top:4px;padding:3px;width:100%;float:right}.dg .has-slider input[type=text]{width:30%;margin-left:0}.dg .slider{float:left;width:66%;margin-left:-5px;margin-right:0;height:19px;margin-top:4px}.dg .slider-fg{height:100%}.dg .c input[type=checkbox]{margin-top:7px}.dg .c select{margin-top:5px}.dg .cr.function,.dg .cr.function .property-name,.dg .cr.function *,.dg .cr.boolean,.dg .cr.boolean *{cursor:pointer}.dg .cr.color{overflow:visible}.dg .selector{display:none;position:absolute;margin-left:-9px;margin-top:23px;z-index:10}.dg .c:hover .selector,.dg .selector.drag{display:block}.dg li.save-row{padding:0}.dg li.save-row .button{display:inline-block;padding:0px 6px}.dg.dialogue{background-color:#222;width:460px;padding:15px;font-size:13px;line-height:15px}#dg-new-constructor{padding:10px;color:#222;font-family:Monaco, monospace;font-size:10px;border:0;resize:none;box-shadow:inset 1px 1px 1px #888;word-wrap:break-word;margin:12px 0;display:block;width:440px;overflow-y:scroll;height:100px;position:relative}#dg-local-explain{display:none;font-size:11px;line-height:17px;border-radius:3px;background-color:#333;padding:8px;margin-top:10px}#dg-local-explain code{font-size:10px}#dat-gui-save-locally{display:none}.dg{color:#eee;font:11px 'Lucida Grande', sans-serif;text-shadow:0 -1px 0 #111}.dg.main::-webkit-scrollbar{width:5px;background:#1a1a1a}.dg.main::-webkit-scrollbar-corner{height:0;display:none}.dg.main::-webkit-scrollbar-thumb{border-radius:5px;background:#676767}.dg li:not(.folder){background:#1a1a1a;border-bottom:1px solid #2c2c2c}.dg li.save-row{line-height:25px;background:#dad5cb;border:0}.dg li.save-row select{margin-left:5px;width:108px}.dg li.save-row .button{margin-left:5px;margin-top:1px;border-radius:2px;font-size:9px;line-height:7px;padding:4px 4px 5px 4px;background:#c5bdad;color:#fff;text-shadow:0 1px 0 #b0a58f;box-shadow:0 -1px 0 #b0a58f;cursor:pointer}.dg li.save-row .button.gears{background:#c5bdad url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAsAAAANCAYAAAB/9ZQ7AAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAQJJREFUeNpiYKAU/P//PwGIC/ApCABiBSAW+I8AClAcgKxQ4T9hoMAEUrxx2QSGN6+egDX+/vWT4e7N82AMYoPAx/evwWoYoSYbACX2s7KxCxzcsezDh3evFoDEBYTEEqycggWAzA9AuUSQQgeYPa9fPv6/YWm/Acx5IPb7ty/fw+QZblw67vDs8R0YHyQhgObx+yAJkBqmG5dPPDh1aPOGR/eugW0G4vlIoTIfyFcA+QekhhHJhPdQxbiAIguMBTQZrPD7108M6roWYDFQiIAAv6Aow/1bFwXgis+f2LUAynwoIaNcz8XNx3Dl7MEJUDGQpx9gtQ8YCueB+D26OECAAQDadt7e46D42QAAAABJRU5ErkJggg==) 2px 1px no-repeat;height:7px;width:8px}.dg li.save-row .button:hover{background-color:#bab19e;box-shadow:0 -1px 0 #b0a58f}.dg li.folder{border-bottom:0}.dg li.title{padding-left:16px;background:#000 url(data:image/gif;base64,R0lGODlhBQAFAJEAAP////Pz8////////yH5BAEAAAIALAAAAAAFAAUAAAIIlI+hKgFxoCgAOw==) 6px 10px no-repeat;cursor:pointer;border-bottom:1px solid rgba(255,255,255,0.2)}.dg .closed li.title{background-image:url(data:image/gif;base64,R0lGODlhBQAFAJEAAP////Pz8////////yH5BAEAAAIALAAAAAAFAAUAAAIIlGIWqMCbWAEAOw==)}.dg .cr.boolean{border-left:3px solid #806787}.dg .cr.color{border-left:3px solid}.dg .cr.function{border-left:3px solid #e61d5f}.dg .cr.number{border-left:3px solid #2FA1D6}.dg .cr.number input[type=text]{color:#2FA1D6}.dg .cr.string{border-left:3px solid #1ed36f}.dg .cr.string input[type=text]{color:#1ed36f}.dg .cr.function:hover,.dg .cr.boolean:hover{background:#111}.dg .c input[type=text]{background:#303030;outline:none}.dg .c input[type=text]:hover{background:#3c3c3c}.dg .c input[type=text]:focus{background:#494949;color:#fff}.dg .c .slider{background:#303030;cursor:ew-resize}.dg .c .slider-fg{background:#2FA1D6;max-width:100%}.dg .c .slider:hover{background:#3c3c3c}.dg .c .slider:hover .slider-fg{background:#44abda}\n"));var fg="Default",mg=function(){try{return!!window.localStorage}catch(e){return!1}}(),gg=void 0,vg=!0,_g=void 0,xg=!1,yg=[],Sg=function e(t){var n=this,i=t||{};this.domElement=document.createElement("div"),this.__ul=document.createElement("ul"),this.domElement.appendChild(this.__ul),Qm.addClass(this.domElement,"dg"),this.__folders={},this.__controllers=[],this.__rememberedObjects=[],this.__rememberedObjectIndecesToControllers=[],this.__listening=[],i=Lm.defaults(i,{closeOnTop:!1,autoPlace:!0,width:e.DEFAULT_WIDTH}),i=Lm.defaults(i,{resizable:i.autoPlace,hideable:i.autoPlace}),Lm.isUndefined(i.load)?i.load={preset:fg}:i.preset&&(i.load.preset=i.preset),Lm.isUndefined(i.parent)&&i.hideable&&yg.push(this),i.resizable=Lm.isUndefined(i.parent)&&i.resizable,i.autoPlace&&Lm.isUndefined(i.scrollable)&&(i.scrollable=!0);var r,a=mg&&"true"===localStorage.getItem(Ag(0,"isLocal")),s=void 0,o=void 0;if(Object.defineProperties(this,{parent:{get:function(){return i.parent}},scrollable:{get:function(){return i.scrollable}},autoPlace:{get:function(){return i.autoPlace}},closeOnTop:{get:function(){return i.closeOnTop}},preset:{get:function(){return n.parent?n.getRoot().preset:i.load.preset},set:function(e){n.parent?n.getRoot().preset=e:i.load.preset=e,function(e){for(var t=0;t1){var i=n.__li.nextElementSibling;return n.remove(),Eg(e,n.object,n.property,{before:i,factoryArgs:[Lm.toArray(arguments)]})}if(Lm.isArray(t)||Lm.isObject(t)){var r=n.__li.nextElementSibling;return n.remove(),Eg(e,n.object,n.property,{before:r,factoryArgs:[t]})}},name:function(e){return n.__li.firstElementChild.firstElementChild.innerHTML=e,n},listen:function(){return n.__gui.listen(n),n},remove:function(){return n.__gui.remove(n),n}}),n instanceof sg){var i=new rg(n.object,n.property,{min:n.__min,max:n.__max,step:n.__step});Lm.each(["updateDisplay","onChange","onFinishChange","step","min","max"],(function(e){var t=n[e],r=i[e];n[e]=i[e]=function(){var e=Array.prototype.slice.call(arguments);return r.apply(i,e),t.apply(n,e)}})),Qm.addClass(t,"has-slider"),n.domElement.insertBefore(i.domElement,n.domElement.firstElementChild)}else if(n instanceof rg){var r=function(t){if(Lm.isNumber(n.__min)&&Lm.isNumber(n.__max)){var i=n.__li.firstElementChild.firstElementChild.innerHTML,r=n.__gui.__listening.indexOf(n)>-1;n.remove();var a=Eg(e,n.object,n.property,{before:n.__li.nextElementSibling,factoryArgs:[n.__min,n.__max,n.__step]});return a.name(i),r&&a.listen(),a}return t};n.min=Lm.compose(r,n.min),n.max=Lm.compose(r,n.max)}else n instanceof $m?(Qm.bind(t,"click",(function(){Qm.fakeEvent(n.__checkbox,"click")})),Qm.bind(n.__checkbox,"click",(function(e){e.stopPropagation()}))):n instanceof og?(Qm.bind(t,"click",(function(){Qm.fakeEvent(n.__button,"click")})),Qm.bind(t,"mouseover",(function(){Qm.addClass(n.__button,"hover")})),Qm.bind(t,"mouseout",(function(){Qm.removeClass(n.__button,"hover")}))):n instanceof lg&&(Qm.addClass(t,"color"),n.updateDisplay=Lm.compose((function(e){return t.style.borderLeftColor=n.__color.toString(),e}),n.updateDisplay),n.updateDisplay());n.setValue=Lm.compose((function(t){return e.getRoot().__preset_select&&n.isModified()&&Mg(e.getRoot(),!0),t}),n.setValue)}(e,l,r),e.__controllers.push(r),r}function Ag(e,t){return document.location.href+"."+t}function Pg(e,t,n){var i=document.createElement("option");i.innerHTML=t,i.value=t,e.__preset_select.appendChild(i),n&&(e.__preset_select.selectedIndex=e.__preset_select.length-1)}function Rg(e,t){t.style.display=e.useLocalStorage?"block":"none"}function Cg(e){var t=void 0;function n(n){return n.preventDefault(),e.width+=t-n.clientX,e.onResize(),t=n.clientX,!1}function i(){Qm.removeClass(e.__closeButton,Sg.CLASS_DRAG),Qm.unbind(window,"mousemove",n),Qm.unbind(window,"mouseup",i)}function r(r){return r.preventDefault(),t=r.clientX,Qm.addClass(e.__closeButton,Sg.CLASS_DRAG),Qm.bind(window,"mousemove",n),Qm.bind(window,"mouseup",i),!1}e.__resize_handle=document.createElement("div"),Lm.extend(e.__resize_handle.style,{width:"6px",marginLeft:"-3px",height:"200px",cursor:"ew-resize",position:"absolute"}),Qm.bind(e.__resize_handle,"mousedown",r),Qm.bind(e.__closeButton,"mousedown",r),e.domElement.insertBefore(e.__resize_handle,e.domElement.firstElementChild)}function Dg(e,t){e.domElement.style.width=t+"px",e.__save_row&&e.autoPlace&&(e.__save_row.style.width=t+"px"),e.__closeButton&&(e.__closeButton.style.width=t+"px")}function Lg(e,t){var n={};return Lm.each(e.__rememberedObjects,(function(i,r){var a={},s=e.__rememberedObjectIndecesToControllers[r];Lm.each(s,(function(e,n){a[n]=t?e.initialValue:e.getValue()})),n[r]=a})),n}function Ig(e){0!==e.length&&ug.call(window,(function(){Ig(e)})),Lm.each(e,(function(e){e.updateDisplay()}))}Sg.toggleHide=function(){xg=!xg,Lm.each(yg,(function(e){e.domElement.style.display=xg?"none":""}))},Sg.CLASS_AUTO_PLACE="a",Sg.CLASS_AUTO_PLACE_CONTAINER="ac",Sg.CLASS_MAIN="main",Sg.CLASS_CONTROLLER_ROW="cr",Sg.CLASS_TOO_TALL="taller-than-window",Sg.CLASS_CLOSED="closed",Sg.CLASS_CLOSE_BUTTON="close-button",Sg.CLASS_CLOSE_TOP="close-top",Sg.CLASS_CLOSE_BOTTOM="close-bottom",Sg.CLASS_DRAG="drag",Sg.DEFAULT_WIDTH=245,Sg.TEXT_CLOSED="Close Controls",Sg.TEXT_OPEN="Open Controls",Sg._keydownHandler=function(e){"text"===document.activeElement.type||72!==e.which&&72!==e.keyCode||Sg.toggleHide()},Qm.bind(window,"keydown",Sg._keydownHandler,!1),Lm.extend(Sg.prototype,{add:function(e,t){return Eg(this,e,t,{factoryArgs:Array.prototype.slice.call(arguments,2)})},addColor:function(e,t){return Eg(this,e,t,{color:!0})},remove:function(e){this.__ul.removeChild(e.__li),this.__controllers.splice(this.__controllers.indexOf(e),1);var t=this;Lm.defer((function(){t.onResize()}))},destroy:function(){if(this.parent)throw new Error("Only the root GUI should be removed with .destroy(). For subfolders, use gui.removeFolder(folder) instead.");this.autoPlace&&_g.removeChild(this.domElement);var e=this;Lm.each(this.__folders,(function(t){e.removeFolder(t)})),Qm.unbind(window,"keydown",Sg._keydownHandler,!1),bg(this)},addFolder:function(e){if(void 0!==this.__folders[e])throw new Error('You already have a folder in this GUI by the name "'+e+'"');var t={name:e,parent:this};t.autoPlace=this.autoPlace,this.load&&this.load.folders&&this.load.folders[e]&&(t.closed=this.load.folders[e].closed,t.load=this.load.folders[e]);var n=new Sg(t);this.__folders[e]=n;var i=wg(this,n.domElement);return Qm.addClass(i,"folder"),n},removeFolder:function(e){this.__ul.removeChild(e.domElement.parentElement),delete this.__folders[e.name],this.load&&this.load.folders&&this.load.folders[e.name]&&delete this.load.folders[e.name],bg(e);var t=this;Lm.each(e.__folders,(function(t){e.removeFolder(t)})),Lm.defer((function(){t.onResize()}))},open:function(){this.closed=!1},close:function(){this.closed=!0},hide:function(){this.domElement.style.display="none"},show:function(){this.domElement.style.display=""},onResize:function(){var e=this.getRoot();if(e.scrollable){var t=Qm.getOffset(e.__ul).top,n=0;Lm.each(e.__ul.childNodes,(function(t){e.autoPlace&&t===e.__save_row||(n+=Qm.getHeight(t))})),window.innerHeight-t-20GUI\'s constructor:\n\n \n\n
\n\n Automatically save\n values to localStorage on exit.\n\n
The values saved to localStorage will\n override those passed to dat.GUI\'s constructor. This makes it\n easier to work incrementally, but localStorage is fragile,\n and your friends may not see the same values you do.\n\n
\n\n
\n\n'),this.parent)throw new Error("You can only call remember on a top level GUI.");var e=this;Lm.each(Array.prototype.slice.call(arguments),(function(t){0===e.__rememberedObjects.length&&function(e){var t=e.__save_row=document.createElement("li");Qm.addClass(e.domElement,"has-save"),e.__ul.insertBefore(t,e.__ul.firstChild),Qm.addClass(t,"save-row");var n=document.createElement("span");n.innerHTML=" ",Qm.addClass(n,"button gears");var i=document.createElement("span");i.innerHTML="Save",Qm.addClass(i,"button"),Qm.addClass(i,"save");var r=document.createElement("span");r.innerHTML="New",Qm.addClass(r,"button"),Qm.addClass(r,"save-as");var a=document.createElement("span");a.innerHTML="Revert",Qm.addClass(a,"button"),Qm.addClass(a,"revert");var s=e.__preset_select=document.createElement("select");if(e.load&&e.load.remembered?Lm.each(e.load.remembered,(function(t,n){Pg(e,n,n===e.preset)})):Pg(e,fg,!1),Qm.bind(s,"change",(function(){for(var t=0;t0&&(e.preset=this.preset,e.remembered||(e.remembered={}),e.remembered[this.preset]=Lg(this)),e.folders={},Lm.each(this.__folders,(function(t,n){e.folders[n]=t.getSaveObject()})),e},save:function(){this.load.remembered||(this.load.remembered={}),this.load.remembered[this.preset]=Lg(this),Mg(this,!1),this.saveToLocalStorageIfPossible()},saveAs:function(e){this.load.remembered||(this.load.remembered={},this.load.remembered[fg]=Lg(this,!0)),this.load.remembered[e]=Lg(this),this.preset=e,Pg(this,e,!0),this.saveToLocalStorageIfPossible()},revert:function(e){Lm.each(this.__controllers,(function(t){this.getRoot().load.remembered?Tg(e||this.getRoot(),t):t.setValue(t.initialValue),t.__onFinishChange&&t.__onFinishChange.call(t,t.getValue())}),this),Lm.each(this.__folders,(function(e){e.revert(e)})),e||Mg(this.getRoot(),!1)},listen:function(e){var t=0===this.__listening.length;this.__listening.push(e),t&&Ig(this.__listening)},updateDisplay:function(){Lm.each(this.__controllers,(function(e){e.updateDisplay()})),Lm.each(this.__folders,(function(e){e.updateDisplay()}))}});var Ug=Sg;const Og=(()=>{const e=navigator.userAgent;return/(tablet|ipad|playbook|silk)|(android(?!.*mobi))/i.test(e)?"tablet":/Mobile|Android|iP(hone|od)|IEMobile|BlackBerry|Kindle|Silk-Accelerated|(hpw|web)OS|Opera M(obi|ini)/.test(e)?"mobile":"desktop"})();console.log(Og);const Ng="mobile"===Og,Fg={},Bg=(e,t="#000000")=>{console.log(`Status information: ${e}`);const n=document.getElementById("status-line");n&&(n.innerText=e,n.style.setProperty("color",t))},zg=e=>{const t=Yg.collectMaterials();rv.updateMaterialUI(qg,t),Bg(`${e}`),Xg.sceneName=e.replace(/:/g,"_")},kg=(e,t)=>{return n=void 0,i=void 0,a=function*(){let n=Fg[t];n||(yield Yg.loadResource(e+".glb",t,(e=>{}),((e,n)=>{n?(Fg[t]={scene:n,glb:!0},zg(e)):Bg(`load ${e}`,"#ff0000")})),n=Fg[t]),Bg(`render ${t}`,"#ff0000"),Yg.update(void 0,n.scene,n.glb),zg(t)},new((r=void 0)||(r=Promise))((function(e,t){function s(e){try{l(a.next(e))}catch(e){t(e)}}function o(e){try{l(a.throw(e))}catch(e){t(e)}}function l(t){var n;t.done?e(t.value):(n=t.value,n instanceof r?n:new r((function(e){e(n)}))).then(s,o)}l((a=a.apply(n,i||[])).next())}));var n,i,r,a},Hg=()=>{let e=mh;switch(Xg.groundMaterial.toLocaleLowerCase()){default:e=mh;break;case"parquet":e=gh;break;case"pavement":e=vh}Yg.setGroundMaterial(e)},Vg=document.getElementById("container"),Gg=new class{constructor(e={}){const{canvas:t=bt(),context:i=null,depth:r=!0,stencil:a=!1,alpha:s=!1,antialias:o=!1,premultipliedAlpha:l=!0,preserveDrawingBuffer:c=!1,powerPreference:h="default",failIfMajorPerformanceCaveat:d=!1,reverseDepthBuffer:u=!1}=e;let p;if(this.isWebGLRenderer=!0,null!==i){if("undefined"!=typeof WebGLRenderingContext&&i instanceof WebGLRenderingContext)throw new Error("THREE.WebGLRenderer: WebGL 1 is not supported since r163.");p=i.getContextAttributes().alpha}else p=s;const f=new Uint32Array(4),m=new Int32Array(4);let g=null,v=null;const _=[],x=[];this.domElement=t,this.debug={checkShaderErrors:!0,onShaderError:null},this.autoClear=!0,this.autoClearColor=!0,this.autoClearDepth=!0,this.autoClearStencil=!0,this.sortObjects=!0,this.clippingPlanes=[],this.localClippingEnabled=!1,this._outputColorSpace=Ge,this.toneMapping=0,this.toneMappingExposure=1;const y=this;let S=!1,w=0,b=0,M=null,T=-1,E=null;const A=new Ht,P=new Ht;let R=null;const C=new gi(0);let D=0,L=t.width,I=t.height,U=1,O=null,N=null;const F=new Ht(0,0,L,I),B=new Ht(0,0,L,I);let z=!1;const k=new _r;let H=!1,V=!1;const G=new Mn,Y=new Mn,Z=new Yt,ee=new Ht,te={background:null,fog:null,environment:null,overrideMaterial:null,isScene:!0};let ne=!1;function ie(){return null===M?U:1}let ae,le,ce,he,de,ue,pe,fe,me,ge,ve,_e,xe,ye,Se,we,be,Me,Te,Ee,Ae,Pe,Re,Ce,De=i;function Le(e,n){return t.getContext(e,n)}try{const e={alpha:!0,depth:r,stencil:a,antialias:o,premultipliedAlpha:l,preserveDrawingBuffer:c,powerPreference:h,failIfMajorPerformanceCaveat:d};if("setAttribute"in t&&t.setAttribute("data-engine",`three.js r${n}`),t.addEventListener("webglcontextlost",Oe,!1),t.addEventListener("webglcontextrestored",Ne,!1),t.addEventListener("webglcontextcreationerror",Fe,!1),null===De){const t="webgl2";if(De=Le(t,e),null===De)throw Le(t)?new Error("Error creating WebGL context with your selected attributes."):new Error("Error creating WebGL context.")}}catch(e){throw console.error("THREE.WebGLRenderer: "+e.message),e}function Ie(){ae=new Jr(De),ae.init(),Pe=new Ks(De,ae),le=new Dr(De,ae,e,Pe),ce=new Ys(De,ae),le.reverseDepthBuffer&&u&&ce.buffers.depth.setReversed(!0),he=new ea(De),de=new Ls,ue=new Zs(De,ae,ce,de,le,Pe,he),pe=new Ir(y),fe=new Kr(y),me=new yr(De),Re=new Rr(De,me),ge=new Qr(De,me,he,Re),ve=new na(De,ge,me,he),Te=new ta(De,le,ue),we=new Lr(de),_e=new Ds(y,pe,fe,ae,le,Re,we),xe=new ao(y,de),ye=new Ns,Se=new Vs(ae),Me=new Pr(y,pe,fe,ce,ve,p,l),be=new js(y,ve,le),Ce=new so(De,he,le,ce),Ee=new Cr(De,ae,he),Ae=new $r(De,ae,he),he.programs=_e.programs,y.capabilities=le,y.extensions=ae,y.properties=de,y.renderLists=ye,y.shadowMap=be,y.state=ce,y.info=he}Ie();const Ue=new no(y,De);function Oe(e){e.preventDefault(),console.log("THREE.WebGLRenderer: Context Lost."),S=!0}function Ne(){console.log("THREE.WebGLRenderer: Context Restored."),S=!1;const e=he.autoReset,t=be.enabled,n=be.autoUpdate,i=be.needsUpdate,r=be.type;Ie(),he.autoReset=e,be.enabled=t,be.autoUpdate=n,be.needsUpdate=i,be.type=r}function Fe(e){console.error("THREE.WebGLRenderer: A WebGL context could not be created. Reason: ",e.statusMessage)}function Be(e){const t=e.target;t.removeEventListener("dispose",Be),function(e){(function(e){const t=de.get(e).programs;void 0!==t&&(t.forEach((function(e){_e.releaseProgram(e)})),e.isShaderMaterial&&_e.releaseShaderCache(e))})(e),de.remove(e)}(t)}function ze(e,t,n){!0===e.transparent&&2===e.side&&!1===e.forceSinglePass?(e.side=1,e.needsUpdate=!0,Je(e,t,n),e.side=0,e.needsUpdate=!0,Je(e,t,n),e.side=2):Je(e,t,n)}this.xr=Ue,this.getContext=function(){return De},this.getContextAttributes=function(){return De.getContextAttributes()},this.forceContextLoss=function(){const e=ae.get("WEBGL_lose_context");e&&e.loseContext()},this.forceContextRestore=function(){const e=ae.get("WEBGL_lose_context");e&&e.restoreContext()},this.getPixelRatio=function(){return U},this.setPixelRatio=function(e){void 0!==e&&(U=e,this.setSize(L,I,!1))},this.getSize=function(e){return e.set(L,I)},this.setSize=function(e,n,i=!0){Ue.isPresenting?console.warn("THREE.WebGLRenderer: Can't change size while VR device is presenting."):(L=e,I=n,t.width=Math.floor(e*U),t.height=Math.floor(n*U),!0===i&&(t.style.width=e+"px",t.style.height=n+"px"),this.setViewport(0,0,e,n))},this.getDrawingBufferSize=function(e){return e.set(L*U,I*U).floor()},this.setDrawingBufferSize=function(e,n,i){L=e,I=n,U=i,t.width=Math.floor(e*i),t.height=Math.floor(n*i),this.setViewport(0,0,e,n)},this.getCurrentViewport=function(e){return e.copy(A)},this.getViewport=function(e){return e.copy(F)},this.setViewport=function(e,t,n,i){e.isVector4?F.set(e.x,e.y,e.z,e.w):F.set(e,t,n,i),ce.viewport(A.copy(F).multiplyScalar(U).round())},this.getScissor=function(e){return e.copy(B)},this.setScissor=function(e,t,n,i){e.isVector4?B.set(e.x,e.y,e.z,e.w):B.set(e,t,n,i),ce.scissor(P.copy(B).multiplyScalar(U).round())},this.getScissorTest=function(){return z},this.setScissorTest=function(e){ce.setScissorTest(z=e)},this.setOpaqueSort=function(e){O=e},this.setTransparentSort=function(e){N=e},this.getClearColor=function(e){return e.copy(Me.getClearColor())},this.setClearColor=function(){Me.setClearColor.apply(Me,arguments)},this.getClearAlpha=function(){return Me.getClearAlpha()},this.setClearAlpha=function(){Me.setClearAlpha.apply(Me,arguments)},this.clear=function(e=!0,t=!0,n=!0){let i=0;if(e){let e=!1;if(null!==M){const t=M.texture.format;e=t===oe||t===se||t===re}if(e){const e=M.texture.type,t=e===j||e===q||e===X||e===$||e===J||e===Q,n=Me.getClearColor(),i=Me.getClearAlpha(),r=n.r,a=n.g,s=n.b;t?(f[0]=r,f[1]=a,f[2]=s,f[3]=i,De.clearBufferuiv(De.COLOR,0,f)):(m[0]=r,m[1]=a,m[2]=s,m[3]=i,De.clearBufferiv(De.COLOR,0,m))}else i|=De.COLOR_BUFFER_BIT}t&&(i|=De.DEPTH_BUFFER_BIT),n&&(i|=De.STENCIL_BUFFER_BIT,this.state.buffers.stencil.setMask(4294967295)),De.clear(i)},this.clearColor=function(){this.clear(!0,!1,!1)},this.clearDepth=function(){this.clear(!1,!0,!1)},this.clearStencil=function(){this.clear(!1,!1,!0)},this.dispose=function(){t.removeEventListener("webglcontextlost",Oe,!1),t.removeEventListener("webglcontextrestored",Ne,!1),t.removeEventListener("webglcontextcreationerror",Fe,!1),ye.dispose(),Se.dispose(),de.dispose(),pe.dispose(),fe.dispose(),ve.dispose(),Re.dispose(),Ce.dispose(),_e.dispose(),Ue.dispose(),Ue.removeEventListener("sessionstart",He),Ue.removeEventListener("sessionend",Ve),je.stop()},this.renderBufferDirect=function(e,t,n,i,r,a){null===t&&(t=te);const s=r.isMesh&&r.matrixWorld.determinant()<0,o=function(e,t,n,i,r){!0!==t.isScene&&(t=te),ue.resetTextureUnits();const a=t.fog,s=i.isMeshStandardMaterial?t.environment:null,o=null===M?y.outputColorSpace:!0===M.isXRRenderTarget?M.texture.colorSpace:We,l=(i.isMeshStandardMaterial?fe:pe).get(i.envMap||s),c=!0===i.vertexColors&&!!n.attributes.color&&4===n.attributes.color.itemSize,h=!!n.attributes.tangent&&(!!i.normalMap||i.anisotropy>0),d=!!n.morphAttributes.position,u=!!n.morphAttributes.normal,p=!!n.morphAttributes.color;let f=0;i.toneMapped&&(null!==M&&!0!==M.isXRRenderTarget||(f=y.toneMapping));const m=n.morphAttributes.position||n.morphAttributes.normal||n.morphAttributes.color,g=void 0!==m?m.length:0,_=de.get(i),x=v.state.lights;if(!0===H&&(!0===V||e!==E)){const t=e===E&&i.id===T;we.setState(i,e,t)}let S=!1;i.version===_.__version?_.needsLights&&_.lightsStateVersion!==x.state.version||_.outputColorSpace!==o||r.isBatchedMesh&&!1===_.batching?S=!0:r.isBatchedMesh||!0!==_.batching?r.isBatchedMesh&&!0===_.batchingColor&&null===r.colorTexture||r.isBatchedMesh&&!1===_.batchingColor&&null!==r.colorTexture||r.isInstancedMesh&&!1===_.instancing?S=!0:r.isInstancedMesh||!0!==_.instancing?r.isSkinnedMesh&&!1===_.skinning?S=!0:r.isSkinnedMesh||!0!==_.skinning?r.isInstancedMesh&&!0===_.instancingColor&&null===r.instanceColor||r.isInstancedMesh&&!1===_.instancingColor&&null!==r.instanceColor||r.isInstancedMesh&&!0===_.instancingMorph&&null===r.morphTexture||r.isInstancedMesh&&!1===_.instancingMorph&&null!==r.morphTexture||_.envMap!==l||!0===i.fog&&_.fog!==a?S=!0:void 0===_.numClippingPlanes||_.numClippingPlanes===we.numPlanes&&_.numIntersection===we.numIntersection?(_.vertexAlphas!==c||_.vertexTangents!==h||_.morphTargets!==d||_.morphNormals!==u||_.morphColors!==p||_.toneMapping!==f||_.morphTargetsCount!==g)&&(S=!0):S=!0:S=!0:S=!0:S=!0:(S=!0,_.__version=i.version);let w=_.currentProgram;!0===S&&(w=Je(i,t,r));let b=!1,A=!1,P=!1;const R=w.getUniforms(),C=_.uniforms;if(ce.useProgram(w.program)&&(b=!0,A=!0,P=!0),i.id!==T&&(T=i.id,A=!0),b||E!==e){ce.buffers.depth.getReversed()?(G.copy(e.projectionMatrix),function(e){const t=e.elements;t[2]=.5*t[2]+.5*t[3],t[6]=.5*t[6]+.5*t[7],t[10]=.5*t[10]+.5*t[11],t[14]=.5*t[14]+.5*t[15]}(G),function(e){const t=e.elements;-1===t[11]?(t[10]=-t[10]-1,t[14]=-t[14]):(t[10]=-t[10],t[14]=1-t[14])}(G),R.setValue(De,"projectionMatrix",G)):R.setValue(De,"projectionMatrix",e.projectionMatrix),R.setValue(De,"viewMatrix",e.matrixWorldInverse);const t=R.map.cameraPosition;void 0!==t&&t.setValue(De,Z.setFromMatrixPosition(e.matrixWorld)),le.logarithmicDepthBuffer&&R.setValue(De,"logDepthBufFC",2/(Math.log(e.far+1)/Math.LN2)),(i.isMeshPhongMaterial||i.isMeshToonMaterial||i.isMeshLambertMaterial||i.isMeshBasicMaterial||i.isMeshStandardMaterial||i.isShaderMaterial)&&R.setValue(De,"isOrthographic",!0===e.isOrthographicCamera),E!==e&&(E=e,A=!0,P=!0)}if(r.isSkinnedMesh){R.setOptional(De,r,"bindMatrix"),R.setOptional(De,r,"bindMatrixInverse");const e=r.skeleton;e&&(null===e.boneTexture&&e.computeBoneTexture(),R.setValue(De,"boneTexture",e.boneTexture,ue))}r.isBatchedMesh&&(R.setOptional(De,r,"batchingTexture"),R.setValue(De,"batchingTexture",r._matricesTexture,ue),R.setOptional(De,r,"batchingIdTexture"),R.setValue(De,"batchingIdTexture",r._indirectTexture,ue),R.setOptional(De,r,"batchingColorTexture"),null!==r._colorsTexture&&R.setValue(De,"batchingColorTexture",r._colorsTexture,ue));const D=n.morphAttributes;var L,O;if(void 0===D.position&&void 0===D.normal&&void 0===D.color||Te.update(r,n,w),(A||_.receiveShadow!==r.receiveShadow)&&(_.receiveShadow=r.receiveShadow,R.setValue(De,"receiveShadow",r.receiveShadow)),i.isMeshGouraudMaterial&&null!==i.envMap&&(C.envMap.value=l,C.flipEnvMap.value=l.isCubeTexture&&!1===l.isRenderTargetTexture?-1:1),i.isMeshStandardMaterial&&null===i.envMap&&null!==t.environment&&(C.envMapIntensity.value=t.environmentIntensity),A&&(R.setValue(De,"toneMappingExposure",y.toneMappingExposure),_.needsLights&&(O=P,(L=C).ambientLightColor.needsUpdate=O,L.lightProbe.needsUpdate=O,L.directionalLights.needsUpdate=O,L.directionalLightShadows.needsUpdate=O,L.pointLights.needsUpdate=O,L.pointLightShadows.needsUpdate=O,L.spotLights.needsUpdate=O,L.spotLightShadows.needsUpdate=O,L.rectAreaLights.needsUpdate=O,L.hemisphereLights.needsUpdate=O),a&&!0===i.fog&&xe.refreshFogUniforms(C,a),xe.refreshMaterialUniforms(C,i,U,I,v.state.transmissionRenderTarget[e.id]),ls.upload(De,Qe(_),C,ue)),i.isShaderMaterial&&!0===i.uniformsNeedUpdate&&(ls.upload(De,Qe(_),C,ue),i.uniformsNeedUpdate=!1),i.isSpriteMaterial&&R.setValue(De,"center",r.center),R.setValue(De,"modelViewMatrix",r.modelViewMatrix),R.setValue(De,"normalMatrix",r.normalMatrix),R.setValue(De,"modelMatrix",r.matrixWorld),i.isShaderMaterial||i.isRawShaderMaterial){const e=i.uniformsGroups;for(let t=0,n=e.length;t{function n(){i.forEach((function(e){de.get(e).currentProgram.isReady()&&i.delete(e)})),0!==i.size?setTimeout(n,10):t(e)}null!==ae.get("KHR_parallel_shader_compile")?n():setTimeout(n,10)}))};let ke=null;function He(){je.stop()}function Ve(){je.start()}const je=new xr;function Xe(e,t,n,i){if(!1===e.visible)return;if(e.layers.test(t.layers))if(e.isGroup)n=e.renderOrder;else if(e.isLOD)!0===e.autoUpdate&&e.update(t);else if(e.isLight)v.pushLight(e),e.castShadow&&v.pushShadow(e);else if(e.isSprite){if(!e.frustumCulled||k.intersectsSprite(e)){i&&ee.setFromMatrixPosition(e.matrixWorld).applyMatrix4(Y);const t=ve.update(e),r=e.material;r.visible&&g.push(e,t,r,n,ee.z,null)}}else if((e.isMesh||e.isLine||e.isPoints)&&(!e.frustumCulled||k.intersectsObject(e))){const t=ve.update(e),r=e.material;if(i&&(void 0!==e.boundingSphere?(null===e.boundingSphere&&e.computeBoundingSphere(),ee.copy(e.boundingSphere.center)):(null===t.boundingSphere&&t.computeBoundingSphere(),ee.copy(t.boundingSphere.center)),ee.applyMatrix4(e.matrixWorld).applyMatrix4(Y)),Array.isArray(r)){const i=t.groups;for(let a=0,s=i.length;a0&&Ze(r,t,n),a.length>0&&Ze(a,t,n),s.length>0&&Ze(s,t,n),ce.buffers.depth.setTest(!0),ce.buffers.depth.setMask(!0),ce.buffers.color.setMask(!0),ce.setPolygonOffset(!1)}function qe(e,t,n,i){if(null!==(!0===n.isScene?n.overrideMaterial:null))return;void 0===v.state.transmissionRenderTarget[i.id]&&(v.state.transmissionRenderTarget[i.id]=new Gt(1,1,{generateMipmaps:!0,type:ae.has("EXT_color_buffer_half_float")||ae.has("EXT_color_buffer_float")?K:j,minFilter:W,samples:4,stencilBuffer:a,resolveDepthBuffer:!1,resolveStencilBuffer:!1,colorSpace:Et.workingColorSpace}));const r=v.state.transmissionRenderTarget[i.id],s=i.viewport||A;r.setSize(s.z,s.w);const o=y.getRenderTarget();y.setRenderTarget(r),y.getClearColor(C),D=y.getClearAlpha(),D<1&&y.setClearColor(16777215,.5),y.clear(),ne&&Me.render(n);const l=y.toneMapping;y.toneMapping=0;const c=i.viewport;if(void 0!==i.viewport&&(i.viewport=void 0),v.setupLightsView(i),!0===H&&we.setGlobalState(y.clippingPlanes,i),Ze(e,n,i),ue.updateMultisampleRenderTarget(r),ue.updateRenderTargetMipmap(r),!1===ae.has("WEBGL_multisampled_render_to_texture")){let e=!1;for(let r=0,a=t.length;r0)for(let t=0,a=n.length;t0&&qe(i,r,e,t),ne&&Me.render(e),Ye(g,e,t);null!==M&&(ue.updateMultisampleRenderTarget(M),ue.updateRenderTargetMipmap(M)),!0===e.isScene&&e.onAfterRender(y,e,t),Re.resetDefaultState(),T=-1,E=null,x.pop(),x.length>0?(v=x[x.length-1],!0===H&&we.setGlobalState(y.clippingPlanes,v.state.camera)):v=null,_.pop(),g=_.length>0?_[_.length-1]:null},this.getActiveCubeFace=function(){return w},this.getActiveMipmapLevel=function(){return b},this.getRenderTarget=function(){return M},this.setRenderTargetTextures=function(e,t,n){de.get(e.texture).__webglTexture=t,de.get(e.depthTexture).__webglTexture=n;const i=de.get(e);i.__hasExternalTextures=!0,i.__autoAllocateDepthBuffer=void 0===n,i.__autoAllocateDepthBuffer||!0===ae.has("WEBGL_multisampled_render_to_texture")&&(console.warn("THREE.WebGLRenderer: Render-to-texture extension was disabled because an external texture was provided"),i.__useRenderToTexture=!1)},this.setRenderTargetFramebuffer=function(e,t){const n=de.get(e);n.__webglFramebuffer=t,n.__useDefaultFramebuffer=void 0===t},this.setRenderTarget=function(e,t=0,n=0){M=e,w=t,b=n;let i=!0,r=null,a=!1,s=!1;if(e){const o=de.get(e);if(void 0!==o.__useDefaultFramebuffer)ce.bindFramebuffer(De.FRAMEBUFFER,null),i=!1;else if(void 0===o.__webglFramebuffer)ue.setupRenderTarget(e);else if(o.__hasExternalTextures)ue.rebindTextures(e,de.get(e.texture).__webglTexture,de.get(e.depthTexture).__webglTexture);else if(e.depthBuffer){const t=e.depthTexture;if(o.__boundDepthTexture!==t){if(null!==t&&de.has(t)&&(e.width!==t.image.width||e.height!==t.image.height))throw new Error("WebGLRenderTarget: Attached DepthTexture is initialized to the incorrect size.");ue.setupDepthRenderbuffer(e)}}const l=e.texture;(l.isData3DTexture||l.isDataArrayTexture||l.isCompressedArrayTexture)&&(s=!0);const c=de.get(e).__webglFramebuffer;e.isWebGLCubeRenderTarget?(r=Array.isArray(c[t])?c[t][n]:c[t],a=!0):r=e.samples>0&&!1===ue.useMultisampledRTT(e)?de.get(e).__webglMultisampledFramebuffer:Array.isArray(c)?c[n]:c,A.copy(e.viewport),P.copy(e.scissor),R=e.scissorTest}else A.copy(F).multiplyScalar(U).floor(),P.copy(B).multiplyScalar(U).floor(),R=z;if(ce.bindFramebuffer(De.FRAMEBUFFER,r)&&i&&ce.drawBuffers(e,r),ce.viewport(A),ce.scissor(P),ce.setScissorTest(R),a){const i=de.get(e.texture);De.framebufferTexture2D(De.FRAMEBUFFER,De.COLOR_ATTACHMENT0,De.TEXTURE_CUBE_MAP_POSITIVE_X+t,i.__webglTexture,n)}else if(s){const i=de.get(e.texture),r=t||0;De.framebufferTextureLayer(De.FRAMEBUFFER,De.COLOR_ATTACHMENT0,i.__webglTexture,n||0,r)}T=-1},this.readRenderTargetPixels=function(e,t,n,i,r,a,s){if(!e||!e.isWebGLRenderTarget)return void console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");let o=de.get(e).__webglFramebuffer;if(e.isWebGLCubeRenderTarget&&void 0!==s&&(o=o[s]),o){ce.bindFramebuffer(De.FRAMEBUFFER,o);try{const s=e.texture,o=s.format,l=s.type;if(!le.textureFormatReadable(o))return void console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in RGBA or implementation defined format.");if(!le.textureTypeReadable(l))return void console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in UnsignedByteType or implementation defined type.");t>=0&&t<=e.width-i&&n>=0&&n<=e.height-r&&De.readPixels(t,n,i,r,Pe.convert(o),Pe.convert(l),a)}finally{const e=null!==M?de.get(M).__webglFramebuffer:null;ce.bindFramebuffer(De.FRAMEBUFFER,e)}}},this.readRenderTargetPixelsAsync=async function(e,t,n,i,r,a,s){if(!e||!e.isWebGLRenderTarget)throw new Error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");let o=de.get(e).__webglFramebuffer;if(e.isWebGLCubeRenderTarget&&void 0!==s&&(o=o[s]),o){const s=e.texture,l=s.format,c=s.type;if(!le.textureFormatReadable(l))throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in RGBA or implementation defined format.");if(!le.textureTypeReadable(c))throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in UnsignedByteType or implementation defined type.");if(t>=0&&t<=e.width-i&&n>=0&&n<=e.height-r){ce.bindFramebuffer(De.FRAMEBUFFER,o);const e=De.createBuffer();De.bindBuffer(De.PIXEL_PACK_BUFFER,e),De.bufferData(De.PIXEL_PACK_BUFFER,a.byteLength,De.STREAM_READ),De.readPixels(t,n,i,r,Pe.convert(l),Pe.convert(c),0);const s=null!==M?de.get(M).__webglFramebuffer:null;ce.bindFramebuffer(De.FRAMEBUFFER,s);const h=De.fenceSync(De.SYNC_GPU_COMMANDS_COMPLETE,0);return De.flush(),await function(e,t){return new Promise((function(n,i){setTimeout((function r(){switch(e.clientWaitSync(t,e.SYNC_FLUSH_COMMANDS_BIT,0)){case e.WAIT_FAILED:i();break;case e.TIMEOUT_EXPIRED:setTimeout(r,4);break;default:n()}}),4)}))}(De,h),De.bindBuffer(De.PIXEL_PACK_BUFFER,e),De.getBufferSubData(De.PIXEL_PACK_BUFFER,0,a),De.deleteBuffer(e),De.deleteSync(h),a}throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: requested read bounds are out of range.")}},this.copyFramebufferToTexture=function(e,t=null,n=0){!0!==e.isTexture&&(Tt("WebGLRenderer: copyFramebufferToTexture function signature has changed."),t=arguments[0]||null,e=arguments[1]);const i=Math.pow(2,-n),r=Math.floor(e.image.width*i),a=Math.floor(e.image.height*i),s=null!==t?t.x:0,o=null!==t?t.y:0;ue.setTexture2D(e,0),De.copyTexSubImage2D(De.TEXTURE_2D,n,0,0,s,o,r,a),ce.unbindTexture()},this.copyTextureToTexture=function(e,t,n=null,i=null,r=0){let a,s,o,l,c,h,d,u,p;!0!==e.isTexture&&(Tt("WebGLRenderer: copyTextureToTexture function signature has changed."),i=arguments[0]||null,e=arguments[1],t=arguments[2],r=arguments[3]||0,n=null);const f=e.isCompressedTexture?e.mipmaps[r]:e.image;null!==n?(a=n.max.x-n.min.x,s=n.max.y-n.min.y,o=n.isBox3?n.max.z-n.min.z:1,l=n.min.x,c=n.min.y,h=n.isBox3?n.min.z:0):(a=f.width,s=f.height,o=f.depth||1,l=0,c=0,h=0),null!==i?(d=i.x,u=i.y,p=i.z):(d=0,u=0,p=0);const m=Pe.convert(t.format),g=Pe.convert(t.type);let v;t.isData3DTexture?(ue.setTexture3D(t,0),v=De.TEXTURE_3D):t.isDataArrayTexture||t.isCompressedArrayTexture?(ue.setTexture2DArray(t,0),v=De.TEXTURE_2D_ARRAY):(ue.setTexture2D(t,0),v=De.TEXTURE_2D),De.pixelStorei(De.UNPACK_FLIP_Y_WEBGL,t.flipY),De.pixelStorei(De.UNPACK_PREMULTIPLY_ALPHA_WEBGL,t.premultiplyAlpha),De.pixelStorei(De.UNPACK_ALIGNMENT,t.unpackAlignment);const _=De.getParameter(De.UNPACK_ROW_LENGTH),x=De.getParameter(De.UNPACK_IMAGE_HEIGHT),y=De.getParameter(De.UNPACK_SKIP_PIXELS),S=De.getParameter(De.UNPACK_SKIP_ROWS),w=De.getParameter(De.UNPACK_SKIP_IMAGES);De.pixelStorei(De.UNPACK_ROW_LENGTH,f.width),De.pixelStorei(De.UNPACK_IMAGE_HEIGHT,f.height),De.pixelStorei(De.UNPACK_SKIP_PIXELS,l),De.pixelStorei(De.UNPACK_SKIP_ROWS,c),De.pixelStorei(De.UNPACK_SKIP_IMAGES,h);const b=e.isDataArrayTexture||e.isData3DTexture,M=t.isDataArrayTexture||t.isData3DTexture;if(e.isRenderTargetTexture||e.isDepthTexture){const n=de.get(e),i=de.get(t),f=de.get(n.__renderTarget),m=de.get(i.__renderTarget);ce.bindFramebuffer(De.READ_FRAMEBUFFER,f.__webglFramebuffer),ce.bindFramebuffer(De.DRAW_FRAMEBUFFER,m.__webglFramebuffer);for(let n=0;n=-1&&am.z<=1&&!0===e.layers.test(i.layers),c=e.element;c.style.display=!0===l?"":"none",!0===l&&(e.onBeforeRender(t,n,i),c.style.transform="translate("+-100*e.center.x+"%,"+-100*e.center.y+"%)translate("+(am.x*r+r)+"px,"+(-am.y*a+a)+"px)",c.parentNode!==o&&o.appendChild(c),e.onAfterRender(t,n,i));const u={distanceToCameraSquared:(h=i,d=e,lm.setFromMatrixPosition(h.matrixWorld),cm.setFromMatrixPosition(d.matrixWorld),lm.distanceToSquared(cm))};s.objects.set(e,u)}for(let t=0,r=e.children.length;t{const t=new Uint8Array(1048576);for(let e=0;e{this.skyEnvironment.changeVisibility(!1),this.backgroundEnvironment.hideBackground(),this.showEnvironment=!0},r=e.toLowerCase();if(r.endsWith(".exr"))this.environmentLoader.loadExr(e,t,!0),n();else if(r.endsWith(".hdr"))this.environmentLoader.loadHdr(e,t,!0),n();else if(r.endsWith(".envmap"))this.environmentLoader.loadEnvmap(e,t,!0),n();else if(r.endsWith(".glb")||r.endsWith(".gltf")){i(e,null);const n=yield this.loadGLTF(t);i(e,n)}}catch(e){console.log(e)}}))}createControls(){var e;null!==(e=this.controls)&&void 0!==e||(this.controls=new Np(this.renderer,this.camera))}changeLightControls(e){var t;e&&!this.transformControls&&(this.transformControls=null===(t=this.controls)||void 0===t?void 0:t.addTransformControl(this.lightSources.getLightSources()[0],this.scene)),this.transformControls&&(this.transformControls.getHelper().visible=e)}setEnvironment(){this.environmentLoader.loadDefaultEnvironment(!0,(()=>new mm({type:pm})),"room environment"),this.environmentLoader.loadDefaultEnvironment(!1,(()=>new mm({type:fm})),"front light environment"),this.environmentLoader.loadEnvmap("test64.envmap",Mm,!1)}updateSceneDependencies(){this.sceneRenderer.bakedGroundContactShadowPass.needsUpdate=!0,this.updateBounds()}updateBounds(){this.sceneRenderer.updateBounds(this.sceneBounds,this.scaleShadowAndAo)}setGroundMaterial(e){this.groundMaterialType!==e&&(this.groundMaterialType=e,this.updateGround(void 0,xh(this.groundMaterialType)),this.sceneRenderer.clearCache())}updateGround(e,t){this.groundMesh||(this.groundMesh=new Zi,this.groundMesh.name="groundMesh",this.groundMesh.userData.isFloor=!0,this.groundMesh.receiveShadow=!0,this.sceneRenderer.groundGroup.add(this.groundMesh)),e&&(this.groundMesh.geometry=e),t&&(t.depthWrite=!1,t.polygonOffset=!0,t.polygonOffsetFactor=4,t.polygonOffsetUnits=4,t.needsUpdate=!0,this.groundMesh.material=t,this.groundMesh.userData.isFloor=!0)}update(e,t,n){t&&this.setNewTurntableGroup(t,null!=n&&n),e&&this.properties.rotate!==(null==e?void 0:e.rotate)&&(this.properties.rotate=null==e?void 0:e.rotate,0===this.properties.rotate&&(this.turnTableGroup.rotation.y=0)),e&&this.properties.dimensions!==(null==e?void 0:e.dimensions)&&(this.properties.dimensions=null==e?void 0:e.dimensions,this.updateDimensions()),e&&this.properties.randomOrientation!==(null==e?void 0:e.randomOrientation)&&(this.properties.randomOrientation=null==e?void 0:e.randomOrientation)}updateDimensions(){if(this.properties.dimensions){if(0===this.dimensioningArrows.length)for(let e=0;e<3;++e){const e=new hm(new Yt,new Yt,{color:0,arrowPixelWidth:10,arrowPixelHeight:15,shaftPixelWidth:3,shaftPixelOffset:1,labelClass:"label",deviceRatio:window.devicePixelRatio});this.dimensioningArrows.push(e),this.dimensioningArrowScene.add(e)}const e=this.sceneRenderer.boundingVolume.bounds,t=this.sceneRenderer.boundingVolume.size,n=.2*Math.min(t.x,t.y,t.z);this.dimensioningArrows[0].setPosition(new Yt(e.min.x,e.min.y,e.max.z+n),new Yt(e.max.x,e.min.y,e.max.z+n)),this.dimensioningArrows[1].setPosition(new Yt(e.min.x-n,e.min.y,e.max.z+n),new Yt(e.min.x-n,e.max.y,e.max.z+n)),this.dimensioningArrows[2].setPosition(new Yt(e.min.x-n,e.min.y,e.max.z),new Yt(e.min.x-n,e.min.y,e.min.z))}else this.dimensioningArrows.forEach((e=>e.setLabel("")))}collectMaterials(){const e=[];return this.scene.traverse((t=>{if(t instanceof Zi&&t.name.length>0){const n=t.material;n&&e.push({materialId:t.name,material:n})}else if(t instanceof Zi&&t.material.name.length>0){const n=t.material;if(n){const i=t.material.name;-1===e.findIndex((e=>e.materialId===i))&&e.push({materialId:i,material:n})}}})),e}updateMaterialProperties(e,t){this.properties.materialNoise!==e.materialNoise&&(this.properties.materialNoise=e.materialNoise,t.forEach((e=>{const t=e.material;t.userData&&"ormMap"in t.userData||(t.roughnessMap=this.properties.materialNoise?this.noiseTexture:null,t.metalnessMap=this.properties.materialNoise?this.noiseTexture:null,t.needsUpdate=!0)})))}resize(e,t){var n;this.camera.aspect=e/t,this.camera.updateProjectionMatrix(),this.renderer.setSize(e,t),this.sceneRenderer.setSize(e,t),null===(n=this.css2Renderer)||void 0===n||n.setSize(e,t)}animate(e){this.properties.rotate>0&&(this.turnTableGroup.rotation.y+=2*Math.PI*e*.001*this.properties.rotate)}prepareRender(e){var t,n;const i=this.environmentLoader.setEnvironment(this.scene,{showEnvironment:this.showEnvironment,environmentRotation:this.environmentRotation,environmentIntensity:this.environmentIntensity});if(i){null===(t=this.groundProjectionSkybox)||void 0===t||t.removeFromParent(),this.groundProjectionSkybox=null;const e=null===(n=this.environmentLoader.currentEnvironment)||void 0===n?void 0:n.equirectangularTexture;this.scene.userData.shadowFromEnvironment=!0,e&&(this.lightSources.currentLightSourceDefinition=zc.noLightSources,this.lightSources.updateLightSources(),this.createGroundProjectionSkybox&&(this.groundProjectionSkybox=new bm(e,1.5,10),this.groundProjectionSkybox.scale.setScalar(this.groundProjectionSkyboxDistance),this.groundProjectionSkybox.name="skybox",this.scene.add(this.groundProjectionSkybox)))}const r=this.createGroundProjectionSkybox&&this.groundProjectionSkybox?2*this.groundProjectionSkyboxDistance:void 0;if(this.sceneRenderer.updateNearAndFarPlaneOfPerspectiveCamera(this.camera,r),i&&this.updateSceneDependencies(),this.sceneRenderer.outlineRenderer.parameters.enabled){this.raycaster.setFromCamera(e,this.camera);const t=this.raycaster.intersectObject(this.turnTableGroup,!0),n=t.length>0?t[0].object:void 0;this.sceneRenderer.selectObjects(n?[n]:[])}}render(e=!0){var t,n;e&&(null===(t=this.controls)||void 0===t||t.update()),this.backgroundEnvironment.update(this.sceneRenderer.width,this.sceneRenderer.height,this.camera),this.sceneRenderer.render(this.scene,this.camera),this.properties.dimensions&&(this.dimensioningArrows.forEach((e=>{e.arrowNeedsUpdate=!0})),this.renderer.autoClear=!1,this.renderer.render(this.dimensioningArrowScene,this.camera),null===(n=this.css2Renderer)||void 0===n||n.render(this.dimensioningArrowScene,this.camera),this.renderer.autoClear=!0)}loadGLTF(e){return Tm(this,void 0,void 0,(function*(){const t=new Vd;t.setDRACOLoader(this.dracoLoader);const n=yield t.loadAsync(e);return this.updateGLTFScene(n,(e=>{if(e.isMesh){const t=e.material;t instanceof Tl&&!1===t.transparent&&(e.castShadow=!0,e.receiveShadow=!0)}})),this.setNewTurntableGroup(n.scene,!0),n.scene}))}updateGLTFScene(e,t){e.scene.traverse((e=>{e instanceof Zi&&(t(e),e.material instanceof Tl&&(e.material.envMapIntensity=1,e.material.needsUpdate=!0))}))}setNewTurntableGroup(e,t){this.turnTableGroup.clear(),this.scaleShadowAndAo=t,this.setInitialObjectPosition(e),this.setInitialCameraPositionAndRotation(),this.sceneRenderer.environmentLights||this.lightSources.setLightSourcesDistances(this.sceneRenderer.boundingVolume,t),this.sceneRenderer.forceShadowUpdates(!0),this.updateSceneDependencies()}setInitialObjectPosition(e){e.updateMatrixWorld(),this.sceneBounds.setFromObject(e);const t=this.sceneBounds.getSize(new Yt),n=this.sceneBounds.getCenter(new Yt);e.applyMatrix4((new Mn).makeTranslation(-n.x,-this.sceneBounds.min.y,-n.z)),this.sceneBounds.translate(new Yt(-n.x,-this.sceneBounds.min.y-t.y/2,-n.z));const i=-t.y/2;this.turnTableGroup.position.y=i,this.turnTableGroup.add(e),this.turnTableGroup.updateMatrixWorld(),this.sceneRenderer.groundLevel=i}setInitialCameraPositionAndRotation(){const e=new Yt(-1.5,.8,2.5).normalize();if(this.properties.randomOrientation){const t=4*Math.random()-2,n=.8*Math.random()+.4;e.set(t,n,2.5).normalize()}this.camera.position.copy(e),this.camera.lookAt(new Yt(0,0,0)),this.camera.updateMatrixWorld();const t=(new Kt).setFromObject(this.turnTableGroup).applyMatrix4(this.camera.matrixWorldInverse),n=this.camera.fov*Math.PI/180/2,i=this.camera.aspect,r=Math.max(-t.min.x/i,t.max.x/i,-t.min.y,t.max.y)/Math.tan(n)+t.max.z+1;this.camera.position.copy(e.multiplyScalar(r)),this.camera.lookAt(new Yt(0,0,0)),this.camera.updateMatrixWorld()}constructLoadingGeometry(e){let t=[];if(1===e){const e=[];for(let t=0;t<=230;t+=15){const n=t*Math.PI/180;e.push({x:-Math.cos(n),y:Math.sin(n)+1})}e.push({x:0,y:0});for(let t=60;t>=-180;t-=15){const n=t*Math.PI/180;e.push({x:-Math.cos(n),y:Math.sin(n)-1})}const n=.6,i=2.5*n,r=new hl(e.map((e=>new Yt(e.x,e.y+2+i,0)))),a=new bl(r,64,n,16,!1),s=new Sl(n,32,16);s.translate(-1,3+i,0);const o=new Sl(n,32,16);o.translate(1,1+i,0);const l=new Sl(n,32,16),c=new El({color:14352384,side:2});t=[{geometry:a,material:c,materialId:"",environment:!1},{geometry:s,material:c,materialId:"",environment:!1},{geometry:o,material:c,materialId:"",environment:!1},{geometry:l,material:c,materialId:"",environment:!1}]}else{const e=(()=>{const e=new Tl({side:2});return oh((t=>e.map=t),ph,new gi(.859,0,0)),e})();t=[{geometry:new Ji,material:e,materialId:"",environment:!1}]}return(e=>{const t=new Qs;return e.forEach((e=>{const n=new Zi(e.geometry,e.material);e.transform&&n.applyMatrix4(e.transform),n.castShadow=!e.environment,n.receiveShadow=!0,t.add(n)})),t})(t)}}(Gg,Wg);Yg.dracoLoader.setDecoderPath("./draco/"),Yg.dracoLoader.setDecoderConfig({type:"js"}),Yg.sceneRenderer.setQualityLevel(em),Yg.createControls(),Yg.setEnvironment(),Yg.updateSceneDependencies(),Hg();const qg=new Ug,Zg=Object.assign({},...t.map((e=>({[e.name]:e.url})))),Kg=qg.add(Xg,"glb",Zg).onChange((e=>{if(""!==e){const n=t.findIndex((t=>t.url===e)),i=n>=0?t[n].name:e;kg(i,e)}}));qg.add(Xg,"randomOrientation").onChange((()=>Yg.update(Xg))),qg.add(Xg,"dimensions").onChange((()=>Yg.update(Xg))),qg.add(Xg,"groundMaterial",{shadow:"onlyshadow",parquet:"parquet",pavement:"pavement"}).onChange((()=>Hg()));const Jg=qg.addFolder("environment"),Qg=Jg.add(Yg,"showEnvironment").onChange((e=>{e&&(ev.hideSky(),nv.hideBackground())}));Jg.add(Yg,"environmentRotation",0,2*Math.PI,.01).onChange((e=>{var t;(null===(t=Yg.scene.userData)||void 0===t?void 0:t.environmentDefinition)&&(Yg.scene.userData.environmentDefinition.rotation=e)})),Jg.add(Yg,"environmentIntensity",0,5,.01).onChange((e=>{var t;(null===(t=Yg.scene.userData)||void 0===t?void 0:t.environmentDefinition)&&(Yg.scene.userData.environmentDefinition.intensity=e)}));const $g=Jg.addFolder("sky"),ev=new class{constructor(e){this.skyEnvironment=e}hideSky(){var e,t;null===(e=this.showSkyController)||void 0===e||e.setValue(!1),null===(t=this.showSkyController)||void 0===t||t.updateDisplay()}addGUI(e,t){this.showSkyController=e.add(this.skyEnvironment.parameters,"visible").onChange((()=>{this.skyEnvironment.updateSky(),t&&t(this.skyEnvironment)}))}}(Yg.skyEnvironment);ev.addGUI($g,(e=>{e.parameters.visible&&(Qg.setValue(!1),Qg.updateDisplay(),nv.hideBackground())}));const tv=Jg.addFolder("background"),nv=new class{constructor(e){this._backgroundEnvironment=e}hideBackground(){var e,t;null===(e=this._backgroundTypeController)||void 0===e||e.setValue("None"),null===(t=this._backgroundTypeController)||void 0===t||t.updateDisplay()}addGUI(e,t){const n={backgroundType:""},i=new Map([["None",Sd],["Grid Paper",wd],["Concrete",bd],["Marble",Md],["Granite",Td],["Vorocracks Marble",Ed],["Kraft",Ad],["Line (slow)",Pd],["Test",Rd]]),r=[];i.forEach(((e,t)=>{r.push(t),this._backgroundEnvironment.parameters.backgroundType===e&&(n.backgroundType=t)})),e.add(n,"backgroundType",r).onChange((e=>{var n;i.has(e)&&(this._backgroundEnvironment.parameters.backgroundType=null!==(n=i.get(e))&&void 0!==n?n:Sd,this._backgroundEnvironment.updateBackground(),t&&t(this._backgroundEnvironment))}))}}(Yg.backgroundEnvironment);nv.addGUI(tv,(e=>{e.parameters.isSet&&(Qg.setValue(!1),Qg.updateDisplay(),ev.hideSky())})),Yg.environmentLoader.addGUI(Jg);const iv=new class{constructor(e){this._qualityLevel="",this._ambientOcclusionType="",this._sceneRenderer=e}addGUI(e,t){this._addRepresentationalGUI(e,t),this._addDebugGUI(e,t);const n=e.addFolder("Shadow type");this._addShadowTypeGUI(n,t);const i=e.addFolder("Shadow and Ambient Occlusion");this._addShadowAndAoGUI(i,t);const r=e.addFolder("Ground Reflection");this._addGroundReflectionGUI(r,t);const a=e.addFolder("Baked Ground Contact Shadow");this._addBakedGroundContactShadowGUI(a,t);const s=e.addFolder("Outline");this._addOutlineGUI(s,t)}_addRepresentationalGUI(e,t){const n=new Map([["LinearSRGBColorSpace",We],["SRGBColorSpace",Ge]]),i=[];n.forEach(((e,t)=>{i.push(t),this._sceneRenderer.renderer.outputColorSpace===e&&(this._sceneRenderer.outputColorSpace=t)})),e.add(this._sceneRenderer,"outputColorSpace",i).onChange((e=>{var i;n.has(e)&&(this._sceneRenderer.renderer.outputColorSpace=null!==(i=n.get(e))&&void 0!==i?i:Ge,t())}));const r=new Map([["NoToneMapping",0],["LinearToneMapping",1],["ReinhardToneMapping",2],["CineonToneMapping",3],["ACESFilmicToneMapping",4]]),a=[];r.forEach(((e,t)=>{a.push(t),this._sceneRenderer.renderer.toneMapping===e&&(this._sceneRenderer.toneMapping=t)})),e.add(this._sceneRenderer,"toneMapping",a).onChange((e=>{var n;r.has(e)&&(this._sceneRenderer.renderer.toneMapping=null!==(n=r.get(e))&&void 0!==n?n:0,t())}))}_addDebugGUI(e,t){const n=new Map([["HIGHEST",em],["HIGH",tm],["MEDIUM",nm],["LOW","low"]]),i=[];n.forEach(((e,t)=>i.push(t))),e.add(this,"_qualityLevel",i).onChange((e=>{var t;n.has(e)&&this._sceneRenderer.setQualityLevel(null!==(t=n.get(e))&&void 0!==t?t:em)})),e.add(this._sceneRenderer,"debugOutput",{"off ":"off","grayscale (no textures)":"grayscale","color buffer":"color","linear depth":"lineardepth","g-buffer normal vector":"g-normal","g-buffer depth":"g-depth","AO pure":"ssao","AO denoised":"ssaodenoise","shadow map":"shadowmap","shadow soft":"shadowsoft","shadow denoised":"shadowdenoise","shadow fade in":"shadowfadein","shadow and AO":"shadowandao","shadow and AO depth":"shadowandaodepth","material AO pass":"materialao","ground reflection base":"groundreflection","ground reflection final":"groundreflectionfinal","baked ground shadow":"bakedgroundshadow","selection outline":"outline","environment map":"environmentmap","light source detection":"lightsourcedetection"}).onChange((()=>t()))}_addShadowTypeGUI(e,t){const n=this._sceneRenderer.screenSpaceShadowMapPass.shadowConfiguration,i=[];n.types.forEach(((e,t)=>{i.push(t)}));const r=()=>{this._sceneRenderer.screenSpaceShadowMapPass.needsUpdate=!0,this._sceneRenderer.screenSpaceShadowMapPass.shadowTypeNeedsUpdate=!0,this._sceneRenderer.shadowAndAoPass.needsUpdate=!0,t()};e.add(n,"shadowType",i).onChange((e=>{this._sceneRenderer.screenSpaceShadowMapPass.switchType(e)&&(a.object=n.currentConfiguration,s.object=n.currentConfiguration,o.object=n.currentConfiguration,a.updateDisplay(),s.updateDisplay(),o.updateDisplay(),r())}));const a=e.add(n.currentConfiguration,"bias",-.001,.001,1e-5).onChange((()=>r())),s=e.add(n.currentConfiguration,"normalBias",-.05,.05).onChange((()=>r())),o=e.add(n.currentConfiguration,"radius",0,100).onChange((()=>r()))}_addShadowAndAoGUI(e,t){const n=()=>{this._sceneRenderer.requestUpdateOfPasses(),t()},i=this._sceneRenderer.shadowAndAoPass.parameters,r=i.shadow,a=this._sceneRenderer.screenSpaceShadowMapPass.parameters,s=i.ao,o=i.poissonDenoise;e.add(i,"enabled").onChange((()=>n())),e.add(i,"applyToMaterial").onChange((()=>{n(),this._sceneRenderer.clearCache()}));const l=new Map([["none",null],["SSAO",0],["SAO",1],["N8AO",2],["HBAO",3],["GTAO",4]]),c=Array.from(l.keys());l.forEach(((e,t)=>{e===s.algorithm&&(this._ambientOcclusionType=t)})),e.add(i,"aoIntensity",0,1).onChange((()=>{n()})),e.add(i,"aoOnGround").onChange((()=>{n(),this._sceneRenderer.clearCache()})),e.add(i,"shadowOnGround").onChange((()=>{n(),this._sceneRenderer.clearCache()})),e.add(i,"shadowIntensity",0,1).onChange((()=>n())),e.add(i,"alwaysUpdate").onChange((()=>n())),e.add(i,"progressiveDenoiseIterations",0,3,1).onChange((()=>n()));const h=e.addFolder("Environment Shadow");h.add(a,"maximumNumberOfLightSources",-1,10,1).onChange((()=>n())),h.add(a,"enableGroundBoundary").onChange((()=>n())),h.add(a,"directionalDependency",0,1,.01).onChange((()=>n())),h.add(a,"directionalExponent",0,2,.01).onChange((()=>n())),h.add(a,"groundBoundary",0,1,.01).onChange((()=>n())),h.add(a,"fadeOutDistance",0,5,.01).onChange((()=>n())),h.add(a,"fadeOutBlur",0,20,1).onChange((()=>n())),h.add(r,"shadowRadius",.001,.5).onChange((()=>n()));const d=e.addFolder("AO");d.add(this,"_ambientOcclusionType",c).onChange((e=>{if(l.has(e)){const t=l.get(e);s.algorithm=void 0!==t?t:0,n()}})),d.add(s,"samples",1,64,1).onChange((()=>n())),d.add(s,"radius",.01,2,.01).onChange((()=>n())),d.add(s,"distanceExponent",.1,4,.1).onChange((()=>n())),d.add(s,"thickness",.01,2,.01).onChange((()=>n())),d.add(s,"distanceFallOff",0,1).onChange((()=>n())),d.add(s,"scale",.01,2,.01).onChange((()=>n())),d.add(s,"bias",1e-4,.01,1e-4).onChange((()=>n())),d.add(s,"screenSpaceRadius").onChange((()=>n()));const u=e.addFolder("Possion Denoise");u.add(o,"iterations",0,4,1).onChange((()=>n())),u.add(o,"samples",0,32,1).onChange((()=>n())),u.add(o,"rings",0,16,.125).onChange((()=>n())),u.add(o,"radiusExponent",.1,4,.01).onChange((()=>n())),u.add(o,"radius",0,50,1).onChange((()=>n())),u.add(o,"depthPhi",0,20,.001).onChange((()=>n())),u.add(o,"normalPhi",0,20,.001).onChange((()=>n()))}_addGroundReflectionGUI(e,t){const n=this._sceneRenderer.parameters.groundReflectionParameters;e.add(n,"enabled"),e.add(n,"intensity",0,1).onChange((()=>t())),e.add(n,"fadeOutDistance",0,4).onChange((()=>t())),e.add(n,"fadeOutExponent",.1,10).onChange((()=>t())),e.add(n,"brightness",0,2).onChange((()=>t())),e.add(n,"blurHorizontal",0,10).onChange((()=>t())),e.add(n,"blurVertical",0,10).onChange((()=>t()))}_addBakedGroundContactShadowGUI(e,t){const n=()=>{this._sceneRenderer.bakedGroundContactShadowPass.applyParameters(),t()},i=this._sceneRenderer.parameters.bakedGroundContactShadowParameters;e.add(i,"enabled").onChange((()=>n())),e.add(i,"cameraHelper").onChange((()=>n())),e.add(i,"alwaysUpdate"),e.add(i,"fadeIn"),e.add(i,"blurMin",0,.2,.001).onChange((()=>n())),e.add(i,"blurMax",0,.5,.01).onChange((()=>n())),e.add(i,"fadeoutFalloff",0,1,.01).onChange((()=>n())),e.add(i,"fadeoutBias",0,.5).onChange((()=>n())),e.add(i,"opacity",0,1,.01).onChange((()=>n())),e.add(i,"maximumPlaneSize",0,50,1).onChange((()=>n())),e.add(i,"cameraFar",.1,10,.1).onChange((()=>n()))}_addOutlineGUI(e,t){const n=()=>{this._sceneRenderer.outlineRenderer.applyParameters(),t()},i=this._sceneRenderer.outlineRenderer.parameters;e.add(i,"enabled"),e.add(i,"edgeStrength",.5,20).onChange((()=>n())),e.add(i,"edgeGlow",0,20).onChange((()=>n())),e.add(i,"edgeThickness",.5,20).onChange((()=>n())),e.add(i,"pulsePeriod",0,5).onChange((()=>n())),e.addColor(i,"visibleEdgeColor").onChange((()=>n())),e.addColor(i,"hiddenEdgeColor").onChange((()=>n()))}}(Yg.sceneRenderer);iv.addGUI(qg,(()=>{}));const rv=new Em,av=qg.addFolder("Light"),sv=new class{constructor(e){this.lightColors=[],this.lightSourceFolders=[],this.lights="none",this.lightSources=e}addGUI(e,t,n){e.add(this.lightSources,"lightControls").onChange(t),e.add(this,"lights",["none","default","fife"]).onChange((e=>{switch(e){default:case"none":this.lightSources.currentLightSourceDefinition=zc.noLightSources;break;case"default":this.lightSources.currentLightSourceDefinition=zc.defaultLightSources;break;case"fife":this.lightSources.currentLightSourceDefinition=zc.fifeLightSources}this.lightSources.updateLightSources(),this.updateGUI(),n()})),this.lightGUI=e,this.updateGUI()}updateGUI(){if(!this.lightGUI)return;const e=this.lightGUI;this.lightSourceFolders.forEach((t=>e.removeFolder(t))),this.lightSourceFolders=[],this.lightColors=[],this.lightSources.getLightSources().forEach((t=>{if(t instanceof _c){this.lightColors.push({color:t.color.getHex()});const n=e.addFolder("Ambient Light");this.lightSourceFolders.push(n),n.add(t,"visible"),n.add(t,"intensity").min(0).max(5).step(.1),n.addColor(this.lightColors[this.lightColors.length-1],"color").onChange((e=>t.color=new gi(e)))}})),this.lightSources.getLightSources().forEach((t=>{var n;if(t instanceof vc){this.lightColors.push({color:t.color.getHex()});const n=e.addFolder("Directional Light "+(this.lightColors.length-1));this.lightSourceFolders.push(n),n.add(t,"visible"),n.add(t,"intensity").min(0).max(10).step(.1),n.add(t,"castShadow"),n.addColor(this.lightColors[this.lightColors.length-1],"color").onChange((e=>t.color=new gi(e)))}else if(t instanceof xc){this.lightColors.push({color:t.color.getHex()});const i=e.addFolder("Rect area Light "+(this.lightColors.length-1));this.lightSourceFolders.push(i);const r=null===(n=this.lightSources.sceneRenderer)||void 0===n?void 0:n.screenSpaceShadowMapPass.findShadowLightSource(t);i.add(t,"visible"),i.add(t,"intensity").min(0).max(200).step(1),r&&i.add(r,"castShadow"),i.addColor(this.lightColors[this.lightColors.length-1],"color").onChange((e=>t.color=new gi(e)))}}))}}(Yg.getLightSources());sv.addGUI(av,(()=>e=>Yg.changeLightControls(e)),(()=>Yg.updateSceneDependencies())),window.addEventListener("resize",(()=>{const e=window.innerWidth,t=window.innerHeight;Yg.resize(e,t)}),!1);const ov=new _t;Gg.domElement.addEventListener("pointermove",(e=>{!1!==e.isPrimary&&(ov.x=e.clientX/window.innerWidth*2-1,ov.y=-e.clientY/window.innerHeight*2+1)})),(()=>{const e=document.getElementById("holder");e&&(e.ondragover=function(){return this.className="hover",!1},e.ondragend=function(){return this.className="",!1},e.ondrop=function(e){this.className="",e.preventDefault();const t=e.dataTransfer.files[0],n=new FileReader;n.onload=e=>((e,t)=>{((e,t)=>{const n=Fg[e];n?(Bg(`render ${e}`,"#ff0000"),Yg.update(void 0,n.scene,n.glb),zg(e)):Yg.loadResource(e,t,(e=>{}),((t,n)=>{n?(Fg[e]={scene:n,glb:!0},zg(t),(e=>{Zg.push(e);let t="";Zg.forEach((e=>{t+=``})),Kg.domElement.children[0].innerHTML=t,Kg.setValue(e),Kg.updateDisplay()})(e)):Bg(`load ${t}`,"#ff0000")}))})(e.name,t.target.result)})(t,e),n.readAsDataURL(t)})})();const lv=document.createElement("a"),cv=e=>{const t=Gg.domElement.toDataURL();lv.href=t,lv.download=e,lv.click()},hv=(e,t)=>{const n=Yg.sceneRenderer.debugOutput;Yg.sceneRenderer.debugOutput=e,Yg.prepareRender(new _t),Yg.render(!1),cv(t),Yg.sceneRenderer.debugOutput=n},dv=document.getElementById("save-button");dv&&(dv.onclick=()=>(()=>{try{cv(Xg.sceneName+".png")}catch(e){console.log(e)}})());const uv=document.getElementById("save-g-buffer-button");let pv,fv;uv&&(uv.onclick=()=>(()=>{try{hv("color",Xg.sceneName+"_color.png"),hv("g-normal",Xg.sceneName+"_normal.png"),hv("g-depth",Xg.sceneName+"_depth.png")}catch(e){console.log(e)}})());const mv=e=>{void 0===pv&&(pv=e),void 0===fv&&(fv=e);const t=e-fv;fv=e,Yg.animate(t),gv(),requestAnimationFrame(mv)},gv=()=>{Yg.prepareRender(ov),Yg.render(),jg.update()};(()=>{const e=t.findIndex((e=>"BrainStem"===e.name));if(e>=0){const n=t[e];kg(n.name,n.url)}})(),requestAnimationFrame(mv)})(); \ No newline at end of file +(()=>{"use strict";var e={};e.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(e){if("object"==typeof window)return window}}(),(()=>{var t;e.g.importScripts&&(t=e.g.location+"");var n=e.g.document;if(!t&&n&&(n.currentScript&&"SCRIPT"===n.currentScript.tagName.toUpperCase()&&(t=n.currentScript.src),!t)){var i=n.getElementsByTagName("script");if(i.length)for(var r=i.length-1;r>-1&&(!t||!/^http(s?):/.test(t));)t=i[r--].src}if(!t)throw new Error("Automatic publicPath is not supported in this browser");t=t.replace(/#.*$/,"").replace(/\?.*$/,"").replace(/\/[^\/]+$/,"/"),e.p=t})();const t=[{name:"BrainStem",url:"./BrainStem.glb"},{name:"DamagedHelmet",url:"./DamagedHelmet.glb"}],n="171",i=0,r=1,a=2,s=100,o=101,l=102,c=200,h=201,d=202,u=203,p=204,f=205,m=206,g=207,v=208,_=209,x=210,y=211,S=212,w=213,b=214,M=0,T=1,E=2,A=3,P=4,R=5,C=6,D=7,L="attached",I=301,U=302,O=306,N=1e3,F=1001,B=1002,z=1003,k=1004,H=1005,V=1006,G=1007,W=1008,j=1009,X=1012,Y=1013,q=1014,Z=1015,K=1016,J=1017,Q=1018,$=1020,ee=1023,te=1026,ne=1027,ie=1028,re=1029,ae=1030,se=1031,oe=1033,le=33776,ce=33777,he=33778,de=33779,ue=35840,pe=35841,fe=35842,me=35843,ge=36196,ve=37492,_e=37496,xe=37808,ye=37809,Se=37810,we=37811,be=37812,Me=37813,Te=37814,Ee=37815,Ae=37816,Pe=37817,Re=37818,Ce=37819,De=37820,Le=37821,Ie=36492,Ue=36494,Oe=36495,Ne=36284,Fe=36285,Be=36286,ze=2300,ke=2301,He=2302,Ve="",Ge="srgb",We="srgb-linear",je="linear",Xe="srgb",Ye=7680,qe=512,Ze=513,Ke=514,Je=515,Qe=516,$e=517,et=518,tt=519,nt=35044,it="300 es",rt=2e3,at=2001;class st{addEventListener(e,t){void 0===this._listeners&&(this._listeners={});const n=this._listeners;void 0===n[e]&&(n[e]=[]),-1===n[e].indexOf(t)&&n[e].push(t)}hasEventListener(e,t){if(void 0===this._listeners)return!1;const n=this._listeners;return void 0!==n[e]&&-1!==n[e].indexOf(t)}removeEventListener(e,t){if(void 0===this._listeners)return;const n=this._listeners[e];if(void 0!==n){const e=n.indexOf(t);-1!==e&&n.splice(e,1)}}dispatchEvent(e){if(void 0===this._listeners)return;const t=this._listeners[e.type];if(void 0!==t){e.target=this;const n=t.slice(0);for(let t=0,i=n.length;t>8&255]+ot[e>>16&255]+ot[e>>24&255]+"-"+ot[255&t]+ot[t>>8&255]+"-"+ot[t>>16&15|64]+ot[t>>24&255]+"-"+ot[63&n|128]+ot[n>>8&255]+"-"+ot[n>>16&255]+ot[n>>24&255]+ot[255&i]+ot[i>>8&255]+ot[i>>16&255]+ot[i>>24&255]).toLowerCase()}function dt(e,t,n){return Math.max(t,Math.min(n,e))}function ut(e,t){return(e%t+t)%t}function pt(e,t,n){return(1-n)*e+n*t}function ft(e,t){switch(t.constructor){case Float32Array:return e;case Uint32Array:return e/4294967295;case Uint16Array:return e/65535;case Uint8Array:return e/255;case Int32Array:return Math.max(e/2147483647,-1);case Int16Array:return Math.max(e/32767,-1);case Int8Array:return Math.max(e/127,-1);default:throw new Error("Invalid component type.")}}function mt(e,t){switch(t.constructor){case Float32Array:return e;case Uint32Array:return Math.round(4294967295*e);case Uint16Array:return Math.round(65535*e);case Uint8Array:return Math.round(255*e);case Int32Array:return Math.round(2147483647*e);case Int16Array:return Math.round(32767*e);case Int8Array:return Math.round(127*e);default:throw new Error("Invalid component type.")}}const gt=lt,vt=function(e){return e*ct};class _t{constructor(e=0,t=0){_t.prototype.isVector2=!0,this.x=e,this.y=t}get width(){return this.x}set width(e){this.x=e}get height(){return this.y}set height(e){this.y=e}set(e,t){return this.x=e,this.y=t,this}setScalar(e){return this.x=e,this.y=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setComponent(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;default:throw new Error("index is out of range: "+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;default:throw new Error("index is out of range: "+e)}}clone(){return new this.constructor(this.x,this.y)}copy(e){return this.x=e.x,this.y=e.y,this}add(e){return this.x+=e.x,this.y+=e.y,this}addScalar(e){return this.x+=e,this.y+=e,this}addVectors(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this}addScaledVector(e,t){return this.x+=e.x*t,this.y+=e.y*t,this}sub(e){return this.x-=e.x,this.y-=e.y,this}subScalar(e){return this.x-=e,this.y-=e,this}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this}multiply(e){return this.x*=e.x,this.y*=e.y,this}multiplyScalar(e){return this.x*=e,this.y*=e,this}divide(e){return this.x/=e.x,this.y/=e.y,this}divideScalar(e){return this.multiplyScalar(1/e)}applyMatrix3(e){const t=this.x,n=this.y,i=e.elements;return this.x=i[0]*t+i[3]*n+i[6],this.y=i[1]*t+i[4]*n+i[7],this}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this}clamp(e,t){return this.x=dt(this.x,e.x,t.x),this.y=dt(this.y,e.y,t.y),this}clampScalar(e,t){return this.x=dt(this.x,e,t),this.y=dt(this.y,e,t),this}clampLength(e,t){const n=this.length();return this.divideScalar(n||1).multiplyScalar(dt(n,e,t))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this}negate(){return this.x=-this.x,this.y=-this.y,this}dot(e){return this.x*e.x+this.y*e.y}cross(e){return this.x*e.y-this.y*e.x}lengthSq(){return this.x*this.x+this.y*this.y}length(){return Math.sqrt(this.x*this.x+this.y*this.y)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)}normalize(){return this.divideScalar(this.length()||1)}angle(){return Math.atan2(-this.y,-this.x)+Math.PI}angleTo(e){const t=Math.sqrt(this.lengthSq()*e.lengthSq());if(0===t)return Math.PI/2;const n=this.dot(e)/t;return Math.acos(dt(n,-1,1))}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){const t=this.x-e.x,n=this.y-e.y;return t*t+n*n}manhattanDistanceTo(e){return Math.abs(this.x-e.x)+Math.abs(this.y-e.y)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this}lerpVectors(e,t,n){return this.x=e.x+(t.x-e.x)*n,this.y=e.y+(t.y-e.y)*n,this}equals(e){return e.x===this.x&&e.y===this.y}fromArray(e,t=0){return this.x=e[t],this.y=e[t+1],this}toArray(e=[],t=0){return e[t]=this.x,e[t+1]=this.y,e}fromBufferAttribute(e,t){return this.x=e.getX(t),this.y=e.getY(t),this}rotateAround(e,t){const n=Math.cos(t),i=Math.sin(t),r=this.x-e.x,a=this.y-e.y;return this.x=r*n-a*i+e.x,this.y=r*i+a*n+e.y,this}random(){return this.x=Math.random(),this.y=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y}}class xt{constructor(e,t,n,i,r,a,s,o,l){xt.prototype.isMatrix3=!0,this.elements=[1,0,0,0,1,0,0,0,1],void 0!==e&&this.set(e,t,n,i,r,a,s,o,l)}set(e,t,n,i,r,a,s,o,l){const c=this.elements;return c[0]=e,c[1]=i,c[2]=s,c[3]=t,c[4]=r,c[5]=o,c[6]=n,c[7]=a,c[8]=l,this}identity(){return this.set(1,0,0,0,1,0,0,0,1),this}copy(e){const t=this.elements,n=e.elements;return t[0]=n[0],t[1]=n[1],t[2]=n[2],t[3]=n[3],t[4]=n[4],t[5]=n[5],t[6]=n[6],t[7]=n[7],t[8]=n[8],this}extractBasis(e,t,n){return e.setFromMatrix3Column(this,0),t.setFromMatrix3Column(this,1),n.setFromMatrix3Column(this,2),this}setFromMatrix4(e){const t=e.elements;return this.set(t[0],t[4],t[8],t[1],t[5],t[9],t[2],t[6],t[10]),this}multiply(e){return this.multiplyMatrices(this,e)}premultiply(e){return this.multiplyMatrices(e,this)}multiplyMatrices(e,t){const n=e.elements,i=t.elements,r=this.elements,a=n[0],s=n[3],o=n[6],l=n[1],c=n[4],h=n[7],d=n[2],u=n[5],p=n[8],f=i[0],m=i[3],g=i[6],v=i[1],_=i[4],x=i[7],y=i[2],S=i[5],w=i[8];return r[0]=a*f+s*v+o*y,r[3]=a*m+s*_+o*S,r[6]=a*g+s*x+o*w,r[1]=l*f+c*v+h*y,r[4]=l*m+c*_+h*S,r[7]=l*g+c*x+h*w,r[2]=d*f+u*v+p*y,r[5]=d*m+u*_+p*S,r[8]=d*g+u*x+p*w,this}multiplyScalar(e){const t=this.elements;return t[0]*=e,t[3]*=e,t[6]*=e,t[1]*=e,t[4]*=e,t[7]*=e,t[2]*=e,t[5]*=e,t[8]*=e,this}determinant(){const e=this.elements,t=e[0],n=e[1],i=e[2],r=e[3],a=e[4],s=e[5],o=e[6],l=e[7],c=e[8];return t*a*c-t*s*l-n*r*c+n*s*o+i*r*l-i*a*o}invert(){const e=this.elements,t=e[0],n=e[1],i=e[2],r=e[3],a=e[4],s=e[5],o=e[6],l=e[7],c=e[8],h=c*a-s*l,d=s*o-c*r,u=l*r-a*o,p=t*h+n*d+i*u;if(0===p)return this.set(0,0,0,0,0,0,0,0,0);const f=1/p;return e[0]=h*f,e[1]=(i*l-c*n)*f,e[2]=(s*n-i*a)*f,e[3]=d*f,e[4]=(c*t-i*o)*f,e[5]=(i*r-s*t)*f,e[6]=u*f,e[7]=(n*o-l*t)*f,e[8]=(a*t-n*r)*f,this}transpose(){let e;const t=this.elements;return e=t[1],t[1]=t[3],t[3]=e,e=t[2],t[2]=t[6],t[6]=e,e=t[5],t[5]=t[7],t[7]=e,this}getNormalMatrix(e){return this.setFromMatrix4(e).invert().transpose()}transposeIntoArray(e){const t=this.elements;return e[0]=t[0],e[1]=t[3],e[2]=t[6],e[3]=t[1],e[4]=t[4],e[5]=t[7],e[6]=t[2],e[7]=t[5],e[8]=t[8],this}setUvTransform(e,t,n,i,r,a,s){const o=Math.cos(r),l=Math.sin(r);return this.set(n*o,n*l,-n*(o*a+l*s)+a+e,-i*l,i*o,-i*(-l*a+o*s)+s+t,0,0,1),this}scale(e,t){return this.premultiply(yt.makeScale(e,t)),this}rotate(e){return this.premultiply(yt.makeRotation(-e)),this}translate(e,t){return this.premultiply(yt.makeTranslation(e,t)),this}makeTranslation(e,t){return e.isVector2?this.set(1,0,e.x,0,1,e.y,0,0,1):this.set(1,0,e,0,1,t,0,0,1),this}makeRotation(e){const t=Math.cos(e),n=Math.sin(e);return this.set(t,-n,0,n,t,0,0,0,1),this}makeScale(e,t){return this.set(e,0,0,0,t,0,0,0,1),this}equals(e){const t=this.elements,n=e.elements;for(let e=0;e<9;e++)if(t[e]!==n[e])return!1;return!0}fromArray(e,t=0){for(let n=0;n<9;n++)this.elements[n]=e[n+t];return this}toArray(e=[],t=0){const n=this.elements;return e[t]=n[0],e[t+1]=n[1],e[t+2]=n[2],e[t+3]=n[3],e[t+4]=n[4],e[t+5]=n[5],e[t+6]=n[6],e[t+7]=n[7],e[t+8]=n[8],e}clone(){return(new this.constructor).fromArray(this.elements)}}const yt=new xt;function St(e){for(let t=e.length-1;t>=0;--t)if(e[t]>=65535)return!0;return!1}function wt(e){return document.createElementNS("http://www.w3.org/1999/xhtml",e)}function bt(){const e=wt("canvas");return e.style.display="block",e}Int8Array,Uint8Array,Uint8ClampedArray,Int16Array,Uint16Array,Int32Array,Uint32Array,Float32Array,Float64Array;const Mt={};function Tt(e){e in Mt||(Mt[e]=!0,console.warn(e))}const Et=(new xt).set(.4123908,.3575843,.1804808,.212639,.7151687,.0721923,.0193308,.1191948,.9505322),At=(new xt).set(3.2409699,-1.5373832,-.4986108,-.9692436,1.8759675,.0415551,.0556301,-.203977,1.0569715);function Pt(){const e={enabled:!0,workingColorSpace:We,spaces:{},convert:function(e,t,n){return!1!==this.enabled&&t!==n&&t&&n?(this.spaces[t].transfer===Xe&&(e.r=Ct(e.r),e.g=Ct(e.g),e.b=Ct(e.b)),this.spaces[t].primaries!==this.spaces[n].primaries&&(e.applyMatrix3(this.spaces[t].toXYZ),e.applyMatrix3(this.spaces[n].fromXYZ)),this.spaces[n].transfer===Xe&&(e.r=Dt(e.r),e.g=Dt(e.g),e.b=Dt(e.b)),e):e},fromWorkingColorSpace:function(e,t){return this.convert(e,this.workingColorSpace,t)},toWorkingColorSpace:function(e,t){return this.convert(e,t,this.workingColorSpace)},getPrimaries:function(e){return this.spaces[e].primaries},getTransfer:function(e){return e===Ve?je:this.spaces[e].transfer},getLuminanceCoefficients:function(e,t=this.workingColorSpace){return e.fromArray(this.spaces[t].luminanceCoefficients)},define:function(e){Object.assign(this.spaces,e)},_getMatrix:function(e,t,n){return e.copy(this.spaces[t].toXYZ).multiply(this.spaces[n].fromXYZ)},_getDrawingBufferColorSpace:function(e){return this.spaces[e].outputColorSpaceConfig.drawingBufferColorSpace},_getUnpackColorSpace:function(e=this.workingColorSpace){return this.spaces[e].workingColorSpaceConfig.unpackColorSpace}},t=[.64,.33,.3,.6,.15,.06],n=[.2126,.7152,.0722],i=[.3127,.329];return e.define({[We]:{primaries:t,whitePoint:i,transfer:je,toXYZ:Et,fromXYZ:At,luminanceCoefficients:n,workingColorSpaceConfig:{unpackColorSpace:Ge},outputColorSpaceConfig:{drawingBufferColorSpace:Ge}},[Ge]:{primaries:t,whitePoint:i,transfer:Xe,toXYZ:Et,fromXYZ:At,luminanceCoefficients:n,outputColorSpaceConfig:{drawingBufferColorSpace:Ge}}}),e}const Rt=Pt();function Ct(e){return e<.04045?.0773993808*e:Math.pow(.9478672986*e+.0521327014,2.4)}function Dt(e){return e<.0031308?12.92*e:1.055*Math.pow(e,.41666)-.055}let Lt;class It{static getDataURL(e){if(/^data:/i.test(e.src))return e.src;if("undefined"==typeof HTMLCanvasElement)return e.src;let t;if(e instanceof HTMLCanvasElement)t=e;else{void 0===Lt&&(Lt=wt("canvas")),Lt.width=e.width,Lt.height=e.height;const n=Lt.getContext("2d");e instanceof ImageData?n.putImageData(e,0,0):n.drawImage(e,0,0,e.width,e.height),t=Lt}return t.width>2048||t.height>2048?(console.warn("THREE.ImageUtils.getDataURL: Image converted to jpg for performance reasons",e),t.toDataURL("image/jpeg",.6)):t.toDataURL("image/png")}static sRGBToLinear(e){if("undefined"!=typeof HTMLImageElement&&e instanceof HTMLImageElement||"undefined"!=typeof HTMLCanvasElement&&e instanceof HTMLCanvasElement||"undefined"!=typeof ImageBitmap&&e instanceof ImageBitmap){const t=wt("canvas");t.width=e.width,t.height=e.height;const n=t.getContext("2d");n.drawImage(e,0,0,e.width,e.height);const i=n.getImageData(0,0,e.width,e.height),r=i.data;for(let e=0;e0&&(n.userData=this.userData),t||(e.textures[this.uuid]=n),n}dispose(){this.dispatchEvent({type:"dispose"})}transformUv(e){if(300!==this.mapping)return e;if(e.applyMatrix3(this.matrix),e.x<0||e.x>1)switch(this.wrapS){case N:e.x=e.x-Math.floor(e.x);break;case F:e.x=e.x<0?0:1;break;case B:1===Math.abs(Math.floor(e.x)%2)?e.x=Math.ceil(e.x)-e.x:e.x=e.x-Math.floor(e.x)}if(e.y<0||e.y>1)switch(this.wrapT){case N:e.y=e.y-Math.floor(e.y);break;case F:e.y=e.y<0?0:1;break;case B:1===Math.abs(Math.floor(e.y)%2)?e.y=Math.ceil(e.y)-e.y:e.y=e.y-Math.floor(e.y)}return this.flipY&&(e.y=1-e.y),e}set needsUpdate(e){!0===e&&(this.version++,this.source.needsUpdate=!0)}set needsPMREMUpdate(e){!0===e&&this.pmremVersion++}}Bt.DEFAULT_IMAGE=null,Bt.DEFAULT_MAPPING=300,Bt.DEFAULT_ANISOTROPY=1;class zt{constructor(e=0,t=0,n=0,i=1){zt.prototype.isVector4=!0,this.x=e,this.y=t,this.z=n,this.w=i}get width(){return this.z}set width(e){this.z=e}get height(){return this.w}set height(e){this.w=e}set(e,t,n,i){return this.x=e,this.y=t,this.z=n,this.w=i,this}setScalar(e){return this.x=e,this.y=e,this.z=e,this.w=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setZ(e){return this.z=e,this}setW(e){return this.w=e,this}setComponent(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;case 2:this.z=t;break;case 3:this.w=t;break;default:throw new Error("index is out of range: "+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;case 2:return this.z;case 3:return this.w;default:throw new Error("index is out of range: "+e)}}clone(){return new this.constructor(this.x,this.y,this.z,this.w)}copy(e){return this.x=e.x,this.y=e.y,this.z=e.z,this.w=void 0!==e.w?e.w:1,this}add(e){return this.x+=e.x,this.y+=e.y,this.z+=e.z,this.w+=e.w,this}addScalar(e){return this.x+=e,this.y+=e,this.z+=e,this.w+=e,this}addVectors(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this.z=e.z+t.z,this.w=e.w+t.w,this}addScaledVector(e,t){return this.x+=e.x*t,this.y+=e.y*t,this.z+=e.z*t,this.w+=e.w*t,this}sub(e){return this.x-=e.x,this.y-=e.y,this.z-=e.z,this.w-=e.w,this}subScalar(e){return this.x-=e,this.y-=e,this.z-=e,this.w-=e,this}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this.z=e.z-t.z,this.w=e.w-t.w,this}multiply(e){return this.x*=e.x,this.y*=e.y,this.z*=e.z,this.w*=e.w,this}multiplyScalar(e){return this.x*=e,this.y*=e,this.z*=e,this.w*=e,this}applyMatrix4(e){const t=this.x,n=this.y,i=this.z,r=this.w,a=e.elements;return this.x=a[0]*t+a[4]*n+a[8]*i+a[12]*r,this.y=a[1]*t+a[5]*n+a[9]*i+a[13]*r,this.z=a[2]*t+a[6]*n+a[10]*i+a[14]*r,this.w=a[3]*t+a[7]*n+a[11]*i+a[15]*r,this}divide(e){return this.x/=e.x,this.y/=e.y,this.z/=e.z,this.w/=e.w,this}divideScalar(e){return this.multiplyScalar(1/e)}setAxisAngleFromQuaternion(e){this.w=2*Math.acos(e.w);const t=Math.sqrt(1-e.w*e.w);return t<1e-4?(this.x=1,this.y=0,this.z=0):(this.x=e.x/t,this.y=e.y/t,this.z=e.z/t),this}setAxisAngleFromRotationMatrix(e){let t,n,i,r;const a=.01,s=.1,o=e.elements,l=o[0],c=o[4],h=o[8],d=o[1],u=o[5],p=o[9],f=o[2],m=o[6],g=o[10];if(Math.abs(c-d)o&&e>v?ev?o=0?1:-1,i=1-t*t;if(i>Number.EPSILON){const r=Math.sqrt(i),a=Math.atan2(r,t*n);e=Math.sin(e*a)/r,s=Math.sin(s*a)/r}const r=s*n;if(o=o*e+d*r,l=l*e+u*r,c=c*e+p*r,h=h*e+f*r,e===1-s){const e=1/Math.sqrt(o*o+l*l+c*c+h*h);o*=e,l*=e,c*=e,h*=e}}e[t]=o,e[t+1]=l,e[t+2]=c,e[t+3]=h}static multiplyQuaternionsFlat(e,t,n,i,r,a){const s=n[i],o=n[i+1],l=n[i+2],c=n[i+3],h=r[a],d=r[a+1],u=r[a+2],p=r[a+3];return e[t]=s*p+c*h+o*u-l*d,e[t+1]=o*p+c*d+l*h-s*u,e[t+2]=l*p+c*u+s*d-o*h,e[t+3]=c*p-s*h-o*d-l*u,e}get x(){return this._x}set x(e){this._x=e,this._onChangeCallback()}get y(){return this._y}set y(e){this._y=e,this._onChangeCallback()}get z(){return this._z}set z(e){this._z=e,this._onChangeCallback()}get w(){return this._w}set w(e){this._w=e,this._onChangeCallback()}set(e,t,n,i){return this._x=e,this._y=t,this._z=n,this._w=i,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._w)}copy(e){return this._x=e.x,this._y=e.y,this._z=e.z,this._w=e.w,this._onChangeCallback(),this}setFromEuler(e,t=!0){const n=e._x,i=e._y,r=e._z,a=e._order,s=Math.cos,o=Math.sin,l=s(n/2),c=s(i/2),h=s(r/2),d=o(n/2),u=o(i/2),p=o(r/2);switch(a){case"XYZ":this._x=d*c*h+l*u*p,this._y=l*u*h-d*c*p,this._z=l*c*p+d*u*h,this._w=l*c*h-d*u*p;break;case"YXZ":this._x=d*c*h+l*u*p,this._y=l*u*h-d*c*p,this._z=l*c*p-d*u*h,this._w=l*c*h+d*u*p;break;case"ZXY":this._x=d*c*h-l*u*p,this._y=l*u*h+d*c*p,this._z=l*c*p+d*u*h,this._w=l*c*h-d*u*p;break;case"ZYX":this._x=d*c*h-l*u*p,this._y=l*u*h+d*c*p,this._z=l*c*p-d*u*h,this._w=l*c*h+d*u*p;break;case"YZX":this._x=d*c*h+l*u*p,this._y=l*u*h+d*c*p,this._z=l*c*p-d*u*h,this._w=l*c*h-d*u*p;break;case"XZY":this._x=d*c*h-l*u*p,this._y=l*u*h-d*c*p,this._z=l*c*p+d*u*h,this._w=l*c*h+d*u*p;break;default:console.warn("THREE.Quaternion: .setFromEuler() encountered an unknown order: "+a)}return!0===t&&this._onChangeCallback(),this}setFromAxisAngle(e,t){const n=t/2,i=Math.sin(n);return this._x=e.x*i,this._y=e.y*i,this._z=e.z*i,this._w=Math.cos(n),this._onChangeCallback(),this}setFromRotationMatrix(e){const t=e.elements,n=t[0],i=t[4],r=t[8],a=t[1],s=t[5],o=t[9],l=t[2],c=t[6],h=t[10],d=n+s+h;if(d>0){const e=.5/Math.sqrt(d+1);this._w=.25/e,this._x=(c-o)*e,this._y=(r-l)*e,this._z=(a-i)*e}else if(n>s&&n>h){const e=2*Math.sqrt(1+n-s-h);this._w=(c-o)/e,this._x=.25*e,this._y=(i+a)/e,this._z=(r+l)/e}else if(s>h){const e=2*Math.sqrt(1+s-n-h);this._w=(r-l)/e,this._x=(i+a)/e,this._y=.25*e,this._z=(o+c)/e}else{const e=2*Math.sqrt(1+h-n-s);this._w=(a-i)/e,this._x=(r+l)/e,this._y=(o+c)/e,this._z=.25*e}return this._onChangeCallback(),this}setFromUnitVectors(e,t){let n=e.dot(t)+1;return nMath.abs(e.z)?(this._x=-e.y,this._y=e.x,this._z=0,this._w=n):(this._x=0,this._y=-e.z,this._z=e.y,this._w=n)):(this._x=e.y*t.z-e.z*t.y,this._y=e.z*t.x-e.x*t.z,this._z=e.x*t.y-e.y*t.x,this._w=n),this.normalize()}angleTo(e){return 2*Math.acos(Math.abs(dt(this.dot(e),-1,1)))}rotateTowards(e,t){const n=this.angleTo(e);if(0===n)return this;const i=Math.min(1,t/n);return this.slerp(e,i),this}identity(){return this.set(0,0,0,1)}invert(){return this.conjugate()}conjugate(){return this._x*=-1,this._y*=-1,this._z*=-1,this._onChangeCallback(),this}dot(e){return this._x*e._x+this._y*e._y+this._z*e._z+this._w*e._w}lengthSq(){return this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w}length(){return Math.sqrt(this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w)}normalize(){let e=this.length();return 0===e?(this._x=0,this._y=0,this._z=0,this._w=1):(e=1/e,this._x=this._x*e,this._y=this._y*e,this._z=this._z*e,this._w=this._w*e),this._onChangeCallback(),this}multiply(e){return this.multiplyQuaternions(this,e)}premultiply(e){return this.multiplyQuaternions(e,this)}multiplyQuaternions(e,t){const n=e._x,i=e._y,r=e._z,a=e._w,s=t._x,o=t._y,l=t._z,c=t._w;return this._x=n*c+a*s+i*l-r*o,this._y=i*c+a*o+r*s-n*l,this._z=r*c+a*l+n*o-i*s,this._w=a*c-n*s-i*o-r*l,this._onChangeCallback(),this}slerp(e,t){if(0===t)return this;if(1===t)return this.copy(e);const n=this._x,i=this._y,r=this._z,a=this._w;let s=a*e._w+n*e._x+i*e._y+r*e._z;if(s<0?(this._w=-e._w,this._x=-e._x,this._y=-e._y,this._z=-e._z,s=-s):this.copy(e),s>=1)return this._w=a,this._x=n,this._y=i,this._z=r,this;const o=1-s*s;if(o<=Number.EPSILON){const e=1-t;return this._w=e*a+t*this._w,this._x=e*n+t*this._x,this._y=e*i+t*this._y,this._z=e*r+t*this._z,this.normalize(),this}const l=Math.sqrt(o),c=Math.atan2(l,s),h=Math.sin((1-t)*c)/l,d=Math.sin(t*c)/l;return this._w=a*h+this._w*d,this._x=n*h+this._x*d,this._y=i*h+this._y*d,this._z=r*h+this._z*d,this._onChangeCallback(),this}slerpQuaternions(e,t,n){return this.copy(e).slerp(t,n)}random(){const e=2*Math.PI*Math.random(),t=2*Math.PI*Math.random(),n=Math.random(),i=Math.sqrt(1-n),r=Math.sqrt(n);return this.set(i*Math.sin(e),i*Math.cos(e),r*Math.sin(t),r*Math.cos(t))}equals(e){return e._x===this._x&&e._y===this._y&&e._z===this._z&&e._w===this._w}fromArray(e,t=0){return this._x=e[t],this._y=e[t+1],this._z=e[t+2],this._w=e[t+3],this._onChangeCallback(),this}toArray(e=[],t=0){return e[t]=this._x,e[t+1]=this._y,e[t+2]=this._z,e[t+3]=this._w,e}fromBufferAttribute(e,t){return this._x=e.getX(t),this._y=e.getY(t),this._z=e.getZ(t),this._w=e.getW(t),this._onChangeCallback(),this}toJSON(){return this.toArray()}_onChange(e){return this._onChangeCallback=e,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._w}}class jt{constructor(e=0,t=0,n=0){jt.prototype.isVector3=!0,this.x=e,this.y=t,this.z=n}set(e,t,n){return void 0===n&&(n=this.z),this.x=e,this.y=t,this.z=n,this}setScalar(e){return this.x=e,this.y=e,this.z=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setZ(e){return this.z=e,this}setComponent(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;case 2:this.z=t;break;default:throw new Error("index is out of range: "+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;case 2:return this.z;default:throw new Error("index is out of range: "+e)}}clone(){return new this.constructor(this.x,this.y,this.z)}copy(e){return this.x=e.x,this.y=e.y,this.z=e.z,this}add(e){return this.x+=e.x,this.y+=e.y,this.z+=e.z,this}addScalar(e){return this.x+=e,this.y+=e,this.z+=e,this}addVectors(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this.z=e.z+t.z,this}addScaledVector(e,t){return this.x+=e.x*t,this.y+=e.y*t,this.z+=e.z*t,this}sub(e){return this.x-=e.x,this.y-=e.y,this.z-=e.z,this}subScalar(e){return this.x-=e,this.y-=e,this.z-=e,this}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this.z=e.z-t.z,this}multiply(e){return this.x*=e.x,this.y*=e.y,this.z*=e.z,this}multiplyScalar(e){return this.x*=e,this.y*=e,this.z*=e,this}multiplyVectors(e,t){return this.x=e.x*t.x,this.y=e.y*t.y,this.z=e.z*t.z,this}applyEuler(e){return this.applyQuaternion(Yt.setFromEuler(e))}applyAxisAngle(e,t){return this.applyQuaternion(Yt.setFromAxisAngle(e,t))}applyMatrix3(e){const t=this.x,n=this.y,i=this.z,r=e.elements;return this.x=r[0]*t+r[3]*n+r[6]*i,this.y=r[1]*t+r[4]*n+r[7]*i,this.z=r[2]*t+r[5]*n+r[8]*i,this}applyNormalMatrix(e){return this.applyMatrix3(e).normalize()}applyMatrix4(e){const t=this.x,n=this.y,i=this.z,r=e.elements,a=1/(r[3]*t+r[7]*n+r[11]*i+r[15]);return this.x=(r[0]*t+r[4]*n+r[8]*i+r[12])*a,this.y=(r[1]*t+r[5]*n+r[9]*i+r[13])*a,this.z=(r[2]*t+r[6]*n+r[10]*i+r[14])*a,this}applyQuaternion(e){const t=this.x,n=this.y,i=this.z,r=e.x,a=e.y,s=e.z,o=e.w,l=2*(a*i-s*n),c=2*(s*t-r*i),h=2*(r*n-a*t);return this.x=t+o*l+a*h-s*c,this.y=n+o*c+s*l-r*h,this.z=i+o*h+r*c-a*l,this}project(e){return this.applyMatrix4(e.matrixWorldInverse).applyMatrix4(e.projectionMatrix)}unproject(e){return this.applyMatrix4(e.projectionMatrixInverse).applyMatrix4(e.matrixWorld)}transformDirection(e){const t=this.x,n=this.y,i=this.z,r=e.elements;return this.x=r[0]*t+r[4]*n+r[8]*i,this.y=r[1]*t+r[5]*n+r[9]*i,this.z=r[2]*t+r[6]*n+r[10]*i,this.normalize()}divide(e){return this.x/=e.x,this.y/=e.y,this.z/=e.z,this}divideScalar(e){return this.multiplyScalar(1/e)}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this.z=Math.min(this.z,e.z),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this.z=Math.max(this.z,e.z),this}clamp(e,t){return this.x=dt(this.x,e.x,t.x),this.y=dt(this.y,e.y,t.y),this.z=dt(this.z,e.z,t.z),this}clampScalar(e,t){return this.x=dt(this.x,e,t),this.y=dt(this.y,e,t),this.z=dt(this.z,e,t),this}clampLength(e,t){const n=this.length();return this.divideScalar(n||1).multiplyScalar(dt(n,e,t))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this.z=Math.trunc(this.z),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this}dot(e){return this.x*e.x+this.y*e.y+this.z*e.z}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)}normalize(){return this.divideScalar(this.length()||1)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this.z+=(e.z-this.z)*t,this}lerpVectors(e,t,n){return this.x=e.x+(t.x-e.x)*n,this.y=e.y+(t.y-e.y)*n,this.z=e.z+(t.z-e.z)*n,this}cross(e){return this.crossVectors(this,e)}crossVectors(e,t){const n=e.x,i=e.y,r=e.z,a=t.x,s=t.y,o=t.z;return this.x=i*o-r*s,this.y=r*a-n*o,this.z=n*s-i*a,this}projectOnVector(e){const t=e.lengthSq();if(0===t)return this.set(0,0,0);const n=e.dot(this)/t;return this.copy(e).multiplyScalar(n)}projectOnPlane(e){return Xt.copy(this).projectOnVector(e),this.sub(Xt)}reflect(e){return this.sub(Xt.copy(e).multiplyScalar(2*this.dot(e)))}angleTo(e){const t=Math.sqrt(this.lengthSq()*e.lengthSq());if(0===t)return Math.PI/2;const n=this.dot(e)/t;return Math.acos(dt(n,-1,1))}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){const t=this.x-e.x,n=this.y-e.y,i=this.z-e.z;return t*t+n*n+i*i}manhattanDistanceTo(e){return Math.abs(this.x-e.x)+Math.abs(this.y-e.y)+Math.abs(this.z-e.z)}setFromSpherical(e){return this.setFromSphericalCoords(e.radius,e.phi,e.theta)}setFromSphericalCoords(e,t,n){const i=Math.sin(t)*e;return this.x=i*Math.sin(n),this.y=Math.cos(t)*e,this.z=i*Math.cos(n),this}setFromCylindrical(e){return this.setFromCylindricalCoords(e.radius,e.theta,e.y)}setFromCylindricalCoords(e,t,n){return this.x=e*Math.sin(t),this.y=n,this.z=e*Math.cos(t),this}setFromMatrixPosition(e){const t=e.elements;return this.x=t[12],this.y=t[13],this.z=t[14],this}setFromMatrixScale(e){const t=this.setFromMatrixColumn(e,0).length(),n=this.setFromMatrixColumn(e,1).length(),i=this.setFromMatrixColumn(e,2).length();return this.x=t,this.y=n,this.z=i,this}setFromMatrixColumn(e,t){return this.fromArray(e.elements,4*t)}setFromMatrix3Column(e,t){return this.fromArray(e.elements,3*t)}setFromEuler(e){return this.x=e._x,this.y=e._y,this.z=e._z,this}setFromColor(e){return this.x=e.r,this.y=e.g,this.z=e.b,this}equals(e){return e.x===this.x&&e.y===this.y&&e.z===this.z}fromArray(e,t=0){return this.x=e[t],this.y=e[t+1],this.z=e[t+2],this}toArray(e=[],t=0){return e[t]=this.x,e[t+1]=this.y,e[t+2]=this.z,e}fromBufferAttribute(e,t){return this.x=e.getX(t),this.y=e.getY(t),this.z=e.getZ(t),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this}randomDirection(){const e=Math.random()*Math.PI*2,t=2*Math.random()-1,n=Math.sqrt(1-t*t);return this.x=n*Math.cos(e),this.y=t,this.z=n*Math.sin(e),this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z}}const Xt=new jt,Yt=new Wt;class qt{constructor(e=new jt(1/0,1/0,1/0),t=new jt(-1/0,-1/0,-1/0)){this.isBox3=!0,this.min=e,this.max=t}set(e,t){return this.min.copy(e),this.max.copy(t),this}setFromArray(e){this.makeEmpty();for(let t=0,n=e.length;t=this.min.x&&e.x<=this.max.x&&e.y>=this.min.y&&e.y<=this.max.y&&e.z>=this.min.z&&e.z<=this.max.z}containsBox(e){return this.min.x<=e.min.x&&e.max.x<=this.max.x&&this.min.y<=e.min.y&&e.max.y<=this.max.y&&this.min.z<=e.min.z&&e.max.z<=this.max.z}getParameter(e,t){return t.set((e.x-this.min.x)/(this.max.x-this.min.x),(e.y-this.min.y)/(this.max.y-this.min.y),(e.z-this.min.z)/(this.max.z-this.min.z))}intersectsBox(e){return e.max.x>=this.min.x&&e.min.x<=this.max.x&&e.max.y>=this.min.y&&e.min.y<=this.max.y&&e.max.z>=this.min.z&&e.min.z<=this.max.z}intersectsSphere(e){return this.clampPoint(e.center,Kt),Kt.distanceToSquared(e.center)<=e.radius*e.radius}intersectsPlane(e){let t,n;return e.normal.x>0?(t=e.normal.x*this.min.x,n=e.normal.x*this.max.x):(t=e.normal.x*this.max.x,n=e.normal.x*this.min.x),e.normal.y>0?(t+=e.normal.y*this.min.y,n+=e.normal.y*this.max.y):(t+=e.normal.y*this.max.y,n+=e.normal.y*this.min.y),e.normal.z>0?(t+=e.normal.z*this.min.z,n+=e.normal.z*this.max.z):(t+=e.normal.z*this.max.z,n+=e.normal.z*this.min.z),t<=-e.constant&&n>=-e.constant}intersectsTriangle(e){if(this.isEmpty())return!1;this.getCenter(an),sn.subVectors(this.max,an),Qt.subVectors(e.a,an),$t.subVectors(e.b,an),en.subVectors(e.c,an),tn.subVectors($t,Qt),nn.subVectors(en,$t),rn.subVectors(Qt,en);let t=[0,-tn.z,tn.y,0,-nn.z,nn.y,0,-rn.z,rn.y,tn.z,0,-tn.x,nn.z,0,-nn.x,rn.z,0,-rn.x,-tn.y,tn.x,0,-nn.y,nn.x,0,-rn.y,rn.x,0];return!!cn(t,Qt,$t,en,sn)&&(t=[1,0,0,0,1,0,0,0,1],!!cn(t,Qt,$t,en,sn)&&(on.crossVectors(tn,nn),t=[on.x,on.y,on.z],cn(t,Qt,$t,en,sn)))}clampPoint(e,t){return t.copy(e).clamp(this.min,this.max)}distanceToPoint(e){return this.clampPoint(e,Kt).distanceTo(e)}getBoundingSphere(e){return this.isEmpty()?e.makeEmpty():(this.getCenter(e.center),e.radius=.5*this.getSize(Kt).length()),e}intersect(e){return this.min.max(e.min),this.max.min(e.max),this.isEmpty()&&this.makeEmpty(),this}union(e){return this.min.min(e.min),this.max.max(e.max),this}applyMatrix4(e){return this.isEmpty()||(Zt[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(e),Zt[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(e),Zt[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(e),Zt[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(e),Zt[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(e),Zt[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(e),Zt[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(e),Zt[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(e),this.setFromPoints(Zt)),this}translate(e){return this.min.add(e),this.max.add(e),this}equals(e){return e.min.equals(this.min)&&e.max.equals(this.max)}}const Zt=[new jt,new jt,new jt,new jt,new jt,new jt,new jt,new jt],Kt=new jt,Jt=new qt,Qt=new jt,$t=new jt,en=new jt,tn=new jt,nn=new jt,rn=new jt,an=new jt,sn=new jt,on=new jt,ln=new jt;function cn(e,t,n,i,r){for(let a=0,s=e.length-3;a<=s;a+=3){ln.fromArray(e,a);const s=r.x*Math.abs(ln.x)+r.y*Math.abs(ln.y)+r.z*Math.abs(ln.z),o=t.dot(ln),l=n.dot(ln),c=i.dot(ln);if(Math.max(-Math.max(o,l,c),Math.min(o,l,c))>s)return!1}return!0}const hn=new qt,dn=new jt,un=new jt;class pn{constructor(e=new jt,t=-1){this.isSphere=!0,this.center=e,this.radius=t}set(e,t){return this.center.copy(e),this.radius=t,this}setFromPoints(e,t){const n=this.center;void 0!==t?n.copy(t):hn.setFromPoints(e).getCenter(n);let i=0;for(let t=0,r=e.length;tthis.radius*this.radius&&(t.sub(this.center).normalize(),t.multiplyScalar(this.radius).add(this.center)),t}getBoundingBox(e){return this.isEmpty()?(e.makeEmpty(),e):(e.set(this.center,this.center),e.expandByScalar(this.radius),e)}applyMatrix4(e){return this.center.applyMatrix4(e),this.radius=this.radius*e.getMaxScaleOnAxis(),this}translate(e){return this.center.add(e),this}expandByPoint(e){if(this.isEmpty())return this.center.copy(e),this.radius=0,this;dn.subVectors(e,this.center);const t=dn.lengthSq();if(t>this.radius*this.radius){const e=Math.sqrt(t),n=.5*(e-this.radius);this.center.addScaledVector(dn,n/e),this.radius+=n}return this}union(e){return e.isEmpty()?this:this.isEmpty()?(this.copy(e),this):(!0===this.center.equals(e.center)?this.radius=Math.max(this.radius,e.radius):(un.subVectors(e.center,this.center).setLength(e.radius),this.expandByPoint(dn.copy(e.center).add(un)),this.expandByPoint(dn.copy(e.center).sub(un))),this)}equals(e){return e.center.equals(this.center)&&e.radius===this.radius}clone(){return(new this.constructor).copy(this)}}const fn=new jt,mn=new jt,gn=new jt,vn=new jt,_n=new jt,xn=new jt,yn=new jt;class Sn{constructor(e=new jt,t=new jt(0,0,-1)){this.origin=e,this.direction=t}set(e,t){return this.origin.copy(e),this.direction.copy(t),this}copy(e){return this.origin.copy(e.origin),this.direction.copy(e.direction),this}at(e,t){return t.copy(this.origin).addScaledVector(this.direction,e)}lookAt(e){return this.direction.copy(e).sub(this.origin).normalize(),this}recast(e){return this.origin.copy(this.at(e,fn)),this}closestPointToPoint(e,t){t.subVectors(e,this.origin);const n=t.dot(this.direction);return n<0?t.copy(this.origin):t.copy(this.origin).addScaledVector(this.direction,n)}distanceToPoint(e){return Math.sqrt(this.distanceSqToPoint(e))}distanceSqToPoint(e){const t=fn.subVectors(e,this.origin).dot(this.direction);return t<0?this.origin.distanceToSquared(e):(fn.copy(this.origin).addScaledVector(this.direction,t),fn.distanceToSquared(e))}distanceSqToSegment(e,t,n,i){mn.copy(e).add(t).multiplyScalar(.5),gn.copy(t).sub(e).normalize(),vn.copy(this.origin).sub(mn);const r=.5*e.distanceTo(t),a=-this.direction.dot(gn),s=vn.dot(this.direction),o=-vn.dot(gn),l=vn.lengthSq(),c=Math.abs(1-a*a);let h,d,u,p;if(c>0)if(h=a*o-s,d=a*s-o,p=r*c,h>=0)if(d>=-p)if(d<=p){const e=1/c;h*=e,d*=e,u=h*(h+a*d+2*s)+d*(a*h+d+2*o)+l}else d=r,h=Math.max(0,-(a*d+s)),u=-h*h+d*(d+2*o)+l;else d=-r,h=Math.max(0,-(a*d+s)),u=-h*h+d*(d+2*o)+l;else d<=-p?(h=Math.max(0,-(-a*r+s)),d=h>0?-r:Math.min(Math.max(-r,-o),r),u=-h*h+d*(d+2*o)+l):d<=p?(h=0,d=Math.min(Math.max(-r,-o),r),u=d*(d+2*o)+l):(h=Math.max(0,-(a*r+s)),d=h>0?r:Math.min(Math.max(-r,-o),r),u=-h*h+d*(d+2*o)+l);else d=a>0?-r:r,h=Math.max(0,-(a*d+s)),u=-h*h+d*(d+2*o)+l;return n&&n.copy(this.origin).addScaledVector(this.direction,h),i&&i.copy(mn).addScaledVector(gn,d),u}intersectSphere(e,t){fn.subVectors(e.center,this.origin);const n=fn.dot(this.direction),i=fn.dot(fn)-n*n,r=e.radius*e.radius;if(i>r)return null;const a=Math.sqrt(r-i),s=n-a,o=n+a;return o<0?null:s<0?this.at(o,t):this.at(s,t)}intersectsSphere(e){return this.distanceSqToPoint(e.center)<=e.radius*e.radius}distanceToPlane(e){const t=e.normal.dot(this.direction);if(0===t)return 0===e.distanceToPoint(this.origin)?0:null;const n=-(this.origin.dot(e.normal)+e.constant)/t;return n>=0?n:null}intersectPlane(e,t){const n=this.distanceToPlane(e);return null===n?null:this.at(n,t)}intersectsPlane(e){const t=e.distanceToPoint(this.origin);return 0===t||e.normal.dot(this.direction)*t<0}intersectBox(e,t){let n,i,r,a,s,o;const l=1/this.direction.x,c=1/this.direction.y,h=1/this.direction.z,d=this.origin;return l>=0?(n=(e.min.x-d.x)*l,i=(e.max.x-d.x)*l):(n=(e.max.x-d.x)*l,i=(e.min.x-d.x)*l),c>=0?(r=(e.min.y-d.y)*c,a=(e.max.y-d.y)*c):(r=(e.max.y-d.y)*c,a=(e.min.y-d.y)*c),n>a||r>i?null:((r>n||isNaN(n))&&(n=r),(a=0?(s=(e.min.z-d.z)*h,o=(e.max.z-d.z)*h):(s=(e.max.z-d.z)*h,o=(e.min.z-d.z)*h),n>o||s>i?null:((s>n||n!=n)&&(n=s),(o=0?n:i,t)))}intersectsBox(e){return null!==this.intersectBox(e,fn)}intersectTriangle(e,t,n,i,r){_n.subVectors(t,e),xn.subVectors(n,e),yn.crossVectors(_n,xn);let a,s=this.direction.dot(yn);if(s>0){if(i)return null;a=1}else{if(!(s<0))return null;a=-1,s=-s}vn.subVectors(this.origin,e);const o=a*this.direction.dot(xn.crossVectors(vn,xn));if(o<0)return null;const l=a*this.direction.dot(_n.cross(vn));if(l<0)return null;if(o+l>s)return null;const c=-a*vn.dot(yn);return c<0?null:this.at(c/s,r)}applyMatrix4(e){return this.origin.applyMatrix4(e),this.direction.transformDirection(e),this}equals(e){return e.origin.equals(this.origin)&&e.direction.equals(this.direction)}clone(){return(new this.constructor).copy(this)}}class wn{constructor(e,t,n,i,r,a,s,o,l,c,h,d,u,p,f,m){wn.prototype.isMatrix4=!0,this.elements=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],void 0!==e&&this.set(e,t,n,i,r,a,s,o,l,c,h,d,u,p,f,m)}set(e,t,n,i,r,a,s,o,l,c,h,d,u,p,f,m){const g=this.elements;return g[0]=e,g[4]=t,g[8]=n,g[12]=i,g[1]=r,g[5]=a,g[9]=s,g[13]=o,g[2]=l,g[6]=c,g[10]=h,g[14]=d,g[3]=u,g[7]=p,g[11]=f,g[15]=m,this}identity(){return this.set(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1),this}clone(){return(new wn).fromArray(this.elements)}copy(e){const t=this.elements,n=e.elements;return t[0]=n[0],t[1]=n[1],t[2]=n[2],t[3]=n[3],t[4]=n[4],t[5]=n[5],t[6]=n[6],t[7]=n[7],t[8]=n[8],t[9]=n[9],t[10]=n[10],t[11]=n[11],t[12]=n[12],t[13]=n[13],t[14]=n[14],t[15]=n[15],this}copyPosition(e){const t=this.elements,n=e.elements;return t[12]=n[12],t[13]=n[13],t[14]=n[14],this}setFromMatrix3(e){const t=e.elements;return this.set(t[0],t[3],t[6],0,t[1],t[4],t[7],0,t[2],t[5],t[8],0,0,0,0,1),this}extractBasis(e,t,n){return e.setFromMatrixColumn(this,0),t.setFromMatrixColumn(this,1),n.setFromMatrixColumn(this,2),this}makeBasis(e,t,n){return this.set(e.x,t.x,n.x,0,e.y,t.y,n.y,0,e.z,t.z,n.z,0,0,0,0,1),this}extractRotation(e){const t=this.elements,n=e.elements,i=1/bn.setFromMatrixColumn(e,0).length(),r=1/bn.setFromMatrixColumn(e,1).length(),a=1/bn.setFromMatrixColumn(e,2).length();return t[0]=n[0]*i,t[1]=n[1]*i,t[2]=n[2]*i,t[3]=0,t[4]=n[4]*r,t[5]=n[5]*r,t[6]=n[6]*r,t[7]=0,t[8]=n[8]*a,t[9]=n[9]*a,t[10]=n[10]*a,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,this}makeRotationFromEuler(e){const t=this.elements,n=e.x,i=e.y,r=e.z,a=Math.cos(n),s=Math.sin(n),o=Math.cos(i),l=Math.sin(i),c=Math.cos(r),h=Math.sin(r);if("XYZ"===e.order){const e=a*c,n=a*h,i=s*c,r=s*h;t[0]=o*c,t[4]=-o*h,t[8]=l,t[1]=n+i*l,t[5]=e-r*l,t[9]=-s*o,t[2]=r-e*l,t[6]=i+n*l,t[10]=a*o}else if("YXZ"===e.order){const e=o*c,n=o*h,i=l*c,r=l*h;t[0]=e+r*s,t[4]=i*s-n,t[8]=a*l,t[1]=a*h,t[5]=a*c,t[9]=-s,t[2]=n*s-i,t[6]=r+e*s,t[10]=a*o}else if("ZXY"===e.order){const e=o*c,n=o*h,i=l*c,r=l*h;t[0]=e-r*s,t[4]=-a*h,t[8]=i+n*s,t[1]=n+i*s,t[5]=a*c,t[9]=r-e*s,t[2]=-a*l,t[6]=s,t[10]=a*o}else if("ZYX"===e.order){const e=a*c,n=a*h,i=s*c,r=s*h;t[0]=o*c,t[4]=i*l-n,t[8]=e*l+r,t[1]=o*h,t[5]=r*l+e,t[9]=n*l-i,t[2]=-l,t[6]=s*o,t[10]=a*o}else if("YZX"===e.order){const e=a*o,n=a*l,i=s*o,r=s*l;t[0]=o*c,t[4]=r-e*h,t[8]=i*h+n,t[1]=h,t[5]=a*c,t[9]=-s*c,t[2]=-l*c,t[6]=n*h+i,t[10]=e-r*h}else if("XZY"===e.order){const e=a*o,n=a*l,i=s*o,r=s*l;t[0]=o*c,t[4]=-h,t[8]=l*c,t[1]=e*h+r,t[5]=a*c,t[9]=n*h-i,t[2]=i*h-n,t[6]=s*c,t[10]=r*h+e}return t[3]=0,t[7]=0,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,this}makeRotationFromQuaternion(e){return this.compose(Tn,e,En)}lookAt(e,t,n){const i=this.elements;return Rn.subVectors(e,t),0===Rn.lengthSq()&&(Rn.z=1),Rn.normalize(),An.crossVectors(n,Rn),0===An.lengthSq()&&(1===Math.abs(n.z)?Rn.x+=1e-4:Rn.z+=1e-4,Rn.normalize(),An.crossVectors(n,Rn)),An.normalize(),Pn.crossVectors(Rn,An),i[0]=An.x,i[4]=Pn.x,i[8]=Rn.x,i[1]=An.y,i[5]=Pn.y,i[9]=Rn.y,i[2]=An.z,i[6]=Pn.z,i[10]=Rn.z,this}multiply(e){return this.multiplyMatrices(this,e)}premultiply(e){return this.multiplyMatrices(e,this)}multiplyMatrices(e,t){const n=e.elements,i=t.elements,r=this.elements,a=n[0],s=n[4],o=n[8],l=n[12],c=n[1],h=n[5],d=n[9],u=n[13],p=n[2],f=n[6],m=n[10],g=n[14],v=n[3],_=n[7],x=n[11],y=n[15],S=i[0],w=i[4],b=i[8],M=i[12],T=i[1],E=i[5],A=i[9],P=i[13],R=i[2],C=i[6],D=i[10],L=i[14],I=i[3],U=i[7],O=i[11],N=i[15];return r[0]=a*S+s*T+o*R+l*I,r[4]=a*w+s*E+o*C+l*U,r[8]=a*b+s*A+o*D+l*O,r[12]=a*M+s*P+o*L+l*N,r[1]=c*S+h*T+d*R+u*I,r[5]=c*w+h*E+d*C+u*U,r[9]=c*b+h*A+d*D+u*O,r[13]=c*M+h*P+d*L+u*N,r[2]=p*S+f*T+m*R+g*I,r[6]=p*w+f*E+m*C+g*U,r[10]=p*b+f*A+m*D+g*O,r[14]=p*M+f*P+m*L+g*N,r[3]=v*S+_*T+x*R+y*I,r[7]=v*w+_*E+x*C+y*U,r[11]=v*b+_*A+x*D+y*O,r[15]=v*M+_*P+x*L+y*N,this}multiplyScalar(e){const t=this.elements;return t[0]*=e,t[4]*=e,t[8]*=e,t[12]*=e,t[1]*=e,t[5]*=e,t[9]*=e,t[13]*=e,t[2]*=e,t[6]*=e,t[10]*=e,t[14]*=e,t[3]*=e,t[7]*=e,t[11]*=e,t[15]*=e,this}determinant(){const e=this.elements,t=e[0],n=e[4],i=e[8],r=e[12],a=e[1],s=e[5],o=e[9],l=e[13],c=e[2],h=e[6],d=e[10],u=e[14];return e[3]*(+r*o*h-i*l*h-r*s*d+n*l*d+i*s*u-n*o*u)+e[7]*(+t*o*u-t*l*d+r*a*d-i*a*u+i*l*c-r*o*c)+e[11]*(+t*l*h-t*s*u-r*a*h+n*a*u+r*s*c-n*l*c)+e[15]*(-i*s*c-t*o*h+t*s*d+i*a*h-n*a*d+n*o*c)}transpose(){const e=this.elements;let t;return t=e[1],e[1]=e[4],e[4]=t,t=e[2],e[2]=e[8],e[8]=t,t=e[6],e[6]=e[9],e[9]=t,t=e[3],e[3]=e[12],e[12]=t,t=e[7],e[7]=e[13],e[13]=t,t=e[11],e[11]=e[14],e[14]=t,this}setPosition(e,t,n){const i=this.elements;return e.isVector3?(i[12]=e.x,i[13]=e.y,i[14]=e.z):(i[12]=e,i[13]=t,i[14]=n),this}invert(){const e=this.elements,t=e[0],n=e[1],i=e[2],r=e[3],a=e[4],s=e[5],o=e[6],l=e[7],c=e[8],h=e[9],d=e[10],u=e[11],p=e[12],f=e[13],m=e[14],g=e[15],v=h*m*l-f*d*l+f*o*u-s*m*u-h*o*g+s*d*g,_=p*d*l-c*m*l-p*o*u+a*m*u+c*o*g-a*d*g,x=c*f*l-p*h*l+p*s*u-a*f*u-c*s*g+a*h*g,y=p*h*o-c*f*o-p*s*d+a*f*d+c*s*m-a*h*m,S=t*v+n*_+i*x+r*y;if(0===S)return this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);const w=1/S;return e[0]=v*w,e[1]=(f*d*r-h*m*r-f*i*u+n*m*u+h*i*g-n*d*g)*w,e[2]=(s*m*r-f*o*r+f*i*l-n*m*l-s*i*g+n*o*g)*w,e[3]=(h*o*r-s*d*r-h*i*l+n*d*l+s*i*u-n*o*u)*w,e[4]=_*w,e[5]=(c*m*r-p*d*r+p*i*u-t*m*u-c*i*g+t*d*g)*w,e[6]=(p*o*r-a*m*r-p*i*l+t*m*l+a*i*g-t*o*g)*w,e[7]=(a*d*r-c*o*r+c*i*l-t*d*l-a*i*u+t*o*u)*w,e[8]=x*w,e[9]=(p*h*r-c*f*r-p*n*u+t*f*u+c*n*g-t*h*g)*w,e[10]=(a*f*r-p*s*r+p*n*l-t*f*l-a*n*g+t*s*g)*w,e[11]=(c*s*r-a*h*r-c*n*l+t*h*l+a*n*u-t*s*u)*w,e[12]=y*w,e[13]=(c*f*i-p*h*i+p*n*d-t*f*d-c*n*m+t*h*m)*w,e[14]=(p*s*i-a*f*i-p*n*o+t*f*o+a*n*m-t*s*m)*w,e[15]=(a*h*i-c*s*i+c*n*o-t*h*o-a*n*d+t*s*d)*w,this}scale(e){const t=this.elements,n=e.x,i=e.y,r=e.z;return t[0]*=n,t[4]*=i,t[8]*=r,t[1]*=n,t[5]*=i,t[9]*=r,t[2]*=n,t[6]*=i,t[10]*=r,t[3]*=n,t[7]*=i,t[11]*=r,this}getMaxScaleOnAxis(){const e=this.elements,t=e[0]*e[0]+e[1]*e[1]+e[2]*e[2],n=e[4]*e[4]+e[5]*e[5]+e[6]*e[6],i=e[8]*e[8]+e[9]*e[9]+e[10]*e[10];return Math.sqrt(Math.max(t,n,i))}makeTranslation(e,t,n){return e.isVector3?this.set(1,0,0,e.x,0,1,0,e.y,0,0,1,e.z,0,0,0,1):this.set(1,0,0,e,0,1,0,t,0,0,1,n,0,0,0,1),this}makeRotationX(e){const t=Math.cos(e),n=Math.sin(e);return this.set(1,0,0,0,0,t,-n,0,0,n,t,0,0,0,0,1),this}makeRotationY(e){const t=Math.cos(e),n=Math.sin(e);return this.set(t,0,n,0,0,1,0,0,-n,0,t,0,0,0,0,1),this}makeRotationZ(e){const t=Math.cos(e),n=Math.sin(e);return this.set(t,-n,0,0,n,t,0,0,0,0,1,0,0,0,0,1),this}makeRotationAxis(e,t){const n=Math.cos(t),i=Math.sin(t),r=1-n,a=e.x,s=e.y,o=e.z,l=r*a,c=r*s;return this.set(l*a+n,l*s-i*o,l*o+i*s,0,l*s+i*o,c*s+n,c*o-i*a,0,l*o-i*s,c*o+i*a,r*o*o+n,0,0,0,0,1),this}makeScale(e,t,n){return this.set(e,0,0,0,0,t,0,0,0,0,n,0,0,0,0,1),this}makeShear(e,t,n,i,r,a){return this.set(1,n,r,0,e,1,a,0,t,i,1,0,0,0,0,1),this}compose(e,t,n){const i=this.elements,r=t._x,a=t._y,s=t._z,o=t._w,l=r+r,c=a+a,h=s+s,d=r*l,u=r*c,p=r*h,f=a*c,m=a*h,g=s*h,v=o*l,_=o*c,x=o*h,y=n.x,S=n.y,w=n.z;return i[0]=(1-(f+g))*y,i[1]=(u+x)*y,i[2]=(p-_)*y,i[3]=0,i[4]=(u-x)*S,i[5]=(1-(d+g))*S,i[6]=(m+v)*S,i[7]=0,i[8]=(p+_)*w,i[9]=(m-v)*w,i[10]=(1-(d+f))*w,i[11]=0,i[12]=e.x,i[13]=e.y,i[14]=e.z,i[15]=1,this}decompose(e,t,n){const i=this.elements;let r=bn.set(i[0],i[1],i[2]).length();const a=bn.set(i[4],i[5],i[6]).length(),s=bn.set(i[8],i[9],i[10]).length();this.determinant()<0&&(r=-r),e.x=i[12],e.y=i[13],e.z=i[14],Mn.copy(this);const o=1/r,l=1/a,c=1/s;return Mn.elements[0]*=o,Mn.elements[1]*=o,Mn.elements[2]*=o,Mn.elements[4]*=l,Mn.elements[5]*=l,Mn.elements[6]*=l,Mn.elements[8]*=c,Mn.elements[9]*=c,Mn.elements[10]*=c,t.setFromRotationMatrix(Mn),n.x=r,n.y=a,n.z=s,this}makePerspective(e,t,n,i,r,a,s=2e3){const o=this.elements,l=2*r/(t-e),c=2*r/(n-i),h=(t+e)/(t-e),d=(n+i)/(n-i);let u,p;if(s===rt)u=-(a+r)/(a-r),p=-2*a*r/(a-r);else{if(s!==at)throw new Error("THREE.Matrix4.makePerspective(): Invalid coordinate system: "+s);u=-a/(a-r),p=-a*r/(a-r)}return o[0]=l,o[4]=0,o[8]=h,o[12]=0,o[1]=0,o[5]=c,o[9]=d,o[13]=0,o[2]=0,o[6]=0,o[10]=u,o[14]=p,o[3]=0,o[7]=0,o[11]=-1,o[15]=0,this}makeOrthographic(e,t,n,i,r,a,s=2e3){const o=this.elements,l=1/(t-e),c=1/(n-i),h=1/(a-r),d=(t+e)*l,u=(n+i)*c;let p,f;if(s===rt)p=(a+r)*h,f=-2*h;else{if(s!==at)throw new Error("THREE.Matrix4.makeOrthographic(): Invalid coordinate system: "+s);p=r*h,f=-1*h}return o[0]=2*l,o[4]=0,o[8]=0,o[12]=-d,o[1]=0,o[5]=2*c,o[9]=0,o[13]=-u,o[2]=0,o[6]=0,o[10]=f,o[14]=-p,o[3]=0,o[7]=0,o[11]=0,o[15]=1,this}equals(e){const t=this.elements,n=e.elements;for(let e=0;e<16;e++)if(t[e]!==n[e])return!1;return!0}fromArray(e,t=0){for(let n=0;n<16;n++)this.elements[n]=e[n+t];return this}toArray(e=[],t=0){const n=this.elements;return e[t]=n[0],e[t+1]=n[1],e[t+2]=n[2],e[t+3]=n[3],e[t+4]=n[4],e[t+5]=n[5],e[t+6]=n[6],e[t+7]=n[7],e[t+8]=n[8],e[t+9]=n[9],e[t+10]=n[10],e[t+11]=n[11],e[t+12]=n[12],e[t+13]=n[13],e[t+14]=n[14],e[t+15]=n[15],e}}const bn=new jt,Mn=new wn,Tn=new jt(0,0,0),En=new jt(1,1,1),An=new jt,Pn=new jt,Rn=new jt,Cn=new wn,Dn=new Wt;class Ln{constructor(e=0,t=0,n=0,i=Ln.DEFAULT_ORDER){this.isEuler=!0,this._x=e,this._y=t,this._z=n,this._order=i}get x(){return this._x}set x(e){this._x=e,this._onChangeCallback()}get y(){return this._y}set y(e){this._y=e,this._onChangeCallback()}get z(){return this._z}set z(e){this._z=e,this._onChangeCallback()}get order(){return this._order}set order(e){this._order=e,this._onChangeCallback()}set(e,t,n,i=this._order){return this._x=e,this._y=t,this._z=n,this._order=i,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._order)}copy(e){return this._x=e._x,this._y=e._y,this._z=e._z,this._order=e._order,this._onChangeCallback(),this}setFromRotationMatrix(e,t=this._order,n=!0){const i=e.elements,r=i[0],a=i[4],s=i[8],o=i[1],l=i[5],c=i[9],h=i[2],d=i[6],u=i[10];switch(t){case"XYZ":this._y=Math.asin(dt(s,-1,1)),Math.abs(s)<.9999999?(this._x=Math.atan2(-c,u),this._z=Math.atan2(-a,r)):(this._x=Math.atan2(d,l),this._z=0);break;case"YXZ":this._x=Math.asin(-dt(c,-1,1)),Math.abs(c)<.9999999?(this._y=Math.atan2(s,u),this._z=Math.atan2(o,l)):(this._y=Math.atan2(-h,r),this._z=0);break;case"ZXY":this._x=Math.asin(dt(d,-1,1)),Math.abs(d)<.9999999?(this._y=Math.atan2(-h,u),this._z=Math.atan2(-a,l)):(this._y=0,this._z=Math.atan2(o,r));break;case"ZYX":this._y=Math.asin(-dt(h,-1,1)),Math.abs(h)<.9999999?(this._x=Math.atan2(d,u),this._z=Math.atan2(o,r)):(this._x=0,this._z=Math.atan2(-a,l));break;case"YZX":this._z=Math.asin(dt(o,-1,1)),Math.abs(o)<.9999999?(this._x=Math.atan2(-c,l),this._y=Math.atan2(-h,r)):(this._x=0,this._y=Math.atan2(s,u));break;case"XZY":this._z=Math.asin(-dt(a,-1,1)),Math.abs(a)<.9999999?(this._x=Math.atan2(d,l),this._y=Math.atan2(s,r)):(this._x=Math.atan2(-c,u),this._y=0);break;default:console.warn("THREE.Euler: .setFromRotationMatrix() encountered an unknown order: "+t)}return this._order=t,!0===n&&this._onChangeCallback(),this}setFromQuaternion(e,t,n){return Cn.makeRotationFromQuaternion(e),this.setFromRotationMatrix(Cn,t,n)}setFromVector3(e,t=this._order){return this.set(e.x,e.y,e.z,t)}reorder(e){return Dn.setFromEuler(this),this.setFromQuaternion(Dn,e)}equals(e){return e._x===this._x&&e._y===this._y&&e._z===this._z&&e._order===this._order}fromArray(e){return this._x=e[0],this._y=e[1],this._z=e[2],void 0!==e[3]&&(this._order=e[3]),this._onChangeCallback(),this}toArray(e=[],t=0){return e[t]=this._x,e[t+1]=this._y,e[t+2]=this._z,e[t+3]=this._order,e}_onChange(e){return this._onChangeCallback=e,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._order}}Ln.DEFAULT_ORDER="XYZ";class In{constructor(){this.mask=1}set(e){this.mask=1<>>0}enable(e){this.mask|=1<1){for(let e=0;e1){for(let e=0;e0&&(i.userData=this.userData),i.layers=this.layers.mask,i.matrix=this.matrix.toArray(),i.up=this.up.toArray(),!1===this.matrixAutoUpdate&&(i.matrixAutoUpdate=!1),this.isInstancedMesh&&(i.type="InstancedMesh",i.count=this.count,i.instanceMatrix=this.instanceMatrix.toJSON(),null!==this.instanceColor&&(i.instanceColor=this.instanceColor.toJSON())),this.isBatchedMesh&&(i.type="BatchedMesh",i.perObjectFrustumCulled=this.perObjectFrustumCulled,i.sortObjects=this.sortObjects,i.drawRanges=this._drawRanges,i.reservedRanges=this._reservedRanges,i.visibility=this._visibility,i.active=this._active,i.bounds=this._bounds.map((e=>({boxInitialized:e.boxInitialized,boxMin:e.box.min.toArray(),boxMax:e.box.max.toArray(),sphereInitialized:e.sphereInitialized,sphereRadius:e.sphere.radius,sphereCenter:e.sphere.center.toArray()}))),i.maxInstanceCount=this._maxInstanceCount,i.maxVertexCount=this._maxVertexCount,i.maxIndexCount=this._maxIndexCount,i.geometryInitialized=this._geometryInitialized,i.geometryCount=this._geometryCount,i.matricesTexture=this._matricesTexture.toJSON(e),null!==this._colorsTexture&&(i.colorsTexture=this._colorsTexture.toJSON(e)),null!==this.boundingSphere&&(i.boundingSphere={center:i.boundingSphere.center.toArray(),radius:i.boundingSphere.radius}),null!==this.boundingBox&&(i.boundingBox={min:i.boundingBox.min.toArray(),max:i.boundingBox.max.toArray()})),this.isScene)this.background&&(this.background.isColor?i.background=this.background.toJSON():this.background.isTexture&&(i.background=this.background.toJSON(e).uuid)),this.environment&&this.environment.isTexture&&!0!==this.environment.isRenderTargetTexture&&(i.environment=this.environment.toJSON(e).uuid);else if(this.isMesh||this.isLine||this.isPoints){i.geometry=r(e.geometries,this.geometry);const t=this.geometry.parameters;if(void 0!==t&&void 0!==t.shapes){const n=t.shapes;if(Array.isArray(n))for(let t=0,i=n.length;t0){i.children=[];for(let t=0;t0){i.animations=[];for(let t=0;t0&&(n.geometries=t),i.length>0&&(n.materials=i),r.length>0&&(n.textures=r),s.length>0&&(n.images=s),o.length>0&&(n.shapes=o),l.length>0&&(n.skeletons=l),c.length>0&&(n.animations=c),h.length>0&&(n.nodes=h)}return n.object=i,n;function a(e){const t=[];for(const n in e){const i=e[n];delete i.metadata,t.push(i)}return t}}clone(e){return(new this.constructor).copy(this,e)}copy(e,t=!0){if(this.name=e.name,this.up.copy(e.up),this.position.copy(e.position),this.rotation.order=e.rotation.order,this.quaternion.copy(e.quaternion),this.scale.copy(e.scale),this.matrix.copy(e.matrix),this.matrixWorld.copy(e.matrixWorld),this.matrixAutoUpdate=e.matrixAutoUpdate,this.matrixWorldAutoUpdate=e.matrixWorldAutoUpdate,this.matrixWorldNeedsUpdate=e.matrixWorldNeedsUpdate,this.layers.mask=e.layers.mask,this.visible=e.visible,this.castShadow=e.castShadow,this.receiveShadow=e.receiveShadow,this.frustumCulled=e.frustumCulled,this.renderOrder=e.renderOrder,this.animations=e.animations.slice(),this.userData=JSON.parse(JSON.stringify(e.userData)),!0===t)for(let t=0;t0?i.multiplyScalar(1/Math.sqrt(r)):i.set(0,0,0)}static getBarycoord(e,t,n,i,r){Kn.subVectors(i,t),Jn.subVectors(n,t),Qn.subVectors(e,t);const a=Kn.dot(Kn),s=Kn.dot(Jn),o=Kn.dot(Qn),l=Jn.dot(Jn),c=Jn.dot(Qn),h=a*l-s*s;if(0===h)return r.set(0,0,0),null;const d=1/h,u=(l*o-s*c)*d,p=(a*c-s*o)*d;return r.set(1-u-p,p,u)}static containsPoint(e,t,n,i){return null!==this.getBarycoord(e,t,n,i,$n)&&$n.x>=0&&$n.y>=0&&$n.x+$n.y<=1}static getInterpolation(e,t,n,i,r,a,s,o){return null===this.getBarycoord(e,t,n,i,$n)?(o.x=0,o.y=0,"z"in o&&(o.z=0),"w"in o&&(o.w=0),null):(o.setScalar(0),o.addScaledVector(r,$n.x),o.addScaledVector(a,$n.y),o.addScaledVector(s,$n.z),o)}static getInterpolatedAttribute(e,t,n,i,r,a){return si.setScalar(0),oi.setScalar(0),li.setScalar(0),si.fromBufferAttribute(e,t),oi.fromBufferAttribute(e,n),li.fromBufferAttribute(e,i),a.setScalar(0),a.addScaledVector(si,r.x),a.addScaledVector(oi,r.y),a.addScaledVector(li,r.z),a}static isFrontFacing(e,t,n,i){return Kn.subVectors(n,t),Jn.subVectors(e,t),Kn.cross(Jn).dot(i)<0}set(e,t,n){return this.a.copy(e),this.b.copy(t),this.c.copy(n),this}setFromPointsAndIndices(e,t,n,i){return this.a.copy(e[t]),this.b.copy(e[n]),this.c.copy(e[i]),this}setFromAttributeAndIndices(e,t,n,i){return this.a.fromBufferAttribute(e,t),this.b.fromBufferAttribute(e,n),this.c.fromBufferAttribute(e,i),this}clone(){return(new this.constructor).copy(this)}copy(e){return this.a.copy(e.a),this.b.copy(e.b),this.c.copy(e.c),this}getArea(){return Kn.subVectors(this.c,this.b),Jn.subVectors(this.a,this.b),.5*Kn.cross(Jn).length()}getMidpoint(e){return e.addVectors(this.a,this.b).add(this.c).multiplyScalar(1/3)}getNormal(e){return ci.getNormal(this.a,this.b,this.c,e)}getPlane(e){return e.setFromCoplanarPoints(this.a,this.b,this.c)}getBarycoord(e,t){return ci.getBarycoord(e,this.a,this.b,this.c,t)}getInterpolation(e,t,n,i,r){return ci.getInterpolation(e,this.a,this.b,this.c,t,n,i,r)}containsPoint(e){return ci.containsPoint(e,this.a,this.b,this.c)}isFrontFacing(e){return ci.isFrontFacing(this.a,this.b,this.c,e)}intersectsBox(e){return e.intersectsTriangle(this)}closestPointToPoint(e,t){const n=this.a,i=this.b,r=this.c;let a,s;ei.subVectors(i,n),ti.subVectors(r,n),ii.subVectors(e,n);const o=ei.dot(ii),l=ti.dot(ii);if(o<=0&&l<=0)return t.copy(n);ri.subVectors(e,i);const c=ei.dot(ri),h=ti.dot(ri);if(c>=0&&h<=c)return t.copy(i);const d=o*h-c*l;if(d<=0&&o>=0&&c<=0)return a=o/(o-c),t.copy(n).addScaledVector(ei,a);ai.subVectors(e,r);const u=ei.dot(ai),p=ti.dot(ai);if(p>=0&&u<=p)return t.copy(r);const f=u*l-o*p;if(f<=0&&l>=0&&p<=0)return s=l/(l-p),t.copy(n).addScaledVector(ti,s);const m=c*p-u*h;if(m<=0&&h-c>=0&&u-p>=0)return ni.subVectors(r,i),s=(h-c)/(h-c+(u-p)),t.copy(i).addScaledVector(ni,s);const g=1/(m+f+d);return a=f*g,s=d*g,t.copy(n).addScaledVector(ei,a).addScaledVector(ti,s)}equals(e){return e.a.equals(this.a)&&e.b.equals(this.b)&&e.c.equals(this.c)}}const hi={aliceblue:15792383,antiquewhite:16444375,aqua:65535,aquamarine:8388564,azure:15794175,beige:16119260,bisque:16770244,black:0,blanchedalmond:16772045,blue:255,blueviolet:9055202,brown:10824234,burlywood:14596231,cadetblue:6266528,chartreuse:8388352,chocolate:13789470,coral:16744272,cornflowerblue:6591981,cornsilk:16775388,crimson:14423100,cyan:65535,darkblue:139,darkcyan:35723,darkgoldenrod:12092939,darkgray:11119017,darkgreen:25600,darkgrey:11119017,darkkhaki:12433259,darkmagenta:9109643,darkolivegreen:5597999,darkorange:16747520,darkorchid:10040012,darkred:9109504,darksalmon:15308410,darkseagreen:9419919,darkslateblue:4734347,darkslategray:3100495,darkslategrey:3100495,darkturquoise:52945,darkviolet:9699539,deeppink:16716947,deepskyblue:49151,dimgray:6908265,dimgrey:6908265,dodgerblue:2003199,firebrick:11674146,floralwhite:16775920,forestgreen:2263842,fuchsia:16711935,gainsboro:14474460,ghostwhite:16316671,gold:16766720,goldenrod:14329120,gray:8421504,green:32768,greenyellow:11403055,grey:8421504,honeydew:15794160,hotpink:16738740,indianred:13458524,indigo:4915330,ivory:16777200,khaki:15787660,lavender:15132410,lavenderblush:16773365,lawngreen:8190976,lemonchiffon:16775885,lightblue:11393254,lightcoral:15761536,lightcyan:14745599,lightgoldenrodyellow:16448210,lightgray:13882323,lightgreen:9498256,lightgrey:13882323,lightpink:16758465,lightsalmon:16752762,lightseagreen:2142890,lightskyblue:8900346,lightslategray:7833753,lightslategrey:7833753,lightsteelblue:11584734,lightyellow:16777184,lime:65280,limegreen:3329330,linen:16445670,magenta:16711935,maroon:8388608,mediumaquamarine:6737322,mediumblue:205,mediumorchid:12211667,mediumpurple:9662683,mediumseagreen:3978097,mediumslateblue:8087790,mediumspringgreen:64154,mediumturquoise:4772300,mediumvioletred:13047173,midnightblue:1644912,mintcream:16121850,mistyrose:16770273,moccasin:16770229,navajowhite:16768685,navy:128,oldlace:16643558,olive:8421376,olivedrab:7048739,orange:16753920,orangered:16729344,orchid:14315734,palegoldenrod:15657130,palegreen:10025880,paleturquoise:11529966,palevioletred:14381203,papayawhip:16773077,peachpuff:16767673,peru:13468991,pink:16761035,plum:14524637,powderblue:11591910,purple:8388736,rebeccapurple:6697881,red:16711680,rosybrown:12357519,royalblue:4286945,saddlebrown:9127187,salmon:16416882,sandybrown:16032864,seagreen:3050327,seashell:16774638,sienna:10506797,silver:12632256,skyblue:8900331,slateblue:6970061,slategray:7372944,slategrey:7372944,snow:16775930,springgreen:65407,steelblue:4620980,tan:13808780,teal:32896,thistle:14204888,tomato:16737095,turquoise:4251856,violet:15631086,wheat:16113331,white:16777215,whitesmoke:16119285,yellow:16776960,yellowgreen:10145074},di={h:0,s:0,l:0},ui={h:0,s:0,l:0};function pi(e,t,n){return n<0&&(n+=1),n>1&&(n-=1),n<1/6?e+6*(t-e)*n:n<.5?t:n<2/3?e+6*(t-e)*(2/3-n):e}class fi{constructor(e,t,n){return this.isColor=!0,this.r=1,this.g=1,this.b=1,this.set(e,t,n)}set(e,t,n){if(void 0===t&&void 0===n){const t=e;t&&t.isColor?this.copy(t):"number"==typeof t?this.setHex(t):"string"==typeof t&&this.setStyle(t)}else this.setRGB(e,t,n);return this}setScalar(e){return this.r=e,this.g=e,this.b=e,this}setHex(e,t=Ge){return e=Math.floor(e),this.r=(e>>16&255)/255,this.g=(e>>8&255)/255,this.b=(255&e)/255,Rt.toWorkingColorSpace(this,t),this}setRGB(e,t,n,i=Rt.workingColorSpace){return this.r=e,this.g=t,this.b=n,Rt.toWorkingColorSpace(this,i),this}setHSL(e,t,n,i=Rt.workingColorSpace){if(e=ut(e,1),t=dt(t,0,1),n=dt(n,0,1),0===t)this.r=this.g=this.b=n;else{const i=n<=.5?n*(1+t):n+t-n*t,r=2*n-i;this.r=pi(r,i,e+1/3),this.g=pi(r,i,e),this.b=pi(r,i,e-1/3)}return Rt.toWorkingColorSpace(this,i),this}setStyle(e,t=Ge){function n(t){void 0!==t&&parseFloat(t)<1&&console.warn("THREE.Color: Alpha component of "+e+" will be ignored.")}let i;if(i=/^(\w+)\(([^\)]*)\)/.exec(e)){let r;const a=i[1],s=i[2];switch(a){case"rgb":case"rgba":if(r=/^\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(s))return n(r[4]),this.setRGB(Math.min(255,parseInt(r[1],10))/255,Math.min(255,parseInt(r[2],10))/255,Math.min(255,parseInt(r[3],10))/255,t);if(r=/^\s*(\d+)\%\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(s))return n(r[4]),this.setRGB(Math.min(100,parseInt(r[1],10))/100,Math.min(100,parseInt(r[2],10))/100,Math.min(100,parseInt(r[3],10))/100,t);break;case"hsl":case"hsla":if(r=/^\s*(\d*\.?\d+)\s*,\s*(\d*\.?\d+)\%\s*,\s*(\d*\.?\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(s))return n(r[4]),this.setHSL(parseFloat(r[1])/360,parseFloat(r[2])/100,parseFloat(r[3])/100,t);break;default:console.warn("THREE.Color: Unknown color model "+e)}}else if(i=/^\#([A-Fa-f\d]+)$/.exec(e)){const n=i[1],r=n.length;if(3===r)return this.setRGB(parseInt(n.charAt(0),16)/15,parseInt(n.charAt(1),16)/15,parseInt(n.charAt(2),16)/15,t);if(6===r)return this.setHex(parseInt(n,16),t);console.warn("THREE.Color: Invalid hex color "+e)}else if(e&&e.length>0)return this.setColorName(e,t);return this}setColorName(e,t=Ge){const n=hi[e.toLowerCase()];return void 0!==n?this.setHex(n,t):console.warn("THREE.Color: Unknown color "+e),this}clone(){return new this.constructor(this.r,this.g,this.b)}copy(e){return this.r=e.r,this.g=e.g,this.b=e.b,this}copySRGBToLinear(e){return this.r=Ct(e.r),this.g=Ct(e.g),this.b=Ct(e.b),this}copyLinearToSRGB(e){return this.r=Dt(e.r),this.g=Dt(e.g),this.b=Dt(e.b),this}convertSRGBToLinear(){return this.copySRGBToLinear(this),this}convertLinearToSRGB(){return this.copyLinearToSRGB(this),this}getHex(e=Ge){return Rt.fromWorkingColorSpace(mi.copy(this),e),65536*Math.round(dt(255*mi.r,0,255))+256*Math.round(dt(255*mi.g,0,255))+Math.round(dt(255*mi.b,0,255))}getHexString(e=Ge){return("000000"+this.getHex(e).toString(16)).slice(-6)}getHSL(e,t=Rt.workingColorSpace){Rt.fromWorkingColorSpace(mi.copy(this),t);const n=mi.r,i=mi.g,r=mi.b,a=Math.max(n,i,r),s=Math.min(n,i,r);let o,l;const c=(s+a)/2;if(s===a)o=0,l=0;else{const e=a-s;switch(l=c<=.5?e/(a+s):e/(2-a-s),a){case n:o=(i-r)/e+(i0!=e>0&&this.version++,this._alphaTest=e}onBeforeRender(){}onBeforeCompile(){}customProgramCacheKey(){return this.onBeforeCompile.toString()}setValues(e){if(void 0!==e)for(const t in e){const n=e[t];if(void 0===n){console.warn(`THREE.Material: parameter '${t}' has value of undefined.`);continue}const i=this[t];void 0!==i?i&&i.isColor?i.set(n):i&&i.isVector3&&n&&n.isVector3?i.copy(n):this[t]=n:console.warn(`THREE.Material: '${t}' is not a property of THREE.${this.type}.`)}}toJSON(e){const t=void 0===e||"string"==typeof e;t&&(e={textures:{},images:{}});const n={metadata:{version:4.6,type:"Material",generator:"Material.toJSON"}};function i(e){const t=[];for(const n in e){const i=e[n];delete i.metadata,t.push(i)}return t}if(n.uuid=this.uuid,n.type=this.type,""!==this.name&&(n.name=this.name),this.color&&this.color.isColor&&(n.color=this.color.getHex()),void 0!==this.roughness&&(n.roughness=this.roughness),void 0!==this.metalness&&(n.metalness=this.metalness),void 0!==this.sheen&&(n.sheen=this.sheen),this.sheenColor&&this.sheenColor.isColor&&(n.sheenColor=this.sheenColor.getHex()),void 0!==this.sheenRoughness&&(n.sheenRoughness=this.sheenRoughness),this.emissive&&this.emissive.isColor&&(n.emissive=this.emissive.getHex()),void 0!==this.emissiveIntensity&&1!==this.emissiveIntensity&&(n.emissiveIntensity=this.emissiveIntensity),this.specular&&this.specular.isColor&&(n.specular=this.specular.getHex()),void 0!==this.specularIntensity&&(n.specularIntensity=this.specularIntensity),this.specularColor&&this.specularColor.isColor&&(n.specularColor=this.specularColor.getHex()),void 0!==this.shininess&&(n.shininess=this.shininess),void 0!==this.clearcoat&&(n.clearcoat=this.clearcoat),void 0!==this.clearcoatRoughness&&(n.clearcoatRoughness=this.clearcoatRoughness),this.clearcoatMap&&this.clearcoatMap.isTexture&&(n.clearcoatMap=this.clearcoatMap.toJSON(e).uuid),this.clearcoatRoughnessMap&&this.clearcoatRoughnessMap.isTexture&&(n.clearcoatRoughnessMap=this.clearcoatRoughnessMap.toJSON(e).uuid),this.clearcoatNormalMap&&this.clearcoatNormalMap.isTexture&&(n.clearcoatNormalMap=this.clearcoatNormalMap.toJSON(e).uuid,n.clearcoatNormalScale=this.clearcoatNormalScale.toArray()),void 0!==this.dispersion&&(n.dispersion=this.dispersion),void 0!==this.iridescence&&(n.iridescence=this.iridescence),void 0!==this.iridescenceIOR&&(n.iridescenceIOR=this.iridescenceIOR),void 0!==this.iridescenceThicknessRange&&(n.iridescenceThicknessRange=this.iridescenceThicknessRange),this.iridescenceMap&&this.iridescenceMap.isTexture&&(n.iridescenceMap=this.iridescenceMap.toJSON(e).uuid),this.iridescenceThicknessMap&&this.iridescenceThicknessMap.isTexture&&(n.iridescenceThicknessMap=this.iridescenceThicknessMap.toJSON(e).uuid),void 0!==this.anisotropy&&(n.anisotropy=this.anisotropy),void 0!==this.anisotropyRotation&&(n.anisotropyRotation=this.anisotropyRotation),this.anisotropyMap&&this.anisotropyMap.isTexture&&(n.anisotropyMap=this.anisotropyMap.toJSON(e).uuid),this.map&&this.map.isTexture&&(n.map=this.map.toJSON(e).uuid),this.matcap&&this.matcap.isTexture&&(n.matcap=this.matcap.toJSON(e).uuid),this.alphaMap&&this.alphaMap.isTexture&&(n.alphaMap=this.alphaMap.toJSON(e).uuid),this.lightMap&&this.lightMap.isTexture&&(n.lightMap=this.lightMap.toJSON(e).uuid,n.lightMapIntensity=this.lightMapIntensity),this.aoMap&&this.aoMap.isTexture&&(n.aoMap=this.aoMap.toJSON(e).uuid,n.aoMapIntensity=this.aoMapIntensity),this.bumpMap&&this.bumpMap.isTexture&&(n.bumpMap=this.bumpMap.toJSON(e).uuid,n.bumpScale=this.bumpScale),this.normalMap&&this.normalMap.isTexture&&(n.normalMap=this.normalMap.toJSON(e).uuid,n.normalMapType=this.normalMapType,n.normalScale=this.normalScale.toArray()),this.displacementMap&&this.displacementMap.isTexture&&(n.displacementMap=this.displacementMap.toJSON(e).uuid,n.displacementScale=this.displacementScale,n.displacementBias=this.displacementBias),this.roughnessMap&&this.roughnessMap.isTexture&&(n.roughnessMap=this.roughnessMap.toJSON(e).uuid),this.metalnessMap&&this.metalnessMap.isTexture&&(n.metalnessMap=this.metalnessMap.toJSON(e).uuid),this.emissiveMap&&this.emissiveMap.isTexture&&(n.emissiveMap=this.emissiveMap.toJSON(e).uuid),this.specularMap&&this.specularMap.isTexture&&(n.specularMap=this.specularMap.toJSON(e).uuid),this.specularIntensityMap&&this.specularIntensityMap.isTexture&&(n.specularIntensityMap=this.specularIntensityMap.toJSON(e).uuid),this.specularColorMap&&this.specularColorMap.isTexture&&(n.specularColorMap=this.specularColorMap.toJSON(e).uuid),this.envMap&&this.envMap.isTexture&&(n.envMap=this.envMap.toJSON(e).uuid,void 0!==this.combine&&(n.combine=this.combine)),void 0!==this.envMapRotation&&(n.envMapRotation=this.envMapRotation.toArray()),void 0!==this.envMapIntensity&&(n.envMapIntensity=this.envMapIntensity),void 0!==this.reflectivity&&(n.reflectivity=this.reflectivity),void 0!==this.refractionRatio&&(n.refractionRatio=this.refractionRatio),this.gradientMap&&this.gradientMap.isTexture&&(n.gradientMap=this.gradientMap.toJSON(e).uuid),void 0!==this.transmission&&(n.transmission=this.transmission),this.transmissionMap&&this.transmissionMap.isTexture&&(n.transmissionMap=this.transmissionMap.toJSON(e).uuid),void 0!==this.thickness&&(n.thickness=this.thickness),this.thicknessMap&&this.thicknessMap.isTexture&&(n.thicknessMap=this.thicknessMap.toJSON(e).uuid),void 0!==this.attenuationDistance&&this.attenuationDistance!==1/0&&(n.attenuationDistance=this.attenuationDistance),void 0!==this.attenuationColor&&(n.attenuationColor=this.attenuationColor.getHex()),void 0!==this.size&&(n.size=this.size),null!==this.shadowSide&&(n.shadowSide=this.shadowSide),void 0!==this.sizeAttenuation&&(n.sizeAttenuation=this.sizeAttenuation),1!==this.blending&&(n.blending=this.blending),0!==this.side&&(n.side=this.side),!0===this.vertexColors&&(n.vertexColors=!0),this.opacity<1&&(n.opacity=this.opacity),!0===this.transparent&&(n.transparent=!0),204!==this.blendSrc&&(n.blendSrc=this.blendSrc),205!==this.blendDst&&(n.blendDst=this.blendDst),this.blendEquation!==s&&(n.blendEquation=this.blendEquation),null!==this.blendSrcAlpha&&(n.blendSrcAlpha=this.blendSrcAlpha),null!==this.blendDstAlpha&&(n.blendDstAlpha=this.blendDstAlpha),null!==this.blendEquationAlpha&&(n.blendEquationAlpha=this.blendEquationAlpha),this.blendColor&&this.blendColor.isColor&&(n.blendColor=this.blendColor.getHex()),0!==this.blendAlpha&&(n.blendAlpha=this.blendAlpha),3!==this.depthFunc&&(n.depthFunc=this.depthFunc),!1===this.depthTest&&(n.depthTest=this.depthTest),!1===this.depthWrite&&(n.depthWrite=this.depthWrite),!1===this.colorWrite&&(n.colorWrite=this.colorWrite),255!==this.stencilWriteMask&&(n.stencilWriteMask=this.stencilWriteMask),519!==this.stencilFunc&&(n.stencilFunc=this.stencilFunc),0!==this.stencilRef&&(n.stencilRef=this.stencilRef),255!==this.stencilFuncMask&&(n.stencilFuncMask=this.stencilFuncMask),this.stencilFail!==Ye&&(n.stencilFail=this.stencilFail),this.stencilZFail!==Ye&&(n.stencilZFail=this.stencilZFail),this.stencilZPass!==Ye&&(n.stencilZPass=this.stencilZPass),!0===this.stencilWrite&&(n.stencilWrite=this.stencilWrite),void 0!==this.rotation&&0!==this.rotation&&(n.rotation=this.rotation),!0===this.polygonOffset&&(n.polygonOffset=!0),0!==this.polygonOffsetFactor&&(n.polygonOffsetFactor=this.polygonOffsetFactor),0!==this.polygonOffsetUnits&&(n.polygonOffsetUnits=this.polygonOffsetUnits),void 0!==this.linewidth&&1!==this.linewidth&&(n.linewidth=this.linewidth),void 0!==this.dashSize&&(n.dashSize=this.dashSize),void 0!==this.gapSize&&(n.gapSize=this.gapSize),void 0!==this.scale&&(n.scale=this.scale),!0===this.dithering&&(n.dithering=!0),this.alphaTest>0&&(n.alphaTest=this.alphaTest),!0===this.alphaHash&&(n.alphaHash=!0),!0===this.alphaToCoverage&&(n.alphaToCoverage=!0),!0===this.premultipliedAlpha&&(n.premultipliedAlpha=!0),!0===this.forceSinglePass&&(n.forceSinglePass=!0),!0===this.wireframe&&(n.wireframe=!0),this.wireframeLinewidth>1&&(n.wireframeLinewidth=this.wireframeLinewidth),"round"!==this.wireframeLinecap&&(n.wireframeLinecap=this.wireframeLinecap),"round"!==this.wireframeLinejoin&&(n.wireframeLinejoin=this.wireframeLinejoin),!0===this.flatShading&&(n.flatShading=!0),!1===this.visible&&(n.visible=!1),!1===this.toneMapped&&(n.toneMapped=!1),!1===this.fog&&(n.fog=!1),Object.keys(this.userData).length>0&&(n.userData=this.userData),t){const t=i(e.textures),r=i(e.images);t.length>0&&(n.textures=t),r.length>0&&(n.images=r)}return n}clone(){return(new this.constructor).copy(this)}copy(e){this.name=e.name,this.blending=e.blending,this.side=e.side,this.vertexColors=e.vertexColors,this.opacity=e.opacity,this.transparent=e.transparent,this.blendSrc=e.blendSrc,this.blendDst=e.blendDst,this.blendEquation=e.blendEquation,this.blendSrcAlpha=e.blendSrcAlpha,this.blendDstAlpha=e.blendDstAlpha,this.blendEquationAlpha=e.blendEquationAlpha,this.blendColor.copy(e.blendColor),this.blendAlpha=e.blendAlpha,this.depthFunc=e.depthFunc,this.depthTest=e.depthTest,this.depthWrite=e.depthWrite,this.stencilWriteMask=e.stencilWriteMask,this.stencilFunc=e.stencilFunc,this.stencilRef=e.stencilRef,this.stencilFuncMask=e.stencilFuncMask,this.stencilFail=e.stencilFail,this.stencilZFail=e.stencilZFail,this.stencilZPass=e.stencilZPass,this.stencilWrite=e.stencilWrite;const t=e.clippingPlanes;let n=null;if(null!==t){const e=t.length;n=new Array(e);for(let i=0;i!==e;++i)n[i]=t[i].clone()}return this.clippingPlanes=n,this.clipIntersection=e.clipIntersection,this.clipShadows=e.clipShadows,this.shadowSide=e.shadowSide,this.colorWrite=e.colorWrite,this.precision=e.precision,this.polygonOffset=e.polygonOffset,this.polygonOffsetFactor=e.polygonOffsetFactor,this.polygonOffsetUnits=e.polygonOffsetUnits,this.dithering=e.dithering,this.alphaTest=e.alphaTest,this.alphaHash=e.alphaHash,this.alphaToCoverage=e.alphaToCoverage,this.premultipliedAlpha=e.premultipliedAlpha,this.forceSinglePass=e.forceSinglePass,this.visible=e.visible,this.toneMapped=e.toneMapped,this.userData=JSON.parse(JSON.stringify(e.userData)),this}dispose(){this.dispatchEvent({type:"dispose"})}set needsUpdate(e){!0===e&&this.version++}onBuild(){console.warn("Material: onBuild() has been removed.")}}class _i extends vi{constructor(e){super(),this.isMeshBasicMaterial=!0,this.type="MeshBasicMaterial",this.color=new fi(16777215),this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new Ln,this.combine=0,this.reflectivity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.specularMap=e.specularMap,this.alphaMap=e.alphaMap,this.envMap=e.envMap,this.envMapRotation.copy(e.envMapRotation),this.combine=e.combine,this.reflectivity=e.reflectivity,this.refractionRatio=e.refractionRatio,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.fog=e.fog,this}}const xi=yi();function yi(){const e=new ArrayBuffer(4),t=new Float32Array(e),n=new Uint32Array(e),i=new Uint32Array(512),r=new Uint32Array(512);for(let e=0;e<256;++e){const t=e-127;t<-27?(i[e]=0,i[256|e]=32768,r[e]=24,r[256|e]=24):t<-14?(i[e]=1024>>-t-14,i[256|e]=1024>>-t-14|32768,r[e]=-t-1,r[256|e]=-t-1):t<=15?(i[e]=t+15<<10,i[256|e]=t+15<<10|32768,r[e]=13,r[256|e]=13):t<128?(i[e]=31744,i[256|e]=64512,r[e]=24,r[256|e]=24):(i[e]=31744,i[256|e]=64512,r[e]=13,r[256|e]=13)}const a=new Uint32Array(2048),s=new Uint32Array(64),o=new Uint32Array(64);for(let e=1;e<1024;++e){let t=e<<13,n=0;for(;!(8388608&t);)t<<=1,n-=8388608;t&=-8388609,n+=947912704,a[e]=t|n}for(let e=1024;e<2048;++e)a[e]=939524096+(e-1024<<13);for(let e=1;e<31;++e)s[e]=e<<23;s[31]=1199570944,s[32]=2147483648;for(let e=33;e<63;++e)s[e]=2147483648+(e-32<<23);s[63]=3347054592;for(let e=1;e<64;++e)32!==e&&(o[e]=1024);return{floatView:t,uint32View:n,baseTable:i,shiftTable:r,mantissaTable:a,exponentTable:s,offsetTable:o}}const Si={toHalfFloat:function(e){Math.abs(e)>65504&&console.warn("THREE.DataUtils.toHalfFloat(): Value out of range."),e=dt(e,-65504,65504),xi.floatView[0]=e;const t=xi.uint32View[0],n=t>>23&511;return xi.baseTable[n]+((8388607&t)>>xi.shiftTable[n])},fromHalfFloat:function(e){const t=e>>10;return xi.uint32View[0]=xi.mantissaTable[xi.offsetTable[t]+(1023&e)]+xi.exponentTable[t],xi.floatView[0]}},wi=new jt,bi=new _t;class Mi{constructor(e,t,n=!1){if(Array.isArray(e))throw new TypeError("THREE.BufferAttribute: array should be a Typed Array.");this.isBufferAttribute=!0,this.name="",this.array=e,this.itemSize=t,this.count=void 0!==e?e.length/t:0,this.normalized=n,this.usage=nt,this.updateRanges=[],this.gpuType=Z,this.version=0}onUploadCallback(){}set needsUpdate(e){!0===e&&this.version++}setUsage(e){return this.usage=e,this}addUpdateRange(e,t){this.updateRanges.push({start:e,count:t})}clearUpdateRanges(){this.updateRanges.length=0}copy(e){return this.name=e.name,this.array=new e.array.constructor(e.array),this.itemSize=e.itemSize,this.count=e.count,this.normalized=e.normalized,this.usage=e.usage,this.gpuType=e.gpuType,this}copyAt(e,t,n){e*=this.itemSize,n*=t.itemSize;for(let i=0,r=this.itemSize;it.count&&console.warn("THREE.BufferGeometry: Buffer size too small for points data. Use .dispose() and create a new geometry."),t.needsUpdate=!0}return this}computeBoundingBox(){null===this.boundingBox&&(this.boundingBox=new qt);const e=this.attributes.position,t=this.morphAttributes.position;if(e&&e.isGLBufferAttribute)return console.error("THREE.BufferGeometry.computeBoundingBox(): GLBufferAttribute requires a manual bounding box.",this),void this.boundingBox.set(new jt(-1/0,-1/0,-1/0),new jt(1/0,1/0,1/0));if(void 0!==e){if(this.boundingBox.setFromBufferAttribute(e),t)for(let e=0,n=t.length;e0&&(e.userData=this.userData),void 0!==this.parameters){const t=this.parameters;for(const n in t)void 0!==t[n]&&(e[n]=t[n]);return e}e.data={attributes:{}};const t=this.index;null!==t&&(e.data.index={type:t.array.constructor.name,array:Array.prototype.slice.call(t.array)});const n=this.attributes;for(const t in n){const i=n[t];e.data.attributes[t]=i.toJSON(e.data)}const i={};let r=!1;for(const t in this.morphAttributes){const n=this.morphAttributes[t],a=[];for(let t=0,i=n.length;t0&&(i[t]=a,r=!0)}r&&(e.data.morphAttributes=i,e.data.morphTargetsRelative=this.morphTargetsRelative);const a=this.groups;a.length>0&&(e.data.groups=JSON.parse(JSON.stringify(a)));const s=this.boundingSphere;return null!==s&&(e.data.boundingSphere={center:s.center.toArray(),radius:s.radius}),e}clone(){return(new this.constructor).copy(this)}copy(e){this.index=null,this.attributes={},this.morphAttributes={},this.groups=[],this.boundingBox=null,this.boundingSphere=null;const t={};this.name=e.name;const n=e.index;null!==n&&this.setIndex(n.clone(t));const i=e.attributes;for(const e in i){const n=i[e];this.setAttribute(e,n.clone(t))}const r=e.morphAttributes;for(const e in r){const n=[],i=r[e];for(let e=0,r=i.length;e0){const n=e[t[0]];if(void 0!==n){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let e=0,t=n.length;e(e.far-e.near)**2)return}Ni.copy(r).invert(),Fi.copy(e.ray).applyMatrix4(Ni),null!==n.boundingBox&&!1===Fi.intersectsBox(n.boundingBox)||this._computeIntersections(e,t,Fi)}}_computeIntersections(e,t,n){let i;const r=this.geometry,a=this.material,s=r.index,o=r.attributes.position,l=r.attributes.uv,c=r.attributes.uv1,h=r.attributes.normal,d=r.groups,u=r.drawRange;if(null!==s)if(Array.isArray(a))for(let r=0,o=d.length;rn.far?null:{distance:c,point:Xi.clone(),object:e}}(e,t,n,i,ki,Hi,Vi,ji);if(h){const e=new jt;ci.getBarycoord(ji,ki,Hi,Vi,e),r&&(h.uv=ci.getInterpolatedAttribute(r,o,l,c,e,new _t)),a&&(h.uv1=ci.getInterpolatedAttribute(a,o,l,c,e,new _t)),s&&(h.normal=ci.getInterpolatedAttribute(s,o,l,c,e,new jt),h.normal.dot(i.direction)>0&&h.normal.multiplyScalar(-1));const t={a:o,b:l,c,normal:new jt,materialIndex:0};ci.getNormal(ki,Hi,Vi,t.normal),h.face=t,h.barycoord=e}return h}class Zi extends Oi{constructor(e=1,t=1,n=1,i=1,r=1,a=1){super(),this.type="BoxGeometry",this.parameters={width:e,height:t,depth:n,widthSegments:i,heightSegments:r,depthSegments:a};const s=this;i=Math.floor(i),r=Math.floor(r),a=Math.floor(a);const o=[],l=[],c=[],h=[];let d=0,u=0;function p(e,t,n,i,r,a,p,f,m,g,v){const _=a/m,x=p/g,y=a/2,S=p/2,w=f/2,b=m+1,M=g+1;let T=0,E=0;const A=new jt;for(let a=0;a0?1:-1,c.push(A.x,A.y,A.z),h.push(o/m),h.push(1-a/g),T+=1}}for(let e=0;e0&&(t.defines=this.defines),t.vertexShader=this.vertexShader,t.fragmentShader=this.fragmentShader,t.lights=this.lights,t.clipping=this.clipping;const n={};for(const e in this.extensions)!0===this.extensions[e]&&(n[e]=!0);return Object.keys(n).length>0&&(t.extensions=n),t}}class tr extends Zn{constructor(){super(),this.isCamera=!0,this.type="Camera",this.matrixWorldInverse=new wn,this.projectionMatrix=new wn,this.projectionMatrixInverse=new wn,this.coordinateSystem=rt}copy(e,t){return super.copy(e,t),this.matrixWorldInverse.copy(e.matrixWorldInverse),this.projectionMatrix.copy(e.projectionMatrix),this.projectionMatrixInverse.copy(e.projectionMatrixInverse),this.coordinateSystem=e.coordinateSystem,this}getWorldDirection(e){return super.getWorldDirection(e).negate()}updateMatrixWorld(e){super.updateMatrixWorld(e),this.matrixWorldInverse.copy(this.matrixWorld).invert()}updateWorldMatrix(e,t){super.updateWorldMatrix(e,t),this.matrixWorldInverse.copy(this.matrixWorld).invert()}clone(){return(new this.constructor).copy(this)}}const nr=new jt,ir=new _t,rr=new _t;class ar extends tr{constructor(e=50,t=1,n=.1,i=2e3){super(),this.isPerspectiveCamera=!0,this.type="PerspectiveCamera",this.fov=e,this.zoom=1,this.near=n,this.far=i,this.focus=10,this.aspect=t,this.view=null,this.filmGauge=35,this.filmOffset=0,this.updateProjectionMatrix()}copy(e,t){return super.copy(e,t),this.fov=e.fov,this.zoom=e.zoom,this.near=e.near,this.far=e.far,this.focus=e.focus,this.aspect=e.aspect,this.view=null===e.view?null:Object.assign({},e.view),this.filmGauge=e.filmGauge,this.filmOffset=e.filmOffset,this}setFocalLength(e){const t=.5*this.getFilmHeight()/e;this.fov=2*ct*Math.atan(t),this.updateProjectionMatrix()}getFocalLength(){const e=Math.tan(.5*lt*this.fov);return.5*this.getFilmHeight()/e}getEffectiveFOV(){return 2*ct*Math.atan(Math.tan(.5*lt*this.fov)/this.zoom)}getFilmWidth(){return this.filmGauge*Math.min(this.aspect,1)}getFilmHeight(){return this.filmGauge/Math.max(this.aspect,1)}getViewBounds(e,t,n){nr.set(-1,-1,.5).applyMatrix4(this.projectionMatrixInverse),t.set(nr.x,nr.y).multiplyScalar(-e/nr.z),nr.set(1,1,.5).applyMatrix4(this.projectionMatrixInverse),n.set(nr.x,nr.y).multiplyScalar(-e/nr.z)}getViewSize(e,t){return this.getViewBounds(e,ir,rr),t.subVectors(rr,ir)}setViewOffset(e,t,n,i,r,a){this.aspect=e/t,null===this.view&&(this.view={enabled:!0,fullWidth:1,fullHeight:1,offsetX:0,offsetY:0,width:1,height:1}),this.view.enabled=!0,this.view.fullWidth=e,this.view.fullHeight=t,this.view.offsetX=n,this.view.offsetY=i,this.view.width=r,this.view.height=a,this.updateProjectionMatrix()}clearViewOffset(){null!==this.view&&(this.view.enabled=!1),this.updateProjectionMatrix()}updateProjectionMatrix(){const e=this.near;let t=e*Math.tan(.5*lt*this.fov)/this.zoom,n=2*t,i=this.aspect*n,r=-.5*i;const a=this.view;if(null!==this.view&&this.view.enabled){const e=a.fullWidth,s=a.fullHeight;r+=a.offsetX*i/e,t-=a.offsetY*n/s,i*=a.width/e,n*=a.height/s}const s=this.filmOffset;0!==s&&(r+=e*s/this.getFilmWidth()),this.projectionMatrix.makePerspective(r,r+i,t,t-n,e,this.far,this.coordinateSystem),this.projectionMatrixInverse.copy(this.projectionMatrix).invert()}toJSON(e){const t=super.toJSON(e);return t.object.fov=this.fov,t.object.zoom=this.zoom,t.object.near=this.near,t.object.far=this.far,t.object.focus=this.focus,t.object.aspect=this.aspect,null!==this.view&&(t.object.view=Object.assign({},this.view)),t.object.filmGauge=this.filmGauge,t.object.filmOffset=this.filmOffset,t}}const sr=-90;class or extends Zn{constructor(e,t,n){super(),this.type="CubeCamera",this.renderTarget=n,this.coordinateSystem=null,this.activeMipmapLevel=0;const i=new ar(sr,1,e,t);i.layers=this.layers,this.add(i);const r=new ar(sr,1,e,t);r.layers=this.layers,this.add(r);const a=new ar(sr,1,e,t);a.layers=this.layers,this.add(a);const s=new ar(sr,1,e,t);s.layers=this.layers,this.add(s);const o=new ar(sr,1,e,t);o.layers=this.layers,this.add(o);const l=new ar(sr,1,e,t);l.layers=this.layers,this.add(l)}updateCoordinateSystem(){const e=this.coordinateSystem,t=this.children.concat(),[n,i,r,a,s,o]=t;for(const e of t)this.remove(e);if(e===rt)n.up.set(0,1,0),n.lookAt(1,0,0),i.up.set(0,1,0),i.lookAt(-1,0,0),r.up.set(0,0,-1),r.lookAt(0,1,0),a.up.set(0,0,1),a.lookAt(0,-1,0),s.up.set(0,1,0),s.lookAt(0,0,1),o.up.set(0,1,0),o.lookAt(0,0,-1);else{if(e!==at)throw new Error("THREE.CubeCamera.updateCoordinateSystem(): Invalid coordinate system: "+e);n.up.set(0,-1,0),n.lookAt(-1,0,0),i.up.set(0,-1,0),i.lookAt(1,0,0),r.up.set(0,0,1),r.lookAt(0,1,0),a.up.set(0,0,-1),a.lookAt(0,-1,0),s.up.set(0,-1,0),s.lookAt(0,0,1),o.up.set(0,-1,0),o.lookAt(0,0,-1)}for(const e of t)this.add(e),e.updateMatrixWorld()}update(e,t){null===this.parent&&this.updateMatrixWorld();const{renderTarget:n,activeMipmapLevel:i}=this;this.coordinateSystem!==e.coordinateSystem&&(this.coordinateSystem=e.coordinateSystem,this.updateCoordinateSystem());const[r,a,s,o,l,c]=this.children,h=e.getRenderTarget(),d=e.getActiveCubeFace(),u=e.getActiveMipmapLevel(),p=e.xr.enabled;e.xr.enabled=!1;const f=n.texture.generateMipmaps;n.texture.generateMipmaps=!1,e.setRenderTarget(n,0,i),e.render(t,r),e.setRenderTarget(n,1,i),e.render(t,a),e.setRenderTarget(n,2,i),e.render(t,s),e.setRenderTarget(n,3,i),e.render(t,o),e.setRenderTarget(n,4,i),e.render(t,l),n.texture.generateMipmaps=f,e.setRenderTarget(n,5,i),e.render(t,c),e.setRenderTarget(h,d,u),e.xr.enabled=p,n.texture.needsPMREMUpdate=!0}}class lr extends Bt{constructor(e,t,n,i,r,a,s,o,l,c){super(e=void 0!==e?e:[],t=void 0!==t?t:I,n,i,r,a,s,o,l,c),this.isCubeTexture=!0,this.flipY=!1}get images(){return this.image}set images(e){this.image=e}}class cr extends Ht{constructor(e=1,t={}){super(e,e,t),this.isWebGLCubeRenderTarget=!0;const n={width:e,height:e,depth:1},i=[n,n,n,n,n,n];this.texture=new lr(i,t.mapping,t.wrapS,t.wrapT,t.magFilter,t.minFilter,t.format,t.type,t.anisotropy,t.colorSpace),this.texture.isRenderTargetTexture=!0,this.texture.generateMipmaps=void 0!==t.generateMipmaps&&t.generateMipmaps,this.texture.minFilter=void 0!==t.minFilter?t.minFilter:V}fromEquirectangularTexture(e,t){this.texture.type=t.type,this.texture.colorSpace=t.colorSpace,this.texture.generateMipmaps=t.generateMipmaps,this.texture.minFilter=t.minFilter,this.texture.magFilter=t.magFilter;const n={tEquirect:{value:null}},i="\n\n\t\t\t\tvarying vec3 vWorldDirection;\n\n\t\t\t\tvec3 transformDirection( in vec3 dir, in mat4 matrix ) {\n\n\t\t\t\t\treturn normalize( ( matrix * vec4( dir, 0.0 ) ).xyz );\n\n\t\t\t\t}\n\n\t\t\t\tvoid main() {\n\n\t\t\t\t\tvWorldDirection = transformDirection( position, modelMatrix );\n\n\t\t\t\t\t#include \n\t\t\t\t\t#include \n\n\t\t\t\t}\n\t\t\t",r="\n\n\t\t\t\tuniform sampler2D tEquirect;\n\n\t\t\t\tvarying vec3 vWorldDirection;\n\n\t\t\t\t#include \n\n\t\t\t\tvoid main() {\n\n\t\t\t\t\tvec3 direction = normalize( vWorldDirection );\n\n\t\t\t\t\tvec2 sampleUV = equirectUv( direction );\n\n\t\t\t\t\tgl_FragColor = texture2D( tEquirect, sampleUV );\n\n\t\t\t\t}\n\t\t\t",a=new Zi(5,5,5),s=new er({name:"CubemapFromEquirect",uniforms:Ki(n),vertexShader:i,fragmentShader:r,side:1,blending:0});s.uniforms.tEquirect.value=t;const o=new Yi(a,s),l=t.minFilter;return t.minFilter===W&&(t.minFilter=V),new or(1,10,this).update(e,o),t.minFilter=l,o.geometry.dispose(),o.material.dispose(),this}clear(e,t,n,i){const r=e.getRenderTarget();for(let r=0;r<6;r++)e.setRenderTarget(this,r),e.clear(t,n,i);e.setRenderTarget(r)}}class hr extends Zn{constructor(){super(),this.isScene=!0,this.type="Scene",this.background=null,this.environment=null,this.fog=null,this.backgroundBlurriness=0,this.backgroundIntensity=1,this.backgroundRotation=new Ln,this.environmentIntensity=1,this.environmentRotation=new Ln,this.overrideMaterial=null,"undefined"!=typeof __THREE_DEVTOOLS__&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}copy(e,t){return super.copy(e,t),null!==e.background&&(this.background=e.background.clone()),null!==e.environment&&(this.environment=e.environment.clone()),null!==e.fog&&(this.fog=e.fog.clone()),this.backgroundBlurriness=e.backgroundBlurriness,this.backgroundIntensity=e.backgroundIntensity,this.backgroundRotation.copy(e.backgroundRotation),this.environmentIntensity=e.environmentIntensity,this.environmentRotation.copy(e.environmentRotation),null!==e.overrideMaterial&&(this.overrideMaterial=e.overrideMaterial.clone()),this.matrixAutoUpdate=e.matrixAutoUpdate,this}toJSON(e){const t=super.toJSON(e);return null!==this.fog&&(t.object.fog=this.fog.toJSON()),this.backgroundBlurriness>0&&(t.object.backgroundBlurriness=this.backgroundBlurriness),1!==this.backgroundIntensity&&(t.object.backgroundIntensity=this.backgroundIntensity),t.object.backgroundRotation=this.backgroundRotation.toArray(),1!==this.environmentIntensity&&(t.object.environmentIntensity=this.environmentIntensity),t.object.environmentRotation=this.environmentRotation.toArray(),t}}class dr{constructor(e,t){this.isInterleavedBuffer=!0,this.array=e,this.stride=t,this.count=void 0!==e?e.length/t:0,this.usage=nt,this.updateRanges=[],this.version=0,this.uuid=ht()}onUploadCallback(){}set needsUpdate(e){!0===e&&this.version++}setUsage(e){return this.usage=e,this}addUpdateRange(e,t){this.updateRanges.push({start:e,count:t})}clearUpdateRanges(){this.updateRanges.length=0}copy(e){return this.array=new e.array.constructor(e.array),this.count=e.count,this.stride=e.stride,this.usage=e.usage,this}copyAt(e,t,n){e*=this.stride,n*=t.stride;for(let i=0,r=this.stride;i1?null:t.copy(e.start).addScaledVector(n,r)}intersectsLine(e){const t=this.distanceToPoint(e.start),n=this.distanceToPoint(e.end);return t<0&&n>0||n<0&&t>0}intersectsBox(e){return e.intersectsPlane(this)}intersectsSphere(e){return e.intersectsPlane(this)}coplanarPoint(e){return e.copy(this.normal).multiplyScalar(-this.constant)}applyMatrix4(e,t){const n=t||kr.getNormalMatrix(e),i=this.coplanarPoint(Br).applyMatrix4(e),r=this.normal.applyMatrix3(n).normalize();return this.constant=-i.dot(r),this}translate(e){return this.constant-=e.dot(this.normal),this}equals(e){return e.normal.equals(this.normal)&&e.constant===this.constant}clone(){return(new this.constructor).copy(this)}}const Vr=new pn,Gr=new jt;class Wr{constructor(e=new Hr,t=new Hr,n=new Hr,i=new Hr,r=new Hr,a=new Hr){this.planes=[e,t,n,i,r,a]}set(e,t,n,i,r,a){const s=this.planes;return s[0].copy(e),s[1].copy(t),s[2].copy(n),s[3].copy(i),s[4].copy(r),s[5].copy(a),this}copy(e){const t=this.planes;for(let n=0;n<6;n++)t[n].copy(e.planes[n]);return this}setFromProjectionMatrix(e,t=2e3){const n=this.planes,i=e.elements,r=i[0],a=i[1],s=i[2],o=i[3],l=i[4],c=i[5],h=i[6],d=i[7],u=i[8],p=i[9],f=i[10],m=i[11],g=i[12],v=i[13],_=i[14],x=i[15];if(n[0].setComponents(o-r,d-l,m-u,x-g).normalize(),n[1].setComponents(o+r,d+l,m+u,x+g).normalize(),n[2].setComponents(o+a,d+c,m+p,x+v).normalize(),n[3].setComponents(o-a,d-c,m-p,x-v).normalize(),n[4].setComponents(o-s,d-h,m-f,x-_).normalize(),t===rt)n[5].setComponents(o+s,d+h,m+f,x+_).normalize();else{if(t!==at)throw new Error("THREE.Frustum.setFromProjectionMatrix(): Invalid coordinate system: "+t);n[5].setComponents(s,h,f,_).normalize()}return this}intersectsObject(e){if(void 0!==e.boundingSphere)null===e.boundingSphere&&e.computeBoundingSphere(),Vr.copy(e.boundingSphere).applyMatrix4(e.matrixWorld);else{const t=e.geometry;null===t.boundingSphere&&t.computeBoundingSphere(),Vr.copy(t.boundingSphere).applyMatrix4(e.matrixWorld)}return this.intersectsSphere(Vr)}intersectsSprite(e){return Vr.center.set(0,0,0),Vr.radius=.7071067811865476,Vr.applyMatrix4(e.matrixWorld),this.intersectsSphere(Vr)}intersectsSphere(e){const t=this.planes,n=e.center,i=-e.radius;for(let e=0;e<6;e++)if(t[e].distanceToPoint(n)0?e.max.x:e.min.x,Gr.y=i.normal.y>0?e.max.y:e.min.y,Gr.z=i.normal.z>0?e.max.z:e.min.z,i.distanceToPoint(Gr)<0)return!1}return!0}containsPoint(e){const t=this.planes;for(let n=0;n<6;n++)if(t[n].distanceToPoint(e)<0)return!1;return!0}clone(){return(new this.constructor).copy(this)}}class jr extends vi{constructor(e){super(),this.isLineBasicMaterial=!0,this.type="LineBasicMaterial",this.color=new fi(16777215),this.map=null,this.linewidth=1,this.linecap="round",this.linejoin="round",this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.linewidth=e.linewidth,this.linecap=e.linecap,this.linejoin=e.linejoin,this.fog=e.fog,this}}const Xr=new jt,Yr=new jt,qr=new wn,Zr=new Sn,Kr=new pn,Jr=new jt,Qr=new jt;class $r extends Zn{constructor(e=new Oi,t=new jr){super(),this.isLine=!0,this.type="Line",this.geometry=e,this.material=t,this.updateMorphTargets()}copy(e,t){return super.copy(e,t),this.material=Array.isArray(e.material)?e.material.slice():e.material,this.geometry=e.geometry,this}computeLineDistances(){const e=this.geometry;if(null===e.index){const t=e.attributes.position,n=[0];for(let e=1,i=t.count;e0){const n=e[t[0]];if(void 0!==n){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let e=0,t=n.length;ei)return;Jr.applyMatrix4(e.matrixWorld);const o=t.ray.origin.distanceTo(Jr);return ot.far?void 0:{distance:o,point:Qr.clone().applyMatrix4(e.matrixWorld),index:r,face:null,faceIndex:null,barycoord:null,object:e}}const ta=new jt,na=new jt;class ia extends $r{constructor(e,t){super(e,t),this.isLineSegments=!0,this.type="LineSegments"}computeLineDistances(){const e=this.geometry;if(null===e.index){const t=e.attributes.position,n=[];for(let e=0,i=t.count;e0){const n=e[t[0]];if(void 0!==n){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let e=0,t=n.length;er.far)return;a.push({distance:l,distanceToRay:Math.sqrt(o),point:n,index:t,face:null,faceIndex:null,barycoord:null,object:s})}}class ua extends Zn{constructor(){super(),this.isGroup=!0,this.type="Group"}}class pa extends Bt{constructor(e,t,n,i,r,a,s,o,l,c=1026){if(c!==te&&c!==ne)throw new Error("DepthTexture format must be either THREE.DepthFormat or THREE.DepthStencilFormat");void 0===n&&c===te&&(n=q),void 0===n&&c===ne&&(n=$),super(null,i,r,a,s,o,c,n,l),this.isDepthTexture=!0,this.image={width:e,height:t},this.magFilter=void 0!==s?s:z,this.minFilter=void 0!==o?o:z,this.flipY=!1,this.generateMipmaps=!1,this.compareFunction=null}copy(e){return super.copy(e),this.compareFunction=e.compareFunction,this}toJSON(e){const t=super.toJSON(e);return null!==this.compareFunction&&(t.compareFunction=this.compareFunction),t}}class fa{constructor(){this.type="Curve",this.arcLengthDivisions=200}getPoint(){return console.warn("THREE.Curve: .getPoint() not implemented."),null}getPointAt(e,t){const n=this.getUtoTmapping(e);return this.getPoint(n,t)}getPoints(e=5){const t=[];for(let n=0;n<=e;n++)t.push(this.getPoint(n/e));return t}getSpacedPoints(e=5){const t=[];for(let n=0;n<=e;n++)t.push(this.getPointAt(n/e));return t}getLength(){const e=this.getLengths();return e[e.length-1]}getLengths(e=this.arcLengthDivisions){if(this.cacheArcLengths&&this.cacheArcLengths.length===e+1&&!this.needsUpdate)return this.cacheArcLengths;this.needsUpdate=!1;const t=[];let n,i=this.getPoint(0),r=0;t.push(0);for(let a=1;a<=e;a++)n=this.getPoint(a/e),r+=n.distanceTo(i),t.push(r),i=n;return this.cacheArcLengths=t,t}updateArcLengths(){this.needsUpdate=!0,this.getLengths()}getUtoTmapping(e,t){const n=this.getLengths();let i=0;const r=n.length;let a;a=t||e*n[r-1];let s,o=0,l=r-1;for(;o<=l;)if(i=Math.floor(o+(l-o)/2),s=n[i]-a,s<0)o=i+1;else{if(!(s>0)){l=i;break}l=i-1}if(i=l,n[i]===a)return i/(r-1);const c=n[i];return(i+(a-c)/(n[i+1]-c))/(r-1)}getTangent(e,t){const n=1e-4;let i=e-n,r=e+n;i<0&&(i=0),r>1&&(r=1);const a=this.getPoint(i),s=this.getPoint(r),o=t||(a.isVector2?new _t:new jt);return o.copy(s).sub(a).normalize(),o}getTangentAt(e,t){const n=this.getUtoTmapping(e);return this.getTangent(n,t)}computeFrenetFrames(e,t){const n=new jt,i=[],r=[],a=[],s=new jt,o=new wn;for(let t=0;t<=e;t++){const n=t/e;i[t]=this.getTangentAt(n,new jt)}r[0]=new jt,a[0]=new jt;let l=Number.MAX_VALUE;const c=Math.abs(i[0].x),h=Math.abs(i[0].y),d=Math.abs(i[0].z);c<=l&&(l=c,n.set(1,0,0)),h<=l&&(l=h,n.set(0,1,0)),d<=l&&n.set(0,0,1),s.crossVectors(i[0],n).normalize(),r[0].crossVectors(i[0],s),a[0].crossVectors(i[0],r[0]);for(let t=1;t<=e;t++){if(r[t]=r[t-1].clone(),a[t]=a[t-1].clone(),s.crossVectors(i[t-1],i[t]),s.length()>Number.EPSILON){s.normalize();const e=Math.acos(dt(i[t-1].dot(i[t]),-1,1));r[t].applyMatrix4(o.makeRotationAxis(s,e))}a[t].crossVectors(i[t],r[t])}if(!0===t){let t=Math.acos(dt(r[0].dot(r[e]),-1,1));t/=e,i[0].dot(s.crossVectors(r[0],r[e]))>0&&(t=-t);for(let n=1;n<=e;n++)r[n].applyMatrix4(o.makeRotationAxis(i[n],t*n)),a[n].crossVectors(i[n],r[n])}return{tangents:i,normals:r,binormals:a}}clone(){return(new this.constructor).copy(this)}copy(e){return this.arcLengthDivisions=e.arcLengthDivisions,this}toJSON(){const e={metadata:{version:4.6,type:"Curve",generator:"Curve.toJSON"}};return e.arcLengthDivisions=this.arcLengthDivisions,e.type=this.type,e}fromJSON(e){return this.arcLengthDivisions=e.arcLengthDivisions,this}}class ma extends fa{constructor(e=0,t=0,n=1,i=1,r=0,a=2*Math.PI,s=!1,o=0){super(),this.isEllipseCurve=!0,this.type="EllipseCurve",this.aX=e,this.aY=t,this.xRadius=n,this.yRadius=i,this.aStartAngle=r,this.aEndAngle=a,this.aClockwise=s,this.aRotation=o}getPoint(e,t=new _t){const n=t,i=2*Math.PI;let r=this.aEndAngle-this.aStartAngle;const a=Math.abs(r)i;)r-=i;r0?0:(Math.floor(Math.abs(l)/r)+1)*r:0===c&&l===r-1&&(l=r-2,c=1),this.closed||l>0?s=i[(l-1)%r]:(va.subVectors(i[0],i[1]).add(i[0]),s=va);const h=i[l%r],d=i[(l+1)%r];if(this.closed||l+2i.length-2?i.length-1:a+1],h=i[a>i.length-3?i.length-1:a+2];return n.set(wa(s,o.x,l.x,c.x,h.x),wa(s,o.y,l.y,c.y,h.y)),n}copy(e){super.copy(e),this.points=[];for(let t=0,n=e.points.length;t0||0!==i)&&(c.push(a,s,l),_+=3),(t>0||i!==r-1)&&(c.push(s,o,l),_+=3)}l.addGroup(g,_,0),g+=_}(),!1===a&&(e>0&&v(!0),t>0&&v(!1)),this.setIndex(c),this.setAttribute("position",new Ai(h,3)),this.setAttribute("normal",new Ai(d,3)),this.setAttribute("uv",new Ai(u,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new Pa(e.radiusTop,e.radiusBottom,e.height,e.radialSegments,e.heightSegments,e.openEnded,e.thetaStart,e.thetaLength)}}class Ra extends Oi{constructor(e=[],t=[],n=1,i=0){super(),this.type="PolyhedronGeometry",this.parameters={vertices:e,indices:t,radius:n,detail:i};const r=[],a=[];function s(e,t,n,i){const r=i+1,a=[];for(let i=0;i<=r;i++){a[i]=[];const s=e.clone().lerp(n,i/r),o=t.clone().lerp(n,i/r),l=r-i;for(let e=0;e<=l;e++)a[i][e]=0===e&&i===r?s:s.clone().lerp(o,e/l)}for(let e=0;e.9&&s<.1&&(t<.2&&(a[e+0]+=1),n<.2&&(a[e+2]+=1),i<.2&&(a[e+4]+=1))}}()}(),this.setAttribute("position",new Ai(r,3)),this.setAttribute("normal",new Ai(r.slice(),3)),this.setAttribute("uv",new Ai(a,2)),0===i?this.computeVertexNormals():this.normalizeNormals()}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new Ra(e.vertices,e.indices,e.radius,e.details)}}class Ca extends Ra{constructor(e=1,t=0){super([1,0,0,-1,0,0,0,1,0,0,-1,0,0,0,1,0,0,-1],[0,2,4,0,4,3,0,3,5,0,5,2,1,2,5,1,5,3,1,3,4,1,4,2],e,t),this.type="OctahedronGeometry",this.parameters={radius:e,detail:t}}static fromJSON(e){return new Ca(e.radius,e.detail)}}class Da extends Oi{constructor(e=1,t=1,n=1,i=1){super(),this.type="PlaneGeometry",this.parameters={width:e,height:t,widthSegments:n,heightSegments:i};const r=e/2,a=t/2,s=Math.floor(n),o=Math.floor(i),l=s+1,c=o+1,h=e/s,d=t/o,u=[],p=[],f=[],m=[];for(let e=0;e0)&&u.push(t,r,l),(e!==n-1||o0!=e>0&&this.version++,this._anisotropy=e}get clearcoat(){return this._clearcoat}set clearcoat(e){this._clearcoat>0!=e>0&&this.version++,this._clearcoat=e}get iridescence(){return this._iridescence}set iridescence(e){this._iridescence>0!=e>0&&this.version++,this._iridescence=e}get dispersion(){return this._dispersion}set dispersion(e){this._dispersion>0!=e>0&&this.version++,this._dispersion=e}get sheen(){return this._sheen}set sheen(e){this._sheen>0!=e>0&&this.version++,this._sheen=e}get transmission(){return this._transmission}set transmission(e){this._transmission>0!=e>0&&this.version++,this._transmission=e}copy(e){return super.copy(e),this.defines={STANDARD:"",PHYSICAL:""},this.anisotropy=e.anisotropy,this.anisotropyRotation=e.anisotropyRotation,this.anisotropyMap=e.anisotropyMap,this.clearcoat=e.clearcoat,this.clearcoatMap=e.clearcoatMap,this.clearcoatRoughness=e.clearcoatRoughness,this.clearcoatRoughnessMap=e.clearcoatRoughnessMap,this.clearcoatNormalMap=e.clearcoatNormalMap,this.clearcoatNormalScale.copy(e.clearcoatNormalScale),this.dispersion=e.dispersion,this.ior=e.ior,this.iridescence=e.iridescence,this.iridescenceMap=e.iridescenceMap,this.iridescenceIOR=e.iridescenceIOR,this.iridescenceThicknessRange=[...e.iridescenceThicknessRange],this.iridescenceThicknessMap=e.iridescenceThicknessMap,this.sheen=e.sheen,this.sheenColor.copy(e.sheenColor),this.sheenColorMap=e.sheenColorMap,this.sheenRoughness=e.sheenRoughness,this.sheenRoughnessMap=e.sheenRoughnessMap,this.transmission=e.transmission,this.transmissionMap=e.transmissionMap,this.thickness=e.thickness,this.thicknessMap=e.thicknessMap,this.attenuationDistance=e.attenuationDistance,this.attenuationColor.copy(e.attenuationColor),this.specularIntensity=e.specularIntensity,this.specularIntensityMap=e.specularIntensityMap,this.specularColor.copy(e.specularColor),this.specularColorMap=e.specularColorMap,this}}class za extends vi{constructor(e){super(),this.isMeshPhongMaterial=!0,this.type="MeshPhongMaterial",this.color=new fi(16777215),this.specular=new fi(1118481),this.shininess=30,this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new fi(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=0,this.normalScale=new _t(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new Ln,this.combine=0,this.reflectivity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.flatShading=!1,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.specular.copy(e.specular),this.shininess=e.shininess,this.map=e.map,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.emissive.copy(e.emissive),this.emissiveMap=e.emissiveMap,this.emissiveIntensity=e.emissiveIntensity,this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.specularMap=e.specularMap,this.alphaMap=e.alphaMap,this.envMap=e.envMap,this.envMapRotation.copy(e.envMapRotation),this.combine=e.combine,this.reflectivity=e.reflectivity,this.refractionRatio=e.refractionRatio,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.flatShading=e.flatShading,this.fog=e.fog,this}}class ka extends vi{constructor(e){super(),this.isMeshNormalMaterial=!0,this.type="MeshNormalMaterial",this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=0,this.normalScale=new _t(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.wireframe=!1,this.wireframeLinewidth=1,this.flatShading=!1,this.setValues(e)}copy(e){return super.copy(e),this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.flatShading=e.flatShading,this}}class Ha extends vi{constructor(e){super(),this.isMeshLambertMaterial=!0,this.type="MeshLambertMaterial",this.color=new fi(16777215),this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new fi(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=0,this.normalScale=new _t(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new Ln,this.combine=0,this.reflectivity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.flatShading=!1,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.emissive.copy(e.emissive),this.emissiveMap=e.emissiveMap,this.emissiveIntensity=e.emissiveIntensity,this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.specularMap=e.specularMap,this.alphaMap=e.alphaMap,this.envMap=e.envMap,this.envMapRotation.copy(e.envMapRotation),this.combine=e.combine,this.reflectivity=e.reflectivity,this.refractionRatio=e.refractionRatio,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.flatShading=e.flatShading,this.fog=e.fog,this}}class Va extends vi{constructor(e){super(),this.isMeshDepthMaterial=!0,this.type="MeshDepthMaterial",this.depthPacking=3200,this.map=null,this.alphaMap=null,this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.wireframe=!1,this.wireframeLinewidth=1,this.setValues(e)}copy(e){return super.copy(e),this.depthPacking=e.depthPacking,this.map=e.map,this.alphaMap=e.alphaMap,this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this}}class Ga extends vi{constructor(e){super(),this.isMeshDistanceMaterial=!0,this.type="MeshDistanceMaterial",this.map=null,this.alphaMap=null,this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.setValues(e)}copy(e){return super.copy(e),this.map=e.map,this.alphaMap=e.alphaMap,this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this}}function Wa(e,t,n){return!e||!n&&e.constructor===t?e:"number"==typeof t.BYTES_PER_ELEMENT?new t(e):Array.prototype.slice.call(e)}function ja(e){const t=e.length,n=new Array(t);for(let e=0;e!==t;++e)n[e]=e;return n.sort((function(t,n){return e[t]-e[n]})),n}function Xa(e,t,n){const i=e.length,r=new e.constructor(i);for(let a=0,s=0;s!==i;++a){const i=n[a]*t;for(let n=0;n!==t;++n)r[s++]=e[i+n]}return r}function Ya(e,t,n,i){let r=1,a=e[0];for(;void 0!==a&&void 0===a[i];)a=e[r++];if(void 0===a)return;let s=a[i];if(void 0!==s)if(Array.isArray(s))do{s=a[i],void 0!==s&&(t.push(a.time),n.push.apply(n,s)),a=e[r++]}while(void 0!==a);else if(void 0!==s.toArray)do{s=a[i],void 0!==s&&(t.push(a.time),s.toArray(n,n.length)),a=e[r++]}while(void 0!==a);else do{s=a[i],void 0!==s&&(t.push(a.time),n.push(s)),a=e[r++]}while(void 0!==a)}class qa{constructor(e,t,n,i){this.parameterPositions=e,this._cachedIndex=0,this.resultBuffer=void 0!==i?i:new t.constructor(n),this.sampleValues=t,this.valueSize=n,this.settings=null,this.DefaultSettings_={}}evaluate(e){const t=this.parameterPositions;let n=this._cachedIndex,i=t[n],r=t[n-1];e:{t:{let a;n:{i:if(!(e=r)break e;{const s=t[1];e=r)break t}a=n,n=0}}for(;n>>1;et;)--a;if(++a,0!==r||a!==i){r>=a&&(a=Math.max(a,1),r=a-1);const e=this.getValueSize();this.times=n.slice(r,a),this.values=this.values.slice(r*e,a*e)}return this}validate(){let e=!0;const t=this.getValueSize();t-Math.floor(t)!=0&&(console.error("THREE.KeyframeTrack: Invalid value size in track.",this),e=!1);const n=this.times,i=this.values,r=n.length;0===r&&(console.error("THREE.KeyframeTrack: Track is empty.",this),e=!1);let a=null;for(let t=0;t!==r;t++){const i=n[t];if("number"==typeof i&&isNaN(i)){console.error("THREE.KeyframeTrack: Time is not a valid number.",this,t,i),e=!1;break}if(null!==a&&a>i){console.error("THREE.KeyframeTrack: Out of order keys.",this,t,i,a),e=!1;break}a=i}if(void 0!==i&&(s=i,ArrayBuffer.isView(s)&&!(s instanceof DataView)))for(let t=0,n=i.length;t!==n;++t){const n=i[t];if(isNaN(n)){console.error("THREE.KeyframeTrack: Value is not a valid number.",this,t,n),e=!1;break}}var s;return e}optimize(){const e=this.times.slice(),t=this.values.slice(),n=this.getValueSize(),i=this.getInterpolation()===He,r=e.length-1;let a=1;for(let s=1;s0){e[a]=e[r];for(let e=r*n,i=a*n,s=0;s!==n;++s)t[i+s]=t[e+s];++a}return a!==e.length?(this.times=e.slice(0,a),this.values=t.slice(0,a*n)):(this.times=e,this.values=t),this}clone(){const e=this.times.slice(),t=this.values.slice(),n=new(0,this.constructor)(this.name,e,t);return n.createInterpolant=this.createInterpolant,n}}Qa.prototype.TimeBufferType=Float32Array,Qa.prototype.ValueBufferType=Float32Array,Qa.prototype.DefaultInterpolation=ke;class $a extends Qa{constructor(e,t,n){super(e,t,n)}}$a.prototype.ValueTypeName="bool",$a.prototype.ValueBufferType=Array,$a.prototype.DefaultInterpolation=ze,$a.prototype.InterpolantFactoryMethodLinear=void 0,$a.prototype.InterpolantFactoryMethodSmooth=void 0;class es extends Qa{}es.prototype.ValueTypeName="color";class ts extends Qa{}ts.prototype.ValueTypeName="number";class ns extends qa{constructor(e,t,n,i){super(e,t,n,i)}interpolate_(e,t,n,i){const r=this.resultBuffer,a=this.sampleValues,s=this.valueSize,o=(n-t)/(i-t);let l=e*s;for(let e=l+s;l!==e;l+=4)Wt.slerpFlat(r,0,a,l-s,a,l,o);return r}}class is extends Qa{InterpolantFactoryMethodLinear(e){return new ns(this.times,this.values,this.getValueSize(),e)}}is.prototype.ValueTypeName="quaternion",is.prototype.InterpolantFactoryMethodSmooth=void 0;class rs extends Qa{constructor(e,t,n){super(e,t,n)}}rs.prototype.ValueTypeName="string",rs.prototype.ValueBufferType=Array,rs.prototype.DefaultInterpolation=ze,rs.prototype.InterpolantFactoryMethodLinear=void 0,rs.prototype.InterpolantFactoryMethodSmooth=void 0;class as extends Qa{}as.prototype.ValueTypeName="vector";class ss{constructor(e="",t=-1,n=[],i=2500){this.name=e,this.tracks=n,this.duration=t,this.blendMode=i,this.uuid=ht(),this.duration<0&&this.resetDuration()}static parse(e){const t=[],n=e.tracks,i=1/(e.fps||1);for(let e=0,r=n.length;e!==r;++e)t.push(os(n[e]).scale(i));const r=new this(e.name,e.duration,t,e.blendMode);return r.uuid=e.uuid,r}static toJSON(e){const t=[],n=e.tracks,i={name:e.name,duration:e.duration,tracks:t,uuid:e.uuid,blendMode:e.blendMode};for(let e=0,i=n.length;e!==i;++e)t.push(Qa.toJSON(n[e]));return i}static CreateFromMorphTargetSequence(e,t,n,i){const r=t.length,a=[];for(let e=0;e1){const e=a[1];let t=i[e];t||(i[e]=t=[]),t.push(n)}}const a=[];for(const e in i)a.push(this.CreateFromMorphTargetSequence(e,i[e],t,n));return a}static parseAnimation(e,t){if(!e)return console.error("THREE.AnimationClip: No animation in JSONLoader data."),null;const n=function(e,t,n,i,r){if(0!==n.length){const a=[],s=[];Ya(n,a,s,i),0!==a.length&&r.push(new e(t,a,s))}},i=[],r=e.name||"default",a=e.fps||30,s=e.blendMode;let o=e.length||-1;const l=e.hierarchy||[];for(let e=0;e{t&&t(r),this.manager.itemEnd(e)}),0),r;if(void 0!==us[e])return void us[e].push({onLoad:t,onProgress:n,onError:i});us[e]=[],us[e].push({onLoad:t,onProgress:n,onError:i});const a=new Request(e,{headers:new Headers(this.requestHeader),credentials:this.withCredentials?"include":"same-origin"}),s=this.mimeType,o=this.responseType;fetch(a).then((t=>{if(200===t.status||0===t.status){if(0===t.status&&console.warn("THREE.FileLoader: HTTP Status 0 received."),"undefined"==typeof ReadableStream||void 0===t.body||void 0===t.body.getReader)return t;const n=us[e],i=t.body.getReader(),r=t.headers.get("X-File-Size")||t.headers.get("Content-Length"),a=r?parseInt(r):0,s=0!==a;let o=0;const l=new ReadableStream({start(e){!function t(){i.read().then((({done:i,value:r})=>{if(i)e.close();else{o+=r.byteLength;const i=new ProgressEvent("progress",{lengthComputable:s,loaded:o,total:a});for(let e=0,t=n.length;e{e.error(t)}))}()}});return new Response(l)}throw new ps(`fetch for "${t.url}" responded with ${t.status}: ${t.statusText}`,t)})).then((e=>{switch(o){case"arraybuffer":return e.arrayBuffer();case"blob":return e.blob();case"document":return e.text().then((e=>(new DOMParser).parseFromString(e,s)));case"json":return e.json();default:if(void 0===s)return e.text();{const t=/charset="?([^;"\s]*)"?/i.exec(s),n=t&&t[1]?t[1].toLowerCase():void 0,i=new TextDecoder(n);return e.arrayBuffer().then((e=>i.decode(e)))}}})).then((t=>{ls.add(e,t);const n=us[e];delete us[e];for(let e=0,i=n.length;e{const n=us[e];if(void 0===n)throw this.manager.itemError(e),t;delete us[e];for(let e=0,i=n.length;e{this.manager.itemEnd(e)})),this.manager.itemStart(e)}setResponseType(e){return this.responseType=e,this}setMimeType(e){return this.mimeType=e,this}}class ms extends ds{constructor(e){super(e)}load(e,t,n,i){void 0!==this.path&&(e=this.path+e),e=this.manager.resolveURL(e);const r=this,a=ls.get(e);if(void 0!==a)return r.manager.itemStart(e),setTimeout((function(){t&&t(a),r.manager.itemEnd(e)}),0),a;const s=wt("img");function o(){c(),ls.add(e,this),t&&t(this),r.manager.itemEnd(e)}function l(t){c(),i&&i(t),r.manager.itemError(e),r.manager.itemEnd(e)}function c(){s.removeEventListener("load",o,!1),s.removeEventListener("error",l,!1)}return s.addEventListener("load",o,!1),s.addEventListener("error",l,!1),"data:"!==e.slice(0,5)&&void 0!==this.crossOrigin&&(s.crossOrigin=this.crossOrigin),r.manager.itemStart(e),s.src=e,s}}class gs extends ds{constructor(e){super(e)}load(e,t,n,i){const r=this,a=new Tr,s=new fs(this.manager);return s.setResponseType("arraybuffer"),s.setRequestHeader(this.requestHeader),s.setPath(this.path),s.setWithCredentials(r.withCredentials),s.load(e,(function(e){let n;try{n=r.parse(e)}catch(e){if(void 0===i)return void console.error(e);i(e)}void 0!==n.image?a.image=n.image:void 0!==n.data&&(a.image.width=n.width,a.image.height=n.height,a.image.data=n.data),a.wrapS=void 0!==n.wrapS?n.wrapS:F,a.wrapT=void 0!==n.wrapT?n.wrapT:F,a.magFilter=void 0!==n.magFilter?n.magFilter:V,a.minFilter=void 0!==n.minFilter?n.minFilter:V,a.anisotropy=void 0!==n.anisotropy?n.anisotropy:1,void 0!==n.colorSpace&&(a.colorSpace=n.colorSpace),void 0!==n.flipY&&(a.flipY=n.flipY),void 0!==n.format&&(a.format=n.format),void 0!==n.type&&(a.type=n.type),void 0!==n.mipmaps&&(a.mipmaps=n.mipmaps,a.minFilter=W),1===n.mipmapCount&&(a.minFilter=V),void 0!==n.generateMipmaps&&(a.generateMipmaps=n.generateMipmaps),a.needsUpdate=!0,t&&t(a,n)}),n,i),a}}class vs extends ds{constructor(e){super(e)}load(e,t,n,i){const r=new Bt,a=new ms(this.manager);return a.setCrossOrigin(this.crossOrigin),a.setPath(this.path),a.load(e,(function(e){r.image=e,r.needsUpdate=!0,void 0!==t&&t(r)}),n,i),r}}class _s extends Zn{constructor(e,t=1){super(),this.isLight=!0,this.type="Light",this.color=new fi(e),this.intensity=t}dispose(){}copy(e,t){return super.copy(e,t),this.color.copy(e.color),this.intensity=e.intensity,this}toJSON(e){const t=super.toJSON(e);return t.object.color=this.color.getHex(),t.object.intensity=this.intensity,void 0!==this.groundColor&&(t.object.groundColor=this.groundColor.getHex()),void 0!==this.distance&&(t.object.distance=this.distance),void 0!==this.angle&&(t.object.angle=this.angle),void 0!==this.decay&&(t.object.decay=this.decay),void 0!==this.penumbra&&(t.object.penumbra=this.penumbra),void 0!==this.shadow&&(t.object.shadow=this.shadow.toJSON()),void 0!==this.target&&(t.object.target=this.target.uuid),t}}const xs=new wn,ys=new jt,Ss=new jt;class ws{constructor(e){this.camera=e,this.intensity=1,this.bias=0,this.normalBias=0,this.radius=1,this.blurSamples=8,this.mapSize=new _t(512,512),this.map=null,this.mapPass=null,this.matrix=new wn,this.autoUpdate=!0,this.needsUpdate=!1,this._frustum=new Wr,this._frameExtents=new _t(1,1),this._viewportCount=1,this._viewports=[new zt(0,0,1,1)]}getViewportCount(){return this._viewportCount}getFrustum(){return this._frustum}updateMatrices(e){const t=this.camera,n=this.matrix;ys.setFromMatrixPosition(e.matrixWorld),t.position.copy(ys),Ss.setFromMatrixPosition(e.target.matrixWorld),t.lookAt(Ss),t.updateMatrixWorld(),xs.multiplyMatrices(t.projectionMatrix,t.matrixWorldInverse),this._frustum.setFromProjectionMatrix(xs),n.set(.5,0,0,.5,0,.5,0,.5,0,0,.5,.5,0,0,0,1),n.multiply(xs)}getViewport(e){return this._viewports[e]}getFrameExtents(){return this._frameExtents}dispose(){this.map&&this.map.dispose(),this.mapPass&&this.mapPass.dispose()}copy(e){return this.camera=e.camera.clone(),this.intensity=e.intensity,this.bias=e.bias,this.radius=e.radius,this.mapSize.copy(e.mapSize),this}clone(){return(new this.constructor).copy(this)}toJSON(){const e={};return 1!==this.intensity&&(e.intensity=this.intensity),0!==this.bias&&(e.bias=this.bias),0!==this.normalBias&&(e.normalBias=this.normalBias),1!==this.radius&&(e.radius=this.radius),512===this.mapSize.x&&512===this.mapSize.y||(e.mapSize=this.mapSize.toArray()),e.camera=this.camera.toJSON(!1).object,delete e.camera.matrix,e}}class bs extends ws{constructor(){super(new ar(50,1,.5,500)),this.isSpotLightShadow=!0,this.focus=1}updateMatrices(e){const t=this.camera,n=2*ct*e.angle*this.focus,i=this.mapSize.width/this.mapSize.height,r=e.distance||t.far;n===t.fov&&i===t.aspect&&r===t.far||(t.fov=n,t.aspect=i,t.far=r,t.updateProjectionMatrix()),super.updateMatrices(e)}copy(e){return super.copy(e),this.focus=e.focus,this}}class Ms extends _s{constructor(e,t,n=0,i=Math.PI/3,r=0,a=2){super(e,t),this.isSpotLight=!0,this.type="SpotLight",this.position.copy(Zn.DEFAULT_UP),this.updateMatrix(),this.target=new Zn,this.distance=n,this.angle=i,this.penumbra=r,this.decay=a,this.map=null,this.shadow=new bs}get power(){return this.intensity*Math.PI}set power(e){this.intensity=e/Math.PI}dispose(){this.shadow.dispose()}copy(e,t){return super.copy(e,t),this.distance=e.distance,this.angle=e.angle,this.penumbra=e.penumbra,this.decay=e.decay,this.target=e.target.clone(),this.shadow=e.shadow.clone(),this}}const Ts=new wn,Es=new jt,As=new jt;class Ps extends ws{constructor(){super(new ar(90,1,.5,500)),this.isPointLightShadow=!0,this._frameExtents=new _t(4,2),this._viewportCount=6,this._viewports=[new zt(2,1,1,1),new zt(0,1,1,1),new zt(3,1,1,1),new zt(1,1,1,1),new zt(3,0,1,1),new zt(1,0,1,1)],this._cubeDirections=[new jt(1,0,0),new jt(-1,0,0),new jt(0,0,1),new jt(0,0,-1),new jt(0,1,0),new jt(0,-1,0)],this._cubeUps=[new jt(0,1,0),new jt(0,1,0),new jt(0,1,0),new jt(0,1,0),new jt(0,0,1),new jt(0,0,-1)]}updateMatrices(e,t=0){const n=this.camera,i=this.matrix,r=e.distance||n.far;r!==n.far&&(n.far=r,n.updateProjectionMatrix()),Es.setFromMatrixPosition(e.matrixWorld),n.position.copy(Es),As.copy(n.position),As.add(this._cubeDirections[t]),n.up.copy(this._cubeUps[t]),n.lookAt(As),n.updateMatrixWorld(),i.makeTranslation(-Es.x,-Es.y,-Es.z),Ts.multiplyMatrices(n.projectionMatrix,n.matrixWorldInverse),this._frustum.setFromProjectionMatrix(Ts)}}class Rs extends _s{constructor(e,t,n=0,i=2){super(e,t),this.isPointLight=!0,this.type="PointLight",this.distance=n,this.decay=i,this.shadow=new Ps}get power(){return 4*this.intensity*Math.PI}set power(e){this.intensity=e/(4*Math.PI)}dispose(){this.shadow.dispose()}copy(e,t){return super.copy(e,t),this.distance=e.distance,this.decay=e.decay,this.shadow=e.shadow.clone(),this}}class Cs extends tr{constructor(e=-1,t=1,n=1,i=-1,r=.1,a=2e3){super(),this.isOrthographicCamera=!0,this.type="OrthographicCamera",this.zoom=1,this.view=null,this.left=e,this.right=t,this.top=n,this.bottom=i,this.near=r,this.far=a,this.updateProjectionMatrix()}copy(e,t){return super.copy(e,t),this.left=e.left,this.right=e.right,this.top=e.top,this.bottom=e.bottom,this.near=e.near,this.far=e.far,this.zoom=e.zoom,this.view=null===e.view?null:Object.assign({},e.view),this}setViewOffset(e,t,n,i,r,a){null===this.view&&(this.view={enabled:!0,fullWidth:1,fullHeight:1,offsetX:0,offsetY:0,width:1,height:1}),this.view.enabled=!0,this.view.fullWidth=e,this.view.fullHeight=t,this.view.offsetX=n,this.view.offsetY=i,this.view.width=r,this.view.height=a,this.updateProjectionMatrix()}clearViewOffset(){null!==this.view&&(this.view.enabled=!1),this.updateProjectionMatrix()}updateProjectionMatrix(){const e=(this.right-this.left)/(2*this.zoom),t=(this.top-this.bottom)/(2*this.zoom),n=(this.right+this.left)/2,i=(this.top+this.bottom)/2;let r=n-e,a=n+e,s=i+t,o=i-t;if(null!==this.view&&this.view.enabled){const e=(this.right-this.left)/this.view.fullWidth/this.zoom,t=(this.top-this.bottom)/this.view.fullHeight/this.zoom;r+=e*this.view.offsetX,a=r+e*this.view.width,s-=t*this.view.offsetY,o=s-t*this.view.height}this.projectionMatrix.makeOrthographic(r,a,s,o,this.near,this.far,this.coordinateSystem),this.projectionMatrixInverse.copy(this.projectionMatrix).invert()}toJSON(e){const t=super.toJSON(e);return t.object.zoom=this.zoom,t.object.left=this.left,t.object.right=this.right,t.object.top=this.top,t.object.bottom=this.bottom,t.object.near=this.near,t.object.far=this.far,null!==this.view&&(t.object.view=Object.assign({},this.view)),t}}class Ds extends ws{constructor(){super(new Cs(-5,5,5,-5,.5,500)),this.isDirectionalLightShadow=!0}}class Ls extends _s{constructor(e,t){super(e,t),this.isDirectionalLight=!0,this.type="DirectionalLight",this.position.copy(Zn.DEFAULT_UP),this.updateMatrix(),this.target=new Zn,this.shadow=new Ds}dispose(){this.shadow.dispose()}copy(e){return super.copy(e),this.target=e.target.clone(),this.shadow=e.shadow.clone(),this}}class Is extends _s{constructor(e,t){super(e,t),this.isAmbientLight=!0,this.type="AmbientLight"}}class Us extends _s{constructor(e,t,n=10,i=10){super(e,t),this.isRectAreaLight=!0,this.type="RectAreaLight",this.width=n,this.height=i}get power(){return this.intensity*this.width*this.height*Math.PI}set power(e){this.intensity=e/(this.width*this.height*Math.PI)}copy(e){return super.copy(e),this.width=e.width,this.height=e.height,this}toJSON(e){const t=super.toJSON(e);return t.object.width=this.width,t.object.height=this.height,t}}class Os{static decodeText(e){if(console.warn("THREE.LoaderUtils: decodeText() has been deprecated with r165 and will be removed with r175. Use TextDecoder instead."),"undefined"!=typeof TextDecoder)return(new TextDecoder).decode(e);let t="";for(let n=0,i=e.length;n{t&&t(n),r.manager.itemEnd(e)})).catch((e=>{i&&i(e)})):(setTimeout((function(){t&&t(a),r.manager.itemEnd(e)}),0),a);const s={};s.credentials="anonymous"===this.crossOrigin?"same-origin":"include",s.headers=this.requestHeader;const o=fetch(e,s).then((function(e){return e.blob()})).then((function(e){return createImageBitmap(e,Object.assign(r.options,{colorSpaceConversion:"none"}))})).then((function(n){return ls.add(e,n),t&&t(n),r.manager.itemEnd(e),n})).catch((function(t){i&&i(t),ls.remove(e),r.manager.itemError(e),r.manager.itemEnd(e)}));ls.add(e,o),r.manager.itemStart(e)}}class Fs extends ar{constructor(e=[]){super(),this.isArrayCamera=!0,this.cameras=e}}const Bs="\\[\\]\\.:\\/",zs=new RegExp("["+Bs+"]","g"),ks="[^"+Bs+"]",Hs="[^"+Bs.replace("\\.","")+"]",Vs=new RegExp("^"+/((?:WC+[\/:])*)/.source.replace("WC",ks)+/(WCOD+)?/.source.replace("WCOD",Hs)+/(?:\.(WC+)(?:\[(.+)\])?)?/.source.replace("WC",ks)+/\.(WC+)(?:\[(.+)\])?/.source.replace("WC",ks)+"$"),Gs=["material","materials","bones","map"];class Ws{constructor(e,t,n){this.path=t,this.parsedPath=n||Ws.parseTrackName(t),this.node=Ws.findNode(e,this.parsedPath.nodeName),this.rootNode=e,this.getValue=this._getValue_unbound,this.setValue=this._setValue_unbound}static create(e,t,n){return e&&e.isAnimationObjectGroup?new Ws.Composite(e,t,n):new Ws(e,t,n)}static sanitizeNodeName(e){return e.replace(/\s/g,"_").replace(zs,"")}static parseTrackName(e){const t=Vs.exec(e);if(null===t)throw new Error("PropertyBinding: Cannot parse trackName: "+e);const n={nodeName:t[2],objectName:t[3],objectIndex:t[4],propertyName:t[5],propertyIndex:t[6]},i=n.nodeName&&n.nodeName.lastIndexOf(".");if(void 0!==i&&-1!==i){const e=n.nodeName.substring(i+1);-1!==Gs.indexOf(e)&&(n.nodeName=n.nodeName.substring(0,i),n.objectName=e)}if(null===n.propertyName||0===n.propertyName.length)throw new Error("PropertyBinding: can not parse propertyName from trackName: "+e);return n}static findNode(e,t){if(void 0===t||""===t||"."===t||-1===t||t===e.name||t===e.uuid)return e;if(e.skeleton){const n=e.skeleton.getBoneByName(t);if(void 0!==n)return n}if(e.children){const n=function(e){for(let i=0;i{var t;switch(e.type){default:break;case"ambient":const n=new Is(new fi(e.color),0);this._lightSources.push(n);break;case"rectArea":const r=new jt(e.position.x,e.position.y,e.position.z);if(this.lightSourceScale&&r.length()this._scene.add(e)))}removeFromScene(){this._lightSources.forEach((e=>this._scene.remove(e)))}reload(){this.removeFromScene(),this.addToScene()}}no.noLightSources=[],no.defaultLightSources=[{type:"ambient",color:"#ffffff"},{type:"rectArea",position:{x:0,y:5,z:3},color:"#ffffff",intensity:60,castShadow:!0},{type:"rectArea",position:{x:-5,y:3,z:2},color:"#ffffff",intensity:60,castShadow:!1}],no.fifeLightSources=[{type:"ambient",color:"#ffffff"},{type:"rectArea",position:{x:0,y:5,z:0},color:"#ffffff",intensity:40,castShadow:!0},{type:"rectArea",position:{x:5,y:5,z:5},color:"#ffffff",intensity:60,castShadow:!0},{type:"rectArea",position:{x:-5,y:5,z:5},color:"#ffffff",intensity:60,castShadow:!0},{type:"rectArea",position:{x:5,y:5,z:-5},color:"#ffffff",intensity:60,castShadow:!0},{type:"rectArea",position:{x:-5,y:5,z:-5},color:"#ffffff",intensity:60,castShadow:!0}];const io={uniforms:{tDiffuse:{value:null},colorTransform:{value:new wn},colorBase:{value:new zt(0,0,0,0)},multiplyChannels:{value:0},uvTransform:{value:new xt}},vertexShader:"\n varying vec2 vUv;\n uniform mat3 uvTransform;\n \n void main() {\n vUv = (uvTransform * vec3(uv, 1.0)).xy;\n gl_Position = (projectionMatrix * modelViewMatrix * vec4(position, 1.0)).xyww;\n }",fragmentShader:"\n uniform sampler2D tDiffuse;\n uniform mat4 colorTransform;\n uniform vec4 colorBase;\n uniform float multiplyChannels;\n varying vec2 vUv;\n \n void main() {\n vec4 color = texture2D(tDiffuse, vUv);\n #if PREMULTIPLIED_ALPHA == 1\n if (color.a > 0.0) color.rgb /= color.a;\n #endif\n color = colorTransform * color + colorBase;\n color.rgb = mix(color.rgb, vec3(color.r * color.g * color.b), multiplyChannels);\n #if LINEAR_TO_SRGB == 1\n color.rgb = mix(color.rgb * 12.92, 1.055 * pow(color.rgb, vec3(0.41666)) - 0.055, step(0.0031308, color.rgb));\n #endif\n gl_FragColor = color;\n }"},ro=new wn,ao=(new wn).set(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,0),so=(new wn).set(0,0,0,1,0,0,0,1,0,0,0,1,0,0,0,0),oo=(new wn).set(1,0,0,0,1,0,0,0,1,0,0,0,0,0,0,1),lo=((new wn).set(0,1,0,0,0,1,0,0,0,1,0,0,0,0,0,1),(new wn).set(0,0,1,0,0,0,1,0,0,0,1,0,0,0,0,1),(new wn).set(1,0,0,0,1,0,0,0,1,0,0,0,0,0,0,1)),co=new zt(0,0,0,0),ho=new zt(0,0,0,1),uo=new xt,po=(new xt).set(1,0,0,0,-1,1,0,0,1),fo="additive";class mo extends er{constructor(e,t=fo,n=!1,i=!1){const r=t===fo?{blendSrc:v,blendDst:c,blendEquation:s,blendSrcAlpha:m,blendDstAlpha:c,blendEquationAlpha:s}:{};super(Object.assign({uniforms:$i.clone(io.uniforms),vertexShader:io.vertexShader,fragmentShader:io.fragmentShader,defines:{LINEAR_TO_SRGB:n?1:0,PREMULTIPLIED_ALPHA:i?1:0},transparent:!0,depthTest:!1,depthWrite:!1},r)),this.update(e)}update(e){return void 0!==(null==e?void 0:e.texture)&&(this.uniforms.tDiffuse.value=null==e?void 0:e.texture),void 0!==(null==e?void 0:e.colorTransform)&&(this.uniforms.colorTransform.value=null==e?void 0:e.colorTransform),void 0!==(null==e?void 0:e.colorBase)&&(this.uniforms.colorBase.value=null==e?void 0:e.colorBase),void 0!==(null==e?void 0:e.multiplyChannels)&&(this.uniforms.multiplyChannels.value=null==e?void 0:e.multiplyChannels),void 0!==(null==e?void 0:e.uvTransform)&&(this.uniforms.uvTransform.value=null==e?void 0:e.uvTransform),void 0!==(null==e?void 0:e.blending)&&(this.blending=null==e?void 0:e.blending),void 0!==(null==e?void 0:e.blendSrc)&&(this.blendSrc=null==e?void 0:e.blendSrc),void 0!==(null==e?void 0:e.blendDst)&&(this.blendDst=null==e?void 0:e.blendDst),void 0!==(null==e?void 0:e.blendEquation)&&(this.blendEquation=null==e?void 0:e.blendEquation),void 0!==(null==e?void 0:e.blendSrcAlpha)&&(this.blendSrcAlpha=null==e?void 0:e.blendSrcAlpha),void 0!==(null==e?void 0:e.blendDstAlpha)&&(this.blendDstAlpha=null==e?void 0:e.blendDstAlpha),void 0!==(null==e?void 0:e.blendEquationAlpha)&&(this.blendEquationAlpha=null==e?void 0:e.blendEquationAlpha),this}}const go={uniforms:{tDiffuse:{value:null},rangeMin:{value:new _t(1/512,1/512)},rangeMax:{value:new _t(1/512,1/512)}},vertexShader:"\n varying vec2 vUv;\n void main() {\n vUv = uv;\n gl_Position = projectionMatrix * modelViewMatrix * vec4(position, 1.0);\n }",fragmentShader:"\n uniform sampler2D tDiffuse;\n uniform vec2 rangeMin;\n uniform vec2 rangeMax;\n varying vec2 vUv;\n \n void main() {\n vec4 baseColor = texture2D(tDiffuse, vUv);\n vec2 blur = mix(rangeMax, rangeMin, baseColor.a);\n vec4 sum = vec4( 0.0 );\n sum += texture2D(tDiffuse, vUv - 1.0 * blur) * 0.051;\n sum += texture2D(tDiffuse, vUv - 0.75 * blur) * 0.0918;\n sum += texture2D(tDiffuse, vUv - 0.5 * blur) * 0.12245;\n sum += texture2D(tDiffuse, vUv - 0.25 * blur) * 0.1531;\n sum += baseColor * 0.1633;\n sum += texture2D(tDiffuse, vUv + 0.25 * blur) * 0.1531;\n sum += texture2D(tDiffuse, vUv + 0.5 * blur) * 0.12245;\n sum += texture2D(tDiffuse, vUv + 0.75 * blur) * 0.0918;\n sum += texture2D(tDiffuse, vUv + 1.0 * blur) * 0.051;\n gl_FragColor = sum;\n }"};new _t(.1,.9),new _t(.1,.9);class vo extends er{constructor(e){super({defines:Object.assign({},vo._linearDepthShader.defines),uniforms:$i.clone(vo._linearDepthShader.uniforms),vertexShader:vo._linearDepthShader.vertexShader,fragmentShader:vo._linearDepthShader.fragmentShader,blending:0}),this.update(e)}update(e){if(void 0!==(null==e?void 0:e.depthTexture)&&(this.uniforms.tDepth.value=null==e?void 0:e.depthTexture),void 0!==(null==e?void 0:e.camera)){const t=(null==e?void 0:e.camera)||(null==e?void 0:e.camera);this.uniforms.cameraNear.value=t.near,this.uniforms.cameraFar.value=t.far}return void 0!==(null==e?void 0:e.depthFilter)&&(this.uniforms.depthFilter.value=null==e?void 0:e.depthFilter),this}}vo._linearDepthShader={uniforms:{tDepth:{value:null},depthFilter:{value:new zt(1,0,0,0)},cameraNear:{value:.1},cameraFar:{value:1}},defines:{PERSPECTIVE_CAMERA:1,ALPHA_DEPTH:0},vertexShader:"varying vec2 vUv;\n void main() {\n vUv = uv;\n gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n }",fragmentShader:"uniform sampler2D tDepth;\n uniform vec4 depthFilter;\n uniform float cameraNear;\n uniform float cameraFar;\n varying vec2 vUv;\n \n #include \n \n float getLinearDepth(const in vec2 screenPosition) {\n float fragCoordZ = dot(texture2D(tDepth, screenPosition), depthFilter);\n #if PERSPECTIVE_CAMERA == 1\n float viewZ = perspectiveDepthToViewZ(fragCoordZ, cameraNear, cameraFar);\n return viewZToOrthographicDepth(viewZ, cameraNear, cameraFar);\n #else\n return fragCoordZ;\n #endif\n }\n \n void main() {\n float depth = getLinearDepth(vUv);\n gl_FragColor = vec4(vec3(1.0 - depth), 1.0);\n }"};class _o{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 xo=new Cs(-1,1,1,-1,0,1),yo=new class extends Oi{constructor(){super(),this.setAttribute("position",new Ai([-1,3,0,-1,-1,0,3,-1,0],3)),this.setAttribute("uv",new Ai([0,2,0,0,2,0],2))}};class So{constructor(e){this._mesh=new Yi(yo,e)}dispose(){this._mesh.geometry.dispose()}render(e){e.render(this._mesh,xo)}get material(){return this._mesh.material}set material(e){this._mesh.material=e}}class wo{constructor(e=Math){this.grad3=[[1,1,0],[-1,1,0],[1,-1,0],[-1,-1,0],[1,0,1],[-1,0,1],[1,0,-1],[-1,0,-1],[0,1,1],[0,-1,1],[0,1,-1],[0,-1,-1]],this.grad4=[[0,1,1,1],[0,1,1,-1],[0,1,-1,1],[0,1,-1,-1],[0,-1,1,1],[0,-1,1,-1],[0,-1,-1,1],[0,-1,-1,-1],[1,0,1,1],[1,0,1,-1],[1,0,-1,1],[1,0,-1,-1],[-1,0,1,1],[-1,0,1,-1],[-1,0,-1,1],[-1,0,-1,-1],[1,1,0,1],[1,1,0,-1],[1,-1,0,1],[1,-1,0,-1],[-1,1,0,1],[-1,1,0,-1],[-1,-1,0,1],[-1,-1,0,-1],[1,1,1,0],[1,1,-1,0],[1,-1,1,0],[1,-1,-1,0],[-1,1,1,0],[-1,1,-1,0],[-1,-1,1,0],[-1,-1,-1,0]],this.p=[];for(let t=0;t<256;t++)this.p[t]=Math.floor(256*e.random());this.perm=[];for(let e=0;e<512;e++)this.perm[e]=this.p[255&e];this.simplex=[[0,1,2,3],[0,1,3,2],[0,0,0,0],[0,2,3,1],[0,0,0,0],[0,0,0,0],[0,0,0,0],[1,2,3,0],[0,2,1,3],[0,0,0,0],[0,3,1,2],[0,3,2,1],[0,0,0,0],[0,0,0,0],[0,0,0,0],[1,3,2,0],[0,0,0,0],[0,0,0,0],[0,0,0,0],[0,0,0,0],[0,0,0,0],[0,0,0,0],[0,0,0,0],[0,0,0,0],[1,2,0,3],[0,0,0,0],[1,3,0,2],[0,0,0,0],[0,0,0,0],[0,0,0,0],[2,3,0,1],[2,3,1,0],[1,0,2,3],[1,0,3,2],[0,0,0,0],[0,0,0,0],[0,0,0,0],[2,0,3,1],[0,0,0,0],[2,1,3,0],[0,0,0,0],[0,0,0,0],[0,0,0,0],[0,0,0,0],[0,0,0,0],[0,0,0,0],[0,0,0,0],[0,0,0,0],[2,0,1,3],[0,0,0,0],[0,0,0,0],[0,0,0,0],[3,0,1,2],[3,0,2,1],[0,0,0,0],[3,1,2,0],[2,1,0,3],[0,0,0,0],[0,0,0,0],[0,0,0,0],[3,1,0,2],[0,0,0,0],[3,2,0,1],[3,2,1,0]]}dot(e,t,n){return e[0]*t+e[1]*n}dot3(e,t,n,i){return e[0]*t+e[1]*n+e[2]*i}dot4(e,t,n,i,r){return e[0]*t+e[1]*n+e[2]*i+e[3]*r}noise(e,t){let n,i,r;const a=(e+t)*(.5*(Math.sqrt(3)-1)),s=Math.floor(e+a),o=Math.floor(t+a),l=(3-Math.sqrt(3))/6,c=(s+o)*l,h=e-(s-c),d=t-(o-c);let u,p;h>d?(u=1,p=0):(u=0,p=1);const f=h-u+l,m=d-p+l,g=h-1+2*l,v=d-1+2*l,_=255&s,x=255&o,y=this.perm[_+this.perm[x]]%12,S=this.perm[_+u+this.perm[x+p]]%12,w=this.perm[_+1+this.perm[x+1]]%12;let b=.5-h*h-d*d;b<0?n=0:(b*=b,n=b*b*this.dot(this.grad3[y],h,d));let M=.5-f*f-m*m;M<0?i=0:(M*=M,i=M*M*this.dot(this.grad3[S],f,m));let T=.5-g*g-v*v;return T<0?r=0:(T*=T,r=T*T*this.dot(this.grad3[w],g,v)),70*(n+i+r)}noise3d(e,t,n){let i,r,a,s;const o=(e+t+n)*(1/3),l=Math.floor(e+o),c=Math.floor(t+o),h=Math.floor(n+o),d=1/6,u=(l+c+h)*d,p=e-(l-u),f=t-(c-u),m=n-(h-u);let g,v,_,x,y,S;p>=f?f>=m?(g=1,v=0,_=0,x=1,y=1,S=0):p>=m?(g=1,v=0,_=0,x=1,y=0,S=1):(g=0,v=0,_=1,x=1,y=0,S=1):fS?32:0)+(y>w?16:0)+(S>w?8:0)+(y>b?4:0)+(S>b?2:0)+(w>b?1:0),T=a[M][0]>=3?1:0,E=a[M][1]>=3?1:0,A=a[M][2]>=3?1:0,P=a[M][3]>=3?1:0,R=a[M][0]>=2?1:0,C=a[M][1]>=2?1:0,D=a[M][2]>=2?1:0,L=a[M][3]>=2?1:0,I=a[M][0]>=1?1:0,U=a[M][1]>=1?1:0,O=a[M][2]>=1?1:0,N=a[M][3]>=1?1:0,F=y-T+l,B=S-E+l,z=w-A+l,k=b-P+l,H=y-R+2*l,V=S-C+2*l,G=w-D+2*l,W=b-L+2*l,j=y-I+3*l,X=S-U+3*l,Y=w-O+3*l,q=b-N+3*l,Z=y-1+4*l,K=S-1+4*l,J=w-1+4*l,Q=b-1+4*l,$=255&m,ee=255&g,te=255&v,ne=255&_,ie=s[$+s[ee+s[te+s[ne]]]]%32,re=s[$+T+s[ee+E+s[te+A+s[ne+P]]]]%32,ae=s[$+R+s[ee+C+s[te+D+s[ne+L]]]]%32,se=s[$+I+s[ee+U+s[te+O+s[ne+N]]]]%32,oe=s[$+1+s[ee+1+s[te+1+s[ne+1]]]]%32;let le=.6-y*y-S*S-w*w-b*b;le<0?c=0:(le*=le,c=le*le*this.dot4(r[ie],y,S,w,b));let ce=.6-F*F-B*B-z*z-k*k;ce<0?h=0:(ce*=ce,h=ce*ce*this.dot4(r[re],F,B,z,k));let he=.6-H*H-V*V-G*G-W*W;he<0?d=0:(he*=he,d=he*he*this.dot4(r[ae],H,V,G,W));let de=.6-j*j-X*X-Y*Y-q*q;de<0?u=0:(de*=de,u=de*de*this.dot4(r[se],j,X,Y,q));let ue=.6-Z*Z-K*K-J*J-Q*Q;return ue<0?p=0:(ue*=ue,p=ue*ue*this.dot4(r[oe],Z,K,J,Q)),27*(c+h+d+u+p)}}const bo=new vs,Mo=e=>{const t=new Uint8Array([Math.floor(255*e.r),Math.floor(255*e.g),Math.floor(255*e.b),255]),n=new Tr(t,1,1);return n.needsUpdate=!0,n},To=(e,t,n)=>{n&&e(Mo(n)),t&&bo.load(t,e)};class Eo{constructor(){this.bounds=new qt(new jt(-1,-1,-1),new jt(1,1,1)),this.size=new jt(2,2,2),this.center=new jt(0,0,0),this.maxSceneDistanceFromCenter=Math.sqrt(3),this.maxSceneDistanceFrom0=Math.sqrt(3)}copyFrom(e){this.bounds.copy(e.bounds),this.size.copy(e.size),this.center.copy(e.center),this.maxSceneDistanceFromCenter=e.maxSceneDistanceFromCenter,this.maxSceneDistanceFrom0=e.maxSceneDistanceFrom0}updateFromObject(e){e.updateMatrixWorld(),this.bounds.setFromObject(e),this.updateFromBox(this.bounds)}updateFromBox(e){this.bounds!==e&&this.bounds.copy(e),this.bounds.getSize(this.size),this.bounds.getCenter(this.center),this.maxSceneDistanceFromCenter=this.size.length()/2,this.maxSceneDistanceFrom0=new jt(Math.max(Math.abs(this.bounds.min.x),Math.abs(this.bounds.max.x)),Math.max(Math.abs(this.bounds.min.y),Math.abs(this.bounds.max.y)),Math.max(Math.abs(this.bounds.min.z),Math.abs(this.bounds.max.z))).length()}updateCameraViewVolumeFromBounds(e){e.updateMatrixWorld();const t=this.bounds.clone().applyMatrix4(e.matrixWorldInverse);e instanceof Cs?((e,t)=>{e.left=t.min.x,e.right=t.max.x,e.bottom=t.min.y,e.top=t.max.y,e.near=Math.min(-t.min.z,-t.max.z),e.far=Math.max(-t.min.z,-t.max.z),e.updateProjectionMatrix()})(e,t):e instanceof ar&&((e,t)=>{const n=Math.min(-t.min.z,-t.max.z),i=Math.max(-t.min.z,-t.max.z);if(n<.001)return;const r=Math.max(Math.abs(t.min.x),Math.abs(t.max.x)),a=Math.max(Math.abs(t.min.y),Math.abs(t.max.y));e.aspect=r/a,e.fov=vt(2*Math.atan2(a,n)),e.near=n,e.far=i,e.updateProjectionMatrix()})(e,t)}getNearAndFarForPerspectiveCamera(e,t=1){const n=e.clone().sub(this.center).length();return[Math.max(.01,n-this.maxSceneDistanceFromCenter-.01),n+this.maxSceneDistanceFromCenter*t+.01]}}const Ao=e=>e.capabilities.maxSamples;class Po{changed(e){var t,n;const i=!(null===(t=this._lastCameraProjection)||void 0===t?void 0:t.equals(e.projectionMatrix))||!(null===(n=this._lastCameraWorld)||void 0===n?void 0:n.equals(e.matrixWorld));return this._lastCameraProjection=e.projectionMatrix.clone(),this._lastCameraWorld=e.matrixWorld.clone(),i}}class Ro{constructor(){this._originalClearColor=new fi,this._originalClearAlpha=0,this._originalAutoClear=!1,this._originalRenderTarget=null,this._screenSpaceQuad=new So(void 0),this._emptyScene=new hr,this._defaultCamera=new ar}renderWithOverrideMaterial(e,t,n,i,r,a,s){this._backup(e),this._prepareRenderer(e,r,a,s);const o=t.overrideMaterial;t.overrideMaterial=i,e.render(t,n),t.overrideMaterial=o,this._restore(e)}clear(e,t,n,i){this._backup(e),this._prepareRenderer(e,t,n,i),e.render(this._emptyScene,this._defaultCamera),this._restore(e)}render(e,t,n,i,r,a){this._backup(e),this._prepareRenderer(e,i,r,a),e.render(t,n),this._restore(e)}renderScreenSpace(e,t,n,i,r){this._backup(e),this._prepareRenderer(e,n,i,r),this._screenSpaceQuad.material=t,this._screenSpaceQuad.render(e),this._restore(e)}_prepareRenderer(e,t,n,i){e.setRenderTarget(t),e.autoClear=!1,null!=n&&(e.setClearColor(n),e.setClearAlpha(i||0),e.clear())}_backup(e){e.getClearColor(this._originalClearColor),this._originalClearAlpha=e.getClearAlpha(),this._originalAutoClear=e.autoClear,this._originalRenderTarget=e.getRenderTarget()}_restore(e){e.setClearColor(this._originalClearColor),e.setClearAlpha(this._originalClearAlpha),e.setRenderTarget(this._originalRenderTarget),e.autoClear=this._originalAutoClear}}class Co{constructor(e,t){var n;this._passRenderer=null!==(n=null==t?void 0:t.passRenderer)&&void 0!==n?n:new Ro,this._blurMaterial=new er(null!=e?e:go),this._blurMaterial.depthTest=!1}dispose(){this._blurMaterial.dispose()}render(e,t,n,i){this._blurMaterial.uniforms.tDiffuse.value=t[0].texture,this._blurMaterial.uniforms.rangeMin.value.x=n[0],this._blurMaterial.uniforms.rangeMin.value.y=0,this._blurMaterial.uniforms.rangeMax.value.x=i[0],this._blurMaterial.uniforms.rangeMax.value.y=0,this._passRenderer.renderScreenSpace(e,this._blurMaterial,t[1]),this._blurMaterial.uniforms.tDiffuse.value=t[1].texture,this._blurMaterial.uniforms.rangeMin.value.x=0,this._blurMaterial.uniforms.rangeMin.value.y=n[1],this._blurMaterial.uniforms.rangeMax.value.x=0,this._blurMaterial.uniforms.rangeMax.value.y=i[1],this._passRenderer.renderScreenSpace(e,this._blurMaterial,t[2])}}const Do=e.p+"9ba94fd0181997dfa7e8.png",Lo="OnlyShadow",Io="Transparent",Uo="Parquet",Oo="Pavement",No={},Fo=e=>{let t=No[e];if(!t){switch(e){default:t=new Fa;break;case Lo:t=new Na,t.opacity=.5;break;case Io:t=new Fa,t.transparent=!0,t.opacity=0;break;case"White":t=new Fa;break;case Uo:{const e=new Ba;To((t=>{Bo(t),e.map=t}),"TexturesCom_Wood_ParquetChevron7_1K_albedo.jpg",new fi(1,.6,.2)),To((t=>{Bo(t),e.normalMap=t}),"TexturesCom_Wood_ParquetChevron7_1K_normal.jpg"),To((t=>{Bo(t),e.roughnessMap=t}),"TexturesCom_Wood_ParquetChevron7_1K_roughness.jpg"),e.aoMapIntensity=0,e.roughness=1,e.metalness=0,e.envMapIntensity=.5,t=e;break}case Oo:{const e=new Ba;To((t=>{Bo(t),e.map=t}),"TexturesCom_Pavement_HerringboneNew_1K_albedo.jpg",new fi(.6,.3,0)),To((t=>{Bo(t),e.normalMap=t}),"TexturesCom_Pavement_HerringboneNew_1K_normal.jpg"),To((t=>{Bo(t),e.roughnessMap=t}),"TexturesCom_Pavement_HerringboneNew_1K_roughness.jpg"),To((t=>{Bo(t),e.aoMap=t}),"TexturesCom_Pavement_HerringboneNew_1K_ao.jpg"),e.aoMapIntensity=1,e.roughness=1,e.metalness=0,e.envMapIntensity=.5,t=e;break}}No[e]=t}return t},Bo=e=>{e.anisotropy=16,e.wrapS=N,e.wrapT=N,e.repeat.set(1e5,1e5)},zo=e=>{const t=Math.atan2(e.y,e.x)/(2*Math.PI)+.5,n=Math.asin(e.z)/Math.PI+.5;return new _t(t,n)};class ko{get colorRenderTarget(){var e;return this._colorRenderTarget=null!==(e=this._colorRenderTarget)&&void 0!==e?e:new Ht,this._colorRenderTarget}environmentMapDecodeTarget(e){var t;const n=e.capabilities.isWebGL2?Z:j;return this._environmentMapDecodeTarget=null!==(t=this._environmentMapDecodeTarget)&&void 0!==t?t:new Ht(1,1,{type:n}),this._environmentMapDecodeTarget}environmentMapDecodeMaterial(e){var t,n;return e?(this._equirectangularDecodeMaterial=null!==(t=this._equirectangularDecodeMaterial)&&void 0!==t?t:new Wo(!0,!1),this._equirectangularDecodeMaterial):(this._pmremDecodeMaterial=null!==(n=this._pmremDecodeMaterial)&&void 0!==n?n:new Wo(!1,!1),this._pmremDecodeMaterial)}get camera(){var e;return this._camera=null!==(e=this._camera)&&void 0!==e?e:new Cs(-1,1,1,-1,-1,1),this._camera}scaleTexture(e,t,n,i){var r;this.colorRenderTarget.setSize(n,i),this._planeMesh=null!==(r=this._planeMesh)&&void 0!==r?r:new Yi(new Da(2,2),new _i({map:t}));const a=e.getRenderTarget();e.setRenderTarget(this.colorRenderTarget),e.render(this._planeMesh,this.camera),e.setRenderTarget(a);const s=this.environmentMapDecodeTarget(e).texture,o=new Uint8Array(n*i*4);return e.readRenderTargetPixels(this.colorRenderTarget,0,0,n,i,o),{texture:s,pixels:o,sRgbaPixels:!1}}newGrayscaleTexture(e,t,n,i){var r;const a=this.environmentMapDecodeMaterial("PMREM.cubeUv"===t.name),s=this.environmentMapDecodeTarget(e);s.setSize(n,i),a.setSourceTexture(t),this._planeMesh=null!==(r=this._planeMesh)&&void 0!==r?r:new Yi(new Da(2,2),a);const o=e.getRenderTarget();e.setRenderTarget(s),e.render(this._planeMesh,this.camera),e.setRenderTarget(o);const l=s.texture,c=s.texture.type===Z,h=c?new Float32Array(n*i*4):new Uint8Array(n*i*4);return e.readRenderTargetPixels(s,0,0,n,i,h),{texture:l,pixels:h,sRgbaPixels:c}}}const Ho={tDiffuse:{value:null}},Vo="\n varying vec2 vUv;\n void main() {\n vUv = uv;\n gl_Position = (projectionMatrix * modelViewMatrix * vec4(position, 1.0)).xyww;\n }",Go="\n uniform sampler2D tDiffuse;\n varying vec2 vUv;\n \n float getFace( vec3 direction ) {\n vec3 absDirection = abs( direction );\n float face = - 1.0;\n if ( absDirection.x > absDirection.z ) {\n if ( absDirection.x > absDirection.y )\n face = direction.x > 0.0 ? 0.0 : 3.0;\n else\n face = direction.y > 0.0 ? 1.0 : 4.0;\n } else {\n if ( absDirection.z > absDirection.y )\n face = direction.z > 0.0 ? 2.0 : 5.0;\n else\n face = direction.y > 0.0 ? 1.0 : 4.0;\n }\n return face;\n }\n\n vec2 getUV( vec3 direction, float face ) {\n vec2 uv;\n if ( face == 0.0 ) {\n uv = vec2( direction.z, direction.y ) / abs( direction.x ); // pos x\n } else if ( face == 1.0 ) {\n uv = vec2( - direction.x, - direction.z ) / abs( direction.y ); // pos y\n } else if ( face == 2.0 ) {\n uv = vec2( - direction.x, direction.y ) / abs( direction.z ); // pos z\n } else if ( face == 3.0 ) {\n uv = vec2( - direction.z, direction.y ) / abs( direction.x ); // neg x\n } else if ( face == 4.0 ) {\n uv = vec2( - direction.x, direction.z ) / abs( direction.y ); // neg y\n } else {\n uv = vec2( direction.x, direction.y ) / abs( direction.z ); // neg z\n }\n return 0.5 * ( uv + 1.0 );\n }\n\n void main() {\n #if PMREM_DECODE == 1\n float altitude = (vUv.y - 0.5) * 3.141593;\n float azimuth = vUv.x * 2.0 * 3.141593;\n vec3 direction = vec3(\n cos(altitude) * cos(azimuth) * -1.0, \n sin(altitude), \n cos(altitude) * sin(azimuth) * -1.0\n );\n float face = getFace(direction);\n vec2 uv = getUV(direction, face) / vec2(3.0, 4.0);\n if (face > 2.5) {\n uv.y += 0.25;\n face -= 3.0;\n }\n uv.x += face / 3.0;\n vec4 color = texture2D(tDiffuse, uv);\n #else\n vec4 color = texture2D(tDiffuse, vUv);\n #endif \n #if GRAYSCALE_CONVERT == 1\n float grayscale = dot(color.rgb, vec3(0.2126, 0.7152, 0.0722));\n //float grayscale = dot(color.rgb, vec3(1.0/3.0));\n gl_FragColor = vec4(vec3(grayscale), 1.0);\n #else\n gl_FragColor = vec4(color.rgb, 1.0);\n #endif\n }";class Wo extends er{constructor(e,t){super({uniforms:$i.clone(Ho),vertexShader:Vo,fragmentShader:Go,defines:{PMREM_DECODE:e?1:0,GRAYSCALE_CONVERT:t?1:0}})}setSourceTexture(e){this.uniforms.tDiffuse.value=e}}class jo{constructor(e){var t,n,i,r;this.samplePoints=[],this.sampleUVs=[],this.grayscaleTexture={texture:new Bt,pixels:new Uint8Array(0),sRgbaPixels:!1},this.detectorTexture=new Bt,this.detectorArray=new Float32Array(0),this.lightSamples=[],this.lightGraph=new Yo(0),this.lightSources=[],this._grayScale=new jt(.2126,.7152,.0722),this._createEquirectangularSamplePoints=e=>{const t=[];for(let n=0;nzo(e)))}detectLightSources(e,t,n){var i;this.textureData=n,this._textureConverter=null!==(i=this._textureConverter)&&void 0!==i?i:new ko,this.grayscaleTexture=this._textureConverter.newGrayscaleTexture(e,t,this._width,this._height),this.detectorArray=this._redFromRgbaToNormalizedFloatArray(this.grayscaleTexture.pixels,this.grayscaleTexture.sRgbaPixels),this.detectorTexture=this._grayscaleTextureFromFloatArray(this.detectorArray,this._width,this._height),this.lightSamples=this._filterLightSamples(this._sampleThreshold),this.lightGraph=this._findClusterSegments(this.lightSamples,this._sampleThreshold),this.lightGraph.findConnectedComponents(),this.lightSources=this.createLightSourcesFromLightGraph(this.lightSamples,this.lightGraph),this.lightSources.sort(((e,t)=>t.maxIntensity-e.maxIntensity))}_redFromRgbaToNormalizedFloatArray(e,t,n){const i=new Float32Array(e.length/4);let r=1,a=0;for(let t=0;te&&t.push(new Xo(this.samplePoints[n],i))}return t}_detectorTextureLuminanceValueFromUV(e){const t=Math.floor(e.x*this._width),n=Math.floor(e.y*this._height)*this._width+t;return this.detectorArray[n]}_originalLuminanceValueFromUV(e){if(!(this.textureData&&this.textureData.data&&this.textureData._width&&this.textureData._height))return 256*this._detectorTextureLuminanceValueFromUV(e);const t=Math.floor(e.x*this.textureData._width),n=Math.floor(e.y*this.textureData._height);let i=0;for(let e=Math.max(0,t-2);e1){l=!1;break}}else c=0}l&&(r.adjacent[a].push(s),r.adjacent[s].push(a),r.edges.push([a,s]))}return r}createLightSourcesFromLightGraph(e,t){const n=t.components.filter((e=>e.length>1)).map((t=>new qo(t.map((t=>e[t])))));return n.forEach((e=>e.calculateLightSourceProperties((e=>this._originalLuminanceValueFromUV(e))))),n}}class Xo{constructor(e,t){this.position=e,this.uv=t}}class Yo{constructor(e){this.edges=[],this.adjacent=[],this.components=[],this.noOfNodes=e;for(let t=0;tt.length-e.length))}_dfs(e,t,n){t[e]=!0,n.push(e);for(const i of this.adjacent[e])t[i]||this._dfs(i,t,n)}}class qo{constructor(e){this.position=new jt,this.uv=new _t,this.averageIntensity=0,this.maxIntensity=0,this.size=0,this.lightSamples=e}calculateLightSourceProperties(e){this.position=new jt,this.averageIntensity=0,this.maxIntensity=0;for(const t of this.lightSamples){this.position.add(t.position);const n=e(t.uv);this.averageIntensity+=n,this.maxIntensity=Math.max(this.maxIntensity,n)}this.averageIntensity/=this.lightSamples.length,this.position.normalize(),this.uv=zo(this.position);let t=0;for(const e of this.lightSamples)t+=e.position.distanceTo(this.position);t/=this.lightSamples.length,this.size=t/Math.PI}}class Zo{constructor(e){this._lightSourceDetector=e}static createPlane(e,t){const n=new Da(2,1),i=null!=t?t:new _i({color:12632256,side:2}),r=new Yi(n,i);return r.position.z=-.1,e.add(r),r}createDebugScene(e,t){this._scene=e,this._createLightGraphInMap(this._lightSourceDetector.sampleUVs,this._lightSourceDetector.lightSamples,this._lightSourceDetector.lightGraph,t)}_createLightGraphInMap(e,t,n,i){const r=[],a=[];for(let e=0;ee.uv)),o=a.map((e=>e.uv)),l=e.filter((e=>!s.includes(e)&&!o.includes(e)));this._createSamplePointsInMap(l,.005,16711680),this._createSamplePointsInMap(s,.01,255),this._createSamplePointsInMap(o,.01,65280),this._createClusterLinesInMap(this._lightSourceDetector.lightSamples,this._lightSourceDetector.lightGraph.edges,128);const c=this._lightSourceDetector.lightSources.map((e=>e.uv));this._createSamplePointsInMap(c,.015,16776960);let h=this._lightSourceDetector.lightSources;void 0!==i&&i>=0&&i{var t;const n=new Yi(i,r);n.position.copy(this._uvToMapPosition(e)),n.name="samplePoint",null===(t=this._scene)||void 0===t||t.add(n)}))}_createCirclesInMap(e,t){const n=new _i({color:t,transparent:!0,opacity:.5});e.forEach((e=>{var t;const i=new Aa(e.size,8,4),r=new Yi(i,n);r.position.copy(this._uvToMapPosition(e.uv)),r.name="samplePoint",null===(t=this._scene)||void 0===t||t.add(r)}))}_createClusterLinesInMap(e,t,n){var i;const r=new jr({color:n}),a=[];t.forEach((t=>{for(let n=1;n.5){const e=(i.y+r.y)/2,t=i.xe.start-t.start));let t=0;for(let e=1;e 0\n\tvec4 plane;\n\t#ifdef ALPHA_TO_COVERAGE\n\t\tfloat distanceToPlane, distanceGradient;\n\t\tfloat clipOpacity = 1.0;\n\t\t#pragma unroll_loop_start\n\t\tfor ( int i = 0; i < UNION_CLIPPING_PLANES; i ++ ) {\n\t\t\tplane = clippingPlanes[ i ];\n\t\t\tdistanceToPlane = - dot( vClipPosition, plane.xyz ) + plane.w;\n\t\t\tdistanceGradient = fwidth( distanceToPlane ) / 2.0;\n\t\t\tclipOpacity *= smoothstep( - distanceGradient, distanceGradient, distanceToPlane );\n\t\t\tif ( clipOpacity == 0.0 ) discard;\n\t\t}\n\t\t#pragma unroll_loop_end\n\t\t#if UNION_CLIPPING_PLANES < NUM_CLIPPING_PLANES\n\t\t\tfloat unionClipOpacity = 1.0;\n\t\t\t#pragma unroll_loop_start\n\t\t\tfor ( int i = UNION_CLIPPING_PLANES; i < NUM_CLIPPING_PLANES; i ++ ) {\n\t\t\t\tplane = clippingPlanes[ i ];\n\t\t\t\tdistanceToPlane = - dot( vClipPosition, plane.xyz ) + plane.w;\n\t\t\t\tdistanceGradient = fwidth( distanceToPlane ) / 2.0;\n\t\t\t\tunionClipOpacity *= 1.0 - smoothstep( - distanceGradient, distanceGradient, distanceToPlane );\n\t\t\t}\n\t\t\t#pragma unroll_loop_end\n\t\t\tclipOpacity *= 1.0 - unionClipOpacity;\n\t\t#endif\n\t\tdiffuseColor.a *= clipOpacity;\n\t\tif ( diffuseColor.a == 0.0 ) discard;\n\t#else\n\t\t#pragma unroll_loop_start\n\t\tfor ( int i = 0; i < UNION_CLIPPING_PLANES; i ++ ) {\n\t\t\tplane = clippingPlanes[ i ];\n\t\t\tif ( dot( vClipPosition, plane.xyz ) > plane.w ) discard;\n\t\t}\n\t\t#pragma unroll_loop_end\n\t\t#if UNION_CLIPPING_PLANES < NUM_CLIPPING_PLANES\n\t\t\tbool clipped = true;\n\t\t\t#pragma unroll_loop_start\n\t\t\tfor ( int i = UNION_CLIPPING_PLANES; i < NUM_CLIPPING_PLANES; i ++ ) {\n\t\t\t\tplane = clippingPlanes[ i ];\n\t\t\t\tclipped = ( dot( vClipPosition, plane.xyz ) > plane.w ) && clipped;\n\t\t\t}\n\t\t\t#pragma unroll_loop_end\n\t\t\tif ( clipped ) discard;\n\t\t#endif\n\t#endif\n#endif",clipping_planes_pars_fragment:"#if NUM_CLIPPING_PLANES > 0\n\tvarying vec3 vClipPosition;\n\tuniform vec4 clippingPlanes[ NUM_CLIPPING_PLANES ];\n#endif",clipping_planes_pars_vertex:"#if NUM_CLIPPING_PLANES > 0\n\tvarying vec3 vClipPosition;\n#endif",clipping_planes_vertex:"#if NUM_CLIPPING_PLANES > 0\n\tvClipPosition = - mvPosition.xyz;\n#endif",color_fragment:"#if defined( USE_COLOR_ALPHA )\n\tdiffuseColor *= vColor;\n#elif defined( USE_COLOR )\n\tdiffuseColor.rgb *= vColor;\n#endif",color_pars_fragment:"#if defined( USE_COLOR_ALPHA )\n\tvarying vec4 vColor;\n#elif defined( USE_COLOR )\n\tvarying vec3 vColor;\n#endif",color_pars_vertex:"#if defined( USE_COLOR_ALPHA )\n\tvarying vec4 vColor;\n#elif defined( USE_COLOR ) || defined( USE_INSTANCING_COLOR ) || defined( USE_BATCHING_COLOR )\n\tvarying vec3 vColor;\n#endif",color_vertex:"#if defined( USE_COLOR_ALPHA )\n\tvColor = vec4( 1.0 );\n#elif defined( USE_COLOR ) || defined( USE_INSTANCING_COLOR ) || defined( USE_BATCHING_COLOR )\n\tvColor = vec3( 1.0 );\n#endif\n#ifdef USE_COLOR\n\tvColor *= color;\n#endif\n#ifdef USE_INSTANCING_COLOR\n\tvColor.xyz *= instanceColor.xyz;\n#endif\n#ifdef USE_BATCHING_COLOR\n\tvec3 batchingColor = getBatchingColor( getIndirectIndex( gl_DrawID ) );\n\tvColor.xyz *= batchingColor.xyz;\n#endif",common:"#define PI 3.141592653589793\n#define PI2 6.283185307179586\n#define PI_HALF 1.5707963267948966\n#define RECIPROCAL_PI 0.3183098861837907\n#define RECIPROCAL_PI2 0.15915494309189535\n#define EPSILON 1e-6\n#ifndef saturate\n#define saturate( a ) clamp( a, 0.0, 1.0 )\n#endif\n#define whiteComplement( a ) ( 1.0 - saturate( a ) )\nfloat pow2( const in float x ) { return x*x; }\nvec3 pow2( const in vec3 x ) { return x*x; }\nfloat pow3( const in float x ) { return x*x*x; }\nfloat pow4( const in float x ) { float x2 = x*x; return x2*x2; }\nfloat max3( const in vec3 v ) { return max( max( v.x, v.y ), v.z ); }\nfloat average( const in vec3 v ) { return dot( v, vec3( 0.3333333 ) ); }\nhighp float rand( const in vec2 uv ) {\n\tconst highp float a = 12.9898, b = 78.233, c = 43758.5453;\n\thighp float dt = dot( uv.xy, vec2( a,b ) ), sn = mod( dt, PI );\n\treturn fract( sin( sn ) * c );\n}\n#ifdef HIGH_PRECISION\n\tfloat precisionSafeLength( vec3 v ) { return length( v ); }\n#else\n\tfloat precisionSafeLength( vec3 v ) {\n\t\tfloat maxComponent = max3( abs( v ) );\n\t\treturn length( v / maxComponent ) * maxComponent;\n\t}\n#endif\nstruct IncidentLight {\n\tvec3 color;\n\tvec3 direction;\n\tbool visible;\n};\nstruct ReflectedLight {\n\tvec3 directDiffuse;\n\tvec3 directSpecular;\n\tvec3 indirectDiffuse;\n\tvec3 indirectSpecular;\n};\n#ifdef USE_ALPHAHASH\n\tvarying vec3 vPosition;\n#endif\nvec3 transformDirection( in vec3 dir, in mat4 matrix ) {\n\treturn normalize( ( matrix * vec4( dir, 0.0 ) ).xyz );\n}\nvec3 inverseTransformDirection( in vec3 dir, in mat4 matrix ) {\n\treturn normalize( ( vec4( dir, 0.0 ) * matrix ).xyz );\n}\nmat3 transposeMat3( const in mat3 m ) {\n\tmat3 tmp;\n\ttmp[ 0 ] = vec3( m[ 0 ].x, m[ 1 ].x, m[ 2 ].x );\n\ttmp[ 1 ] = vec3( m[ 0 ].y, m[ 1 ].y, m[ 2 ].y );\n\ttmp[ 2 ] = vec3( m[ 0 ].z, m[ 1 ].z, m[ 2 ].z );\n\treturn tmp;\n}\nbool isPerspectiveMatrix( mat4 m ) {\n\treturn m[ 2 ][ 3 ] == - 1.0;\n}\nvec2 equirectUv( in vec3 dir ) {\n\tfloat u = atan( dir.z, dir.x ) * RECIPROCAL_PI2 + 0.5;\n\tfloat v = asin( clamp( dir.y, - 1.0, 1.0 ) ) * RECIPROCAL_PI + 0.5;\n\treturn vec2( u, v );\n}\nvec3 BRDF_Lambert( const in vec3 diffuseColor ) {\n\treturn RECIPROCAL_PI * diffuseColor;\n}\nvec3 F_Schlick( const in vec3 f0, const in float f90, const in float dotVH ) {\n\tfloat fresnel = exp2( ( - 5.55473 * dotVH - 6.98316 ) * dotVH );\n\treturn f0 * ( 1.0 - fresnel ) + ( f90 * fresnel );\n}\nfloat F_Schlick( const in float f0, const in float f90, const in float dotVH ) {\n\tfloat fresnel = exp2( ( - 5.55473 * dotVH - 6.98316 ) * dotVH );\n\treturn f0 * ( 1.0 - fresnel ) + ( f90 * fresnel );\n} // validated",cube_uv_reflection_fragment:"#ifdef ENVMAP_TYPE_CUBE_UV\n\t#define cubeUV_minMipLevel 4.0\n\t#define cubeUV_minTileSize 16.0\n\tfloat getFace( vec3 direction ) {\n\t\tvec3 absDirection = abs( direction );\n\t\tfloat face = - 1.0;\n\t\tif ( absDirection.x > absDirection.z ) {\n\t\t\tif ( absDirection.x > absDirection.y )\n\t\t\t\tface = direction.x > 0.0 ? 0.0 : 3.0;\n\t\t\telse\n\t\t\t\tface = direction.y > 0.0 ? 1.0 : 4.0;\n\t\t} else {\n\t\t\tif ( absDirection.z > absDirection.y )\n\t\t\t\tface = direction.z > 0.0 ? 2.0 : 5.0;\n\t\t\telse\n\t\t\t\tface = direction.y > 0.0 ? 1.0 : 4.0;\n\t\t}\n\t\treturn face;\n\t}\n\tvec2 getUV( vec3 direction, float face ) {\n\t\tvec2 uv;\n\t\tif ( face == 0.0 ) {\n\t\t\tuv = vec2( direction.z, direction.y ) / abs( direction.x );\n\t\t} else if ( face == 1.0 ) {\n\t\t\tuv = vec2( - direction.x, - direction.z ) / abs( direction.y );\n\t\t} else if ( face == 2.0 ) {\n\t\t\tuv = vec2( - direction.x, direction.y ) / abs( direction.z );\n\t\t} else if ( face == 3.0 ) {\n\t\t\tuv = vec2( - direction.z, direction.y ) / abs( direction.x );\n\t\t} else if ( face == 4.0 ) {\n\t\t\tuv = vec2( - direction.x, direction.z ) / abs( direction.y );\n\t\t} else {\n\t\t\tuv = vec2( direction.x, direction.y ) / abs( direction.z );\n\t\t}\n\t\treturn 0.5 * ( uv + 1.0 );\n\t}\n\tvec3 bilinearCubeUV( sampler2D envMap, vec3 direction, float mipInt ) {\n\t\tfloat face = getFace( direction );\n\t\tfloat filterInt = max( cubeUV_minMipLevel - mipInt, 0.0 );\n\t\tmipInt = max( mipInt, cubeUV_minMipLevel );\n\t\tfloat faceSize = exp2( mipInt );\n\t\thighp vec2 uv = getUV( direction, face ) * ( faceSize - 2.0 ) + 1.0;\n\t\tif ( face > 2.0 ) {\n\t\t\tuv.y += faceSize;\n\t\t\tface -= 3.0;\n\t\t}\n\t\tuv.x += face * faceSize;\n\t\tuv.x += filterInt * 3.0 * cubeUV_minTileSize;\n\t\tuv.y += 4.0 * ( exp2( CUBEUV_MAX_MIP ) - faceSize );\n\t\tuv.x *= CUBEUV_TEXEL_WIDTH;\n\t\tuv.y *= CUBEUV_TEXEL_HEIGHT;\n\t\t#ifdef texture2DGradEXT\n\t\t\treturn texture2DGradEXT( envMap, uv, vec2( 0.0 ), vec2( 0.0 ) ).rgb;\n\t\t#else\n\t\t\treturn texture2D( envMap, uv ).rgb;\n\t\t#endif\n\t}\n\t#define cubeUV_r0 1.0\n\t#define cubeUV_m0 - 2.0\n\t#define cubeUV_r1 0.8\n\t#define cubeUV_m1 - 1.0\n\t#define cubeUV_r4 0.4\n\t#define cubeUV_m4 2.0\n\t#define cubeUV_r5 0.305\n\t#define cubeUV_m5 3.0\n\t#define cubeUV_r6 0.21\n\t#define cubeUV_m6 4.0\n\tfloat roughnessToMip( float roughness ) {\n\t\tfloat mip = 0.0;\n\t\tif ( roughness >= cubeUV_r1 ) {\n\t\t\tmip = ( cubeUV_r0 - roughness ) * ( cubeUV_m1 - cubeUV_m0 ) / ( cubeUV_r0 - cubeUV_r1 ) + cubeUV_m0;\n\t\t} else if ( roughness >= cubeUV_r4 ) {\n\t\t\tmip = ( cubeUV_r1 - roughness ) * ( cubeUV_m4 - cubeUV_m1 ) / ( cubeUV_r1 - cubeUV_r4 ) + cubeUV_m1;\n\t\t} else if ( roughness >= cubeUV_r5 ) {\n\t\t\tmip = ( cubeUV_r4 - roughness ) * ( cubeUV_m5 - cubeUV_m4 ) / ( cubeUV_r4 - cubeUV_r5 ) + cubeUV_m4;\n\t\t} else if ( roughness >= cubeUV_r6 ) {\n\t\t\tmip = ( cubeUV_r5 - roughness ) * ( cubeUV_m6 - cubeUV_m5 ) / ( cubeUV_r5 - cubeUV_r6 ) + cubeUV_m5;\n\t\t} else {\n\t\t\tmip = - 2.0 * log2( 1.16 * roughness );\t\t}\n\t\treturn mip;\n\t}\n\tvec4 textureCubeUV( sampler2D envMap, vec3 sampleDir, float roughness ) {\n\t\tfloat mip = clamp( roughnessToMip( roughness ), cubeUV_m0, CUBEUV_MAX_MIP );\n\t\tfloat mipF = fract( mip );\n\t\tfloat mipInt = floor( mip );\n\t\tvec3 color0 = bilinearCubeUV( envMap, sampleDir, mipInt );\n\t\tif ( mipF == 0.0 ) {\n\t\t\treturn vec4( color0, 1.0 );\n\t\t} else {\n\t\t\tvec3 color1 = bilinearCubeUV( envMap, sampleDir, mipInt + 1.0 );\n\t\t\treturn vec4( mix( color0, color1, mipF ), 1.0 );\n\t\t}\n\t}\n#endif",defaultnormal_vertex:"vec3 transformedNormal = objectNormal;\n#ifdef USE_TANGENT\n\tvec3 transformedTangent = objectTangent;\n#endif\n#ifdef USE_BATCHING\n\tmat3 bm = mat3( batchingMatrix );\n\ttransformedNormal /= vec3( dot( bm[ 0 ], bm[ 0 ] ), dot( bm[ 1 ], bm[ 1 ] ), dot( bm[ 2 ], bm[ 2 ] ) );\n\ttransformedNormal = bm * transformedNormal;\n\t#ifdef USE_TANGENT\n\t\ttransformedTangent = bm * transformedTangent;\n\t#endif\n#endif\n#ifdef USE_INSTANCING\n\tmat3 im = mat3( instanceMatrix );\n\ttransformedNormal /= vec3( dot( im[ 0 ], im[ 0 ] ), dot( im[ 1 ], im[ 1 ] ), dot( im[ 2 ], im[ 2 ] ) );\n\ttransformedNormal = im * transformedNormal;\n\t#ifdef USE_TANGENT\n\t\ttransformedTangent = im * transformedTangent;\n\t#endif\n#endif\ntransformedNormal = normalMatrix * transformedNormal;\n#ifdef FLIP_SIDED\n\ttransformedNormal = - transformedNormal;\n#endif\n#ifdef USE_TANGENT\n\ttransformedTangent = ( modelViewMatrix * vec4( transformedTangent, 0.0 ) ).xyz;\n\t#ifdef FLIP_SIDED\n\t\ttransformedTangent = - transformedTangent;\n\t#endif\n#endif",displacementmap_pars_vertex:"#ifdef USE_DISPLACEMENTMAP\n\tuniform sampler2D displacementMap;\n\tuniform float displacementScale;\n\tuniform float displacementBias;\n#endif",displacementmap_vertex:"#ifdef USE_DISPLACEMENTMAP\n\ttransformed += normalize( objectNormal ) * ( texture2D( displacementMap, vDisplacementMapUv ).x * displacementScale + displacementBias );\n#endif",emissivemap_fragment:"#ifdef USE_EMISSIVEMAP\n\tvec4 emissiveColor = texture2D( emissiveMap, vEmissiveMapUv );\n\t#ifdef DECODE_VIDEO_TEXTURE_EMISSIVE\n\t\temissiveColor = sRGBTransferEOTF( emissiveColor );\n\t#endif\n\ttotalEmissiveRadiance *= emissiveColor.rgb;\n#endif",emissivemap_pars_fragment:"#ifdef USE_EMISSIVEMAP\n\tuniform sampler2D emissiveMap;\n#endif",colorspace_fragment:"gl_FragColor = linearToOutputTexel( gl_FragColor );",colorspace_pars_fragment:"vec4 LinearTransferOETF( in vec4 value ) {\n\treturn value;\n}\nvec4 sRGBTransferEOTF( in vec4 value ) {\n\treturn vec4( mix( pow( value.rgb * 0.9478672986 + vec3( 0.0521327014 ), vec3( 2.4 ) ), value.rgb * 0.0773993808, vec3( lessThanEqual( value.rgb, vec3( 0.04045 ) ) ) ), value.a );\n}\nvec4 sRGBTransferOETF( in vec4 value ) {\n\treturn vec4( mix( pow( value.rgb, vec3( 0.41666 ) ) * 1.055 - vec3( 0.055 ), value.rgb * 12.92, vec3( lessThanEqual( value.rgb, vec3( 0.0031308 ) ) ) ), value.a );\n}",envmap_fragment:"#ifdef USE_ENVMAP\n\t#ifdef ENV_WORLDPOS\n\t\tvec3 cameraToFrag;\n\t\tif ( isOrthographic ) {\n\t\t\tcameraToFrag = normalize( vec3( - viewMatrix[ 0 ][ 2 ], - viewMatrix[ 1 ][ 2 ], - viewMatrix[ 2 ][ 2 ] ) );\n\t\t} else {\n\t\t\tcameraToFrag = normalize( vWorldPosition - cameraPosition );\n\t\t}\n\t\tvec3 worldNormal = inverseTransformDirection( normal, viewMatrix );\n\t\t#ifdef ENVMAP_MODE_REFLECTION\n\t\t\tvec3 reflectVec = reflect( cameraToFrag, worldNormal );\n\t\t#else\n\t\t\tvec3 reflectVec = refract( cameraToFrag, worldNormal, refractionRatio );\n\t\t#endif\n\t#else\n\t\tvec3 reflectVec = vReflect;\n\t#endif\n\t#ifdef ENVMAP_TYPE_CUBE\n\t\tvec4 envColor = textureCube( envMap, envMapRotation * vec3( flipEnvMap * reflectVec.x, reflectVec.yz ) );\n\t#else\n\t\tvec4 envColor = vec4( 0.0 );\n\t#endif\n\t#ifdef ENVMAP_BLENDING_MULTIPLY\n\t\toutgoingLight = mix( outgoingLight, outgoingLight * envColor.xyz, specularStrength * reflectivity );\n\t#elif defined( ENVMAP_BLENDING_MIX )\n\t\toutgoingLight = mix( outgoingLight, envColor.xyz, specularStrength * reflectivity );\n\t#elif defined( ENVMAP_BLENDING_ADD )\n\t\toutgoingLight += envColor.xyz * specularStrength * reflectivity;\n\t#endif\n#endif",envmap_common_pars_fragment:"#ifdef USE_ENVMAP\n\tuniform float envMapIntensity;\n\tuniform float flipEnvMap;\n\tuniform mat3 envMapRotation;\n\t#ifdef ENVMAP_TYPE_CUBE\n\t\tuniform samplerCube envMap;\n\t#else\n\t\tuniform sampler2D envMap;\n\t#endif\n\t\n#endif",envmap_pars_fragment:"#ifdef USE_ENVMAP\n\tuniform float reflectivity;\n\t#if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG ) || defined( LAMBERT )\n\t\t#define ENV_WORLDPOS\n\t#endif\n\t#ifdef ENV_WORLDPOS\n\t\tvarying vec3 vWorldPosition;\n\t\tuniform float refractionRatio;\n\t#else\n\t\tvarying vec3 vReflect;\n\t#endif\n#endif",envmap_pars_vertex:"#ifdef USE_ENVMAP\n\t#if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG ) || defined( LAMBERT )\n\t\t#define ENV_WORLDPOS\n\t#endif\n\t#ifdef ENV_WORLDPOS\n\t\t\n\t\tvarying vec3 vWorldPosition;\n\t#else\n\t\tvarying vec3 vReflect;\n\t\tuniform float refractionRatio;\n\t#endif\n#endif",envmap_physical_pars_fragment:"#ifdef USE_ENVMAP\n\tvec3 getIBLIrradiance( const in vec3 normal ) {\n\t\t#ifdef ENVMAP_TYPE_CUBE_UV\n\t\t\tvec3 worldNormal = inverseTransformDirection( normal, viewMatrix );\n\t\t\tvec4 envMapColor = textureCubeUV( envMap, envMapRotation * worldNormal, 1.0 );\n\t\t\treturn PI * envMapColor.rgb * envMapIntensity;\n\t\t#else\n\t\t\treturn vec3( 0.0 );\n\t\t#endif\n\t}\n\tvec3 getIBLRadiance( const in vec3 viewDir, const in vec3 normal, const in float roughness ) {\n\t\t#ifdef ENVMAP_TYPE_CUBE_UV\n\t\t\tvec3 reflectVec = reflect( - viewDir, normal );\n\t\t\treflectVec = normalize( mix( reflectVec, normal, roughness * roughness) );\n\t\t\treflectVec = inverseTransformDirection( reflectVec, viewMatrix );\n\t\t\tvec4 envMapColor = textureCubeUV( envMap, envMapRotation * reflectVec, roughness );\n\t\t\treturn envMapColor.rgb * envMapIntensity;\n\t\t#else\n\t\t\treturn vec3( 0.0 );\n\t\t#endif\n\t}\n\t#ifdef USE_ANISOTROPY\n\t\tvec3 getIBLAnisotropyRadiance( const in vec3 viewDir, const in vec3 normal, const in float roughness, const in vec3 bitangent, const in float anisotropy ) {\n\t\t\t#ifdef ENVMAP_TYPE_CUBE_UV\n\t\t\t\tvec3 bentNormal = cross( bitangent, viewDir );\n\t\t\t\tbentNormal = normalize( cross( bentNormal, bitangent ) );\n\t\t\t\tbentNormal = normalize( mix( bentNormal, normal, pow2( pow2( 1.0 - anisotropy * ( 1.0 - roughness ) ) ) ) );\n\t\t\t\treturn getIBLRadiance( viewDir, bentNormal, roughness );\n\t\t\t#else\n\t\t\t\treturn vec3( 0.0 );\n\t\t\t#endif\n\t\t}\n\t#endif\n#endif",envmap_vertex:"#ifdef USE_ENVMAP\n\t#ifdef ENV_WORLDPOS\n\t\tvWorldPosition = worldPosition.xyz;\n\t#else\n\t\tvec3 cameraToVertex;\n\t\tif ( isOrthographic ) {\n\t\t\tcameraToVertex = normalize( vec3( - viewMatrix[ 0 ][ 2 ], - viewMatrix[ 1 ][ 2 ], - viewMatrix[ 2 ][ 2 ] ) );\n\t\t} else {\n\t\t\tcameraToVertex = normalize( worldPosition.xyz - cameraPosition );\n\t\t}\n\t\tvec3 worldNormal = inverseTransformDirection( transformedNormal, viewMatrix );\n\t\t#ifdef ENVMAP_MODE_REFLECTION\n\t\t\tvReflect = reflect( cameraToVertex, worldNormal );\n\t\t#else\n\t\t\tvReflect = refract( cameraToVertex, worldNormal, refractionRatio );\n\t\t#endif\n\t#endif\n#endif",fog_vertex:"#ifdef USE_FOG\n\tvFogDepth = - mvPosition.z;\n#endif",fog_pars_vertex:"#ifdef USE_FOG\n\tvarying float vFogDepth;\n#endif",fog_fragment:"#ifdef USE_FOG\n\t#ifdef FOG_EXP2\n\t\tfloat fogFactor = 1.0 - exp( - fogDensity * fogDensity * vFogDepth * vFogDepth );\n\t#else\n\t\tfloat fogFactor = smoothstep( fogNear, fogFar, vFogDepth );\n\t#endif\n\tgl_FragColor.rgb = mix( gl_FragColor.rgb, fogColor, fogFactor );\n#endif",fog_pars_fragment:"#ifdef USE_FOG\n\tuniform vec3 fogColor;\n\tvarying float vFogDepth;\n\t#ifdef FOG_EXP2\n\t\tuniform float fogDensity;\n\t#else\n\t\tuniform float fogNear;\n\t\tuniform float fogFar;\n\t#endif\n#endif",gradientmap_pars_fragment:"#ifdef USE_GRADIENTMAP\n\tuniform sampler2D gradientMap;\n#endif\nvec3 getGradientIrradiance( vec3 normal, vec3 lightDirection ) {\n\tfloat dotNL = dot( normal, lightDirection );\n\tvec2 coord = vec2( dotNL * 0.5 + 0.5, 0.0 );\n\t#ifdef USE_GRADIENTMAP\n\t\treturn vec3( texture2D( gradientMap, coord ).r );\n\t#else\n\t\tvec2 fw = fwidth( coord ) * 0.5;\n\t\treturn mix( vec3( 0.7 ), vec3( 1.0 ), smoothstep( 0.7 - fw.x, 0.7 + fw.x, coord.x ) );\n\t#endif\n}",lightmap_pars_fragment:"#ifdef USE_LIGHTMAP\n\tuniform sampler2D lightMap;\n\tuniform float lightMapIntensity;\n#endif",lights_lambert_fragment:"LambertMaterial material;\nmaterial.diffuseColor = diffuseColor.rgb;\nmaterial.specularStrength = specularStrength;",lights_lambert_pars_fragment:"varying vec3 vViewPosition;\nstruct LambertMaterial {\n\tvec3 diffuseColor;\n\tfloat specularStrength;\n};\nvoid RE_Direct_Lambert( const in IncidentLight directLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in LambertMaterial material, inout ReflectedLight reflectedLight ) {\n\tfloat dotNL = saturate( dot( geometryNormal, directLight.direction ) );\n\tvec3 irradiance = dotNL * directLight.color;\n\treflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );\n}\nvoid RE_IndirectDiffuse_Lambert( const in vec3 irradiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in LambertMaterial material, inout ReflectedLight reflectedLight ) {\n\treflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );\n}\n#define RE_Direct\t\t\t\tRE_Direct_Lambert\n#define RE_IndirectDiffuse\t\tRE_IndirectDiffuse_Lambert",lights_pars_begin:"uniform bool receiveShadow;\nuniform vec3 ambientLightColor;\n#if defined( USE_LIGHT_PROBES )\n\tuniform vec3 lightProbe[ 9 ];\n#endif\nvec3 shGetIrradianceAt( in vec3 normal, in vec3 shCoefficients[ 9 ] ) {\n\tfloat x = normal.x, y = normal.y, z = normal.z;\n\tvec3 result = shCoefficients[ 0 ] * 0.886227;\n\tresult += shCoefficients[ 1 ] * 2.0 * 0.511664 * y;\n\tresult += shCoefficients[ 2 ] * 2.0 * 0.511664 * z;\n\tresult += shCoefficients[ 3 ] * 2.0 * 0.511664 * x;\n\tresult += shCoefficients[ 4 ] * 2.0 * 0.429043 * x * y;\n\tresult += shCoefficients[ 5 ] * 2.0 * 0.429043 * y * z;\n\tresult += shCoefficients[ 6 ] * ( 0.743125 * z * z - 0.247708 );\n\tresult += shCoefficients[ 7 ] * 2.0 * 0.429043 * x * z;\n\tresult += shCoefficients[ 8 ] * 0.429043 * ( x * x - y * y );\n\treturn result;\n}\nvec3 getLightProbeIrradiance( const in vec3 lightProbe[ 9 ], const in vec3 normal ) {\n\tvec3 worldNormal = inverseTransformDirection( normal, viewMatrix );\n\tvec3 irradiance = shGetIrradianceAt( worldNormal, lightProbe );\n\treturn irradiance;\n}\nvec3 getAmbientLightIrradiance( const in vec3 ambientLightColor ) {\n\tvec3 irradiance = ambientLightColor;\n\treturn irradiance;\n}\nfloat getDistanceAttenuation( const in float lightDistance, const in float cutoffDistance, const in float decayExponent ) {\n\tfloat distanceFalloff = 1.0 / max( pow( lightDistance, decayExponent ), 0.01 );\n\tif ( cutoffDistance > 0.0 ) {\n\t\tdistanceFalloff *= pow2( saturate( 1.0 - pow4( lightDistance / cutoffDistance ) ) );\n\t}\n\treturn distanceFalloff;\n}\nfloat getSpotAttenuation( const in float coneCosine, const in float penumbraCosine, const in float angleCosine ) {\n\treturn smoothstep( coneCosine, penumbraCosine, angleCosine );\n}\n#if NUM_DIR_LIGHTS > 0\n\tstruct DirectionalLight {\n\t\tvec3 direction;\n\t\tvec3 color;\n\t};\n\tuniform DirectionalLight directionalLights[ NUM_DIR_LIGHTS ];\n\tvoid getDirectionalLightInfo( const in DirectionalLight directionalLight, out IncidentLight light ) {\n\t\tlight.color = directionalLight.color;\n\t\tlight.direction = directionalLight.direction;\n\t\tlight.visible = true;\n\t}\n#endif\n#if NUM_POINT_LIGHTS > 0\n\tstruct PointLight {\n\t\tvec3 position;\n\t\tvec3 color;\n\t\tfloat distance;\n\t\tfloat decay;\n\t};\n\tuniform PointLight pointLights[ NUM_POINT_LIGHTS ];\n\tvoid getPointLightInfo( const in PointLight pointLight, const in vec3 geometryPosition, out IncidentLight light ) {\n\t\tvec3 lVector = pointLight.position - geometryPosition;\n\t\tlight.direction = normalize( lVector );\n\t\tfloat lightDistance = length( lVector );\n\t\tlight.color = pointLight.color;\n\t\tlight.color *= getDistanceAttenuation( lightDistance, pointLight.distance, pointLight.decay );\n\t\tlight.visible = ( light.color != vec3( 0.0 ) );\n\t}\n#endif\n#if NUM_SPOT_LIGHTS > 0\n\tstruct SpotLight {\n\t\tvec3 position;\n\t\tvec3 direction;\n\t\tvec3 color;\n\t\tfloat distance;\n\t\tfloat decay;\n\t\tfloat coneCos;\n\t\tfloat penumbraCos;\n\t};\n\tuniform SpotLight spotLights[ NUM_SPOT_LIGHTS ];\n\tvoid getSpotLightInfo( const in SpotLight spotLight, const in vec3 geometryPosition, out IncidentLight light ) {\n\t\tvec3 lVector = spotLight.position - geometryPosition;\n\t\tlight.direction = normalize( lVector );\n\t\tfloat angleCos = dot( light.direction, spotLight.direction );\n\t\tfloat spotAttenuation = getSpotAttenuation( spotLight.coneCos, spotLight.penumbraCos, angleCos );\n\t\tif ( spotAttenuation > 0.0 ) {\n\t\t\tfloat lightDistance = length( lVector );\n\t\t\tlight.color = spotLight.color * spotAttenuation;\n\t\t\tlight.color *= getDistanceAttenuation( lightDistance, spotLight.distance, spotLight.decay );\n\t\t\tlight.visible = ( light.color != vec3( 0.0 ) );\n\t\t} else {\n\t\t\tlight.color = vec3( 0.0 );\n\t\t\tlight.visible = false;\n\t\t}\n\t}\n#endif\n#if NUM_RECT_AREA_LIGHTS > 0\n\tstruct RectAreaLight {\n\t\tvec3 color;\n\t\tvec3 position;\n\t\tvec3 halfWidth;\n\t\tvec3 halfHeight;\n\t};\n\tuniform sampler2D ltc_1;\tuniform sampler2D ltc_2;\n\tuniform RectAreaLight rectAreaLights[ NUM_RECT_AREA_LIGHTS ];\n#endif\n#if NUM_HEMI_LIGHTS > 0\n\tstruct HemisphereLight {\n\t\tvec3 direction;\n\t\tvec3 skyColor;\n\t\tvec3 groundColor;\n\t};\n\tuniform HemisphereLight hemisphereLights[ NUM_HEMI_LIGHTS ];\n\tvec3 getHemisphereLightIrradiance( const in HemisphereLight hemiLight, const in vec3 normal ) {\n\t\tfloat dotNL = dot( normal, hemiLight.direction );\n\t\tfloat hemiDiffuseWeight = 0.5 * dotNL + 0.5;\n\t\tvec3 irradiance = mix( hemiLight.groundColor, hemiLight.skyColor, hemiDiffuseWeight );\n\t\treturn irradiance;\n\t}\n#endif",lights_toon_fragment:"ToonMaterial material;\nmaterial.diffuseColor = diffuseColor.rgb;",lights_toon_pars_fragment:"varying vec3 vViewPosition;\nstruct ToonMaterial {\n\tvec3 diffuseColor;\n};\nvoid RE_Direct_Toon( const in IncidentLight directLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in ToonMaterial material, inout ReflectedLight reflectedLight ) {\n\tvec3 irradiance = getGradientIrradiance( geometryNormal, directLight.direction ) * directLight.color;\n\treflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );\n}\nvoid RE_IndirectDiffuse_Toon( const in vec3 irradiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in ToonMaterial material, inout ReflectedLight reflectedLight ) {\n\treflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );\n}\n#define RE_Direct\t\t\t\tRE_Direct_Toon\n#define RE_IndirectDiffuse\t\tRE_IndirectDiffuse_Toon",lights_phong_fragment:"BlinnPhongMaterial material;\nmaterial.diffuseColor = diffuseColor.rgb;\nmaterial.specularColor = specular;\nmaterial.specularShininess = shininess;\nmaterial.specularStrength = specularStrength;",lights_phong_pars_fragment:"varying vec3 vViewPosition;\nstruct BlinnPhongMaterial {\n\tvec3 diffuseColor;\n\tvec3 specularColor;\n\tfloat specularShininess;\n\tfloat specularStrength;\n};\nvoid RE_Direct_BlinnPhong( const in IncidentLight directLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in BlinnPhongMaterial material, inout ReflectedLight reflectedLight ) {\n\tfloat dotNL = saturate( dot( geometryNormal, directLight.direction ) );\n\tvec3 irradiance = dotNL * directLight.color;\n\treflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );\n\treflectedLight.directSpecular += irradiance * BRDF_BlinnPhong( directLight.direction, geometryViewDir, geometryNormal, material.specularColor, material.specularShininess ) * material.specularStrength;\n}\nvoid RE_IndirectDiffuse_BlinnPhong( const in vec3 irradiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in BlinnPhongMaterial material, inout ReflectedLight reflectedLight ) {\n\treflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );\n}\n#define RE_Direct\t\t\t\tRE_Direct_BlinnPhong\n#define RE_IndirectDiffuse\t\tRE_IndirectDiffuse_BlinnPhong",lights_physical_fragment:"PhysicalMaterial material;\nmaterial.diffuseColor = diffuseColor.rgb * ( 1.0 - metalnessFactor );\nvec3 dxy = max( abs( dFdx( nonPerturbedNormal ) ), abs( dFdy( nonPerturbedNormal ) ) );\nfloat geometryRoughness = max( max( dxy.x, dxy.y ), dxy.z );\nmaterial.roughness = max( roughnessFactor, 0.0525 );material.roughness += geometryRoughness;\nmaterial.roughness = min( material.roughness, 1.0 );\n#ifdef IOR\n\tmaterial.ior = ior;\n\t#ifdef USE_SPECULAR\n\t\tfloat specularIntensityFactor = specularIntensity;\n\t\tvec3 specularColorFactor = specularColor;\n\t\t#ifdef USE_SPECULAR_COLORMAP\n\t\t\tspecularColorFactor *= texture2D( specularColorMap, vSpecularColorMapUv ).rgb;\n\t\t#endif\n\t\t#ifdef USE_SPECULAR_INTENSITYMAP\n\t\t\tspecularIntensityFactor *= texture2D( specularIntensityMap, vSpecularIntensityMapUv ).a;\n\t\t#endif\n\t\tmaterial.specularF90 = mix( specularIntensityFactor, 1.0, metalnessFactor );\n\t#else\n\t\tfloat specularIntensityFactor = 1.0;\n\t\tvec3 specularColorFactor = vec3( 1.0 );\n\t\tmaterial.specularF90 = 1.0;\n\t#endif\n\tmaterial.specularColor = mix( min( pow2( ( material.ior - 1.0 ) / ( material.ior + 1.0 ) ) * specularColorFactor, vec3( 1.0 ) ) * specularIntensityFactor, diffuseColor.rgb, metalnessFactor );\n#else\n\tmaterial.specularColor = mix( vec3( 0.04 ), diffuseColor.rgb, metalnessFactor );\n\tmaterial.specularF90 = 1.0;\n#endif\n#ifdef USE_CLEARCOAT\n\tmaterial.clearcoat = clearcoat;\n\tmaterial.clearcoatRoughness = clearcoatRoughness;\n\tmaterial.clearcoatF0 = vec3( 0.04 );\n\tmaterial.clearcoatF90 = 1.0;\n\t#ifdef USE_CLEARCOATMAP\n\t\tmaterial.clearcoat *= texture2D( clearcoatMap, vClearcoatMapUv ).x;\n\t#endif\n\t#ifdef USE_CLEARCOAT_ROUGHNESSMAP\n\t\tmaterial.clearcoatRoughness *= texture2D( clearcoatRoughnessMap, vClearcoatRoughnessMapUv ).y;\n\t#endif\n\tmaterial.clearcoat = saturate( material.clearcoat );\tmaterial.clearcoatRoughness = max( material.clearcoatRoughness, 0.0525 );\n\tmaterial.clearcoatRoughness += geometryRoughness;\n\tmaterial.clearcoatRoughness = min( material.clearcoatRoughness, 1.0 );\n#endif\n#ifdef USE_DISPERSION\n\tmaterial.dispersion = dispersion;\n#endif\n#ifdef USE_IRIDESCENCE\n\tmaterial.iridescence = iridescence;\n\tmaterial.iridescenceIOR = iridescenceIOR;\n\t#ifdef USE_IRIDESCENCEMAP\n\t\tmaterial.iridescence *= texture2D( iridescenceMap, vIridescenceMapUv ).r;\n\t#endif\n\t#ifdef USE_IRIDESCENCE_THICKNESSMAP\n\t\tmaterial.iridescenceThickness = (iridescenceThicknessMaximum - iridescenceThicknessMinimum) * texture2D( iridescenceThicknessMap, vIridescenceThicknessMapUv ).g + iridescenceThicknessMinimum;\n\t#else\n\t\tmaterial.iridescenceThickness = iridescenceThicknessMaximum;\n\t#endif\n#endif\n#ifdef USE_SHEEN\n\tmaterial.sheenColor = sheenColor;\n\t#ifdef USE_SHEEN_COLORMAP\n\t\tmaterial.sheenColor *= texture2D( sheenColorMap, vSheenColorMapUv ).rgb;\n\t#endif\n\tmaterial.sheenRoughness = clamp( sheenRoughness, 0.07, 1.0 );\n\t#ifdef USE_SHEEN_ROUGHNESSMAP\n\t\tmaterial.sheenRoughness *= texture2D( sheenRoughnessMap, vSheenRoughnessMapUv ).a;\n\t#endif\n#endif\n#ifdef USE_ANISOTROPY\n\t#ifdef USE_ANISOTROPYMAP\n\t\tmat2 anisotropyMat = mat2( anisotropyVector.x, anisotropyVector.y, - anisotropyVector.y, anisotropyVector.x );\n\t\tvec3 anisotropyPolar = texture2D( anisotropyMap, vAnisotropyMapUv ).rgb;\n\t\tvec2 anisotropyV = anisotropyMat * normalize( 2.0 * anisotropyPolar.rg - vec2( 1.0 ) ) * anisotropyPolar.b;\n\t#else\n\t\tvec2 anisotropyV = anisotropyVector;\n\t#endif\n\tmaterial.anisotropy = length( anisotropyV );\n\tif( material.anisotropy == 0.0 ) {\n\t\tanisotropyV = vec2( 1.0, 0.0 );\n\t} else {\n\t\tanisotropyV /= material.anisotropy;\n\t\tmaterial.anisotropy = saturate( material.anisotropy );\n\t}\n\tmaterial.alphaT = mix( pow2( material.roughness ), 1.0, pow2( material.anisotropy ) );\n\tmaterial.anisotropyT = tbn[ 0 ] * anisotropyV.x + tbn[ 1 ] * anisotropyV.y;\n\tmaterial.anisotropyB = tbn[ 1 ] * anisotropyV.x - tbn[ 0 ] * anisotropyV.y;\n#endif",lights_physical_pars_fragment:"struct PhysicalMaterial {\n\tvec3 diffuseColor;\n\tfloat roughness;\n\tvec3 specularColor;\n\tfloat specularF90;\n\tfloat dispersion;\n\t#ifdef USE_CLEARCOAT\n\t\tfloat clearcoat;\n\t\tfloat clearcoatRoughness;\n\t\tvec3 clearcoatF0;\n\t\tfloat clearcoatF90;\n\t#endif\n\t#ifdef USE_IRIDESCENCE\n\t\tfloat iridescence;\n\t\tfloat iridescenceIOR;\n\t\tfloat iridescenceThickness;\n\t\tvec3 iridescenceFresnel;\n\t\tvec3 iridescenceF0;\n\t#endif\n\t#ifdef USE_SHEEN\n\t\tvec3 sheenColor;\n\t\tfloat sheenRoughness;\n\t#endif\n\t#ifdef IOR\n\t\tfloat ior;\n\t#endif\n\t#ifdef USE_TRANSMISSION\n\t\tfloat transmission;\n\t\tfloat transmissionAlpha;\n\t\tfloat thickness;\n\t\tfloat attenuationDistance;\n\t\tvec3 attenuationColor;\n\t#endif\n\t#ifdef USE_ANISOTROPY\n\t\tfloat anisotropy;\n\t\tfloat alphaT;\n\t\tvec3 anisotropyT;\n\t\tvec3 anisotropyB;\n\t#endif\n};\nvec3 clearcoatSpecularDirect = vec3( 0.0 );\nvec3 clearcoatSpecularIndirect = vec3( 0.0 );\nvec3 sheenSpecularDirect = vec3( 0.0 );\nvec3 sheenSpecularIndirect = vec3(0.0 );\nvec3 Schlick_to_F0( const in vec3 f, const in float f90, const in float dotVH ) {\n float x = clamp( 1.0 - dotVH, 0.0, 1.0 );\n float x2 = x * x;\n float x5 = clamp( x * x2 * x2, 0.0, 0.9999 );\n return ( f - vec3( f90 ) * x5 ) / ( 1.0 - x5 );\n}\nfloat V_GGX_SmithCorrelated( const in float alpha, const in float dotNL, const in float dotNV ) {\n\tfloat a2 = pow2( alpha );\n\tfloat gv = dotNL * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNV ) );\n\tfloat gl = dotNV * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNL ) );\n\treturn 0.5 / max( gv + gl, EPSILON );\n}\nfloat D_GGX( const in float alpha, const in float dotNH ) {\n\tfloat a2 = pow2( alpha );\n\tfloat denom = pow2( dotNH ) * ( a2 - 1.0 ) + 1.0;\n\treturn RECIPROCAL_PI * a2 / pow2( denom );\n}\n#ifdef USE_ANISOTROPY\n\tfloat V_GGX_SmithCorrelated_Anisotropic( const in float alphaT, const in float alphaB, const in float dotTV, const in float dotBV, const in float dotTL, const in float dotBL, const in float dotNV, const in float dotNL ) {\n\t\tfloat gv = dotNL * length( vec3( alphaT * dotTV, alphaB * dotBV, dotNV ) );\n\t\tfloat gl = dotNV * length( vec3( alphaT * dotTL, alphaB * dotBL, dotNL ) );\n\t\tfloat v = 0.5 / ( gv + gl );\n\t\treturn saturate(v);\n\t}\n\tfloat D_GGX_Anisotropic( const in float alphaT, const in float alphaB, const in float dotNH, const in float dotTH, const in float dotBH ) {\n\t\tfloat a2 = alphaT * alphaB;\n\t\thighp vec3 v = vec3( alphaB * dotTH, alphaT * dotBH, a2 * dotNH );\n\t\thighp float v2 = dot( v, v );\n\t\tfloat w2 = a2 / v2;\n\t\treturn RECIPROCAL_PI * a2 * pow2 ( w2 );\n\t}\n#endif\n#ifdef USE_CLEARCOAT\n\tvec3 BRDF_GGX_Clearcoat( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in PhysicalMaterial material) {\n\t\tvec3 f0 = material.clearcoatF0;\n\t\tfloat f90 = material.clearcoatF90;\n\t\tfloat roughness = material.clearcoatRoughness;\n\t\tfloat alpha = pow2( roughness );\n\t\tvec3 halfDir = normalize( lightDir + viewDir );\n\t\tfloat dotNL = saturate( dot( normal, lightDir ) );\n\t\tfloat dotNV = saturate( dot( normal, viewDir ) );\n\t\tfloat dotNH = saturate( dot( normal, halfDir ) );\n\t\tfloat dotVH = saturate( dot( viewDir, halfDir ) );\n\t\tvec3 F = F_Schlick( f0, f90, dotVH );\n\t\tfloat V = V_GGX_SmithCorrelated( alpha, dotNL, dotNV );\n\t\tfloat D = D_GGX( alpha, dotNH );\n\t\treturn F * ( V * D );\n\t}\n#endif\nvec3 BRDF_GGX( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in PhysicalMaterial material ) {\n\tvec3 f0 = material.specularColor;\n\tfloat f90 = material.specularF90;\n\tfloat roughness = material.roughness;\n\tfloat alpha = pow2( roughness );\n\tvec3 halfDir = normalize( lightDir + viewDir );\n\tfloat dotNL = saturate( dot( normal, lightDir ) );\n\tfloat dotNV = saturate( dot( normal, viewDir ) );\n\tfloat dotNH = saturate( dot( normal, halfDir ) );\n\tfloat dotVH = saturate( dot( viewDir, halfDir ) );\n\tvec3 F = F_Schlick( f0, f90, dotVH );\n\t#ifdef USE_IRIDESCENCE\n\t\tF = mix( F, material.iridescenceFresnel, material.iridescence );\n\t#endif\n\t#ifdef USE_ANISOTROPY\n\t\tfloat dotTL = dot( material.anisotropyT, lightDir );\n\t\tfloat dotTV = dot( material.anisotropyT, viewDir );\n\t\tfloat dotTH = dot( material.anisotropyT, halfDir );\n\t\tfloat dotBL = dot( material.anisotropyB, lightDir );\n\t\tfloat dotBV = dot( material.anisotropyB, viewDir );\n\t\tfloat dotBH = dot( material.anisotropyB, halfDir );\n\t\tfloat V = V_GGX_SmithCorrelated_Anisotropic( material.alphaT, alpha, dotTV, dotBV, dotTL, dotBL, dotNV, dotNL );\n\t\tfloat D = D_GGX_Anisotropic( material.alphaT, alpha, dotNH, dotTH, dotBH );\n\t#else\n\t\tfloat V = V_GGX_SmithCorrelated( alpha, dotNL, dotNV );\n\t\tfloat D = D_GGX( alpha, dotNH );\n\t#endif\n\treturn F * ( V * D );\n}\nvec2 LTC_Uv( const in vec3 N, const in vec3 V, const in float roughness ) {\n\tconst float LUT_SIZE = 64.0;\n\tconst float LUT_SCALE = ( LUT_SIZE - 1.0 ) / LUT_SIZE;\n\tconst float LUT_BIAS = 0.5 / LUT_SIZE;\n\tfloat dotNV = saturate( dot( N, V ) );\n\tvec2 uv = vec2( roughness, sqrt( 1.0 - dotNV ) );\n\tuv = uv * LUT_SCALE + LUT_BIAS;\n\treturn uv;\n}\nfloat LTC_ClippedSphereFormFactor( const in vec3 f ) {\n\tfloat l = length( f );\n\treturn max( ( l * l + f.z ) / ( l + 1.0 ), 0.0 );\n}\nvec3 LTC_EdgeVectorFormFactor( const in vec3 v1, const in vec3 v2 ) {\n\tfloat x = dot( v1, v2 );\n\tfloat y = abs( x );\n\tfloat a = 0.8543985 + ( 0.4965155 + 0.0145206 * y ) * y;\n\tfloat b = 3.4175940 + ( 4.1616724 + y ) * y;\n\tfloat v = a / b;\n\tfloat theta_sintheta = ( x > 0.0 ) ? v : 0.5 * inversesqrt( max( 1.0 - x * x, 1e-7 ) ) - v;\n\treturn cross( v1, v2 ) * theta_sintheta;\n}\nvec3 LTC_Evaluate( const in vec3 N, const in vec3 V, const in vec3 P, const in mat3 mInv, const in vec3 rectCoords[ 4 ] ) {\n\tvec3 v1 = rectCoords[ 1 ] - rectCoords[ 0 ];\n\tvec3 v2 = rectCoords[ 3 ] - rectCoords[ 0 ];\n\tvec3 lightNormal = cross( v1, v2 );\n\tif( dot( lightNormal, P - rectCoords[ 0 ] ) < 0.0 ) return vec3( 0.0 );\n\tvec3 T1, T2;\n\tT1 = normalize( V - N * dot( V, N ) );\n\tT2 = - cross( N, T1 );\n\tmat3 mat = mInv * transposeMat3( mat3( T1, T2, N ) );\n\tvec3 coords[ 4 ];\n\tcoords[ 0 ] = mat * ( rectCoords[ 0 ] - P );\n\tcoords[ 1 ] = mat * ( rectCoords[ 1 ] - P );\n\tcoords[ 2 ] = mat * ( rectCoords[ 2 ] - P );\n\tcoords[ 3 ] = mat * ( rectCoords[ 3 ] - P );\n\tcoords[ 0 ] = normalize( coords[ 0 ] );\n\tcoords[ 1 ] = normalize( coords[ 1 ] );\n\tcoords[ 2 ] = normalize( coords[ 2 ] );\n\tcoords[ 3 ] = normalize( coords[ 3 ] );\n\tvec3 vectorFormFactor = vec3( 0.0 );\n\tvectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 0 ], coords[ 1 ] );\n\tvectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 1 ], coords[ 2 ] );\n\tvectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 2 ], coords[ 3 ] );\n\tvectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 3 ], coords[ 0 ] );\n\tfloat result = LTC_ClippedSphereFormFactor( vectorFormFactor );\n\treturn vec3( result );\n}\n#if defined( USE_SHEEN )\nfloat D_Charlie( float roughness, float dotNH ) {\n\tfloat alpha = pow2( roughness );\n\tfloat invAlpha = 1.0 / alpha;\n\tfloat cos2h = dotNH * dotNH;\n\tfloat sin2h = max( 1.0 - cos2h, 0.0078125 );\n\treturn ( 2.0 + invAlpha ) * pow( sin2h, invAlpha * 0.5 ) / ( 2.0 * PI );\n}\nfloat V_Neubelt( float dotNV, float dotNL ) {\n\treturn saturate( 1.0 / ( 4.0 * ( dotNL + dotNV - dotNL * dotNV ) ) );\n}\nvec3 BRDF_Sheen( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, vec3 sheenColor, const in float sheenRoughness ) {\n\tvec3 halfDir = normalize( lightDir + viewDir );\n\tfloat dotNL = saturate( dot( normal, lightDir ) );\n\tfloat dotNV = saturate( dot( normal, viewDir ) );\n\tfloat dotNH = saturate( dot( normal, halfDir ) );\n\tfloat D = D_Charlie( sheenRoughness, dotNH );\n\tfloat V = V_Neubelt( dotNV, dotNL );\n\treturn sheenColor * ( D * V );\n}\n#endif\nfloat IBLSheenBRDF( const in vec3 normal, const in vec3 viewDir, const in float roughness ) {\n\tfloat dotNV = saturate( dot( normal, viewDir ) );\n\tfloat r2 = roughness * roughness;\n\tfloat a = roughness < 0.25 ? -339.2 * r2 + 161.4 * roughness - 25.9 : -8.48 * r2 + 14.3 * roughness - 9.95;\n\tfloat b = roughness < 0.25 ? 44.0 * r2 - 23.7 * roughness + 3.26 : 1.97 * r2 - 3.27 * roughness + 0.72;\n\tfloat DG = exp( a * dotNV + b ) + ( roughness < 0.25 ? 0.0 : 0.1 * ( roughness - 0.25 ) );\n\treturn saturate( DG * RECIPROCAL_PI );\n}\nvec2 DFGApprox( const in vec3 normal, const in vec3 viewDir, const in float roughness ) {\n\tfloat dotNV = saturate( dot( normal, viewDir ) );\n\tconst vec4 c0 = vec4( - 1, - 0.0275, - 0.572, 0.022 );\n\tconst vec4 c1 = vec4( 1, 0.0425, 1.04, - 0.04 );\n\tvec4 r = roughness * c0 + c1;\n\tfloat a004 = min( r.x * r.x, exp2( - 9.28 * dotNV ) ) * r.x + r.y;\n\tvec2 fab = vec2( - 1.04, 1.04 ) * a004 + r.zw;\n\treturn fab;\n}\nvec3 EnvironmentBRDF( const in vec3 normal, const in vec3 viewDir, const in vec3 specularColor, const in float specularF90, const in float roughness ) {\n\tvec2 fab = DFGApprox( normal, viewDir, roughness );\n\treturn specularColor * fab.x + specularF90 * fab.y;\n}\n#ifdef USE_IRIDESCENCE\nvoid computeMultiscatteringIridescence( const in vec3 normal, const in vec3 viewDir, const in vec3 specularColor, const in float specularF90, const in float iridescence, const in vec3 iridescenceF0, const in float roughness, inout vec3 singleScatter, inout vec3 multiScatter ) {\n#else\nvoid computeMultiscattering( const in vec3 normal, const in vec3 viewDir, const in vec3 specularColor, const in float specularF90, const in float roughness, inout vec3 singleScatter, inout vec3 multiScatter ) {\n#endif\n\tvec2 fab = DFGApprox( normal, viewDir, roughness );\n\t#ifdef USE_IRIDESCENCE\n\t\tvec3 Fr = mix( specularColor, iridescenceF0, iridescence );\n\t#else\n\t\tvec3 Fr = specularColor;\n\t#endif\n\tvec3 FssEss = Fr * fab.x + specularF90 * fab.y;\n\tfloat Ess = fab.x + fab.y;\n\tfloat Ems = 1.0 - Ess;\n\tvec3 Favg = Fr + ( 1.0 - Fr ) * 0.047619;\tvec3 Fms = FssEss * Favg / ( 1.0 - Ems * Favg );\n\tsingleScatter += FssEss;\n\tmultiScatter += Fms * Ems;\n}\n#if NUM_RECT_AREA_LIGHTS > 0\n\tvoid RE_Direct_RectArea_Physical( const in RectAreaLight rectAreaLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {\n\t\tvec3 normal = geometryNormal;\n\t\tvec3 viewDir = geometryViewDir;\n\t\tvec3 position = geometryPosition;\n\t\tvec3 lightPos = rectAreaLight.position;\n\t\tvec3 halfWidth = rectAreaLight.halfWidth;\n\t\tvec3 halfHeight = rectAreaLight.halfHeight;\n\t\tvec3 lightColor = rectAreaLight.color;\n\t\tfloat roughness = material.roughness;\n\t\tvec3 rectCoords[ 4 ];\n\t\trectCoords[ 0 ] = lightPos + halfWidth - halfHeight;\t\trectCoords[ 1 ] = lightPos - halfWidth - halfHeight;\n\t\trectCoords[ 2 ] = lightPos - halfWidth + halfHeight;\n\t\trectCoords[ 3 ] = lightPos + halfWidth + halfHeight;\n\t\tvec2 uv = LTC_Uv( normal, viewDir, roughness );\n\t\tvec4 t1 = texture2D( ltc_1, uv );\n\t\tvec4 t2 = texture2D( ltc_2, uv );\n\t\tmat3 mInv = mat3(\n\t\t\tvec3( t1.x, 0, t1.y ),\n\t\t\tvec3( 0, 1, 0 ),\n\t\t\tvec3( t1.z, 0, t1.w )\n\t\t);\n\t\tvec3 fresnel = ( material.specularColor * t2.x + ( vec3( 1.0 ) - material.specularColor ) * t2.y );\n\t\treflectedLight.directSpecular += lightColor * fresnel * LTC_Evaluate( normal, viewDir, position, mInv, rectCoords );\n\t\treflectedLight.directDiffuse += lightColor * material.diffuseColor * LTC_Evaluate( normal, viewDir, position, mat3( 1.0 ), rectCoords );\n\t}\n#endif\nvoid RE_Direct_Physical( const in IncidentLight directLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {\n\tfloat dotNL = saturate( dot( geometryNormal, directLight.direction ) );\n\tvec3 irradiance = dotNL * directLight.color;\n\t#ifdef USE_CLEARCOAT\n\t\tfloat dotNLcc = saturate( dot( geometryClearcoatNormal, directLight.direction ) );\n\t\tvec3 ccIrradiance = dotNLcc * directLight.color;\n\t\tclearcoatSpecularDirect += ccIrradiance * BRDF_GGX_Clearcoat( directLight.direction, geometryViewDir, geometryClearcoatNormal, material );\n\t#endif\n\t#ifdef USE_SHEEN\n\t\tsheenSpecularDirect += irradiance * BRDF_Sheen( directLight.direction, geometryViewDir, geometryNormal, material.sheenColor, material.sheenRoughness );\n\t#endif\n\treflectedLight.directSpecular += irradiance * BRDF_GGX( directLight.direction, geometryViewDir, geometryNormal, material );\n\treflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );\n}\nvoid RE_IndirectDiffuse_Physical( const in vec3 irradiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {\n\treflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );\n}\nvoid RE_IndirectSpecular_Physical( const in vec3 radiance, const in vec3 irradiance, const in vec3 clearcoatRadiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in PhysicalMaterial material, inout ReflectedLight reflectedLight) {\n\t#ifdef USE_CLEARCOAT\n\t\tclearcoatSpecularIndirect += clearcoatRadiance * EnvironmentBRDF( geometryClearcoatNormal, geometryViewDir, material.clearcoatF0, material.clearcoatF90, material.clearcoatRoughness );\n\t#endif\n\t#ifdef USE_SHEEN\n\t\tsheenSpecularIndirect += irradiance * material.sheenColor * IBLSheenBRDF( geometryNormal, geometryViewDir, material.sheenRoughness );\n\t#endif\n\tvec3 singleScattering = vec3( 0.0 );\n\tvec3 multiScattering = vec3( 0.0 );\n\tvec3 cosineWeightedIrradiance = irradiance * RECIPROCAL_PI;\n\t#ifdef USE_IRIDESCENCE\n\t\tcomputeMultiscatteringIridescence( geometryNormal, geometryViewDir, material.specularColor, material.specularF90, material.iridescence, material.iridescenceFresnel, material.roughness, singleScattering, multiScattering );\n\t#else\n\t\tcomputeMultiscattering( geometryNormal, geometryViewDir, material.specularColor, material.specularF90, material.roughness, singleScattering, multiScattering );\n\t#endif\n\tvec3 totalScattering = singleScattering + multiScattering;\n\tvec3 diffuse = material.diffuseColor * ( 1.0 - max( max( totalScattering.r, totalScattering.g ), totalScattering.b ) );\n\treflectedLight.indirectSpecular += radiance * singleScattering;\n\treflectedLight.indirectSpecular += multiScattering * cosineWeightedIrradiance;\n\treflectedLight.indirectDiffuse += diffuse * cosineWeightedIrradiance;\n}\n#define RE_Direct\t\t\t\tRE_Direct_Physical\n#define RE_Direct_RectArea\t\tRE_Direct_RectArea_Physical\n#define RE_IndirectDiffuse\t\tRE_IndirectDiffuse_Physical\n#define RE_IndirectSpecular\t\tRE_IndirectSpecular_Physical\nfloat computeSpecularOcclusion( const in float dotNV, const in float ambientOcclusion, const in float roughness ) {\n\treturn saturate( pow( dotNV + ambientOcclusion, exp2( - 16.0 * roughness - 1.0 ) ) - 1.0 + ambientOcclusion );\n}",lights_fragment_begin:"\nvec3 geometryPosition = - vViewPosition;\nvec3 geometryNormal = normal;\nvec3 geometryViewDir = ( isOrthographic ) ? vec3( 0, 0, 1 ) : normalize( vViewPosition );\nvec3 geometryClearcoatNormal = vec3( 0.0 );\n#ifdef USE_CLEARCOAT\n\tgeometryClearcoatNormal = clearcoatNormal;\n#endif\n#ifdef USE_IRIDESCENCE\n\tfloat dotNVi = saturate( dot( normal, geometryViewDir ) );\n\tif ( material.iridescenceThickness == 0.0 ) {\n\t\tmaterial.iridescence = 0.0;\n\t} else {\n\t\tmaterial.iridescence = saturate( material.iridescence );\n\t}\n\tif ( material.iridescence > 0.0 ) {\n\t\tmaterial.iridescenceFresnel = evalIridescence( 1.0, material.iridescenceIOR, dotNVi, material.iridescenceThickness, material.specularColor );\n\t\tmaterial.iridescenceF0 = Schlick_to_F0( material.iridescenceFresnel, 1.0, dotNVi );\n\t}\n#endif\nIncidentLight directLight;\n#if ( NUM_POINT_LIGHTS > 0 ) && defined( RE_Direct )\n\tPointLight pointLight;\n\t#if defined( USE_SHADOWMAP ) && NUM_POINT_LIGHT_SHADOWS > 0\n\tPointLightShadow pointLightShadow;\n\t#endif\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_POINT_LIGHTS; i ++ ) {\n\t\tpointLight = pointLights[ i ];\n\t\tgetPointLightInfo( pointLight, geometryPosition, directLight );\n\t\t#if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_POINT_LIGHT_SHADOWS )\n\t\tpointLightShadow = pointLightShadows[ i ];\n\t\tdirectLight.color *= ( directLight.visible && receiveShadow ) ? getPointShadow( pointShadowMap[ i ], pointLightShadow.shadowMapSize, pointLightShadow.shadowIntensity, pointLightShadow.shadowBias, pointLightShadow.shadowRadius, vPointShadowCoord[ i ], pointLightShadow.shadowCameraNear, pointLightShadow.shadowCameraFar ) : 1.0;\n\t\t#endif\n\t\tRE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );\n\t}\n\t#pragma unroll_loop_end\n#endif\n#if ( NUM_SPOT_LIGHTS > 0 ) && defined( RE_Direct )\n\tSpotLight spotLight;\n\tvec4 spotColor;\n\tvec3 spotLightCoord;\n\tbool inSpotLightMap;\n\t#if defined( USE_SHADOWMAP ) && NUM_SPOT_LIGHT_SHADOWS > 0\n\tSpotLightShadow spotLightShadow;\n\t#endif\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_SPOT_LIGHTS; i ++ ) {\n\t\tspotLight = spotLights[ i ];\n\t\tgetSpotLightInfo( spotLight, geometryPosition, directLight );\n\t\t#if ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS )\n\t\t#define SPOT_LIGHT_MAP_INDEX UNROLLED_LOOP_INDEX\n\t\t#elif ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS )\n\t\t#define SPOT_LIGHT_MAP_INDEX NUM_SPOT_LIGHT_MAPS\n\t\t#else\n\t\t#define SPOT_LIGHT_MAP_INDEX ( UNROLLED_LOOP_INDEX - NUM_SPOT_LIGHT_SHADOWS + NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS )\n\t\t#endif\n\t\t#if ( SPOT_LIGHT_MAP_INDEX < NUM_SPOT_LIGHT_MAPS )\n\t\t\tspotLightCoord = vSpotLightCoord[ i ].xyz / vSpotLightCoord[ i ].w;\n\t\t\tinSpotLightMap = all( lessThan( abs( spotLightCoord * 2. - 1. ), vec3( 1.0 ) ) );\n\t\t\tspotColor = texture2D( spotLightMap[ SPOT_LIGHT_MAP_INDEX ], spotLightCoord.xy );\n\t\t\tdirectLight.color = inSpotLightMap ? directLight.color * spotColor.rgb : directLight.color;\n\t\t#endif\n\t\t#undef SPOT_LIGHT_MAP_INDEX\n\t\t#if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS )\n\t\tspotLightShadow = spotLightShadows[ i ];\n\t\tdirectLight.color *= ( directLight.visible && receiveShadow ) ? getShadow( spotShadowMap[ i ], spotLightShadow.shadowMapSize, spotLightShadow.shadowIntensity, spotLightShadow.shadowBias, spotLightShadow.shadowRadius, vSpotLightCoord[ i ] ) : 1.0;\n\t\t#endif\n\t\tRE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );\n\t}\n\t#pragma unroll_loop_end\n#endif\n#if ( NUM_DIR_LIGHTS > 0 ) && defined( RE_Direct )\n\tDirectionalLight directionalLight;\n\t#if defined( USE_SHADOWMAP ) && NUM_DIR_LIGHT_SHADOWS > 0\n\tDirectionalLightShadow directionalLightShadow;\n\t#endif\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_DIR_LIGHTS; i ++ ) {\n\t\tdirectionalLight = directionalLights[ i ];\n\t\tgetDirectionalLightInfo( directionalLight, directLight );\n\t\t#if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_DIR_LIGHT_SHADOWS )\n\t\tdirectionalLightShadow = directionalLightShadows[ i ];\n\t\tdirectLight.color *= ( directLight.visible && receiveShadow ) ? getShadow( directionalShadowMap[ i ], directionalLightShadow.shadowMapSize, directionalLightShadow.shadowIntensity, directionalLightShadow.shadowBias, directionalLightShadow.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0;\n\t\t#endif\n\t\tRE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );\n\t}\n\t#pragma unroll_loop_end\n#endif\n#if ( NUM_RECT_AREA_LIGHTS > 0 ) && defined( RE_Direct_RectArea )\n\tRectAreaLight rectAreaLight;\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_RECT_AREA_LIGHTS; i ++ ) {\n\t\trectAreaLight = rectAreaLights[ i ];\n\t\tRE_Direct_RectArea( rectAreaLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );\n\t}\n\t#pragma unroll_loop_end\n#endif\n#if defined( RE_IndirectDiffuse )\n\tvec3 iblIrradiance = vec3( 0.0 );\n\tvec3 irradiance = getAmbientLightIrradiance( ambientLightColor );\n\t#if defined( USE_LIGHT_PROBES )\n\t\tirradiance += getLightProbeIrradiance( lightProbe, geometryNormal );\n\t#endif\n\t#if ( NUM_HEMI_LIGHTS > 0 )\n\t\t#pragma unroll_loop_start\n\t\tfor ( int i = 0; i < NUM_HEMI_LIGHTS; i ++ ) {\n\t\t\tirradiance += getHemisphereLightIrradiance( hemisphereLights[ i ], geometryNormal );\n\t\t}\n\t\t#pragma unroll_loop_end\n\t#endif\n#endif\n#if defined( RE_IndirectSpecular )\n\tvec3 radiance = vec3( 0.0 );\n\tvec3 clearcoatRadiance = vec3( 0.0 );\n#endif",lights_fragment_maps:"#if defined( RE_IndirectDiffuse )\n\t#ifdef USE_LIGHTMAP\n\t\tvec4 lightMapTexel = texture2D( lightMap, vLightMapUv );\n\t\tvec3 lightMapIrradiance = lightMapTexel.rgb * lightMapIntensity;\n\t\tirradiance += lightMapIrradiance;\n\t#endif\n\t#if defined( USE_ENVMAP ) && defined( STANDARD ) && defined( ENVMAP_TYPE_CUBE_UV )\n\t\tiblIrradiance += getIBLIrradiance( geometryNormal );\n\t#endif\n#endif\n#if defined( USE_ENVMAP ) && defined( RE_IndirectSpecular )\n\t#ifdef USE_ANISOTROPY\n\t\tradiance += getIBLAnisotropyRadiance( geometryViewDir, geometryNormal, material.roughness, material.anisotropyB, material.anisotropy );\n\t#else\n\t\tradiance += getIBLRadiance( geometryViewDir, geometryNormal, material.roughness );\n\t#endif\n\t#ifdef USE_CLEARCOAT\n\t\tclearcoatRadiance += getIBLRadiance( geometryViewDir, geometryClearcoatNormal, material.clearcoatRoughness );\n\t#endif\n#endif",lights_fragment_end:"#if defined( RE_IndirectDiffuse )\n\tRE_IndirectDiffuse( irradiance, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );\n#endif\n#if defined( RE_IndirectSpecular )\n\tRE_IndirectSpecular( radiance, iblIrradiance, clearcoatRadiance, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );\n#endif",logdepthbuf_fragment:"#if defined( USE_LOGDEPTHBUF )\n\tgl_FragDepth = vIsPerspective == 0.0 ? gl_FragCoord.z : log2( vFragDepth ) * logDepthBufFC * 0.5;\n#endif",logdepthbuf_pars_fragment:"#if defined( USE_LOGDEPTHBUF )\n\tuniform float logDepthBufFC;\n\tvarying float vFragDepth;\n\tvarying float vIsPerspective;\n#endif",logdepthbuf_pars_vertex:"#ifdef USE_LOGDEPTHBUF\n\tvarying float vFragDepth;\n\tvarying float vIsPerspective;\n#endif",logdepthbuf_vertex:"#ifdef USE_LOGDEPTHBUF\n\tvFragDepth = 1.0 + gl_Position.w;\n\tvIsPerspective = float( isPerspectiveMatrix( projectionMatrix ) );\n#endif",map_fragment:"#ifdef USE_MAP\n\tvec4 sampledDiffuseColor = texture2D( map, vMapUv );\n\t#ifdef DECODE_VIDEO_TEXTURE\n\t\tsampledDiffuseColor = sRGBTransferEOTF( sampledDiffuseColor );\n\t#endif\n\tdiffuseColor *= sampledDiffuseColor;\n#endif",map_pars_fragment:"#ifdef USE_MAP\n\tuniform sampler2D map;\n#endif",map_particle_fragment:"#if defined( USE_MAP ) || defined( USE_ALPHAMAP )\n\t#if defined( USE_POINTS_UV )\n\t\tvec2 uv = vUv;\n\t#else\n\t\tvec2 uv = ( uvTransform * vec3( gl_PointCoord.x, 1.0 - gl_PointCoord.y, 1 ) ).xy;\n\t#endif\n#endif\n#ifdef USE_MAP\n\tdiffuseColor *= texture2D( map, uv );\n#endif\n#ifdef USE_ALPHAMAP\n\tdiffuseColor.a *= texture2D( alphaMap, uv ).g;\n#endif",map_particle_pars_fragment:"#if defined( USE_POINTS_UV )\n\tvarying vec2 vUv;\n#else\n\t#if defined( USE_MAP ) || defined( USE_ALPHAMAP )\n\t\tuniform mat3 uvTransform;\n\t#endif\n#endif\n#ifdef USE_MAP\n\tuniform sampler2D map;\n#endif\n#ifdef USE_ALPHAMAP\n\tuniform sampler2D alphaMap;\n#endif",metalnessmap_fragment:"float metalnessFactor = metalness;\n#ifdef USE_METALNESSMAP\n\tvec4 texelMetalness = texture2D( metalnessMap, vMetalnessMapUv );\n\tmetalnessFactor *= texelMetalness.b;\n#endif",metalnessmap_pars_fragment:"#ifdef USE_METALNESSMAP\n\tuniform sampler2D metalnessMap;\n#endif",morphinstance_vertex:"#ifdef USE_INSTANCING_MORPH\n\tfloat morphTargetInfluences[ MORPHTARGETS_COUNT ];\n\tfloat morphTargetBaseInfluence = texelFetch( morphTexture, ivec2( 0, gl_InstanceID ), 0 ).r;\n\tfor ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {\n\t\tmorphTargetInfluences[i] = texelFetch( morphTexture, ivec2( i + 1, gl_InstanceID ), 0 ).r;\n\t}\n#endif",morphcolor_vertex:"#if defined( USE_MORPHCOLORS )\n\tvColor *= morphTargetBaseInfluence;\n\tfor ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {\n\t\t#if defined( USE_COLOR_ALPHA )\n\t\t\tif ( morphTargetInfluences[ i ] != 0.0 ) vColor += getMorph( gl_VertexID, i, 2 ) * morphTargetInfluences[ i ];\n\t\t#elif defined( USE_COLOR )\n\t\t\tif ( morphTargetInfluences[ i ] != 0.0 ) vColor += getMorph( gl_VertexID, i, 2 ).rgb * morphTargetInfluences[ i ];\n\t\t#endif\n\t}\n#endif",morphnormal_vertex:"#ifdef USE_MORPHNORMALS\n\tobjectNormal *= morphTargetBaseInfluence;\n\tfor ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {\n\t\tif ( morphTargetInfluences[ i ] != 0.0 ) objectNormal += getMorph( gl_VertexID, i, 1 ).xyz * morphTargetInfluences[ i ];\n\t}\n#endif",morphtarget_pars_vertex:"#ifdef USE_MORPHTARGETS\n\t#ifndef USE_INSTANCING_MORPH\n\t\tuniform float morphTargetBaseInfluence;\n\t\tuniform float morphTargetInfluences[ MORPHTARGETS_COUNT ];\n\t#endif\n\tuniform sampler2DArray morphTargetsTexture;\n\tuniform ivec2 morphTargetsTextureSize;\n\tvec4 getMorph( const in int vertexIndex, const in int morphTargetIndex, const in int offset ) {\n\t\tint texelIndex = vertexIndex * MORPHTARGETS_TEXTURE_STRIDE + offset;\n\t\tint y = texelIndex / morphTargetsTextureSize.x;\n\t\tint x = texelIndex - y * morphTargetsTextureSize.x;\n\t\tivec3 morphUV = ivec3( x, y, morphTargetIndex );\n\t\treturn texelFetch( morphTargetsTexture, morphUV, 0 );\n\t}\n#endif",morphtarget_vertex:"#ifdef USE_MORPHTARGETS\n\ttransformed *= morphTargetBaseInfluence;\n\tfor ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {\n\t\tif ( morphTargetInfluences[ i ] != 0.0 ) transformed += getMorph( gl_VertexID, i, 0 ).xyz * morphTargetInfluences[ i ];\n\t}\n#endif",normal_fragment_begin:"float faceDirection = gl_FrontFacing ? 1.0 : - 1.0;\n#ifdef FLAT_SHADED\n\tvec3 fdx = dFdx( vViewPosition );\n\tvec3 fdy = dFdy( vViewPosition );\n\tvec3 normal = normalize( cross( fdx, fdy ) );\n#else\n\tvec3 normal = normalize( vNormal );\n\t#ifdef DOUBLE_SIDED\n\t\tnormal *= faceDirection;\n\t#endif\n#endif\n#if defined( USE_NORMALMAP_TANGENTSPACE ) || defined( USE_CLEARCOAT_NORMALMAP ) || defined( USE_ANISOTROPY )\n\t#ifdef USE_TANGENT\n\t\tmat3 tbn = mat3( normalize( vTangent ), normalize( vBitangent ), normal );\n\t#else\n\t\tmat3 tbn = getTangentFrame( - vViewPosition, normal,\n\t\t#if defined( USE_NORMALMAP )\n\t\t\tvNormalMapUv\n\t\t#elif defined( USE_CLEARCOAT_NORMALMAP )\n\t\t\tvClearcoatNormalMapUv\n\t\t#else\n\t\t\tvUv\n\t\t#endif\n\t\t);\n\t#endif\n\t#if defined( DOUBLE_SIDED ) && ! defined( FLAT_SHADED )\n\t\ttbn[0] *= faceDirection;\n\t\ttbn[1] *= faceDirection;\n\t#endif\n#endif\n#ifdef USE_CLEARCOAT_NORMALMAP\n\t#ifdef USE_TANGENT\n\t\tmat3 tbn2 = mat3( normalize( vTangent ), normalize( vBitangent ), normal );\n\t#else\n\t\tmat3 tbn2 = getTangentFrame( - vViewPosition, normal, vClearcoatNormalMapUv );\n\t#endif\n\t#if defined( DOUBLE_SIDED ) && ! defined( FLAT_SHADED )\n\t\ttbn2[0] *= faceDirection;\n\t\ttbn2[1] *= faceDirection;\n\t#endif\n#endif\nvec3 nonPerturbedNormal = normal;",normal_fragment_maps:"#ifdef USE_NORMALMAP_OBJECTSPACE\n\tnormal = texture2D( normalMap, vNormalMapUv ).xyz * 2.0 - 1.0;\n\t#ifdef FLIP_SIDED\n\t\tnormal = - normal;\n\t#endif\n\t#ifdef DOUBLE_SIDED\n\t\tnormal = normal * faceDirection;\n\t#endif\n\tnormal = normalize( normalMatrix * normal );\n#elif defined( USE_NORMALMAP_TANGENTSPACE )\n\tvec3 mapN = texture2D( normalMap, vNormalMapUv ).xyz * 2.0 - 1.0;\n\tmapN.xy *= normalScale;\n\tnormal = normalize( tbn * mapN );\n#elif defined( USE_BUMPMAP )\n\tnormal = perturbNormalArb( - vViewPosition, normal, dHdxy_fwd(), faceDirection );\n#endif",normal_pars_fragment:"#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n\t#ifdef USE_TANGENT\n\t\tvarying vec3 vTangent;\n\t\tvarying vec3 vBitangent;\n\t#endif\n#endif",normal_pars_vertex:"#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n\t#ifdef USE_TANGENT\n\t\tvarying vec3 vTangent;\n\t\tvarying vec3 vBitangent;\n\t#endif\n#endif",normal_vertex:"#ifndef FLAT_SHADED\n\tvNormal = normalize( transformedNormal );\n\t#ifdef USE_TANGENT\n\t\tvTangent = normalize( transformedTangent );\n\t\tvBitangent = normalize( cross( vNormal, vTangent ) * tangent.w );\n\t#endif\n#endif",normalmap_pars_fragment:"#ifdef USE_NORMALMAP\n\tuniform sampler2D normalMap;\n\tuniform vec2 normalScale;\n#endif\n#ifdef USE_NORMALMAP_OBJECTSPACE\n\tuniform mat3 normalMatrix;\n#endif\n#if ! defined ( USE_TANGENT ) && ( defined ( USE_NORMALMAP_TANGENTSPACE ) || defined ( USE_CLEARCOAT_NORMALMAP ) || defined( USE_ANISOTROPY ) )\n\tmat3 getTangentFrame( vec3 eye_pos, vec3 surf_norm, vec2 uv ) {\n\t\tvec3 q0 = dFdx( eye_pos.xyz );\n\t\tvec3 q1 = dFdy( eye_pos.xyz );\n\t\tvec2 st0 = dFdx( uv.st );\n\t\tvec2 st1 = dFdy( uv.st );\n\t\tvec3 N = surf_norm;\n\t\tvec3 q1perp = cross( q1, N );\n\t\tvec3 q0perp = cross( N, q0 );\n\t\tvec3 T = q1perp * st0.x + q0perp * st1.x;\n\t\tvec3 B = q1perp * st0.y + q0perp * st1.y;\n\t\tfloat det = max( dot( T, T ), dot( B, B ) );\n\t\tfloat scale = ( det == 0.0 ) ? 0.0 : inversesqrt( det );\n\t\treturn mat3( T * scale, B * scale, N );\n\t}\n#endif",clearcoat_normal_fragment_begin:"#ifdef USE_CLEARCOAT\n\tvec3 clearcoatNormal = nonPerturbedNormal;\n#endif",clearcoat_normal_fragment_maps:"#ifdef USE_CLEARCOAT_NORMALMAP\n\tvec3 clearcoatMapN = texture2D( clearcoatNormalMap, vClearcoatNormalMapUv ).xyz * 2.0 - 1.0;\n\tclearcoatMapN.xy *= clearcoatNormalScale;\n\tclearcoatNormal = normalize( tbn2 * clearcoatMapN );\n#endif",clearcoat_pars_fragment:"#ifdef USE_CLEARCOATMAP\n\tuniform sampler2D clearcoatMap;\n#endif\n#ifdef USE_CLEARCOAT_NORMALMAP\n\tuniform sampler2D clearcoatNormalMap;\n\tuniform vec2 clearcoatNormalScale;\n#endif\n#ifdef USE_CLEARCOAT_ROUGHNESSMAP\n\tuniform sampler2D clearcoatRoughnessMap;\n#endif",iridescence_pars_fragment:"#ifdef USE_IRIDESCENCEMAP\n\tuniform sampler2D iridescenceMap;\n#endif\n#ifdef USE_IRIDESCENCE_THICKNESSMAP\n\tuniform sampler2D iridescenceThicknessMap;\n#endif",opaque_fragment:"#ifdef OPAQUE\ndiffuseColor.a = 1.0;\n#endif\n#ifdef USE_TRANSMISSION\ndiffuseColor.a *= material.transmissionAlpha;\n#endif\ngl_FragColor = vec4( outgoingLight, diffuseColor.a );",packing:"vec3 packNormalToRGB( const in vec3 normal ) {\n\treturn normalize( normal ) * 0.5 + 0.5;\n}\nvec3 unpackRGBToNormal( const in vec3 rgb ) {\n\treturn 2.0 * rgb.xyz - 1.0;\n}\nconst float PackUpscale = 256. / 255.;const float UnpackDownscale = 255. / 256.;const float ShiftRight8 = 1. / 256.;\nconst float Inv255 = 1. / 255.;\nconst vec4 PackFactors = vec4( 1.0, 256.0, 256.0 * 256.0, 256.0 * 256.0 * 256.0 );\nconst vec2 UnpackFactors2 = vec2( UnpackDownscale, 1.0 / PackFactors.g );\nconst vec3 UnpackFactors3 = vec3( UnpackDownscale / PackFactors.rg, 1.0 / PackFactors.b );\nconst vec4 UnpackFactors4 = vec4( UnpackDownscale / PackFactors.rgb, 1.0 / PackFactors.a );\nvec4 packDepthToRGBA( const in float v ) {\n\tif( v <= 0.0 )\n\t\treturn vec4( 0., 0., 0., 0. );\n\tif( v >= 1.0 )\n\t\treturn vec4( 1., 1., 1., 1. );\n\tfloat vuf;\n\tfloat af = modf( v * PackFactors.a, vuf );\n\tfloat bf = modf( vuf * ShiftRight8, vuf );\n\tfloat gf = modf( vuf * ShiftRight8, vuf );\n\treturn vec4( vuf * Inv255, gf * PackUpscale, bf * PackUpscale, af );\n}\nvec3 packDepthToRGB( const in float v ) {\n\tif( v <= 0.0 )\n\t\treturn vec3( 0., 0., 0. );\n\tif( v >= 1.0 )\n\t\treturn vec3( 1., 1., 1. );\n\tfloat vuf;\n\tfloat bf = modf( v * PackFactors.b, vuf );\n\tfloat gf = modf( vuf * ShiftRight8, vuf );\n\treturn vec3( vuf * Inv255, gf * PackUpscale, bf );\n}\nvec2 packDepthToRG( const in float v ) {\n\tif( v <= 0.0 )\n\t\treturn vec2( 0., 0. );\n\tif( v >= 1.0 )\n\t\treturn vec2( 1., 1. );\n\tfloat vuf;\n\tfloat gf = modf( v * 256., vuf );\n\treturn vec2( vuf * Inv255, gf );\n}\nfloat unpackRGBAToDepth( const in vec4 v ) {\n\treturn dot( v, UnpackFactors4 );\n}\nfloat unpackRGBToDepth( const in vec3 v ) {\n\treturn dot( v, UnpackFactors3 );\n}\nfloat unpackRGToDepth( const in vec2 v ) {\n\treturn v.r * UnpackFactors2.r + v.g * UnpackFactors2.g;\n}\nvec4 pack2HalfToRGBA( const in vec2 v ) {\n\tvec4 r = vec4( v.x, fract( v.x * 255.0 ), v.y, fract( v.y * 255.0 ) );\n\treturn vec4( r.x - r.y / 255.0, r.y, r.z - r.w / 255.0, r.w );\n}\nvec2 unpackRGBATo2Half( const in vec4 v ) {\n\treturn vec2( v.x + ( v.y / 255.0 ), v.z + ( v.w / 255.0 ) );\n}\nfloat viewZToOrthographicDepth( const in float viewZ, const in float near, const in float far ) {\n\treturn ( viewZ + near ) / ( near - far );\n}\nfloat orthographicDepthToViewZ( const in float depth, const in float near, const in float far ) {\n\treturn depth * ( near - far ) - near;\n}\nfloat viewZToPerspectiveDepth( const in float viewZ, const in float near, const in float far ) {\n\treturn ( ( near + viewZ ) * far ) / ( ( far - near ) * viewZ );\n}\nfloat perspectiveDepthToViewZ( const in float depth, const in float near, const in float far ) {\n\treturn ( near * far ) / ( ( far - near ) * depth - far );\n}",premultiplied_alpha_fragment:"#ifdef PREMULTIPLIED_ALPHA\n\tgl_FragColor.rgb *= gl_FragColor.a;\n#endif",project_vertex:"vec4 mvPosition = vec4( transformed, 1.0 );\n#ifdef USE_BATCHING\n\tmvPosition = batchingMatrix * mvPosition;\n#endif\n#ifdef USE_INSTANCING\n\tmvPosition = instanceMatrix * mvPosition;\n#endif\nmvPosition = modelViewMatrix * mvPosition;\ngl_Position = projectionMatrix * mvPosition;",dithering_fragment:"#ifdef DITHERING\n\tgl_FragColor.rgb = dithering( gl_FragColor.rgb );\n#endif",dithering_pars_fragment:"#ifdef DITHERING\n\tvec3 dithering( vec3 color ) {\n\t\tfloat grid_position = rand( gl_FragCoord.xy );\n\t\tvec3 dither_shift_RGB = vec3( 0.25 / 255.0, -0.25 / 255.0, 0.25 / 255.0 );\n\t\tdither_shift_RGB = mix( 2.0 * dither_shift_RGB, -2.0 * dither_shift_RGB, grid_position );\n\t\treturn color + dither_shift_RGB;\n\t}\n#endif",roughnessmap_fragment:"float roughnessFactor = roughness;\n#ifdef USE_ROUGHNESSMAP\n\tvec4 texelRoughness = texture2D( roughnessMap, vRoughnessMapUv );\n\troughnessFactor *= texelRoughness.g;\n#endif",roughnessmap_pars_fragment:"#ifdef USE_ROUGHNESSMAP\n\tuniform sampler2D roughnessMap;\n#endif",shadowmap_pars_fragment:"#if NUM_SPOT_LIGHT_COORDS > 0\n\tvarying vec4 vSpotLightCoord[ NUM_SPOT_LIGHT_COORDS ];\n#endif\n#if NUM_SPOT_LIGHT_MAPS > 0\n\tuniform sampler2D spotLightMap[ NUM_SPOT_LIGHT_MAPS ];\n#endif\n#ifdef USE_SHADOWMAP\n\t#if NUM_DIR_LIGHT_SHADOWS > 0\n\t\tuniform sampler2D directionalShadowMap[ NUM_DIR_LIGHT_SHADOWS ];\n\t\tvarying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHT_SHADOWS ];\n\t\tstruct DirectionalLightShadow {\n\t\t\tfloat shadowIntensity;\n\t\t\tfloat shadowBias;\n\t\t\tfloat shadowNormalBias;\n\t\t\tfloat shadowRadius;\n\t\t\tvec2 shadowMapSize;\n\t\t};\n\t\tuniform DirectionalLightShadow directionalLightShadows[ NUM_DIR_LIGHT_SHADOWS ];\n\t#endif\n\t#if NUM_SPOT_LIGHT_SHADOWS > 0\n\t\tuniform sampler2D spotShadowMap[ NUM_SPOT_LIGHT_SHADOWS ];\n\t\tstruct SpotLightShadow {\n\t\t\tfloat shadowIntensity;\n\t\t\tfloat shadowBias;\n\t\t\tfloat shadowNormalBias;\n\t\t\tfloat shadowRadius;\n\t\t\tvec2 shadowMapSize;\n\t\t};\n\t\tuniform SpotLightShadow spotLightShadows[ NUM_SPOT_LIGHT_SHADOWS ];\n\t#endif\n\t#if NUM_POINT_LIGHT_SHADOWS > 0\n\t\tuniform sampler2D pointShadowMap[ NUM_POINT_LIGHT_SHADOWS ];\n\t\tvarying vec4 vPointShadowCoord[ NUM_POINT_LIGHT_SHADOWS ];\n\t\tstruct PointLightShadow {\n\t\t\tfloat shadowIntensity;\n\t\t\tfloat shadowBias;\n\t\t\tfloat shadowNormalBias;\n\t\t\tfloat shadowRadius;\n\t\t\tvec2 shadowMapSize;\n\t\t\tfloat shadowCameraNear;\n\t\t\tfloat shadowCameraFar;\n\t\t};\n\t\tuniform PointLightShadow pointLightShadows[ NUM_POINT_LIGHT_SHADOWS ];\n\t#endif\n\tfloat texture2DCompare( sampler2D depths, vec2 uv, float compare ) {\n\t\treturn step( compare, unpackRGBAToDepth( texture2D( depths, uv ) ) );\n\t}\n\tvec2 texture2DDistribution( sampler2D shadow, vec2 uv ) {\n\t\treturn unpackRGBATo2Half( texture2D( shadow, uv ) );\n\t}\n\tfloat VSMShadow (sampler2D shadow, vec2 uv, float compare ){\n\t\tfloat occlusion = 1.0;\n\t\tvec2 distribution = texture2DDistribution( shadow, uv );\n\t\tfloat hard_shadow = step( compare , distribution.x );\n\t\tif (hard_shadow != 1.0 ) {\n\t\t\tfloat distance = compare - distribution.x ;\n\t\t\tfloat variance = max( 0.00000, distribution.y * distribution.y );\n\t\t\tfloat softness_probability = variance / (variance + distance * distance );\t\t\tsoftness_probability = clamp( ( softness_probability - 0.3 ) / ( 0.95 - 0.3 ), 0.0, 1.0 );\t\t\tocclusion = clamp( max( hard_shadow, softness_probability ), 0.0, 1.0 );\n\t\t}\n\t\treturn occlusion;\n\t}\n\tfloat getShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowIntensity, float shadowBias, float shadowRadius, vec4 shadowCoord ) {\n\t\tfloat shadow = 1.0;\n\t\tshadowCoord.xyz /= shadowCoord.w;\n\t\tshadowCoord.z += shadowBias;\n\t\tbool inFrustum = shadowCoord.x >= 0.0 && shadowCoord.x <= 1.0 && shadowCoord.y >= 0.0 && shadowCoord.y <= 1.0;\n\t\tbool frustumTest = inFrustum && shadowCoord.z <= 1.0;\n\t\tif ( frustumTest ) {\n\t\t#if defined( SHADOWMAP_TYPE_PCF )\n\t\t\tvec2 texelSize = vec2( 1.0 ) / shadowMapSize;\n\t\t\tfloat dx0 = - texelSize.x * shadowRadius;\n\t\t\tfloat dy0 = - texelSize.y * shadowRadius;\n\t\t\tfloat dx1 = + texelSize.x * shadowRadius;\n\t\t\tfloat dy1 = + texelSize.y * shadowRadius;\n\t\t\tfloat dx2 = dx0 / 2.0;\n\t\t\tfloat dy2 = dy0 / 2.0;\n\t\t\tfloat dx3 = dx1 / 2.0;\n\t\t\tfloat dy3 = dy1 / 2.0;\n\t\t\tshadow = (\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, dy0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, dy0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, dy2 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy2 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, dy2 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, 0.0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, 0.0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy, shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, 0.0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, 0.0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, dy3 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy3 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, dy3 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, dy1 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy1 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, dy1 ), shadowCoord.z )\n\t\t\t) * ( 1.0 / 17.0 );\n\t\t#elif defined( SHADOWMAP_TYPE_PCF_SOFT )\n\t\t\tvec2 texelSize = vec2( 1.0 ) / shadowMapSize;\n\t\t\tfloat dx = texelSize.x;\n\t\t\tfloat dy = texelSize.y;\n\t\t\tvec2 uv = shadowCoord.xy;\n\t\t\tvec2 f = fract( uv * shadowMapSize + 0.5 );\n\t\t\tuv -= f * texelSize;\n\t\t\tshadow = (\n\t\t\t\ttexture2DCompare( shadowMap, uv, shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, uv + vec2( dx, 0.0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, uv + vec2( 0.0, dy ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, uv + texelSize, shadowCoord.z ) +\n\t\t\t\tmix( texture2DCompare( shadowMap, uv + vec2( -dx, 0.0 ), shadowCoord.z ),\n\t\t\t\t\t texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, 0.0 ), shadowCoord.z ),\n\t\t\t\t\t f.x ) +\n\t\t\t\tmix( texture2DCompare( shadowMap, uv + vec2( -dx, dy ), shadowCoord.z ),\n\t\t\t\t\t texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, dy ), shadowCoord.z ),\n\t\t\t\t\t f.x ) +\n\t\t\t\tmix( texture2DCompare( shadowMap, uv + vec2( 0.0, -dy ), shadowCoord.z ),\n\t\t\t\t\t texture2DCompare( shadowMap, uv + vec2( 0.0, 2.0 * dy ), shadowCoord.z ),\n\t\t\t\t\t f.y ) +\n\t\t\t\tmix( texture2DCompare( shadowMap, uv + vec2( dx, -dy ), shadowCoord.z ),\n\t\t\t\t\t texture2DCompare( shadowMap, uv + vec2( dx, 2.0 * dy ), shadowCoord.z ),\n\t\t\t\t\t f.y ) +\n\t\t\t\tmix( mix( texture2DCompare( shadowMap, uv + vec2( -dx, -dy ), shadowCoord.z ),\n\t\t\t\t\t\t texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, -dy ), shadowCoord.z ),\n\t\t\t\t\t\t f.x ),\n\t\t\t\t\t mix( texture2DCompare( shadowMap, uv + vec2( -dx, 2.0 * dy ), shadowCoord.z ),\n\t\t\t\t\t\t texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, 2.0 * dy ), shadowCoord.z ),\n\t\t\t\t\t\t f.x ),\n\t\t\t\t\t f.y )\n\t\t\t) * ( 1.0 / 9.0 );\n\t\t#elif defined( SHADOWMAP_TYPE_VSM )\n\t\t\tshadow = VSMShadow( shadowMap, shadowCoord.xy, shadowCoord.z );\n\t\t#else\n\t\t\tshadow = texture2DCompare( shadowMap, shadowCoord.xy, shadowCoord.z );\n\t\t#endif\n\t\t}\n\t\treturn mix( 1.0, shadow, shadowIntensity );\n\t}\n\tvec2 cubeToUV( vec3 v, float texelSizeY ) {\n\t\tvec3 absV = abs( v );\n\t\tfloat scaleToCube = 1.0 / max( absV.x, max( absV.y, absV.z ) );\n\t\tabsV *= scaleToCube;\n\t\tv *= scaleToCube * ( 1.0 - 2.0 * texelSizeY );\n\t\tvec2 planar = v.xy;\n\t\tfloat almostATexel = 1.5 * texelSizeY;\n\t\tfloat almostOne = 1.0 - almostATexel;\n\t\tif ( absV.z >= almostOne ) {\n\t\t\tif ( v.z > 0.0 )\n\t\t\t\tplanar.x = 4.0 - v.x;\n\t\t} else if ( absV.x >= almostOne ) {\n\t\t\tfloat signX = sign( v.x );\n\t\t\tplanar.x = v.z * signX + 2.0 * signX;\n\t\t} else if ( absV.y >= almostOne ) {\n\t\t\tfloat signY = sign( v.y );\n\t\t\tplanar.x = v.x + 2.0 * signY + 2.0;\n\t\t\tplanar.y = v.z * signY - 2.0;\n\t\t}\n\t\treturn vec2( 0.125, 0.25 ) * planar + vec2( 0.375, 0.75 );\n\t}\n\tfloat getPointShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowIntensity, float shadowBias, float shadowRadius, vec4 shadowCoord, float shadowCameraNear, float shadowCameraFar ) {\n\t\tfloat shadow = 1.0;\n\t\tvec3 lightToPosition = shadowCoord.xyz;\n\t\t\n\t\tfloat lightToPositionLength = length( lightToPosition );\n\t\tif ( lightToPositionLength - shadowCameraFar <= 0.0 && lightToPositionLength - shadowCameraNear >= 0.0 ) {\n\t\t\tfloat dp = ( lightToPositionLength - shadowCameraNear ) / ( shadowCameraFar - shadowCameraNear );\t\t\tdp += shadowBias;\n\t\t\tvec3 bd3D = normalize( lightToPosition );\n\t\t\tvec2 texelSize = vec2( 1.0 ) / ( shadowMapSize * vec2( 4.0, 2.0 ) );\n\t\t\t#if defined( SHADOWMAP_TYPE_PCF ) || defined( SHADOWMAP_TYPE_PCF_SOFT ) || defined( SHADOWMAP_TYPE_VSM )\n\t\t\t\tvec2 offset = vec2( - 1, 1 ) * shadowRadius * texelSize.y;\n\t\t\t\tshadow = (\n\t\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.xyy, texelSize.y ), dp ) +\n\t\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.yyy, texelSize.y ), dp ) +\n\t\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.xyx, texelSize.y ), dp ) +\n\t\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.yyx, texelSize.y ), dp ) +\n\t\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D, texelSize.y ), dp ) +\n\t\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.xxy, texelSize.y ), dp ) +\n\t\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.yxy, texelSize.y ), dp ) +\n\t\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.xxx, texelSize.y ), dp ) +\n\t\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.yxx, texelSize.y ), dp )\n\t\t\t\t) * ( 1.0 / 9.0 );\n\t\t\t#else\n\t\t\t\tshadow = texture2DCompare( shadowMap, cubeToUV( bd3D, texelSize.y ), dp );\n\t\t\t#endif\n\t\t}\n\t\treturn mix( 1.0, shadow, shadowIntensity );\n\t}\n#endif",shadowmap_pars_vertex:"#if NUM_SPOT_LIGHT_COORDS > 0\n\tuniform mat4 spotLightMatrix[ NUM_SPOT_LIGHT_COORDS ];\n\tvarying vec4 vSpotLightCoord[ NUM_SPOT_LIGHT_COORDS ];\n#endif\n#ifdef USE_SHADOWMAP\n\t#if NUM_DIR_LIGHT_SHADOWS > 0\n\t\tuniform mat4 directionalShadowMatrix[ NUM_DIR_LIGHT_SHADOWS ];\n\t\tvarying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHT_SHADOWS ];\n\t\tstruct DirectionalLightShadow {\n\t\t\tfloat shadowIntensity;\n\t\t\tfloat shadowBias;\n\t\t\tfloat shadowNormalBias;\n\t\t\tfloat shadowRadius;\n\t\t\tvec2 shadowMapSize;\n\t\t};\n\t\tuniform DirectionalLightShadow directionalLightShadows[ NUM_DIR_LIGHT_SHADOWS ];\n\t#endif\n\t#if NUM_SPOT_LIGHT_SHADOWS > 0\n\t\tstruct SpotLightShadow {\n\t\t\tfloat shadowIntensity;\n\t\t\tfloat shadowBias;\n\t\t\tfloat shadowNormalBias;\n\t\t\tfloat shadowRadius;\n\t\t\tvec2 shadowMapSize;\n\t\t};\n\t\tuniform SpotLightShadow spotLightShadows[ NUM_SPOT_LIGHT_SHADOWS ];\n\t#endif\n\t#if NUM_POINT_LIGHT_SHADOWS > 0\n\t\tuniform mat4 pointShadowMatrix[ NUM_POINT_LIGHT_SHADOWS ];\n\t\tvarying vec4 vPointShadowCoord[ NUM_POINT_LIGHT_SHADOWS ];\n\t\tstruct PointLightShadow {\n\t\t\tfloat shadowIntensity;\n\t\t\tfloat shadowBias;\n\t\t\tfloat shadowNormalBias;\n\t\t\tfloat shadowRadius;\n\t\t\tvec2 shadowMapSize;\n\t\t\tfloat shadowCameraNear;\n\t\t\tfloat shadowCameraFar;\n\t\t};\n\t\tuniform PointLightShadow pointLightShadows[ NUM_POINT_LIGHT_SHADOWS ];\n\t#endif\n#endif",shadowmap_vertex:"#if ( defined( USE_SHADOWMAP ) && ( NUM_DIR_LIGHT_SHADOWS > 0 || NUM_POINT_LIGHT_SHADOWS > 0 ) ) || ( NUM_SPOT_LIGHT_COORDS > 0 )\n\tvec3 shadowWorldNormal = inverseTransformDirection( transformedNormal, viewMatrix );\n\tvec4 shadowWorldPosition;\n#endif\n#if defined( USE_SHADOWMAP )\n\t#if NUM_DIR_LIGHT_SHADOWS > 0\n\t\t#pragma unroll_loop_start\n\t\tfor ( int i = 0; i < NUM_DIR_LIGHT_SHADOWS; i ++ ) {\n\t\t\tshadowWorldPosition = worldPosition + vec4( shadowWorldNormal * directionalLightShadows[ i ].shadowNormalBias, 0 );\n\t\t\tvDirectionalShadowCoord[ i ] = directionalShadowMatrix[ i ] * shadowWorldPosition;\n\t\t}\n\t\t#pragma unroll_loop_end\n\t#endif\n\t#if NUM_POINT_LIGHT_SHADOWS > 0\n\t\t#pragma unroll_loop_start\n\t\tfor ( int i = 0; i < NUM_POINT_LIGHT_SHADOWS; i ++ ) {\n\t\t\tshadowWorldPosition = worldPosition + vec4( shadowWorldNormal * pointLightShadows[ i ].shadowNormalBias, 0 );\n\t\t\tvPointShadowCoord[ i ] = pointShadowMatrix[ i ] * shadowWorldPosition;\n\t\t}\n\t\t#pragma unroll_loop_end\n\t#endif\n#endif\n#if NUM_SPOT_LIGHT_COORDS > 0\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_SPOT_LIGHT_COORDS; i ++ ) {\n\t\tshadowWorldPosition = worldPosition;\n\t\t#if ( defined( USE_SHADOWMAP ) && UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS )\n\t\t\tshadowWorldPosition.xyz += shadowWorldNormal * spotLightShadows[ i ].shadowNormalBias;\n\t\t#endif\n\t\tvSpotLightCoord[ i ] = spotLightMatrix[ i ] * shadowWorldPosition;\n\t}\n\t#pragma unroll_loop_end\n#endif",shadowmask_pars_fragment:"float getShadowMask() {\n\tfloat shadow = 1.0;\n\t#ifdef USE_SHADOWMAP\n\t#if NUM_DIR_LIGHT_SHADOWS > 0\n\tDirectionalLightShadow directionalLight;\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_DIR_LIGHT_SHADOWS; i ++ ) {\n\t\tdirectionalLight = directionalLightShadows[ i ];\n\t\tshadow *= receiveShadow ? getShadow( directionalShadowMap[ i ], directionalLight.shadowMapSize, directionalLight.shadowIntensity, directionalLight.shadowBias, directionalLight.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0;\n\t}\n\t#pragma unroll_loop_end\n\t#endif\n\t#if NUM_SPOT_LIGHT_SHADOWS > 0\n\tSpotLightShadow spotLight;\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_SPOT_LIGHT_SHADOWS; i ++ ) {\n\t\tspotLight = spotLightShadows[ i ];\n\t\tshadow *= receiveShadow ? getShadow( spotShadowMap[ i ], spotLight.shadowMapSize, spotLight.shadowIntensity, spotLight.shadowBias, spotLight.shadowRadius, vSpotLightCoord[ i ] ) : 1.0;\n\t}\n\t#pragma unroll_loop_end\n\t#endif\n\t#if NUM_POINT_LIGHT_SHADOWS > 0\n\tPointLightShadow pointLight;\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_POINT_LIGHT_SHADOWS; i ++ ) {\n\t\tpointLight = pointLightShadows[ i ];\n\t\tshadow *= receiveShadow ? getPointShadow( pointShadowMap[ i ], pointLight.shadowMapSize, pointLight.shadowIntensity, pointLight.shadowBias, pointLight.shadowRadius, vPointShadowCoord[ i ], pointLight.shadowCameraNear, pointLight.shadowCameraFar ) : 1.0;\n\t}\n\t#pragma unroll_loop_end\n\t#endif\n\t#endif\n\treturn shadow;\n}",skinbase_vertex:"#ifdef USE_SKINNING\n\tmat4 boneMatX = getBoneMatrix( skinIndex.x );\n\tmat4 boneMatY = getBoneMatrix( skinIndex.y );\n\tmat4 boneMatZ = getBoneMatrix( skinIndex.z );\n\tmat4 boneMatW = getBoneMatrix( skinIndex.w );\n#endif",skinning_pars_vertex:"#ifdef USE_SKINNING\n\tuniform mat4 bindMatrix;\n\tuniform mat4 bindMatrixInverse;\n\tuniform highp sampler2D boneTexture;\n\tmat4 getBoneMatrix( const in float i ) {\n\t\tint size = textureSize( boneTexture, 0 ).x;\n\t\tint j = int( i ) * 4;\n\t\tint x = j % size;\n\t\tint y = j / size;\n\t\tvec4 v1 = texelFetch( boneTexture, ivec2( x, y ), 0 );\n\t\tvec4 v2 = texelFetch( boneTexture, ivec2( x + 1, y ), 0 );\n\t\tvec4 v3 = texelFetch( boneTexture, ivec2( x + 2, y ), 0 );\n\t\tvec4 v4 = texelFetch( boneTexture, ivec2( x + 3, y ), 0 );\n\t\treturn mat4( v1, v2, v3, v4 );\n\t}\n#endif",skinning_vertex:"#ifdef USE_SKINNING\n\tvec4 skinVertex = bindMatrix * vec4( transformed, 1.0 );\n\tvec4 skinned = vec4( 0.0 );\n\tskinned += boneMatX * skinVertex * skinWeight.x;\n\tskinned += boneMatY * skinVertex * skinWeight.y;\n\tskinned += boneMatZ * skinVertex * skinWeight.z;\n\tskinned += boneMatW * skinVertex * skinWeight.w;\n\ttransformed = ( bindMatrixInverse * skinned ).xyz;\n#endif",skinnormal_vertex:"#ifdef USE_SKINNING\n\tmat4 skinMatrix = mat4( 0.0 );\n\tskinMatrix += skinWeight.x * boneMatX;\n\tskinMatrix += skinWeight.y * boneMatY;\n\tskinMatrix += skinWeight.z * boneMatZ;\n\tskinMatrix += skinWeight.w * boneMatW;\n\tskinMatrix = bindMatrixInverse * skinMatrix * bindMatrix;\n\tobjectNormal = vec4( skinMatrix * vec4( objectNormal, 0.0 ) ).xyz;\n\t#ifdef USE_TANGENT\n\t\tobjectTangent = vec4( skinMatrix * vec4( objectTangent, 0.0 ) ).xyz;\n\t#endif\n#endif",specularmap_fragment:"float specularStrength;\n#ifdef USE_SPECULARMAP\n\tvec4 texelSpecular = texture2D( specularMap, vSpecularMapUv );\n\tspecularStrength = texelSpecular.r;\n#else\n\tspecularStrength = 1.0;\n#endif",specularmap_pars_fragment:"#ifdef USE_SPECULARMAP\n\tuniform sampler2D specularMap;\n#endif",tonemapping_fragment:"#if defined( TONE_MAPPING )\n\tgl_FragColor.rgb = toneMapping( gl_FragColor.rgb );\n#endif",tonemapping_pars_fragment:"#ifndef saturate\n#define saturate( a ) clamp( a, 0.0, 1.0 )\n#endif\nuniform float toneMappingExposure;\nvec3 LinearToneMapping( vec3 color ) {\n\treturn saturate( toneMappingExposure * color );\n}\nvec3 ReinhardToneMapping( vec3 color ) {\n\tcolor *= toneMappingExposure;\n\treturn saturate( color / ( vec3( 1.0 ) + color ) );\n}\nvec3 CineonToneMapping( vec3 color ) {\n\tcolor *= toneMappingExposure;\n\tcolor = max( vec3( 0.0 ), color - 0.004 );\n\treturn pow( ( color * ( 6.2 * color + 0.5 ) ) / ( color * ( 6.2 * color + 1.7 ) + 0.06 ), vec3( 2.2 ) );\n}\nvec3 RRTAndODTFit( vec3 v ) {\n\tvec3 a = v * ( v + 0.0245786 ) - 0.000090537;\n\tvec3 b = v * ( 0.983729 * v + 0.4329510 ) + 0.238081;\n\treturn a / b;\n}\nvec3 ACESFilmicToneMapping( vec3 color ) {\n\tconst mat3 ACESInputMat = mat3(\n\t\tvec3( 0.59719, 0.07600, 0.02840 ),\t\tvec3( 0.35458, 0.90834, 0.13383 ),\n\t\tvec3( 0.04823, 0.01566, 0.83777 )\n\t);\n\tconst mat3 ACESOutputMat = mat3(\n\t\tvec3( 1.60475, -0.10208, -0.00327 ),\t\tvec3( -0.53108, 1.10813, -0.07276 ),\n\t\tvec3( -0.07367, -0.00605, 1.07602 )\n\t);\n\tcolor *= toneMappingExposure / 0.6;\n\tcolor = ACESInputMat * color;\n\tcolor = RRTAndODTFit( color );\n\tcolor = ACESOutputMat * color;\n\treturn saturate( color );\n}\nconst mat3 LINEAR_REC2020_TO_LINEAR_SRGB = mat3(\n\tvec3( 1.6605, - 0.1246, - 0.0182 ),\n\tvec3( - 0.5876, 1.1329, - 0.1006 ),\n\tvec3( - 0.0728, - 0.0083, 1.1187 )\n);\nconst mat3 LINEAR_SRGB_TO_LINEAR_REC2020 = mat3(\n\tvec3( 0.6274, 0.0691, 0.0164 ),\n\tvec3( 0.3293, 0.9195, 0.0880 ),\n\tvec3( 0.0433, 0.0113, 0.8956 )\n);\nvec3 agxDefaultContrastApprox( vec3 x ) {\n\tvec3 x2 = x * x;\n\tvec3 x4 = x2 * x2;\n\treturn + 15.5 * x4 * x2\n\t\t- 40.14 * x4 * x\n\t\t+ 31.96 * x4\n\t\t- 6.868 * x2 * x\n\t\t+ 0.4298 * x2\n\t\t+ 0.1191 * x\n\t\t- 0.00232;\n}\nvec3 AgXToneMapping( vec3 color ) {\n\tconst mat3 AgXInsetMatrix = mat3(\n\t\tvec3( 0.856627153315983, 0.137318972929847, 0.11189821299995 ),\n\t\tvec3( 0.0951212405381588, 0.761241990602591, 0.0767994186031903 ),\n\t\tvec3( 0.0482516061458583, 0.101439036467562, 0.811302368396859 )\n\t);\n\tconst mat3 AgXOutsetMatrix = mat3(\n\t\tvec3( 1.1271005818144368, - 0.1413297634984383, - 0.14132976349843826 ),\n\t\tvec3( - 0.11060664309660323, 1.157823702216272, - 0.11060664309660294 ),\n\t\tvec3( - 0.016493938717834573, - 0.016493938717834257, 1.2519364065950405 )\n\t);\n\tconst float AgxMinEv = - 12.47393;\tconst float AgxMaxEv = 4.026069;\n\tcolor *= toneMappingExposure;\n\tcolor = LINEAR_SRGB_TO_LINEAR_REC2020 * color;\n\tcolor = AgXInsetMatrix * color;\n\tcolor = max( color, 1e-10 );\tcolor = log2( color );\n\tcolor = ( color - AgxMinEv ) / ( AgxMaxEv - AgxMinEv );\n\tcolor = clamp( color, 0.0, 1.0 );\n\tcolor = agxDefaultContrastApprox( color );\n\tcolor = AgXOutsetMatrix * color;\n\tcolor = pow( max( vec3( 0.0 ), color ), vec3( 2.2 ) );\n\tcolor = LINEAR_REC2020_TO_LINEAR_SRGB * color;\n\tcolor = clamp( color, 0.0, 1.0 );\n\treturn color;\n}\nvec3 NeutralToneMapping( vec3 color ) {\n\tconst float StartCompression = 0.8 - 0.04;\n\tconst float Desaturation = 0.15;\n\tcolor *= toneMappingExposure;\n\tfloat x = min( color.r, min( color.g, color.b ) );\n\tfloat offset = x < 0.08 ? x - 6.25 * x * x : 0.04;\n\tcolor -= offset;\n\tfloat peak = max( color.r, max( color.g, color.b ) );\n\tif ( peak < StartCompression ) return color;\n\tfloat d = 1. - StartCompression;\n\tfloat newPeak = 1. - d * d / ( peak + d - StartCompression );\n\tcolor *= newPeak / peak;\n\tfloat g = 1. - 1. / ( Desaturation * ( peak - newPeak ) + 1. );\n\treturn mix( color, vec3( newPeak ), g );\n}\nvec3 CustomToneMapping( vec3 color ) { return color; }",transmission_fragment:"#ifdef USE_TRANSMISSION\n\tmaterial.transmission = transmission;\n\tmaterial.transmissionAlpha = 1.0;\n\tmaterial.thickness = thickness;\n\tmaterial.attenuationDistance = attenuationDistance;\n\tmaterial.attenuationColor = attenuationColor;\n\t#ifdef USE_TRANSMISSIONMAP\n\t\tmaterial.transmission *= texture2D( transmissionMap, vTransmissionMapUv ).r;\n\t#endif\n\t#ifdef USE_THICKNESSMAP\n\t\tmaterial.thickness *= texture2D( thicknessMap, vThicknessMapUv ).g;\n\t#endif\n\tvec3 pos = vWorldPosition;\n\tvec3 v = normalize( cameraPosition - pos );\n\tvec3 n = inverseTransformDirection( normal, viewMatrix );\n\tvec4 transmitted = getIBLVolumeRefraction(\n\t\tn, v, material.roughness, material.diffuseColor, material.specularColor, material.specularF90,\n\t\tpos, modelMatrix, viewMatrix, projectionMatrix, material.dispersion, material.ior, material.thickness,\n\t\tmaterial.attenuationColor, material.attenuationDistance );\n\tmaterial.transmissionAlpha = mix( material.transmissionAlpha, transmitted.a, material.transmission );\n\ttotalDiffuse = mix( totalDiffuse, transmitted.rgb, material.transmission );\n#endif",transmission_pars_fragment:"#ifdef USE_TRANSMISSION\n\tuniform float transmission;\n\tuniform float thickness;\n\tuniform float attenuationDistance;\n\tuniform vec3 attenuationColor;\n\t#ifdef USE_TRANSMISSIONMAP\n\t\tuniform sampler2D transmissionMap;\n\t#endif\n\t#ifdef USE_THICKNESSMAP\n\t\tuniform sampler2D thicknessMap;\n\t#endif\n\tuniform vec2 transmissionSamplerSize;\n\tuniform sampler2D transmissionSamplerMap;\n\tuniform mat4 modelMatrix;\n\tuniform mat4 projectionMatrix;\n\tvarying vec3 vWorldPosition;\n\tfloat w0( float a ) {\n\t\treturn ( 1.0 / 6.0 ) * ( a * ( a * ( - a + 3.0 ) - 3.0 ) + 1.0 );\n\t}\n\tfloat w1( float a ) {\n\t\treturn ( 1.0 / 6.0 ) * ( a * a * ( 3.0 * a - 6.0 ) + 4.0 );\n\t}\n\tfloat w2( float a ){\n\t\treturn ( 1.0 / 6.0 ) * ( a * ( a * ( - 3.0 * a + 3.0 ) + 3.0 ) + 1.0 );\n\t}\n\tfloat w3( float a ) {\n\t\treturn ( 1.0 / 6.0 ) * ( a * a * a );\n\t}\n\tfloat g0( float a ) {\n\t\treturn w0( a ) + w1( a );\n\t}\n\tfloat g1( float a ) {\n\t\treturn w2( a ) + w3( a );\n\t}\n\tfloat h0( float a ) {\n\t\treturn - 1.0 + w1( a ) / ( w0( a ) + w1( a ) );\n\t}\n\tfloat h1( float a ) {\n\t\treturn 1.0 + w3( a ) / ( w2( a ) + w3( a ) );\n\t}\n\tvec4 bicubic( sampler2D tex, vec2 uv, vec4 texelSize, float lod ) {\n\t\tuv = uv * texelSize.zw + 0.5;\n\t\tvec2 iuv = floor( uv );\n\t\tvec2 fuv = fract( uv );\n\t\tfloat g0x = g0( fuv.x );\n\t\tfloat g1x = g1( fuv.x );\n\t\tfloat h0x = h0( fuv.x );\n\t\tfloat h1x = h1( fuv.x );\n\t\tfloat h0y = h0( fuv.y );\n\t\tfloat h1y = h1( fuv.y );\n\t\tvec2 p0 = ( vec2( iuv.x + h0x, iuv.y + h0y ) - 0.5 ) * texelSize.xy;\n\t\tvec2 p1 = ( vec2( iuv.x + h1x, iuv.y + h0y ) - 0.5 ) * texelSize.xy;\n\t\tvec2 p2 = ( vec2( iuv.x + h0x, iuv.y + h1y ) - 0.5 ) * texelSize.xy;\n\t\tvec2 p3 = ( vec2( iuv.x + h1x, iuv.y + h1y ) - 0.5 ) * texelSize.xy;\n\t\treturn g0( fuv.y ) * ( g0x * textureLod( tex, p0, lod ) + g1x * textureLod( tex, p1, lod ) ) +\n\t\t\tg1( fuv.y ) * ( g0x * textureLod( tex, p2, lod ) + g1x * textureLod( tex, p3, lod ) );\n\t}\n\tvec4 textureBicubic( sampler2D sampler, vec2 uv, float lod ) {\n\t\tvec2 fLodSize = vec2( textureSize( sampler, int( lod ) ) );\n\t\tvec2 cLodSize = vec2( textureSize( sampler, int( lod + 1.0 ) ) );\n\t\tvec2 fLodSizeInv = 1.0 / fLodSize;\n\t\tvec2 cLodSizeInv = 1.0 / cLodSize;\n\t\tvec4 fSample = bicubic( sampler, uv, vec4( fLodSizeInv, fLodSize ), floor( lod ) );\n\t\tvec4 cSample = bicubic( sampler, uv, vec4( cLodSizeInv, cLodSize ), ceil( lod ) );\n\t\treturn mix( fSample, cSample, fract( lod ) );\n\t}\n\tvec3 getVolumeTransmissionRay( const in vec3 n, const in vec3 v, const in float thickness, const in float ior, const in mat4 modelMatrix ) {\n\t\tvec3 refractionVector = refract( - v, normalize( n ), 1.0 / ior );\n\t\tvec3 modelScale;\n\t\tmodelScale.x = length( vec3( modelMatrix[ 0 ].xyz ) );\n\t\tmodelScale.y = length( vec3( modelMatrix[ 1 ].xyz ) );\n\t\tmodelScale.z = length( vec3( modelMatrix[ 2 ].xyz ) );\n\t\treturn normalize( refractionVector ) * thickness * modelScale;\n\t}\n\tfloat applyIorToRoughness( const in float roughness, const in float ior ) {\n\t\treturn roughness * clamp( ior * 2.0 - 2.0, 0.0, 1.0 );\n\t}\n\tvec4 getTransmissionSample( const in vec2 fragCoord, const in float roughness, const in float ior ) {\n\t\tfloat lod = log2( transmissionSamplerSize.x ) * applyIorToRoughness( roughness, ior );\n\t\treturn textureBicubic( transmissionSamplerMap, fragCoord.xy, lod );\n\t}\n\tvec3 volumeAttenuation( const in float transmissionDistance, const in vec3 attenuationColor, const in float attenuationDistance ) {\n\t\tif ( isinf( attenuationDistance ) ) {\n\t\t\treturn vec3( 1.0 );\n\t\t} else {\n\t\t\tvec3 attenuationCoefficient = -log( attenuationColor ) / attenuationDistance;\n\t\t\tvec3 transmittance = exp( - attenuationCoefficient * transmissionDistance );\t\t\treturn transmittance;\n\t\t}\n\t}\n\tvec4 getIBLVolumeRefraction( const in vec3 n, const in vec3 v, const in float roughness, const in vec3 diffuseColor,\n\t\tconst in vec3 specularColor, const in float specularF90, const in vec3 position, const in mat4 modelMatrix,\n\t\tconst in mat4 viewMatrix, const in mat4 projMatrix, const in float dispersion, const in float ior, const in float thickness,\n\t\tconst in vec3 attenuationColor, const in float attenuationDistance ) {\n\t\tvec4 transmittedLight;\n\t\tvec3 transmittance;\n\t\t#ifdef USE_DISPERSION\n\t\t\tfloat halfSpread = ( ior - 1.0 ) * 0.025 * dispersion;\n\t\t\tvec3 iors = vec3( ior - halfSpread, ior, ior + halfSpread );\n\t\t\tfor ( int i = 0; i < 3; i ++ ) {\n\t\t\t\tvec3 transmissionRay = getVolumeTransmissionRay( n, v, thickness, iors[ i ], modelMatrix );\n\t\t\t\tvec3 refractedRayExit = position + transmissionRay;\n\t\t\n\t\t\t\tvec4 ndcPos = projMatrix * viewMatrix * vec4( refractedRayExit, 1.0 );\n\t\t\t\tvec2 refractionCoords = ndcPos.xy / ndcPos.w;\n\t\t\t\trefractionCoords += 1.0;\n\t\t\t\trefractionCoords /= 2.0;\n\t\t\n\t\t\t\tvec4 transmissionSample = getTransmissionSample( refractionCoords, roughness, iors[ i ] );\n\t\t\t\ttransmittedLight[ i ] = transmissionSample[ i ];\n\t\t\t\ttransmittedLight.a += transmissionSample.a;\n\t\t\t\ttransmittance[ i ] = diffuseColor[ i ] * volumeAttenuation( length( transmissionRay ), attenuationColor, attenuationDistance )[ i ];\n\t\t\t}\n\t\t\ttransmittedLight.a /= 3.0;\n\t\t\n\t\t#else\n\t\t\n\t\t\tvec3 transmissionRay = getVolumeTransmissionRay( n, v, thickness, ior, modelMatrix );\n\t\t\tvec3 refractedRayExit = position + transmissionRay;\n\t\t\tvec4 ndcPos = projMatrix * viewMatrix * vec4( refractedRayExit, 1.0 );\n\t\t\tvec2 refractionCoords = ndcPos.xy / ndcPos.w;\n\t\t\trefractionCoords += 1.0;\n\t\t\trefractionCoords /= 2.0;\n\t\t\ttransmittedLight = getTransmissionSample( refractionCoords, roughness, ior );\n\t\t\ttransmittance = diffuseColor * volumeAttenuation( length( transmissionRay ), attenuationColor, attenuationDistance );\n\t\t\n\t\t#endif\n\t\tvec3 attenuatedColor = transmittance * transmittedLight.rgb;\n\t\tvec3 F = EnvironmentBRDF( n, v, specularColor, specularF90, roughness );\n\t\tfloat transmittanceFactor = ( transmittance.r + transmittance.g + transmittance.b ) / 3.0;\n\t\treturn vec4( ( 1.0 - F ) * attenuatedColor, 1.0 - ( 1.0 - transmittedLight.a ) * transmittanceFactor );\n\t}\n#endif",uv_pars_fragment:"#if defined( USE_UV ) || defined( USE_ANISOTROPY )\n\tvarying vec2 vUv;\n#endif\n#ifdef USE_MAP\n\tvarying vec2 vMapUv;\n#endif\n#ifdef USE_ALPHAMAP\n\tvarying vec2 vAlphaMapUv;\n#endif\n#ifdef USE_LIGHTMAP\n\tvarying vec2 vLightMapUv;\n#endif\n#ifdef USE_AOMAP\n\tvarying vec2 vAoMapUv;\n#endif\n#ifdef USE_BUMPMAP\n\tvarying vec2 vBumpMapUv;\n#endif\n#ifdef USE_NORMALMAP\n\tvarying vec2 vNormalMapUv;\n#endif\n#ifdef USE_EMISSIVEMAP\n\tvarying vec2 vEmissiveMapUv;\n#endif\n#ifdef USE_METALNESSMAP\n\tvarying vec2 vMetalnessMapUv;\n#endif\n#ifdef USE_ROUGHNESSMAP\n\tvarying vec2 vRoughnessMapUv;\n#endif\n#ifdef USE_ANISOTROPYMAP\n\tvarying vec2 vAnisotropyMapUv;\n#endif\n#ifdef USE_CLEARCOATMAP\n\tvarying vec2 vClearcoatMapUv;\n#endif\n#ifdef USE_CLEARCOAT_NORMALMAP\n\tvarying vec2 vClearcoatNormalMapUv;\n#endif\n#ifdef USE_CLEARCOAT_ROUGHNESSMAP\n\tvarying vec2 vClearcoatRoughnessMapUv;\n#endif\n#ifdef USE_IRIDESCENCEMAP\n\tvarying vec2 vIridescenceMapUv;\n#endif\n#ifdef USE_IRIDESCENCE_THICKNESSMAP\n\tvarying vec2 vIridescenceThicknessMapUv;\n#endif\n#ifdef USE_SHEEN_COLORMAP\n\tvarying vec2 vSheenColorMapUv;\n#endif\n#ifdef USE_SHEEN_ROUGHNESSMAP\n\tvarying vec2 vSheenRoughnessMapUv;\n#endif\n#ifdef USE_SPECULARMAP\n\tvarying vec2 vSpecularMapUv;\n#endif\n#ifdef USE_SPECULAR_COLORMAP\n\tvarying vec2 vSpecularColorMapUv;\n#endif\n#ifdef USE_SPECULAR_INTENSITYMAP\n\tvarying vec2 vSpecularIntensityMapUv;\n#endif\n#ifdef USE_TRANSMISSIONMAP\n\tuniform mat3 transmissionMapTransform;\n\tvarying vec2 vTransmissionMapUv;\n#endif\n#ifdef USE_THICKNESSMAP\n\tuniform mat3 thicknessMapTransform;\n\tvarying vec2 vThicknessMapUv;\n#endif",uv_pars_vertex:"#if defined( USE_UV ) || defined( USE_ANISOTROPY )\n\tvarying vec2 vUv;\n#endif\n#ifdef USE_MAP\n\tuniform mat3 mapTransform;\n\tvarying vec2 vMapUv;\n#endif\n#ifdef USE_ALPHAMAP\n\tuniform mat3 alphaMapTransform;\n\tvarying vec2 vAlphaMapUv;\n#endif\n#ifdef USE_LIGHTMAP\n\tuniform mat3 lightMapTransform;\n\tvarying vec2 vLightMapUv;\n#endif\n#ifdef USE_AOMAP\n\tuniform mat3 aoMapTransform;\n\tvarying vec2 vAoMapUv;\n#endif\n#ifdef USE_BUMPMAP\n\tuniform mat3 bumpMapTransform;\n\tvarying vec2 vBumpMapUv;\n#endif\n#ifdef USE_NORMALMAP\n\tuniform mat3 normalMapTransform;\n\tvarying vec2 vNormalMapUv;\n#endif\n#ifdef USE_DISPLACEMENTMAP\n\tuniform mat3 displacementMapTransform;\n\tvarying vec2 vDisplacementMapUv;\n#endif\n#ifdef USE_EMISSIVEMAP\n\tuniform mat3 emissiveMapTransform;\n\tvarying vec2 vEmissiveMapUv;\n#endif\n#ifdef USE_METALNESSMAP\n\tuniform mat3 metalnessMapTransform;\n\tvarying vec2 vMetalnessMapUv;\n#endif\n#ifdef USE_ROUGHNESSMAP\n\tuniform mat3 roughnessMapTransform;\n\tvarying vec2 vRoughnessMapUv;\n#endif\n#ifdef USE_ANISOTROPYMAP\n\tuniform mat3 anisotropyMapTransform;\n\tvarying vec2 vAnisotropyMapUv;\n#endif\n#ifdef USE_CLEARCOATMAP\n\tuniform mat3 clearcoatMapTransform;\n\tvarying vec2 vClearcoatMapUv;\n#endif\n#ifdef USE_CLEARCOAT_NORMALMAP\n\tuniform mat3 clearcoatNormalMapTransform;\n\tvarying vec2 vClearcoatNormalMapUv;\n#endif\n#ifdef USE_CLEARCOAT_ROUGHNESSMAP\n\tuniform mat3 clearcoatRoughnessMapTransform;\n\tvarying vec2 vClearcoatRoughnessMapUv;\n#endif\n#ifdef USE_SHEEN_COLORMAP\n\tuniform mat3 sheenColorMapTransform;\n\tvarying vec2 vSheenColorMapUv;\n#endif\n#ifdef USE_SHEEN_ROUGHNESSMAP\n\tuniform mat3 sheenRoughnessMapTransform;\n\tvarying vec2 vSheenRoughnessMapUv;\n#endif\n#ifdef USE_IRIDESCENCEMAP\n\tuniform mat3 iridescenceMapTransform;\n\tvarying vec2 vIridescenceMapUv;\n#endif\n#ifdef USE_IRIDESCENCE_THICKNESSMAP\n\tuniform mat3 iridescenceThicknessMapTransform;\n\tvarying vec2 vIridescenceThicknessMapUv;\n#endif\n#ifdef USE_SPECULARMAP\n\tuniform mat3 specularMapTransform;\n\tvarying vec2 vSpecularMapUv;\n#endif\n#ifdef USE_SPECULAR_COLORMAP\n\tuniform mat3 specularColorMapTransform;\n\tvarying vec2 vSpecularColorMapUv;\n#endif\n#ifdef USE_SPECULAR_INTENSITYMAP\n\tuniform mat3 specularIntensityMapTransform;\n\tvarying vec2 vSpecularIntensityMapUv;\n#endif\n#ifdef USE_TRANSMISSIONMAP\n\tuniform mat3 transmissionMapTransform;\n\tvarying vec2 vTransmissionMapUv;\n#endif\n#ifdef USE_THICKNESSMAP\n\tuniform mat3 thicknessMapTransform;\n\tvarying vec2 vThicknessMapUv;\n#endif",uv_vertex:"#if defined( USE_UV ) || defined( USE_ANISOTROPY )\n\tvUv = vec3( uv, 1 ).xy;\n#endif\n#ifdef USE_MAP\n\tvMapUv = ( mapTransform * vec3( MAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_ALPHAMAP\n\tvAlphaMapUv = ( alphaMapTransform * vec3( ALPHAMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_LIGHTMAP\n\tvLightMapUv = ( lightMapTransform * vec3( LIGHTMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_AOMAP\n\tvAoMapUv = ( aoMapTransform * vec3( AOMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_BUMPMAP\n\tvBumpMapUv = ( bumpMapTransform * vec3( BUMPMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_NORMALMAP\n\tvNormalMapUv = ( normalMapTransform * vec3( NORMALMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_DISPLACEMENTMAP\n\tvDisplacementMapUv = ( displacementMapTransform * vec3( DISPLACEMENTMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_EMISSIVEMAP\n\tvEmissiveMapUv = ( emissiveMapTransform * vec3( EMISSIVEMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_METALNESSMAP\n\tvMetalnessMapUv = ( metalnessMapTransform * vec3( METALNESSMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_ROUGHNESSMAP\n\tvRoughnessMapUv = ( roughnessMapTransform * vec3( ROUGHNESSMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_ANISOTROPYMAP\n\tvAnisotropyMapUv = ( anisotropyMapTransform * vec3( ANISOTROPYMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_CLEARCOATMAP\n\tvClearcoatMapUv = ( clearcoatMapTransform * vec3( CLEARCOATMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_CLEARCOAT_NORMALMAP\n\tvClearcoatNormalMapUv = ( clearcoatNormalMapTransform * vec3( CLEARCOAT_NORMALMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_CLEARCOAT_ROUGHNESSMAP\n\tvClearcoatRoughnessMapUv = ( clearcoatRoughnessMapTransform * vec3( CLEARCOAT_ROUGHNESSMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_IRIDESCENCEMAP\n\tvIridescenceMapUv = ( iridescenceMapTransform * vec3( IRIDESCENCEMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_IRIDESCENCE_THICKNESSMAP\n\tvIridescenceThicknessMapUv = ( iridescenceThicknessMapTransform * vec3( IRIDESCENCE_THICKNESSMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_SHEEN_COLORMAP\n\tvSheenColorMapUv = ( sheenColorMapTransform * vec3( SHEEN_COLORMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_SHEEN_ROUGHNESSMAP\n\tvSheenRoughnessMapUv = ( sheenRoughnessMapTransform * vec3( SHEEN_ROUGHNESSMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_SPECULARMAP\n\tvSpecularMapUv = ( specularMapTransform * vec3( SPECULARMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_SPECULAR_COLORMAP\n\tvSpecularColorMapUv = ( specularColorMapTransform * vec3( SPECULAR_COLORMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_SPECULAR_INTENSITYMAP\n\tvSpecularIntensityMapUv = ( specularIntensityMapTransform * vec3( SPECULAR_INTENSITYMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_TRANSMISSIONMAP\n\tvTransmissionMapUv = ( transmissionMapTransform * vec3( TRANSMISSIONMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_THICKNESSMAP\n\tvThicknessMapUv = ( thicknessMapTransform * vec3( THICKNESSMAP_UV, 1 ) ).xy;\n#endif",worldpos_vertex:"#if defined( USE_ENVMAP ) || defined( DISTANCE ) || defined ( USE_SHADOWMAP ) || defined ( USE_TRANSMISSION ) || NUM_SPOT_LIGHT_COORDS > 0\n\tvec4 worldPosition = vec4( transformed, 1.0 );\n\t#ifdef USE_BATCHING\n\t\tworldPosition = batchingMatrix * worldPosition;\n\t#endif\n\t#ifdef USE_INSTANCING\n\t\tworldPosition = instanceMatrix * worldPosition;\n\t#endif\n\tworldPosition = modelMatrix * worldPosition;\n#endif",background_vert:"varying vec2 vUv;\nuniform mat3 uvTransform;\nvoid main() {\n\tvUv = ( uvTransform * vec3( uv, 1 ) ).xy;\n\tgl_Position = vec4( position.xy, 1.0, 1.0 );\n}",background_frag:"uniform sampler2D t2D;\nuniform float backgroundIntensity;\nvarying vec2 vUv;\nvoid main() {\n\tvec4 texColor = texture2D( t2D, vUv );\n\t#ifdef DECODE_VIDEO_TEXTURE\n\t\ttexColor = vec4( mix( pow( texColor.rgb * 0.9478672986 + vec3( 0.0521327014 ), vec3( 2.4 ) ), texColor.rgb * 0.0773993808, vec3( lessThanEqual( texColor.rgb, vec3( 0.04045 ) ) ) ), texColor.w );\n\t#endif\n\ttexColor.rgb *= backgroundIntensity;\n\tgl_FragColor = texColor;\n\t#include \n\t#include \n}",backgroundCube_vert:"varying vec3 vWorldDirection;\n#include \nvoid main() {\n\tvWorldDirection = transformDirection( position, modelMatrix );\n\t#include \n\t#include \n\tgl_Position.z = gl_Position.w;\n}",backgroundCube_frag:"#ifdef ENVMAP_TYPE_CUBE\n\tuniform samplerCube envMap;\n#elif defined( ENVMAP_TYPE_CUBE_UV )\n\tuniform sampler2D envMap;\n#endif\nuniform float flipEnvMap;\nuniform float backgroundBlurriness;\nuniform float backgroundIntensity;\nuniform mat3 backgroundRotation;\nvarying vec3 vWorldDirection;\n#include \nvoid main() {\n\t#ifdef ENVMAP_TYPE_CUBE\n\t\tvec4 texColor = textureCube( envMap, backgroundRotation * vec3( flipEnvMap * vWorldDirection.x, vWorldDirection.yz ) );\n\t#elif defined( ENVMAP_TYPE_CUBE_UV )\n\t\tvec4 texColor = textureCubeUV( envMap, backgroundRotation * vWorldDirection, backgroundBlurriness );\n\t#else\n\t\tvec4 texColor = vec4( 0.0, 0.0, 0.0, 1.0 );\n\t#endif\n\ttexColor.rgb *= backgroundIntensity;\n\tgl_FragColor = texColor;\n\t#include \n\t#include \n}",cube_vert:"varying vec3 vWorldDirection;\n#include \nvoid main() {\n\tvWorldDirection = transformDirection( position, modelMatrix );\n\t#include \n\t#include \n\tgl_Position.z = gl_Position.w;\n}",cube_frag:"uniform samplerCube tCube;\nuniform float tFlip;\nuniform float opacity;\nvarying vec3 vWorldDirection;\nvoid main() {\n\tvec4 texColor = textureCube( tCube, vec3( tFlip * vWorldDirection.x, vWorldDirection.yz ) );\n\tgl_FragColor = texColor;\n\tgl_FragColor.a *= opacity;\n\t#include \n\t#include \n}",depth_vert:"#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvarying vec2 vHighPrecisionZW;\nvoid main() {\n\t#include \n\t#include \n\t#include \n\t#include \n\t#ifdef USE_DISPLACEMENTMAP\n\t\t#include \n\t\t#include \n\t\t#include \n\t#endif\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tvHighPrecisionZW = gl_Position.zw;\n}",depth_frag:"#if DEPTH_PACKING == 3200\n\tuniform float opacity;\n#endif\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvarying vec2 vHighPrecisionZW;\nvoid main() {\n\tvec4 diffuseColor = vec4( 1.0 );\n\t#include \n\t#if DEPTH_PACKING == 3200\n\t\tdiffuseColor.a = opacity;\n\t#endif\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tfloat fragCoordZ = 0.5 * vHighPrecisionZW[0] / vHighPrecisionZW[1] + 0.5;\n\t#if DEPTH_PACKING == 3200\n\t\tgl_FragColor = vec4( vec3( 1.0 - fragCoordZ ), opacity );\n\t#elif DEPTH_PACKING == 3201\n\t\tgl_FragColor = packDepthToRGBA( fragCoordZ );\n\t#elif DEPTH_PACKING == 3202\n\t\tgl_FragColor = vec4( packDepthToRGB( fragCoordZ ), 1.0 );\n\t#elif DEPTH_PACKING == 3203\n\t\tgl_FragColor = vec4( packDepthToRG( fragCoordZ ), 0.0, 1.0 );\n\t#endif\n}",distanceRGBA_vert:"#define DISTANCE\nvarying vec3 vWorldPosition;\n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\t#include \n\t#include \n\t#include \n\t#ifdef USE_DISPLACEMENTMAP\n\t\t#include \n\t\t#include \n\t\t#include \n\t#endif\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tvWorldPosition = worldPosition.xyz;\n}",distanceRGBA_frag:"#define DISTANCE\nuniform vec3 referencePosition;\nuniform float nearDistance;\nuniform float farDistance;\nvarying vec3 vWorldPosition;\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main () {\n\tvec4 diffuseColor = vec4( 1.0 );\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tfloat dist = length( vWorldPosition - referencePosition );\n\tdist = ( dist - nearDistance ) / ( farDistance - nearDistance );\n\tdist = saturate( dist );\n\tgl_FragColor = packDepthToRGBA( dist );\n}",equirect_vert:"varying vec3 vWorldDirection;\n#include \nvoid main() {\n\tvWorldDirection = transformDirection( position, modelMatrix );\n\t#include \n\t#include \n}",equirect_frag:"uniform sampler2D tEquirect;\nvarying vec3 vWorldDirection;\n#include \nvoid main() {\n\tvec3 direction = normalize( vWorldDirection );\n\tvec2 sampleUV = equirectUv( direction );\n\tgl_FragColor = texture2D( tEquirect, sampleUV );\n\t#include \n\t#include \n}",linedashed_vert:"uniform float scale;\nattribute float lineDistance;\nvarying float vLineDistance;\n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\tvLineDistance = scale * lineDistance;\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n}",linedashed_frag:"uniform vec3 diffuse;\nuniform float opacity;\nuniform float dashSize;\nuniform float totalSize;\nvarying float vLineDistance;\n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include \n\tif ( mod( vLineDistance, totalSize ) > dashSize ) {\n\t\tdiscard;\n\t}\n\tvec3 outgoingLight = vec3( 0.0 );\n\t#include \n\t#include \n\t#include \n\toutgoingLight = diffuseColor.rgb;\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n}",meshbasic_vert:"#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#if defined ( USE_ENVMAP ) || defined ( USE_SKINNING )\n\t\t#include \n\t\t#include \n\t\t#include \n\t\t#include \n\t\t#include \n\t#endif\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n}",meshbasic_frag:"uniform vec3 diffuse;\nuniform float opacity;\n#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n#endif\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n\t#ifdef USE_LIGHTMAP\n\t\tvec4 lightMapTexel = texture2D( lightMap, vLightMapUv );\n\t\treflectedLight.indirectDiffuse += lightMapTexel.rgb * lightMapIntensity * RECIPROCAL_PI;\n\t#else\n\t\treflectedLight.indirectDiffuse += vec3( 1.0 );\n\t#endif\n\t#include \n\treflectedLight.indirectDiffuse *= diffuseColor.rgb;\n\tvec3 outgoingLight = reflectedLight.indirectDiffuse;\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n}",meshlambert_vert:"#define LAMBERT\nvarying vec3 vViewPosition;\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tvViewPosition = - mvPosition.xyz;\n\t#include \n\t#include \n\t#include \n\t#include \n}",meshlambert_frag:"#define LAMBERT\nuniform vec3 diffuse;\nuniform vec3 emissive;\nuniform float opacity;\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include \n\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n\tvec3 totalEmissiveRadiance = emissive;\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tvec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + totalEmissiveRadiance;\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n}",meshmatcap_vert:"#define MATCAP\nvarying vec3 vViewPosition;\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tvViewPosition = - mvPosition.xyz;\n}",meshmatcap_frag:"#define MATCAP\nuniform vec3 diffuse;\nuniform float opacity;\nuniform sampler2D matcap;\nvarying vec3 vViewPosition;\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tvec3 viewDir = normalize( vViewPosition );\n\tvec3 x = normalize( vec3( viewDir.z, 0.0, - viewDir.x ) );\n\tvec3 y = cross( viewDir, x );\n\tvec2 uv = vec2( dot( x, normal ), dot( y, normal ) ) * 0.495 + 0.5;\n\t#ifdef USE_MATCAP\n\t\tvec4 matcapColor = texture2D( matcap, uv );\n\t#else\n\t\tvec4 matcapColor = vec4( vec3( mix( 0.2, 0.8, uv.y ) ), 1.0 );\n\t#endif\n\tvec3 outgoingLight = diffuseColor.rgb * matcapColor.rgb;\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n}",meshnormal_vert:"#define NORMAL\n#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE )\n\tvarying vec3 vViewPosition;\n#endif\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE )\n\tvViewPosition = - mvPosition.xyz;\n#endif\n}",meshnormal_frag:"#define NORMAL\nuniform float opacity;\n#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE )\n\tvarying vec3 vViewPosition;\n#endif\n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\tvec4 diffuseColor = vec4( 0.0, 0.0, 0.0, opacity );\n\t#include \n\t#include \n\t#include \n\t#include \n\tgl_FragColor = vec4( packNormalToRGB( normal ), diffuseColor.a );\n\t#ifdef OPAQUE\n\t\tgl_FragColor.a = 1.0;\n\t#endif\n}",meshphong_vert:"#define PHONG\nvarying vec3 vViewPosition;\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tvViewPosition = - mvPosition.xyz;\n\t#include \n\t#include \n\t#include \n\t#include \n}",meshphong_frag:"#define PHONG\nuniform vec3 diffuse;\nuniform vec3 emissive;\nuniform vec3 specular;\nuniform float shininess;\nuniform float opacity;\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include \n\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n\tvec3 totalEmissiveRadiance = emissive;\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tvec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + reflectedLight.directSpecular + reflectedLight.indirectSpecular + totalEmissiveRadiance;\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n}",meshphysical_vert:"#define STANDARD\nvarying vec3 vViewPosition;\n#ifdef USE_TRANSMISSION\n\tvarying vec3 vWorldPosition;\n#endif\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tvViewPosition = - mvPosition.xyz;\n\t#include \n\t#include \n\t#include \n#ifdef USE_TRANSMISSION\n\tvWorldPosition = worldPosition.xyz;\n#endif\n}",meshphysical_frag:"#define STANDARD\n#ifdef PHYSICAL\n\t#define IOR\n\t#define USE_SPECULAR\n#endif\nuniform vec3 diffuse;\nuniform vec3 emissive;\nuniform float roughness;\nuniform float metalness;\nuniform float opacity;\n#ifdef IOR\n\tuniform float ior;\n#endif\n#ifdef USE_SPECULAR\n\tuniform float specularIntensity;\n\tuniform vec3 specularColor;\n\t#ifdef USE_SPECULAR_COLORMAP\n\t\tuniform sampler2D specularColorMap;\n\t#endif\n\t#ifdef USE_SPECULAR_INTENSITYMAP\n\t\tuniform sampler2D specularIntensityMap;\n\t#endif\n#endif\n#ifdef USE_CLEARCOAT\n\tuniform float clearcoat;\n\tuniform float clearcoatRoughness;\n#endif\n#ifdef USE_DISPERSION\n\tuniform float dispersion;\n#endif\n#ifdef USE_IRIDESCENCE\n\tuniform float iridescence;\n\tuniform float iridescenceIOR;\n\tuniform float iridescenceThicknessMinimum;\n\tuniform float iridescenceThicknessMaximum;\n#endif\n#ifdef USE_SHEEN\n\tuniform vec3 sheenColor;\n\tuniform float sheenRoughness;\n\t#ifdef USE_SHEEN_COLORMAP\n\t\tuniform sampler2D sheenColorMap;\n\t#endif\n\t#ifdef USE_SHEEN_ROUGHNESSMAP\n\t\tuniform sampler2D sheenRoughnessMap;\n\t#endif\n#endif\n#ifdef USE_ANISOTROPY\n\tuniform vec2 anisotropyVector;\n\t#ifdef USE_ANISOTROPYMAP\n\t\tuniform sampler2D anisotropyMap;\n\t#endif\n#endif\nvarying vec3 vViewPosition;\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include \n\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n\tvec3 totalEmissiveRadiance = emissive;\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tvec3 totalDiffuse = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse;\n\tvec3 totalSpecular = reflectedLight.directSpecular + reflectedLight.indirectSpecular;\n\t#include \n\tvec3 outgoingLight = totalDiffuse + totalSpecular + totalEmissiveRadiance;\n\t#ifdef USE_SHEEN\n\t\tfloat sheenEnergyComp = 1.0 - 0.157 * max3( material.sheenColor );\n\t\toutgoingLight = outgoingLight * sheenEnergyComp + sheenSpecularDirect + sheenSpecularIndirect;\n\t#endif\n\t#ifdef USE_CLEARCOAT\n\t\tfloat dotNVcc = saturate( dot( geometryClearcoatNormal, geometryViewDir ) );\n\t\tvec3 Fcc = F_Schlick( material.clearcoatF0, material.clearcoatF90, dotNVcc );\n\t\toutgoingLight = outgoingLight * ( 1.0 - material.clearcoat * Fcc ) + ( clearcoatSpecularDirect + clearcoatSpecularIndirect ) * material.clearcoat;\n\t#endif\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n}",meshtoon_vert:"#define TOON\nvarying vec3 vViewPosition;\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tvViewPosition = - mvPosition.xyz;\n\t#include \n\t#include \n\t#include \n}",meshtoon_frag:"#define TOON\nuniform vec3 diffuse;\nuniform vec3 emissive;\nuniform float opacity;\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include \n\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n\tvec3 totalEmissiveRadiance = emissive;\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tvec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + totalEmissiveRadiance;\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n}",points_vert:"uniform float size;\nuniform float scale;\n#include \n#include \n#include \n#include \n#include \n#include \n#ifdef USE_POINTS_UV\n\tvarying vec2 vUv;\n\tuniform mat3 uvTransform;\n#endif\nvoid main() {\n\t#ifdef USE_POINTS_UV\n\t\tvUv = ( uvTransform * vec3( uv, 1 ) ).xy;\n\t#endif\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tgl_PointSize = size;\n\t#ifdef USE_SIZEATTENUATION\n\t\tbool isPerspective = isPerspectiveMatrix( projectionMatrix );\n\t\tif ( isPerspective ) gl_PointSize *= ( scale / - mvPosition.z );\n\t#endif\n\t#include \n\t#include \n\t#include \n\t#include \n}",points_frag:"uniform vec3 diffuse;\nuniform float opacity;\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include \n\tvec3 outgoingLight = vec3( 0.0 );\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\toutgoingLight = diffuseColor.rgb;\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n}",shadow_vert:"#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n}",shadow_frag:"uniform vec3 color;\nuniform float opacity;\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\tgl_FragColor = vec4( color, opacity * ( 1.0 - getShadowMask() ) );\n\t#include \n\t#include \n\t#include \n}",sprite_vert:"uniform float rotation;\nuniform vec2 center;\n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\tvec4 mvPosition = modelViewMatrix[ 3 ];\n\tvec2 scale = vec2( length( modelMatrix[ 0 ].xyz ), length( modelMatrix[ 1 ].xyz ) );\n\t#ifndef USE_SIZEATTENUATION\n\t\tbool isPerspective = isPerspectiveMatrix( projectionMatrix );\n\t\tif ( isPerspective ) scale *= - mvPosition.z;\n\t#endif\n\tvec2 alignedPosition = ( position.xy - ( center - vec2( 0.5 ) ) ) * scale;\n\tvec2 rotatedPosition;\n\trotatedPosition.x = cos( rotation ) * alignedPosition.x - sin( rotation ) * alignedPosition.y;\n\trotatedPosition.y = sin( rotation ) * alignedPosition.x + cos( rotation ) * alignedPosition.y;\n\tmvPosition.xy += rotatedPosition;\n\tgl_Position = projectionMatrix * mvPosition;\n\t#include \n\t#include \n\t#include \n}",sprite_frag:"uniform vec3 diffuse;\nuniform float opacity;\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include \n\tvec3 outgoingLight = vec3( 0.0 );\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\toutgoingLight = diffuseColor.rgb;\n\t#include \n\t#include \n\t#include \n\t#include \n}"},$o={common:{diffuse:{value:new fi(16777215)},opacity:{value:1},map:{value:null},mapTransform:{value:new xt},alphaMap:{value:null},alphaMapTransform:{value:new xt},alphaTest:{value:0}},specularmap:{specularMap:{value:null},specularMapTransform:{value:new xt}},envmap:{envMap:{value:null},envMapRotation:{value:new xt},flipEnvMap:{value:-1},reflectivity:{value:1},ior:{value:1.5},refractionRatio:{value:.98}},aomap:{aoMap:{value:null},aoMapIntensity:{value:1},aoMapTransform:{value:new xt}},lightmap:{lightMap:{value:null},lightMapIntensity:{value:1},lightMapTransform:{value:new xt}},bumpmap:{bumpMap:{value:null},bumpMapTransform:{value:new xt},bumpScale:{value:1}},normalmap:{normalMap:{value:null},normalMapTransform:{value:new xt},normalScale:{value:new _t(1,1)}},displacementmap:{displacementMap:{value:null},displacementMapTransform:{value:new xt},displacementScale:{value:1},displacementBias:{value:0}},emissivemap:{emissiveMap:{value:null},emissiveMapTransform:{value:new xt}},metalnessmap:{metalnessMap:{value:null},metalnessMapTransform:{value:new xt}},roughnessmap:{roughnessMap:{value:null},roughnessMapTransform:{value:new xt}},gradientmap:{gradientMap:{value:null}},fog:{fogDensity:{value:25e-5},fogNear:{value:1},fogFar:{value:2e3},fogColor:{value:new fi(16777215)}},lights:{ambientLightColor:{value:[]},lightProbe:{value:[]},directionalLights:{value:[],properties:{direction:{},color:{}}},directionalLightShadows:{value:[],properties:{shadowIntensity:1,shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{}}},directionalShadowMap:{value:[]},directionalShadowMatrix:{value:[]},spotLights:{value:[],properties:{color:{},position:{},direction:{},distance:{},coneCos:{},penumbraCos:{},decay:{}}},spotLightShadows:{value:[],properties:{shadowIntensity:1,shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{}}},spotLightMap:{value:[]},spotShadowMap:{value:[]},spotLightMatrix:{value:[]},pointLights:{value:[],properties:{color:{},position:{},decay:{},distance:{}}},pointLightShadows:{value:[],properties:{shadowIntensity:1,shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{},shadowCameraNear:{},shadowCameraFar:{}}},pointShadowMap:{value:[]},pointShadowMatrix:{value:[]},hemisphereLights:{value:[],properties:{direction:{},skyColor:{},groundColor:{}}},rectAreaLights:{value:[],properties:{color:{},position:{},width:{},height:{}}},ltc_1:{value:null},ltc_2:{value:null}},points:{diffuse:{value:new fi(16777215)},opacity:{value:1},size:{value:1},scale:{value:1},map:{value:null},alphaMap:{value:null},alphaMapTransform:{value:new xt},alphaTest:{value:0},uvTransform:{value:new xt}},sprite:{diffuse:{value:new fi(16777215)},opacity:{value:1},center:{value:new _t(.5,.5)},rotation:{value:0},map:{value:null},mapTransform:{value:new xt},alphaMap:{value:null},alphaMapTransform:{value:new xt},alphaTest:{value:0}}},el={basic:{uniforms:Ji([$o.common,$o.specularmap,$o.envmap,$o.aomap,$o.lightmap,$o.fog]),vertexShader:Qo.meshbasic_vert,fragmentShader:Qo.meshbasic_frag},lambert:{uniforms:Ji([$o.common,$o.specularmap,$o.envmap,$o.aomap,$o.lightmap,$o.emissivemap,$o.bumpmap,$o.normalmap,$o.displacementmap,$o.fog,$o.lights,{emissive:{value:new fi(0)}}]),vertexShader:Qo.meshlambert_vert,fragmentShader:Qo.meshlambert_frag},phong:{uniforms:Ji([$o.common,$o.specularmap,$o.envmap,$o.aomap,$o.lightmap,$o.emissivemap,$o.bumpmap,$o.normalmap,$o.displacementmap,$o.fog,$o.lights,{emissive:{value:new fi(0)},specular:{value:new fi(1118481)},shininess:{value:30}}]),vertexShader:Qo.meshphong_vert,fragmentShader:Qo.meshphong_frag},standard:{uniforms:Ji([$o.common,$o.envmap,$o.aomap,$o.lightmap,$o.emissivemap,$o.bumpmap,$o.normalmap,$o.displacementmap,$o.roughnessmap,$o.metalnessmap,$o.fog,$o.lights,{emissive:{value:new fi(0)},roughness:{value:1},metalness:{value:0},envMapIntensity:{value:1}}]),vertexShader:Qo.meshphysical_vert,fragmentShader:Qo.meshphysical_frag},toon:{uniforms:Ji([$o.common,$o.aomap,$o.lightmap,$o.emissivemap,$o.bumpmap,$o.normalmap,$o.displacementmap,$o.gradientmap,$o.fog,$o.lights,{emissive:{value:new fi(0)}}]),vertexShader:Qo.meshtoon_vert,fragmentShader:Qo.meshtoon_frag},matcap:{uniforms:Ji([$o.common,$o.bumpmap,$o.normalmap,$o.displacementmap,$o.fog,{matcap:{value:null}}]),vertexShader:Qo.meshmatcap_vert,fragmentShader:Qo.meshmatcap_frag},points:{uniforms:Ji([$o.points,$o.fog]),vertexShader:Qo.points_vert,fragmentShader:Qo.points_frag},dashed:{uniforms:Ji([$o.common,$o.fog,{scale:{value:1},dashSize:{value:1},totalSize:{value:2}}]),vertexShader:Qo.linedashed_vert,fragmentShader:Qo.linedashed_frag},depth:{uniforms:Ji([$o.common,$o.displacementmap]),vertexShader:Qo.depth_vert,fragmentShader:Qo.depth_frag},normal:{uniforms:Ji([$o.common,$o.bumpmap,$o.normalmap,$o.displacementmap,{opacity:{value:1}}]),vertexShader:Qo.meshnormal_vert,fragmentShader:Qo.meshnormal_frag},sprite:{uniforms:Ji([$o.sprite,$o.fog]),vertexShader:Qo.sprite_vert,fragmentShader:Qo.sprite_frag},background:{uniforms:{uvTransform:{value:new xt},t2D:{value:null},backgroundIntensity:{value:1}},vertexShader:Qo.background_vert,fragmentShader:Qo.background_frag},backgroundCube:{uniforms:{envMap:{value:null},flipEnvMap:{value:-1},backgroundBlurriness:{value:0},backgroundIntensity:{value:1},backgroundRotation:{value:new xt}},vertexShader:Qo.backgroundCube_vert,fragmentShader:Qo.backgroundCube_frag},cube:{uniforms:{tCube:{value:null},tFlip:{value:-1},opacity:{value:1}},vertexShader:Qo.cube_vert,fragmentShader:Qo.cube_frag},equirect:{uniforms:{tEquirect:{value:null}},vertexShader:Qo.equirect_vert,fragmentShader:Qo.equirect_frag},distanceRGBA:{uniforms:Ji([$o.common,$o.displacementmap,{referencePosition:{value:new jt},nearDistance:{value:1},farDistance:{value:1e3}}]),vertexShader:Qo.distanceRGBA_vert,fragmentShader:Qo.distanceRGBA_frag},shadow:{uniforms:Ji([$o.lights,$o.fog,{color:{value:new fi(0)},opacity:{value:1}}]),vertexShader:Qo.shadow_vert,fragmentShader:Qo.shadow_frag}};el.physical={uniforms:Ji([el.standard.uniforms,{clearcoat:{value:0},clearcoatMap:{value:null},clearcoatMapTransform:{value:new xt},clearcoatNormalMap:{value:null},clearcoatNormalMapTransform:{value:new xt},clearcoatNormalScale:{value:new _t(1,1)},clearcoatRoughness:{value:0},clearcoatRoughnessMap:{value:null},clearcoatRoughnessMapTransform:{value:new xt},dispersion:{value:0},iridescence:{value:0},iridescenceMap:{value:null},iridescenceMapTransform:{value:new xt},iridescenceIOR:{value:1.3},iridescenceThicknessMinimum:{value:100},iridescenceThicknessMaximum:{value:400},iridescenceThicknessMap:{value:null},iridescenceThicknessMapTransform:{value:new xt},sheen:{value:0},sheenColor:{value:new fi(0)},sheenColorMap:{value:null},sheenColorMapTransform:{value:new xt},sheenRoughness:{value:1},sheenRoughnessMap:{value:null},sheenRoughnessMapTransform:{value:new xt},transmission:{value:0},transmissionMap:{value:null},transmissionMapTransform:{value:new xt},transmissionSamplerSize:{value:new _t},transmissionSamplerMap:{value:null},thickness:{value:0},thicknessMap:{value:null},thicknessMapTransform:{value:new xt},attenuationDistance:{value:0},attenuationColor:{value:new fi(0)},specularColor:{value:new fi(1,1,1)},specularColorMap:{value:null},specularColorMapTransform:{value:new xt},specularIntensity:{value:1},specularIntensityMap:{value:null},specularIntensityMapTransform:{value:new xt},anisotropyVector:{value:new _t},anisotropyMap:{value:null},anisotropyMapTransform:{value:new xt}}]),vertexShader:Qo.meshphysical_vert,fragmentShader:Qo.meshphysical_frag};const tl={r:0,b:0,g:0},nl=new Ln,il=new wn;function rl(e,t,n,i,r,a,s){const o=new fi(0);let l,c,h=!0===a?0:1,d=null,u=0,p=null;function f(e){let i=!0===e.isScene?e.background:null;return i&&i.isTexture&&(i=(e.backgroundBlurriness>0?n:t).get(i)),i}function m(t,n){t.getRGB(tl,Qi(e)),i.buffers.color.setClear(tl.r,tl.g,tl.b,n,s)}return{getClearColor:function(){return o},setClearColor:function(e,t=1){o.set(e),h=t,m(o,h)},getClearAlpha:function(){return h},setClearAlpha:function(e){h=e,m(o,h)},render:function(t){let n=!1;const r=f(t);null===r?m(o,h):r&&r.isColor&&(m(r,1),n=!0);const a=e.xr.getEnvironmentBlendMode();"additive"===a?i.buffers.color.setClear(0,0,0,1,s):"alpha-blend"===a&&i.buffers.color.setClear(0,0,0,0,s),(e.autoClear||n)&&(i.buffers.depth.setTest(!0),i.buffers.depth.setMask(!0),i.buffers.color.setMask(!0),e.clear(e.autoClearColor,e.autoClearDepth,e.autoClearStencil))},addToRenderList:function(t,n){const i=f(n);i&&(i.isCubeTexture||i.mapping===O)?(void 0===c&&(c=new Yi(new Zi(1,1,1),new er({name:"BackgroundCubeMaterial",uniforms:Ki(el.backgroundCube.uniforms),vertexShader:el.backgroundCube.vertexShader,fragmentShader:el.backgroundCube.fragmentShader,side:1,depthTest:!1,depthWrite:!1,fog:!1})),c.geometry.deleteAttribute("normal"),c.geometry.deleteAttribute("uv"),c.onBeforeRender=function(e,t,n){this.matrixWorld.copyPosition(n.matrixWorld)},Object.defineProperty(c.material,"envMap",{get:function(){return this.uniforms.envMap.value}}),r.update(c)),nl.copy(n.backgroundRotation),nl.x*=-1,nl.y*=-1,nl.z*=-1,i.isCubeTexture&&!1===i.isRenderTargetTexture&&(nl.y*=-1,nl.z*=-1),c.material.uniforms.envMap.value=i,c.material.uniforms.flipEnvMap.value=i.isCubeTexture&&!1===i.isRenderTargetTexture?-1:1,c.material.uniforms.backgroundBlurriness.value=n.backgroundBlurriness,c.material.uniforms.backgroundIntensity.value=n.backgroundIntensity,c.material.uniforms.backgroundRotation.value.setFromMatrix4(il.makeRotationFromEuler(nl)),c.material.toneMapped=Rt.getTransfer(i.colorSpace)!==Xe,d===i&&u===i.version&&p===e.toneMapping||(c.material.needsUpdate=!0,d=i,u=i.version,p=e.toneMapping),c.layers.enableAll(),t.unshift(c,c.geometry,c.material,0,0,null)):i&&i.isTexture&&(void 0===l&&(l=new Yi(new Da(2,2),new er({name:"BackgroundMaterial",uniforms:Ki(el.background.uniforms),vertexShader:el.background.vertexShader,fragmentShader:el.background.fragmentShader,side:0,depthTest:!1,depthWrite:!1,fog:!1})),l.geometry.deleteAttribute("normal"),Object.defineProperty(l.material,"map",{get:function(){return this.uniforms.t2D.value}}),r.update(l)),l.material.uniforms.t2D.value=i,l.material.uniforms.backgroundIntensity.value=n.backgroundIntensity,l.material.toneMapped=Rt.getTransfer(i.colorSpace)!==Xe,!0===i.matrixAutoUpdate&&i.updateMatrix(),l.material.uniforms.uvTransform.value.copy(i.matrix),d===i&&u===i.version&&p===e.toneMapping||(l.material.needsUpdate=!0,d=i,u=i.version,p=e.toneMapping),l.layers.enableAll(),t.unshift(l,l.geometry,l.material,0,0,null))},dispose:function(){void 0!==c&&(c.geometry.dispose(),c.material.dispose()),void 0!==l&&(l.geometry.dispose(),l.material.dispose())}}}function al(e,t){const n=e.getParameter(e.MAX_VERTEX_ATTRIBS),i={},r=c(null);let a=r,s=!1;function o(t){return e.bindVertexArray(t)}function l(t){return e.deleteVertexArray(t)}function c(e){const t=[],i=[],r=[];for(let e=0;e=0){const n=r[t];let i=s[t];if(void 0===i&&("instanceMatrix"===t&&e.instanceMatrix&&(i=e.instanceMatrix),"instanceColor"===t&&e.instanceColor&&(i=e.instanceColor)),void 0===n)return!0;if(n.attribute!==i)return!0;if(i&&n.data!==i.data)return!0;o++}return a.attributesNum!==o||a.index!==i}(n,m,l,g),v&&function(e,t,n,i){const r={},s=t.attributes;let o=0;const l=n.getAttributes();for(const t in l)if(l[t].location>=0){let n=s[t];void 0===n&&("instanceMatrix"===t&&e.instanceMatrix&&(n=e.instanceMatrix),"instanceColor"===t&&e.instanceColor&&(n=e.instanceColor));const i={};i.attribute=n,n&&n.data&&(i.data=n.data),r[t]=i,o++}a.attributes=r,a.attributesNum=o,a.index=i}(n,m,l,g),null!==g&&t.update(g,e.ELEMENT_ARRAY_BUFFER),(v||s)&&(s=!1,function(n,i,r,a){h();const s=a.attributes,o=r.getAttributes(),l=i.defaultAttributeValues;for(const i in o){const r=o[i];if(r.location>=0){let o=s[i];if(void 0===o&&("instanceMatrix"===i&&n.instanceMatrix&&(o=n.instanceMatrix),"instanceColor"===i&&n.instanceColor&&(o=n.instanceColor)),void 0!==o){const i=o.normalized,s=o.itemSize,l=t.get(o);if(void 0===l)continue;const c=l.buffer,h=l.type,p=l.bytesPerElement,m=h===e.INT||h===e.UNSIGNED_INT||o.gpuType===Y;if(o.isInterleavedBufferAttribute){const t=o.data,l=t.stride,g=o.offset;if(t.isInstancedInterleavedBuffer){for(let e=0;e0&&e.getShaderPrecisionFormat(e.FRAGMENT_SHADER,e.HIGH_FLOAT).precision>0)return"highp";t="mediump"}return"mediump"===t&&e.getShaderPrecisionFormat(e.VERTEX_SHADER,e.MEDIUM_FLOAT).precision>0&&e.getShaderPrecisionFormat(e.FRAGMENT_SHADER,e.MEDIUM_FLOAT).precision>0?"mediump":"lowp"}let s=void 0!==n.precision?n.precision:"highp";const o=a(s);o!==s&&(console.warn("THREE.WebGLRenderer:",s,"not supported, using",o,"instead."),s=o);const l=!0===n.logarithmicDepthBuffer,c=!0===n.reverseDepthBuffer&&t.has("EXT_clip_control"),h=e.getParameter(e.MAX_TEXTURE_IMAGE_UNITS),d=e.getParameter(e.MAX_VERTEX_TEXTURE_IMAGE_UNITS);return{isWebGL2:!0,getMaxAnisotropy:function(){if(void 0!==r)return r;if(!0===t.has("EXT_texture_filter_anisotropic")){const n=t.get("EXT_texture_filter_anisotropic");r=e.getParameter(n.MAX_TEXTURE_MAX_ANISOTROPY_EXT)}else r=0;return r},getMaxPrecision:a,textureFormatReadable:function(t){return t===ee||i.convert(t)===e.getParameter(e.IMPLEMENTATION_COLOR_READ_FORMAT)},textureTypeReadable:function(n){const r=n===K&&(t.has("EXT_color_buffer_half_float")||t.has("EXT_color_buffer_float"));return!(n!==j&&i.convert(n)!==e.getParameter(e.IMPLEMENTATION_COLOR_READ_TYPE)&&n!==Z&&!r)},precision:s,logarithmicDepthBuffer:l,reverseDepthBuffer:c,maxTextures:h,maxVertexTextures:d,maxTextureSize:e.getParameter(e.MAX_TEXTURE_SIZE),maxCubemapSize:e.getParameter(e.MAX_CUBE_MAP_TEXTURE_SIZE),maxAttributes:e.getParameter(e.MAX_VERTEX_ATTRIBS),maxVertexUniforms:e.getParameter(e.MAX_VERTEX_UNIFORM_VECTORS),maxVaryings:e.getParameter(e.MAX_VARYING_VECTORS),maxFragmentUniforms:e.getParameter(e.MAX_FRAGMENT_UNIFORM_VECTORS),vertexTextures:d>0,maxSamples:e.getParameter(e.MAX_SAMPLES)}}function ll(e){const t=this;let n=null,i=0,r=!1,a=!1;const s=new Hr,o=new xt,l={value:null,needsUpdate:!1};function c(e,n,i,r){const a=null!==e?e.length:0;let c=null;if(0!==a){if(c=l.value,!0!==r||null===c){const t=i+4*a,r=n.matrixWorldInverse;o.getNormalMatrix(r),(null===c||c.length0),t.numPlanes=i,t.numIntersection=0);else{const e=a?0:i,t=4*e;let r=f.clippingState||null;l.value=r,r=c(d,o,t,h);for(let e=0;e!==t;++e)r[e]=n[e];f.clippingState=r,this.numIntersection=u?this.numPlanes:0,this.numPlanes+=e}}}function cl(e){let t=new WeakMap;function n(e,t){return 303===t?e.mapping=I:304===t&&(e.mapping=U),e}function i(e){const n=e.target;n.removeEventListener("dispose",i);const r=t.get(n);void 0!==r&&(t.delete(n),r.dispose())}return{get:function(r){if(r&&r.isTexture){const a=r.mapping;if(303===a||304===a){if(t.has(r))return n(t.get(r).texture,r.mapping);{const a=r.image;if(a&&a.height>0){const s=new cr(a.height);return s.fromEquirectangularTexture(e,r),t.set(r,s),r.addEventListener("dispose",i),n(s.texture,r.mapping)}return null}}}return r},dispose:function(){t=new WeakMap}}}const hl=[.125,.215,.35,.446,.526,.582],dl=new Cs,ul=new fi;let pl=null,fl=0,ml=0,gl=!1;const vl=(1+Math.sqrt(5))/2,_l=1/vl,xl=[new jt(-vl,_l,0),new jt(vl,_l,0),new jt(-_l,0,vl),new jt(_l,0,vl),new jt(0,vl,-_l),new jt(0,vl,_l),new jt(-1,1,-1),new jt(1,1,-1),new jt(-1,1,1),new jt(1,1,1)];class yl{constructor(e){this._renderer=e,this._pingPongRenderTarget=null,this._lodMax=0,this._cubeSize=0,this._lodPlanes=[],this._sizeLods=[],this._sigmas=[],this._blurMaterial=null,this._cubemapMaterial=null,this._equirectMaterial=null,this._compileMaterial(this._blurMaterial)}fromScene(e,t=0,n=.1,i=100){pl=this._renderer.getRenderTarget(),fl=this._renderer.getActiveCubeFace(),ml=this._renderer.getActiveMipmapLevel(),gl=this._renderer.xr.enabled,this._renderer.xr.enabled=!1,this._setSize(256);const r=this._allocateTargets();return r.depthBuffer=!0,this._sceneToCubeUV(e,n,i,r),t>0&&this._blur(r,0,0,t),this._applyPMREM(r),this._cleanup(r),r}fromEquirectangular(e,t=null){return this._fromTexture(e,t)}fromCubemap(e,t=null){return this._fromTexture(e,t)}compileCubemapShader(){null===this._cubemapMaterial&&(this._cubemapMaterial=Ml(),this._compileMaterial(this._cubemapMaterial))}compileEquirectangularShader(){null===this._equirectMaterial&&(this._equirectMaterial=bl(),this._compileMaterial(this._equirectMaterial))}dispose(){this._dispose(),null!==this._cubemapMaterial&&this._cubemapMaterial.dispose(),null!==this._equirectMaterial&&this._equirectMaterial.dispose()}_setSize(e){this._lodMax=Math.floor(Math.log2(e)),this._cubeSize=Math.pow(2,this._lodMax)}_dispose(){null!==this._blurMaterial&&this._blurMaterial.dispose(),null!==this._pingPongRenderTarget&&this._pingPongRenderTarget.dispose();for(let e=0;ee-4?o=hl[s-e+4-1]:0===s&&(o=0),i.push(o);const l=1/(a-2),c=-l,h=1+l,d=[c,c,h,c,h,h,c,c,h,h,c,h],u=6,p=6,f=3,m=2,g=1,v=new Float32Array(f*p*u),_=new Float32Array(m*p*u),x=new Float32Array(g*p*u);for(let e=0;e2?0:-1,i=[t,n,0,t+2/3,n,0,t+2/3,n+1,0,t,n,0,t+2/3,n+1,0,t,n+1,0];v.set(i,f*p*e),_.set(d,m*p*e);const r=[e,e,e,e,e,e];x.set(r,g*p*e)}const y=new Oi;y.setAttribute("position",new Mi(v,f)),y.setAttribute("uv",new Mi(_,m)),y.setAttribute("faceIndex",new Mi(x,g)),t.push(y),r>4&&r--}return{lodPlanes:t,sizeLods:n,sigmas:i}}(i)),this._blurMaterial=function(e,t,n){const i=new Float32Array(20),r=new jt(0,1,0);return new er({name:"SphericalGaussianBlur",defines:{n:20,CUBEUV_TEXEL_WIDTH:1/t,CUBEUV_TEXEL_HEIGHT:1/n,CUBEUV_MAX_MIP:`${e}.0`},uniforms:{envMap:{value:null},samples:{value:1},weights:{value:i},latitudinal:{value:!1},dTheta:{value:0},mipInt:{value:0},poleAxis:{value:r}},vertexShader:"\n\n\t\tprecision mediump float;\n\t\tprecision mediump int;\n\n\t\tattribute float faceIndex;\n\n\t\tvarying vec3 vOutputDirection;\n\n\t\t// RH coordinate system; PMREM face-indexing convention\n\t\tvec3 getDirection( vec2 uv, float face ) {\n\n\t\t\tuv = 2.0 * uv - 1.0;\n\n\t\t\tvec3 direction = vec3( uv, 1.0 );\n\n\t\t\tif ( face == 0.0 ) {\n\n\t\t\t\tdirection = direction.zyx; // ( 1, v, u ) pos x\n\n\t\t\t} else if ( face == 1.0 ) {\n\n\t\t\t\tdirection = direction.xzy;\n\t\t\t\tdirection.xz *= -1.0; // ( -u, 1, -v ) pos y\n\n\t\t\t} else if ( face == 2.0 ) {\n\n\t\t\t\tdirection.x *= -1.0; // ( -u, v, 1 ) pos z\n\n\t\t\t} else if ( face == 3.0 ) {\n\n\t\t\t\tdirection = direction.zyx;\n\t\t\t\tdirection.xz *= -1.0; // ( -1, v, -u ) neg x\n\n\t\t\t} else if ( face == 4.0 ) {\n\n\t\t\t\tdirection = direction.xzy;\n\t\t\t\tdirection.xy *= -1.0; // ( -u, -1, v ) neg y\n\n\t\t\t} else if ( face == 5.0 ) {\n\n\t\t\t\tdirection.z *= -1.0; // ( u, v, -1 ) neg z\n\n\t\t\t}\n\n\t\t\treturn direction;\n\n\t\t}\n\n\t\tvoid main() {\n\n\t\t\tvOutputDirection = getDirection( uv, faceIndex );\n\t\t\tgl_Position = vec4( position, 1.0 );\n\n\t\t}\n\t",fragmentShader:"\n\n\t\t\tprecision mediump float;\n\t\t\tprecision mediump int;\n\n\t\t\tvarying vec3 vOutputDirection;\n\n\t\t\tuniform sampler2D envMap;\n\t\t\tuniform int samples;\n\t\t\tuniform float weights[ n ];\n\t\t\tuniform bool latitudinal;\n\t\t\tuniform float dTheta;\n\t\t\tuniform float mipInt;\n\t\t\tuniform vec3 poleAxis;\n\n\t\t\t#define ENVMAP_TYPE_CUBE_UV\n\t\t\t#include \n\n\t\t\tvec3 getSample( float theta, vec3 axis ) {\n\n\t\t\t\tfloat cosTheta = cos( theta );\n\t\t\t\t// Rodrigues' axis-angle rotation\n\t\t\t\tvec3 sampleDirection = vOutputDirection * cosTheta\n\t\t\t\t\t+ cross( axis, vOutputDirection ) * sin( theta )\n\t\t\t\t\t+ axis * dot( axis, vOutputDirection ) * ( 1.0 - cosTheta );\n\n\t\t\t\treturn bilinearCubeUV( envMap, sampleDirection, mipInt );\n\n\t\t\t}\n\n\t\t\tvoid main() {\n\n\t\t\t\tvec3 axis = latitudinal ? poleAxis : cross( poleAxis, vOutputDirection );\n\n\t\t\t\tif ( all( equal( axis, vec3( 0.0 ) ) ) ) {\n\n\t\t\t\t\taxis = vec3( vOutputDirection.z, 0.0, - vOutputDirection.x );\n\n\t\t\t\t}\n\n\t\t\t\taxis = normalize( axis );\n\n\t\t\t\tgl_FragColor = vec4( 0.0, 0.0, 0.0, 1.0 );\n\t\t\t\tgl_FragColor.rgb += weights[ 0 ] * getSample( 0.0, axis );\n\n\t\t\t\tfor ( int i = 1; i < n; i++ ) {\n\n\t\t\t\t\tif ( i >= samples ) {\n\n\t\t\t\t\t\tbreak;\n\n\t\t\t\t\t}\n\n\t\t\t\t\tfloat theta = dTheta * float( i );\n\t\t\t\t\tgl_FragColor.rgb += weights[ i ] * getSample( -1.0 * theta, axis );\n\t\t\t\t\tgl_FragColor.rgb += weights[ i ] * getSample( theta, axis );\n\n\t\t\t\t}\n\n\t\t\t}\n\t\t",blending:0,depthTest:!1,depthWrite:!1})}(i,e,t)}return i}_compileMaterial(e){const t=new Yi(this._lodPlanes[0],e);this._renderer.compile(t,dl)}_sceneToCubeUV(e,t,n,i){const r=new ar(90,1,t,n),a=[1,-1,1,1,1,1],s=[1,1,1,-1,-1,-1],o=this._renderer,l=o.autoClear,c=o.toneMapping;o.getClearColor(ul),o.toneMapping=0,o.autoClear=!1;const h=new _i({name:"PMREM.Background",side:1,depthWrite:!1,depthTest:!1}),d=new Yi(new Zi,h);let u=!1;const p=e.background;p?p.isColor&&(h.color.copy(p),e.background=null,u=!0):(h.color.copy(ul),u=!0);for(let t=0;t<6;t++){const n=t%3;0===n?(r.up.set(0,a[t],0),r.lookAt(s[t],0,0)):1===n?(r.up.set(0,0,a[t]),r.lookAt(0,s[t],0)):(r.up.set(0,a[t],0),r.lookAt(0,0,s[t]));const l=this._cubeSize;wl(i,n*l,t>2?l:0,l,l),o.setRenderTarget(i),u&&o.render(d,r),o.render(e,r)}d.geometry.dispose(),d.material.dispose(),o.toneMapping=c,o.autoClear=l,e.background=p}_textureToCubeUV(e,t){const n=this._renderer,i=e.mapping===I||e.mapping===U;i?(null===this._cubemapMaterial&&(this._cubemapMaterial=Ml()),this._cubemapMaterial.uniforms.flipEnvMap.value=!1===e.isRenderTargetTexture?-1:1):null===this._equirectMaterial&&(this._equirectMaterial=bl());const r=i?this._cubemapMaterial:this._equirectMaterial,a=new Yi(this._lodPlanes[0],r);r.uniforms.envMap.value=e;const s=this._cubeSize;wl(t,0,0,3*s,2*s),n.setRenderTarget(t),n.render(a,dl)}_applyPMREM(e){const t=this._renderer,n=t.autoClear;t.autoClear=!1;const i=this._lodPlanes.length;for(let t=1;t20&&console.warn(`sigmaRadians, ${r}, is too large and will clip, as it requested ${f} samples when the maximum is set to 20`);const m=[];let g=0;for(let e=0;e<20;++e){const t=e/p,n=Math.exp(-t*t/2);m.push(n),0===e?g+=n:ev-4?i-v+4:0),4*(this._cubeSize-_),3*_,2*_),o.setRenderTarget(t),o.render(c,dl)}}function Sl(e,t,n){const i=new Ht(e,t,n);return i.texture.mapping=O,i.texture.name="PMREM.cubeUv",i.scissorTest=!0,i}function wl(e,t,n,i,r){e.viewport.set(t,n,i,r),e.scissor.set(t,n,i,r)}function bl(){return new er({name:"EquirectangularToCubeUV",uniforms:{envMap:{value:null}},vertexShader:"\n\n\t\tprecision mediump float;\n\t\tprecision mediump int;\n\n\t\tattribute float faceIndex;\n\n\t\tvarying vec3 vOutputDirection;\n\n\t\t// RH coordinate system; PMREM face-indexing convention\n\t\tvec3 getDirection( vec2 uv, float face ) {\n\n\t\t\tuv = 2.0 * uv - 1.0;\n\n\t\t\tvec3 direction = vec3( uv, 1.0 );\n\n\t\t\tif ( face == 0.0 ) {\n\n\t\t\t\tdirection = direction.zyx; // ( 1, v, u ) pos x\n\n\t\t\t} else if ( face == 1.0 ) {\n\n\t\t\t\tdirection = direction.xzy;\n\t\t\t\tdirection.xz *= -1.0; // ( -u, 1, -v ) pos y\n\n\t\t\t} else if ( face == 2.0 ) {\n\n\t\t\t\tdirection.x *= -1.0; // ( -u, v, 1 ) pos z\n\n\t\t\t} else if ( face == 3.0 ) {\n\n\t\t\t\tdirection = direction.zyx;\n\t\t\t\tdirection.xz *= -1.0; // ( -1, v, -u ) neg x\n\n\t\t\t} else if ( face == 4.0 ) {\n\n\t\t\t\tdirection = direction.xzy;\n\t\t\t\tdirection.xy *= -1.0; // ( -u, -1, v ) neg y\n\n\t\t\t} else if ( face == 5.0 ) {\n\n\t\t\t\tdirection.z *= -1.0; // ( u, v, -1 ) neg z\n\n\t\t\t}\n\n\t\t\treturn direction;\n\n\t\t}\n\n\t\tvoid main() {\n\n\t\t\tvOutputDirection = getDirection( uv, faceIndex );\n\t\t\tgl_Position = vec4( position, 1.0 );\n\n\t\t}\n\t",fragmentShader:"\n\n\t\t\tprecision mediump float;\n\t\t\tprecision mediump int;\n\n\t\t\tvarying vec3 vOutputDirection;\n\n\t\t\tuniform sampler2D envMap;\n\n\t\t\t#include \n\n\t\t\tvoid main() {\n\n\t\t\t\tvec3 outputDirection = normalize( vOutputDirection );\n\t\t\t\tvec2 uv = equirectUv( outputDirection );\n\n\t\t\t\tgl_FragColor = vec4( texture2D ( envMap, uv ).rgb, 1.0 );\n\n\t\t\t}\n\t\t",blending:0,depthTest:!1,depthWrite:!1})}function Ml(){return new er({name:"CubemapToCubeUV",uniforms:{envMap:{value:null},flipEnvMap:{value:-1}},vertexShader:"\n\n\t\tprecision mediump float;\n\t\tprecision mediump int;\n\n\t\tattribute float faceIndex;\n\n\t\tvarying vec3 vOutputDirection;\n\n\t\t// RH coordinate system; PMREM face-indexing convention\n\t\tvec3 getDirection( vec2 uv, float face ) {\n\n\t\t\tuv = 2.0 * uv - 1.0;\n\n\t\t\tvec3 direction = vec3( uv, 1.0 );\n\n\t\t\tif ( face == 0.0 ) {\n\n\t\t\t\tdirection = direction.zyx; // ( 1, v, u ) pos x\n\n\t\t\t} else if ( face == 1.0 ) {\n\n\t\t\t\tdirection = direction.xzy;\n\t\t\t\tdirection.xz *= -1.0; // ( -u, 1, -v ) pos y\n\n\t\t\t} else if ( face == 2.0 ) {\n\n\t\t\t\tdirection.x *= -1.0; // ( -u, v, 1 ) pos z\n\n\t\t\t} else if ( face == 3.0 ) {\n\n\t\t\t\tdirection = direction.zyx;\n\t\t\t\tdirection.xz *= -1.0; // ( -1, v, -u ) neg x\n\n\t\t\t} else if ( face == 4.0 ) {\n\n\t\t\t\tdirection = direction.xzy;\n\t\t\t\tdirection.xy *= -1.0; // ( -u, -1, v ) neg y\n\n\t\t\t} else if ( face == 5.0 ) {\n\n\t\t\t\tdirection.z *= -1.0; // ( u, v, -1 ) neg z\n\n\t\t\t}\n\n\t\t\treturn direction;\n\n\t\t}\n\n\t\tvoid main() {\n\n\t\t\tvOutputDirection = getDirection( uv, faceIndex );\n\t\t\tgl_Position = vec4( position, 1.0 );\n\n\t\t}\n\t",fragmentShader:"\n\n\t\t\tprecision mediump float;\n\t\t\tprecision mediump int;\n\n\t\t\tuniform float flipEnvMap;\n\n\t\t\tvarying vec3 vOutputDirection;\n\n\t\t\tuniform samplerCube envMap;\n\n\t\t\tvoid main() {\n\n\t\t\t\tgl_FragColor = textureCube( envMap, vec3( flipEnvMap * vOutputDirection.x, vOutputDirection.yz ) );\n\n\t\t\t}\n\t\t",blending:0,depthTest:!1,depthWrite:!1})}function Tl(e){let t=new WeakMap,n=null;function i(e){const n=e.target;n.removeEventListener("dispose",i);const r=t.get(n);void 0!==r&&(t.delete(n),r.dispose())}return{get:function(r){if(r&&r.isTexture){const a=r.mapping,s=303===a||304===a,o=a===I||a===U;if(s||o){let a=t.get(r);const l=void 0!==a?a.texture.pmremVersion:0;if(r.isRenderTargetTexture&&r.pmremVersion!==l)return null===n&&(n=new yl(e)),a=s?n.fromEquirectangular(r,a):n.fromCubemap(r,a),a.texture.pmremVersion=r.pmremVersion,t.set(r,a),a.texture;if(void 0!==a)return a.texture;{const l=r.image;return s&&l&&l.height>0||o&&l&&function(e){let t=0;for(let n=0;n<6;n++)void 0!==e[n]&&t++;return 6===t}(l)?(null===n&&(n=new yl(e)),a=s?n.fromEquirectangular(r):n.fromCubemap(r),a.texture.pmremVersion=r.pmremVersion,t.set(r,a),r.addEventListener("dispose",i),a.texture):null}}}return r},dispose:function(){t=new WeakMap,null!==n&&(n.dispose(),n=null)}}}function El(e){const t={};function n(n){if(void 0!==t[n])return t[n];let i;switch(n){case"WEBGL_depth_texture":i=e.getExtension("WEBGL_depth_texture")||e.getExtension("MOZ_WEBGL_depth_texture")||e.getExtension("WEBKIT_WEBGL_depth_texture");break;case"EXT_texture_filter_anisotropic":i=e.getExtension("EXT_texture_filter_anisotropic")||e.getExtension("MOZ_EXT_texture_filter_anisotropic")||e.getExtension("WEBKIT_EXT_texture_filter_anisotropic");break;case"WEBGL_compressed_texture_s3tc":i=e.getExtension("WEBGL_compressed_texture_s3tc")||e.getExtension("MOZ_WEBGL_compressed_texture_s3tc")||e.getExtension("WEBKIT_WEBGL_compressed_texture_s3tc");break;case"WEBGL_compressed_texture_pvrtc":i=e.getExtension("WEBGL_compressed_texture_pvrtc")||e.getExtension("WEBKIT_WEBGL_compressed_texture_pvrtc");break;default:i=e.getExtension(n)}return t[n]=i,i}return{has:function(e){return null!==n(e)},init:function(){n("EXT_color_buffer_float"),n("WEBGL_clip_cull_distance"),n("OES_texture_float_linear"),n("EXT_color_buffer_half_float"),n("WEBGL_multisampled_render_to_texture"),n("WEBGL_render_shared_exponent")},get:function(e){const t=n(e);return null===t&&Tt("THREE.WebGLRenderer: "+e+" extension not supported."),t}}}function Al(e,t,n,i){const r={},a=new WeakMap;function s(e){const o=e.target;null!==o.index&&t.remove(o.index);for(const e in o.attributes)t.remove(o.attributes[e]);o.removeEventListener("dispose",s),delete r[o.id];const l=a.get(o);l&&(t.remove(l),a.delete(o)),i.releaseStatesOfGeometry(o),!0===o.isInstancedBufferGeometry&&delete o._maxInstanceCount,n.memory.geometries--}function o(e){const n=[],i=e.index,r=e.attributes.position;let s=0;if(null!==i){const e=i.array;s=i.version;for(let t=0,i=e.length;tt.maxTextureSize&&(y=Math.ceil(x/t.maxTextureSize),x=t.maxTextureSize);const S=new Float32Array(x*y*4*h),w=new Vt(S,x,y,h);w.type=Z,w.needsUpdate=!0;const b=4*_;for(let T=0;T0)return e;const r=t*n;let a=Fl[r];if(void 0===a&&(a=new Float32Array(r),Fl[r]=a),0!==t){i.toArray(a,0);for(let i=1,r=0;i!==t;++i)r+=n,e[i].toArray(a,r)}return a}function Gl(e,t){if(e.length!==t.length)return!1;for(let n=0,i=e.length;n":" "} ${r}: ${n[e]}`)}return i.join("\n")}(e.getShaderSource(t),i)}return r}function Hc(e,t){const n=function(e){Rt._getMatrix(zc,Rt.workingColorSpace,e);const t=`mat3( ${zc.elements.map((e=>e.toFixed(4)))} )`;switch(Rt.getTransfer(e)){case je:return[t,"LinearTransferOETF"];case Xe:return[t,"sRGBTransferOETF"];default:return console.warn("THREE.WebGLProgram: Unsupported color space: ",e),[t,"LinearTransferOETF"]}}(t);return[`vec4 ${e}( vec4 value ) {`,`\treturn ${n[1]}( vec4( value.rgb * ${n[0]}, value.a ) );`,"}"].join("\n")}function Vc(e,t){let n;switch(t){case 1:n="Linear";break;case 2:n="Reinhard";break;case 3:n="Cineon";break;case 4:n="ACESFilmic";break;case 6:n="AgX";break;case 7:n="Neutral";break;case 5:n="Custom";break;default:console.warn("THREE.WebGLProgram: Unsupported toneMapping:",t),n="Linear"}return"vec3 "+e+"( vec3 color ) { return "+n+"ToneMapping( color ); }"}const Gc=new jt;function Wc(e){return""!==e}function jc(e,t){const n=t.numSpotLightShadows+t.numSpotLightMaps-t.numSpotLightShadowsWithMaps;return e.replace(/NUM_DIR_LIGHTS/g,t.numDirLights).replace(/NUM_SPOT_LIGHTS/g,t.numSpotLights).replace(/NUM_SPOT_LIGHT_MAPS/g,t.numSpotLightMaps).replace(/NUM_SPOT_LIGHT_COORDS/g,n).replace(/NUM_RECT_AREA_LIGHTS/g,t.numRectAreaLights).replace(/NUM_POINT_LIGHTS/g,t.numPointLights).replace(/NUM_HEMI_LIGHTS/g,t.numHemiLights).replace(/NUM_DIR_LIGHT_SHADOWS/g,t.numDirLightShadows).replace(/NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS/g,t.numSpotLightShadowsWithMaps).replace(/NUM_SPOT_LIGHT_SHADOWS/g,t.numSpotLightShadows).replace(/NUM_POINT_LIGHT_SHADOWS/g,t.numPointLightShadows)}function Xc(e,t){return e.replace(/NUM_CLIPPING_PLANES/g,t.numClippingPlanes).replace(/UNION_CLIPPING_PLANES/g,t.numClippingPlanes-t.numClipIntersection)}const Yc=/^[ \t]*#include +<([\w\d./]+)>/gm;function qc(e){return e.replace(Yc,Kc)}const Zc=new Map;function Kc(e,t){let n=Qo[t];if(void 0===n){const e=Zc.get(t);if(void 0===e)throw new Error("Can not resolve #include <"+t+">");n=Qo[e],console.warn('THREE.WebGLRenderer: Shader chunk "%s" has been deprecated. Use "%s" instead.',t,e)}return qc(n)}const Jc=/#pragma unroll_loop_start\s+for\s*\(\s*int\s+i\s*=\s*(\d+)\s*;\s*i\s*<\s*(\d+)\s*;\s*i\s*\+\+\s*\)\s*{([\s\S]+?)}\s+#pragma unroll_loop_end/g;function Qc(e){return e.replace(Jc,$c)}function $c(e,t,n,i){let r="";for(let e=parseInt(t);e0&&(g+="\n"),v=["#define SHADER_TYPE "+n.shaderType,"#define SHADER_NAME "+n.shaderName,f].filter(Wc).join("\n"),v.length>0&&(v+="\n")):(g=[eh(n),"#define SHADER_TYPE "+n.shaderType,"#define SHADER_NAME "+n.shaderName,f,n.extensionClipCullDistance?"#define USE_CLIP_DISTANCE":"",n.batching?"#define USE_BATCHING":"",n.batchingColor?"#define USE_BATCHING_COLOR":"",n.instancing?"#define USE_INSTANCING":"",n.instancingColor?"#define USE_INSTANCING_COLOR":"",n.instancingMorph?"#define USE_INSTANCING_MORPH":"",n.useFog&&n.fog?"#define USE_FOG":"",n.useFog&&n.fogExp2?"#define FOG_EXP2":"",n.map?"#define USE_MAP":"",n.envMap?"#define USE_ENVMAP":"",n.envMap?"#define "+h:"",n.lightMap?"#define USE_LIGHTMAP":"",n.aoMap?"#define USE_AOMAP":"",n.bumpMap?"#define USE_BUMPMAP":"",n.normalMap?"#define USE_NORMALMAP":"",n.normalMapObjectSpace?"#define USE_NORMALMAP_OBJECTSPACE":"",n.normalMapTangentSpace?"#define USE_NORMALMAP_TANGENTSPACE":"",n.displacementMap?"#define USE_DISPLACEMENTMAP":"",n.emissiveMap?"#define USE_EMISSIVEMAP":"",n.anisotropy?"#define USE_ANISOTROPY":"",n.anisotropyMap?"#define USE_ANISOTROPYMAP":"",n.clearcoatMap?"#define USE_CLEARCOATMAP":"",n.clearcoatRoughnessMap?"#define USE_CLEARCOAT_ROUGHNESSMAP":"",n.clearcoatNormalMap?"#define USE_CLEARCOAT_NORMALMAP":"",n.iridescenceMap?"#define USE_IRIDESCENCEMAP":"",n.iridescenceThicknessMap?"#define USE_IRIDESCENCE_THICKNESSMAP":"",n.specularMap?"#define USE_SPECULARMAP":"",n.specularColorMap?"#define USE_SPECULAR_COLORMAP":"",n.specularIntensityMap?"#define USE_SPECULAR_INTENSITYMAP":"",n.roughnessMap?"#define USE_ROUGHNESSMAP":"",n.metalnessMap?"#define USE_METALNESSMAP":"",n.alphaMap?"#define USE_ALPHAMAP":"",n.alphaHash?"#define USE_ALPHAHASH":"",n.transmission?"#define USE_TRANSMISSION":"",n.transmissionMap?"#define USE_TRANSMISSIONMAP":"",n.thicknessMap?"#define USE_THICKNESSMAP":"",n.sheenColorMap?"#define USE_SHEEN_COLORMAP":"",n.sheenRoughnessMap?"#define USE_SHEEN_ROUGHNESSMAP":"",n.mapUv?"#define MAP_UV "+n.mapUv:"",n.alphaMapUv?"#define ALPHAMAP_UV "+n.alphaMapUv:"",n.lightMapUv?"#define LIGHTMAP_UV "+n.lightMapUv:"",n.aoMapUv?"#define AOMAP_UV "+n.aoMapUv:"",n.emissiveMapUv?"#define EMISSIVEMAP_UV "+n.emissiveMapUv:"",n.bumpMapUv?"#define BUMPMAP_UV "+n.bumpMapUv:"",n.normalMapUv?"#define NORMALMAP_UV "+n.normalMapUv:"",n.displacementMapUv?"#define DISPLACEMENTMAP_UV "+n.displacementMapUv:"",n.metalnessMapUv?"#define METALNESSMAP_UV "+n.metalnessMapUv:"",n.roughnessMapUv?"#define ROUGHNESSMAP_UV "+n.roughnessMapUv:"",n.anisotropyMapUv?"#define ANISOTROPYMAP_UV "+n.anisotropyMapUv:"",n.clearcoatMapUv?"#define CLEARCOATMAP_UV "+n.clearcoatMapUv:"",n.clearcoatNormalMapUv?"#define CLEARCOAT_NORMALMAP_UV "+n.clearcoatNormalMapUv:"",n.clearcoatRoughnessMapUv?"#define CLEARCOAT_ROUGHNESSMAP_UV "+n.clearcoatRoughnessMapUv:"",n.iridescenceMapUv?"#define IRIDESCENCEMAP_UV "+n.iridescenceMapUv:"",n.iridescenceThicknessMapUv?"#define IRIDESCENCE_THICKNESSMAP_UV "+n.iridescenceThicknessMapUv:"",n.sheenColorMapUv?"#define SHEEN_COLORMAP_UV "+n.sheenColorMapUv:"",n.sheenRoughnessMapUv?"#define SHEEN_ROUGHNESSMAP_UV "+n.sheenRoughnessMapUv:"",n.specularMapUv?"#define SPECULARMAP_UV "+n.specularMapUv:"",n.specularColorMapUv?"#define SPECULAR_COLORMAP_UV "+n.specularColorMapUv:"",n.specularIntensityMapUv?"#define SPECULAR_INTENSITYMAP_UV "+n.specularIntensityMapUv:"",n.transmissionMapUv?"#define TRANSMISSIONMAP_UV "+n.transmissionMapUv:"",n.thicknessMapUv?"#define THICKNESSMAP_UV "+n.thicknessMapUv:"",n.vertexTangents&&!1===n.flatShading?"#define USE_TANGENT":"",n.vertexColors?"#define USE_COLOR":"",n.vertexAlphas?"#define USE_COLOR_ALPHA":"",n.vertexUv1s?"#define USE_UV1":"",n.vertexUv2s?"#define USE_UV2":"",n.vertexUv3s?"#define USE_UV3":"",n.pointsUvs?"#define USE_POINTS_UV":"",n.flatShading?"#define FLAT_SHADED":"",n.skinning?"#define USE_SKINNING":"",n.morphTargets?"#define USE_MORPHTARGETS":"",n.morphNormals&&!1===n.flatShading?"#define USE_MORPHNORMALS":"",n.morphColors?"#define USE_MORPHCOLORS":"",n.morphTargetsCount>0?"#define MORPHTARGETS_TEXTURE_STRIDE "+n.morphTextureStride:"",n.morphTargetsCount>0?"#define MORPHTARGETS_COUNT "+n.morphTargetsCount:"",n.doubleSided?"#define DOUBLE_SIDED":"",n.flipSided?"#define FLIP_SIDED":"",n.shadowMapEnabled?"#define USE_SHADOWMAP":"",n.shadowMapEnabled?"#define "+l:"",n.sizeAttenuation?"#define USE_SIZEATTENUATION":"",n.numLightProbes>0?"#define USE_LIGHT_PROBES":"",n.logarithmicDepthBuffer?"#define USE_LOGDEPTHBUF":"",n.reverseDepthBuffer?"#define USE_REVERSEDEPTHBUF":"","uniform mat4 modelMatrix;","uniform mat4 modelViewMatrix;","uniform mat4 projectionMatrix;","uniform mat4 viewMatrix;","uniform mat3 normalMatrix;","uniform vec3 cameraPosition;","uniform bool isOrthographic;","#ifdef USE_INSTANCING","\tattribute mat4 instanceMatrix;","#endif","#ifdef USE_INSTANCING_COLOR","\tattribute vec3 instanceColor;","#endif","#ifdef USE_INSTANCING_MORPH","\tuniform sampler2D morphTexture;","#endif","attribute vec3 position;","attribute vec3 normal;","attribute vec2 uv;","#ifdef USE_UV1","\tattribute vec2 uv1;","#endif","#ifdef USE_UV2","\tattribute vec2 uv2;","#endif","#ifdef USE_UV3","\tattribute vec2 uv3;","#endif","#ifdef USE_TANGENT","\tattribute vec4 tangent;","#endif","#if defined( USE_COLOR_ALPHA )","\tattribute vec4 color;","#elif defined( USE_COLOR )","\tattribute vec3 color;","#endif","#ifdef USE_SKINNING","\tattribute vec4 skinIndex;","\tattribute vec4 skinWeight;","#endif","\n"].filter(Wc).join("\n"),v=[eh(n),"#define SHADER_TYPE "+n.shaderType,"#define SHADER_NAME "+n.shaderName,f,n.useFog&&n.fog?"#define USE_FOG":"",n.useFog&&n.fogExp2?"#define FOG_EXP2":"",n.alphaToCoverage?"#define ALPHA_TO_COVERAGE":"",n.map?"#define USE_MAP":"",n.matcap?"#define USE_MATCAP":"",n.envMap?"#define USE_ENVMAP":"",n.envMap?"#define "+c:"",n.envMap?"#define "+h:"",n.envMap?"#define "+d:"",u?"#define CUBEUV_TEXEL_WIDTH "+u.texelWidth:"",u?"#define CUBEUV_TEXEL_HEIGHT "+u.texelHeight:"",u?"#define CUBEUV_MAX_MIP "+u.maxMip+".0":"",n.lightMap?"#define USE_LIGHTMAP":"",n.aoMap?"#define USE_AOMAP":"",n.bumpMap?"#define USE_BUMPMAP":"",n.normalMap?"#define USE_NORMALMAP":"",n.normalMapObjectSpace?"#define USE_NORMALMAP_OBJECTSPACE":"",n.normalMapTangentSpace?"#define USE_NORMALMAP_TANGENTSPACE":"",n.emissiveMap?"#define USE_EMISSIVEMAP":"",n.anisotropy?"#define USE_ANISOTROPY":"",n.anisotropyMap?"#define USE_ANISOTROPYMAP":"",n.clearcoat?"#define USE_CLEARCOAT":"",n.clearcoatMap?"#define USE_CLEARCOATMAP":"",n.clearcoatRoughnessMap?"#define USE_CLEARCOAT_ROUGHNESSMAP":"",n.clearcoatNormalMap?"#define USE_CLEARCOAT_NORMALMAP":"",n.dispersion?"#define USE_DISPERSION":"",n.iridescence?"#define USE_IRIDESCENCE":"",n.iridescenceMap?"#define USE_IRIDESCENCEMAP":"",n.iridescenceThicknessMap?"#define USE_IRIDESCENCE_THICKNESSMAP":"",n.specularMap?"#define USE_SPECULARMAP":"",n.specularColorMap?"#define USE_SPECULAR_COLORMAP":"",n.specularIntensityMap?"#define USE_SPECULAR_INTENSITYMAP":"",n.roughnessMap?"#define USE_ROUGHNESSMAP":"",n.metalnessMap?"#define USE_METALNESSMAP":"",n.alphaMap?"#define USE_ALPHAMAP":"",n.alphaTest?"#define USE_ALPHATEST":"",n.alphaHash?"#define USE_ALPHAHASH":"",n.sheen?"#define USE_SHEEN":"",n.sheenColorMap?"#define USE_SHEEN_COLORMAP":"",n.sheenRoughnessMap?"#define USE_SHEEN_ROUGHNESSMAP":"",n.transmission?"#define USE_TRANSMISSION":"",n.transmissionMap?"#define USE_TRANSMISSIONMAP":"",n.thicknessMap?"#define USE_THICKNESSMAP":"",n.vertexTangents&&!1===n.flatShading?"#define USE_TANGENT":"",n.vertexColors||n.instancingColor||n.batchingColor?"#define USE_COLOR":"",n.vertexAlphas?"#define USE_COLOR_ALPHA":"",n.vertexUv1s?"#define USE_UV1":"",n.vertexUv2s?"#define USE_UV2":"",n.vertexUv3s?"#define USE_UV3":"",n.pointsUvs?"#define USE_POINTS_UV":"",n.gradientMap?"#define USE_GRADIENTMAP":"",n.flatShading?"#define FLAT_SHADED":"",n.doubleSided?"#define DOUBLE_SIDED":"",n.flipSided?"#define FLIP_SIDED":"",n.shadowMapEnabled?"#define USE_SHADOWMAP":"",n.shadowMapEnabled?"#define "+l:"",n.premultipliedAlpha?"#define PREMULTIPLIED_ALPHA":"",n.numLightProbes>0?"#define USE_LIGHT_PROBES":"",n.decodeVideoTexture?"#define DECODE_VIDEO_TEXTURE":"",n.decodeVideoTextureEmissive?"#define DECODE_VIDEO_TEXTURE_EMISSIVE":"",n.logarithmicDepthBuffer?"#define USE_LOGDEPTHBUF":"",n.reverseDepthBuffer?"#define USE_REVERSEDEPTHBUF":"","uniform mat4 viewMatrix;","uniform vec3 cameraPosition;","uniform bool isOrthographic;",0!==n.toneMapping?"#define TONE_MAPPING":"",0!==n.toneMapping?Qo.tonemapping_pars_fragment:"",0!==n.toneMapping?Vc("toneMapping",n.toneMapping):"",n.dithering?"#define DITHERING":"",n.opaque?"#define OPAQUE":"",Qo.colorspace_pars_fragment,Hc("linearToOutputTexel",n.outputColorSpace),(Rt.getLuminanceCoefficients(Gc),["float luminance( const in vec3 rgb ) {",`\tconst vec3 weights = vec3( ${Gc.x.toFixed(4)}, ${Gc.y.toFixed(4)}, ${Gc.z.toFixed(4)} );`,"\treturn dot( weights, rgb );","}"].join("\n")),n.useDepthPacking?"#define DEPTH_PACKING "+n.depthPacking:"","\n"].filter(Wc).join("\n")),s=qc(s),s=jc(s,n),s=Xc(s,n),o=qc(o),o=jc(o,n),o=Xc(o,n),s=Qc(s),o=Qc(o),!0!==n.isRawShaderMaterial&&(_="#version 300 es\n",g=[p,"#define attribute in","#define varying out","#define texture2D texture"].join("\n")+"\n"+g,v=["#define varying in",n.glslVersion===it?"":"layout(location = 0) out highp vec4 pc_fragColor;",n.glslVersion===it?"":"#define gl_FragColor pc_fragColor","#define gl_FragDepthEXT gl_FragDepth","#define texture2D texture","#define textureCube texture","#define texture2DProj textureProj","#define texture2DLodEXT textureLod","#define texture2DProjLodEXT textureProjLod","#define textureCubeLodEXT textureLod","#define texture2DGradEXT textureGrad","#define texture2DProjGradEXT textureProjGrad","#define textureCubeGradEXT textureGrad"].join("\n")+"\n"+v);const x=_+g+s,y=_+v+o,S=Fc(r,r.VERTEX_SHADER,x),w=Fc(r,r.FRAGMENT_SHADER,y);function b(t){if(e.debug.checkShaderErrors){const n=r.getProgramInfoLog(m).trim(),i=r.getShaderInfoLog(S).trim(),a=r.getShaderInfoLog(w).trim();let s=!0,o=!0;if(!1===r.getProgramParameter(m,r.LINK_STATUS))if(s=!1,"function"==typeof e.debug.onShaderError)e.debug.onShaderError(r,m,S,w);else{const e=kc(r,S,"vertex"),i=kc(r,w,"fragment");console.error("THREE.WebGLProgram: Shader Error "+r.getError()+" - VALIDATE_STATUS "+r.getProgramParameter(m,r.VALIDATE_STATUS)+"\n\nMaterial Name: "+t.name+"\nMaterial Type: "+t.type+"\n\nProgram Info Log: "+n+"\n"+e+"\n"+i)}else""!==n?console.warn("THREE.WebGLProgram: Program Info Log:",n):""!==i&&""!==a||(o=!1);o&&(t.diagnostics={runnable:s,programLog:n,vertexShader:{log:i,prefix:g},fragmentShader:{log:a,prefix:v}})}r.deleteShader(S),r.deleteShader(w),M=new Nc(r,m),T=function(e,t){const n={},i=e.getProgramParameter(t,e.ACTIVE_ATTRIBUTES);for(let r=0;r0,q=a.clearcoat>0,Z=a.dispersion>0,K=a.iridescence>0,J=a.sheen>0,Q=a.transmission>0,$=Y&&!!a.anisotropyMap,ee=q&&!!a.clearcoatMap,te=q&&!!a.clearcoatNormalMap,ne=q&&!!a.clearcoatRoughnessMap,ie=K&&!!a.iridescenceMap,re=K&&!!a.iridescenceThicknessMap,ae=J&&!!a.sheenColorMap,se=J&&!!a.sheenRoughnessMap,oe=!!a.specularMap,le=!!a.specularColorMap,ce=!!a.specularIntensityMap,he=Q&&!!a.transmissionMap,de=Q&&!!a.thicknessMap,ue=!!a.gradientMap,pe=!!a.alphaMap,fe=a.alphaTest>0,me=!!a.alphaHash,ge=!!a.extensions;let ve=0;a.toneMapped&&(null!==D&&!0!==D.isXRRenderTarget||(ve=e.toneMapping));const _e={shaderID:b,shaderType:a.type,shaderName:a.name,vertexShader:E,fragmentShader:A,defines:a.defines,customVertexShaderID:P,customFragmentShaderID:R,isRawShaderMaterial:!0===a.isRawShaderMaterial,glslVersion:a.glslVersion,precision:p,batching:U,batchingColor:U&&null!==v._colorsTexture,instancing:I,instancingColor:I&&null!==v.instanceColor,instancingMorph:I&&null!==v.morphTexture,supportsVertexTextures:u,outputColorSpace:null===D?e.outputColorSpace:!0===D.isXRRenderTarget?D.texture.colorSpace:We,alphaToCoverage:!!a.alphaToCoverage,map:N,matcap:F,envMap:B,envMapMode:B&&S.mapping,envMapCubeUVHeight:w,aoMap:z,lightMap:k,bumpMap:H,normalMap:V,displacementMap:u&&G,emissiveMap:W,normalMapObjectSpace:V&&1===a.normalMapType,normalMapTangentSpace:V&&0===a.normalMapType,metalnessMap:j,roughnessMap:X,anisotropy:Y,anisotropyMap:$,clearcoat:q,clearcoatMap:ee,clearcoatNormalMap:te,clearcoatRoughnessMap:ne,dispersion:Z,iridescence:K,iridescenceMap:ie,iridescenceThicknessMap:re,sheen:J,sheenColorMap:ae,sheenRoughnessMap:se,specularMap:oe,specularColorMap:le,specularIntensityMap:ce,transmission:Q,transmissionMap:he,thicknessMap:de,gradientMap:ue,opaque:!1===a.transparent&&1===a.blending&&!1===a.alphaToCoverage,alphaMap:pe,alphaTest:fe,alphaHash:me,combine:a.combine,mapUv:N&&m(a.map.channel),aoMapUv:z&&m(a.aoMap.channel),lightMapUv:k&&m(a.lightMap.channel),bumpMapUv:H&&m(a.bumpMap.channel),normalMapUv:V&&m(a.normalMap.channel),displacementMapUv:G&&m(a.displacementMap.channel),emissiveMapUv:W&&m(a.emissiveMap.channel),metalnessMapUv:j&&m(a.metalnessMap.channel),roughnessMapUv:X&&m(a.roughnessMap.channel),anisotropyMapUv:$&&m(a.anisotropyMap.channel),clearcoatMapUv:ee&&m(a.clearcoatMap.channel),clearcoatNormalMapUv:te&&m(a.clearcoatNormalMap.channel),clearcoatRoughnessMapUv:ne&&m(a.clearcoatRoughnessMap.channel),iridescenceMapUv:ie&&m(a.iridescenceMap.channel),iridescenceThicknessMapUv:re&&m(a.iridescenceThicknessMap.channel),sheenColorMapUv:ae&&m(a.sheenColorMap.channel),sheenRoughnessMapUv:se&&m(a.sheenRoughnessMap.channel),specularMapUv:oe&&m(a.specularMap.channel),specularColorMapUv:le&&m(a.specularColorMap.channel),specularIntensityMapUv:ce&&m(a.specularIntensityMap.channel),transmissionMapUv:he&&m(a.transmissionMap.channel),thicknessMapUv:de&&m(a.thicknessMap.channel),alphaMapUv:pe&&m(a.alphaMap.channel),vertexTangents:!!x.attributes.tangent&&(V||Y),vertexColors:a.vertexColors,vertexAlphas:!0===a.vertexColors&&!!x.attributes.color&&4===x.attributes.color.itemSize,pointsUvs:!0===v.isPoints&&!!x.attributes.uv&&(N||pe),fog:!!_,useFog:!0===a.fog,fogExp2:!!_&&_.isFogExp2,flatShading:!0===a.flatShading,sizeAttenuation:!0===a.sizeAttenuation,logarithmicDepthBuffer:d,reverseDepthBuffer:L,skinning:!0===v.isSkinnedMesh,morphTargets:void 0!==x.morphAttributes.position,morphNormals:void 0!==x.morphAttributes.normal,morphColors:void 0!==x.morphAttributes.color,morphTargetsCount:T,morphTextureStride:C,numDirLights:o.directional.length,numPointLights:o.point.length,numSpotLights:o.spot.length,numSpotLightMaps:o.spotLightMap.length,numRectAreaLights:o.rectArea.length,numHemiLights:o.hemi.length,numDirLightShadows:o.directionalShadowMap.length,numPointLightShadows:o.pointShadowMap.length,numSpotLightShadows:o.spotShadowMap.length,numSpotLightShadowsWithMaps:o.numSpotLightShadowsWithMaps,numLightProbes:o.numLightProbes,numClippingPlanes:s.numPlanes,numClipIntersection:s.numIntersection,dithering:a.dithering,shadowMapEnabled:e.shadowMap.enabled&&h.length>0,shadowMapType:e.shadowMap.type,toneMapping:ve,decodeVideoTexture:N&&!0===a.map.isVideoTexture&&Rt.getTransfer(a.map.colorSpace)===Xe,decodeVideoTextureEmissive:W&&!0===a.emissiveMap.isVideoTexture&&Rt.getTransfer(a.emissiveMap.colorSpace)===Xe,premultipliedAlpha:a.premultipliedAlpha,doubleSided:2===a.side,flipSided:1===a.side,useDepthPacking:a.depthPacking>=0,depthPacking:a.depthPacking||0,index0AttributeName:a.index0AttributeName,extensionClipCullDistance:ge&&!0===a.extensions.clipCullDistance&&i.has("WEBGL_clip_cull_distance"),extensionMultiDraw:(ge&&!0===a.extensions.multiDraw||U)&&i.has("WEBGL_multi_draw"),rendererExtensionParallelShaderCompile:i.has("KHR_parallel_shader_compile"),customProgramCacheKey:a.customProgramCacheKey()};return _e.vertexUv1s=c.has(1),_e.vertexUv2s=c.has(2),_e.vertexUv3s=c.has(3),c.clear(),_e},getProgramCacheKey:function(t){const n=[];if(t.shaderID?n.push(t.shaderID):(n.push(t.customVertexShaderID),n.push(t.customFragmentShaderID)),void 0!==t.defines)for(const e in t.defines)n.push(e),n.push(t.defines[e]);return!1===t.isRawShaderMaterial&&(function(e,t){e.push(t.precision),e.push(t.outputColorSpace),e.push(t.envMapMode),e.push(t.envMapCubeUVHeight),e.push(t.mapUv),e.push(t.alphaMapUv),e.push(t.lightMapUv),e.push(t.aoMapUv),e.push(t.bumpMapUv),e.push(t.normalMapUv),e.push(t.displacementMapUv),e.push(t.emissiveMapUv),e.push(t.metalnessMapUv),e.push(t.roughnessMapUv),e.push(t.anisotropyMapUv),e.push(t.clearcoatMapUv),e.push(t.clearcoatNormalMapUv),e.push(t.clearcoatRoughnessMapUv),e.push(t.iridescenceMapUv),e.push(t.iridescenceThicknessMapUv),e.push(t.sheenColorMapUv),e.push(t.sheenRoughnessMapUv),e.push(t.specularMapUv),e.push(t.specularColorMapUv),e.push(t.specularIntensityMapUv),e.push(t.transmissionMapUv),e.push(t.thicknessMapUv),e.push(t.combine),e.push(t.fogExp2),e.push(t.sizeAttenuation),e.push(t.morphTargetsCount),e.push(t.morphAttributeCount),e.push(t.numDirLights),e.push(t.numPointLights),e.push(t.numSpotLights),e.push(t.numSpotLightMaps),e.push(t.numHemiLights),e.push(t.numRectAreaLights),e.push(t.numDirLightShadows),e.push(t.numPointLightShadows),e.push(t.numSpotLightShadows),e.push(t.numSpotLightShadowsWithMaps),e.push(t.numLightProbes),e.push(t.shadowMapType),e.push(t.toneMapping),e.push(t.numClippingPlanes),e.push(t.numClipIntersection),e.push(t.depthPacking)}(n,t),function(e,t){o.disableAll(),t.supportsVertexTextures&&o.enable(0),t.instancing&&o.enable(1),t.instancingColor&&o.enable(2),t.instancingMorph&&o.enable(3),t.matcap&&o.enable(4),t.envMap&&o.enable(5),t.normalMapObjectSpace&&o.enable(6),t.normalMapTangentSpace&&o.enable(7),t.clearcoat&&o.enable(8),t.iridescence&&o.enable(9),t.alphaTest&&o.enable(10),t.vertexColors&&o.enable(11),t.vertexAlphas&&o.enable(12),t.vertexUv1s&&o.enable(13),t.vertexUv2s&&o.enable(14),t.vertexUv3s&&o.enable(15),t.vertexTangents&&o.enable(16),t.anisotropy&&o.enable(17),t.alphaHash&&o.enable(18),t.batching&&o.enable(19),t.dispersion&&o.enable(20),t.batchingColor&&o.enable(21),e.push(o.mask),o.disableAll(),t.fog&&o.enable(0),t.useFog&&o.enable(1),t.flatShading&&o.enable(2),t.logarithmicDepthBuffer&&o.enable(3),t.reverseDepthBuffer&&o.enable(4),t.skinning&&o.enable(5),t.morphTargets&&o.enable(6),t.morphNormals&&o.enable(7),t.morphColors&&o.enable(8),t.premultipliedAlpha&&o.enable(9),t.shadowMapEnabled&&o.enable(10),t.doubleSided&&o.enable(11),t.flipSided&&o.enable(12),t.useDepthPacking&&o.enable(13),t.dithering&&o.enable(14),t.transmission&&o.enable(15),t.sheen&&o.enable(16),t.opaque&&o.enable(17),t.pointsUvs&&o.enable(18),t.decodeVideoTexture&&o.enable(19),t.decodeVideoTextureEmissive&&o.enable(20),t.alphaToCoverage&&o.enable(21),e.push(o.mask)}(n,t),n.push(e.outputColorSpace)),n.push(t.customProgramCacheKey),n.join()},getUniforms:function(e){const t=f[e.type];let n;if(t){const e=el[t];n=$i.clone(e.uniforms)}else n=e.uniforms;return n},acquireProgram:function(t,n){let i;for(let e=0,t=h.length;e0?i.push(h):!0===s.transparent?r.push(h):n.push(h)},unshift:function(e,t,s,o,l,c){const h=a(e,t,s,o,l,c);s.transmission>0?i.unshift(h):!0===s.transparent?r.unshift(h):n.unshift(h)},finish:function(){for(let n=t,i=e.length;n1&&n.sort(e||oh),i.length>1&&i.sort(t||lh),r.length>1&&r.sort(t||lh)}}}function hh(){let e=new WeakMap;return{get:function(t,n){const i=e.get(t);let r;return void 0===i?(r=new ch,e.set(t,[r])):n>=i.length?(r=new ch,i.push(r)):r=i[n],r},dispose:function(){e=new WeakMap}}}function dh(){const e={};return{get:function(t){if(void 0!==e[t.id])return e[t.id];let n;switch(t.type){case"DirectionalLight":n={direction:new jt,color:new fi};break;case"SpotLight":n={position:new jt,direction:new jt,color:new fi,distance:0,coneCos:0,penumbraCos:0,decay:0};break;case"PointLight":n={position:new jt,color:new fi,distance:0,decay:0};break;case"HemisphereLight":n={direction:new jt,skyColor:new fi,groundColor:new fi};break;case"RectAreaLight":n={color:new fi,position:new jt,halfWidth:new jt,halfHeight:new jt}}return e[t.id]=n,n}}}let uh=0;function ph(e,t){return(t.castShadow?2:0)-(e.castShadow?2:0)+(t.map?1:0)-(e.map?1:0)}function fh(e){const t=new dh,n=function(){const e={};return{get:function(t){if(void 0!==e[t.id])return e[t.id];let n;switch(t.type){case"DirectionalLight":case"SpotLight":n={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new _t};break;case"PointLight":n={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new _t,shadowCameraNear:1,shadowCameraFar:1e3}}return e[t.id]=n,n}}}(),i={version:0,hash:{directionalLength:-1,pointLength:-1,spotLength:-1,rectAreaLength:-1,hemiLength:-1,numDirectionalShadows:-1,numPointShadows:-1,numSpotShadows:-1,numSpotMaps:-1,numLightProbes:-1},ambient:[0,0,0],probe:[],directional:[],directionalShadow:[],directionalShadowMap:[],directionalShadowMatrix:[],spot:[],spotLightMap:[],spotShadow:[],spotShadowMap:[],spotLightMatrix:[],rectArea:[],rectAreaLTC1:null,rectAreaLTC2:null,point:[],pointShadow:[],pointShadowMap:[],pointShadowMatrix:[],hemi:[],numSpotLightShadowsWithMaps:0,numLightProbes:0};for(let e=0;e<9;e++)i.probe.push(new jt);const r=new jt,a=new wn,s=new wn;return{setup:function(r){let a=0,s=0,o=0;for(let e=0;e<9;e++)i.probe[e].set(0,0,0);let l=0,c=0,h=0,d=0,u=0,p=0,f=0,m=0,g=0,v=0,_=0;r.sort(ph);for(let e=0,x=r.length;e0&&(!0===e.has("OES_texture_float_linear")?(i.rectAreaLTC1=$o.LTC_FLOAT_1,i.rectAreaLTC2=$o.LTC_FLOAT_2):(i.rectAreaLTC1=$o.LTC_HALF_1,i.rectAreaLTC2=$o.LTC_HALF_2)),i.ambient[0]=a,i.ambient[1]=s,i.ambient[2]=o;const x=i.hash;x.directionalLength===l&&x.pointLength===c&&x.spotLength===h&&x.rectAreaLength===d&&x.hemiLength===u&&x.numDirectionalShadows===p&&x.numPointShadows===f&&x.numSpotShadows===m&&x.numSpotMaps===g&&x.numLightProbes===_||(i.directional.length=l,i.spot.length=h,i.rectArea.length=d,i.point.length=c,i.hemi.length=u,i.directionalShadow.length=p,i.directionalShadowMap.length=p,i.pointShadow.length=f,i.pointShadowMap.length=f,i.spotShadow.length=m,i.spotShadowMap.length=m,i.directionalShadowMatrix.length=p,i.pointShadowMatrix.length=f,i.spotLightMatrix.length=m+g-v,i.spotLightMap.length=g,i.numSpotLightShadowsWithMaps=v,i.numLightProbes=_,x.directionalLength=l,x.pointLength=c,x.spotLength=h,x.rectAreaLength=d,x.hemiLength=u,x.numDirectionalShadows=p,x.numPointShadows=f,x.numSpotShadows=m,x.numSpotMaps=g,x.numLightProbes=_,i.version=uh++)},setupView:function(e,t){let n=0,o=0,l=0,c=0,h=0;const d=t.matrixWorldInverse;for(let t=0,u=e.length;t=r.length?(a=new mh(e),r.push(a)):a=r[i],a},dispose:function(){t=new WeakMap}}}function vh(e,t,n){let s=new Wr;const o=new _t,l=new _t,c=new zt,h=new Va({depthPacking:3201}),d=new Ga,u={},p=n.maxTextureSize,f={[i]:1,[r]:0,[a]:2},m=new er({defines:{VSM_SAMPLES:8},uniforms:{shadow_pass:{value:null},resolution:{value:new _t},radius:{value:4}},vertexShader:"void main() {\n\tgl_Position = vec4( position, 1.0 );\n}",fragmentShader:"uniform sampler2D shadow_pass;\nuniform vec2 resolution;\nuniform float radius;\n#include \nvoid main() {\n\tconst float samples = float( VSM_SAMPLES );\n\tfloat mean = 0.0;\n\tfloat squared_mean = 0.0;\n\tfloat uvStride = samples <= 1.0 ? 0.0 : 2.0 / ( samples - 1.0 );\n\tfloat uvStart = samples <= 1.0 ? 0.0 : - 1.0;\n\tfor ( float i = 0.0; i < samples; i ++ ) {\n\t\tfloat uvOffset = uvStart + i * uvStride;\n\t\t#ifdef HORIZONTAL_PASS\n\t\t\tvec2 distribution = unpackRGBATo2Half( texture2D( shadow_pass, ( gl_FragCoord.xy + vec2( uvOffset, 0.0 ) * radius ) / resolution ) );\n\t\t\tmean += distribution.x;\n\t\t\tsquared_mean += distribution.y * distribution.y + distribution.x * distribution.x;\n\t\t#else\n\t\t\tfloat depth = unpackRGBAToDepth( texture2D( shadow_pass, ( gl_FragCoord.xy + vec2( 0.0, uvOffset ) * radius ) / resolution ) );\n\t\t\tmean += depth;\n\t\t\tsquared_mean += depth * depth;\n\t\t#endif\n\t}\n\tmean = mean / samples;\n\tsquared_mean = squared_mean / samples;\n\tfloat std_dev = sqrt( squared_mean - mean * mean );\n\tgl_FragColor = pack2HalfToRGBA( vec2( mean, std_dev ) );\n}"}),g=m.clone();g.defines.HORIZONTAL_PASS=1;const v=new Oi;v.setAttribute("position",new Mi(new Float32Array([-1,-1,.5,3,-1,.5,-1,3,.5]),3));const _=new Yi(v,m),x=this;this.enabled=!1,this.autoUpdate=!0,this.needsUpdate=!1,this.type=1;let y=this.type;function S(n,i){const r=t.update(_);m.defines.VSM_SAMPLES!==n.blurSamples&&(m.defines.VSM_SAMPLES=n.blurSamples,g.defines.VSM_SAMPLES=n.blurSamples,m.needsUpdate=!0,g.needsUpdate=!0),null===n.mapPass&&(n.mapPass=new Ht(o.x,o.y)),m.uniforms.shadow_pass.value=n.map.texture,m.uniforms.resolution.value=n.mapSize,m.uniforms.radius.value=n.radius,e.setRenderTarget(n.mapPass),e.clear(),e.renderBufferDirect(i,null,r,m,_,null),g.uniforms.shadow_pass.value=n.mapPass.texture,g.uniforms.resolution.value=n.mapSize,g.uniforms.radius.value=n.radius,e.setRenderTarget(n.map),e.clear(),e.renderBufferDirect(i,null,r,g,_,null)}function w(t,n,i,r){let a=null;const s=!0===i.isPointLight?t.customDistanceMaterial:t.customDepthMaterial;if(void 0!==s)a=s;else if(a=!0===i.isPointLight?d:h,e.localClippingEnabled&&!0===n.clipShadows&&Array.isArray(n.clippingPlanes)&&0!==n.clippingPlanes.length||n.displacementMap&&0!==n.displacementScale||n.alphaMap&&n.alphaTest>0||n.map&&n.alphaTest>0){const e=a.uuid,t=n.uuid;let i=u[e];void 0===i&&(i={},u[e]=i);let r=i[t];void 0===r&&(r=a.clone(),i[t]=r,n.addEventListener("dispose",M)),a=r}return a.visible=n.visible,a.wireframe=n.wireframe,a.side=3===r?null!==n.shadowSide?n.shadowSide:n.side:null!==n.shadowSide?n.shadowSide:f[n.side],a.alphaMap=n.alphaMap,a.alphaTest=n.alphaTest,a.map=n.map,a.clipShadows=n.clipShadows,a.clippingPlanes=n.clippingPlanes,a.clipIntersection=n.clipIntersection,a.displacementMap=n.displacementMap,a.displacementScale=n.displacementScale,a.displacementBias=n.displacementBias,a.wireframeLinewidth=n.wireframeLinewidth,a.linewidth=n.linewidth,!0===i.isPointLight&&!0===a.isMeshDistanceMaterial&&(e.properties.get(a).light=i),a}function b(n,i,r,a,o){if(!1===n.visible)return;if(n.layers.test(i.layers)&&(n.isMesh||n.isLine||n.isPoints)&&(n.castShadow||n.receiveShadow&&3===o)&&(!n.frustumCulled||s.intersectsObject(n))){n.modelViewMatrix.multiplyMatrices(r.matrixWorldInverse,n.matrixWorld);const s=t.update(n),l=n.material;if(Array.isArray(l)){const t=s.groups;for(let c=0,h=t.length;cp||o.y>p)&&(o.x>p&&(l.x=Math.floor(p/m.x),o.x=l.x*m.x,h.mapSize.x=l.x),o.y>p&&(l.y=Math.floor(p/m.y),o.y=l.y*m.y,h.mapSize.y=l.y)),null===h.map||!0===u||!0===f){const e=3!==this.type?{minFilter:z,magFilter:z}:{};null!==h.map&&h.map.dispose(),h.map=new Ht(o.x,o.y,e),h.map.texture.name=a.name+".shadowMap",h.camera.updateProjectionMatrix()}e.setRenderTarget(h.map),e.clear();const g=h.getViewportCount();for(let e=0;e=1):-1!==Z.indexOf("OpenGL ES")&&(q=parseFloat(/^OpenGL ES (\d)/.exec(Z)[1]),Y=q>=2);let K=null,J={};const Q=e.getParameter(e.SCISSOR_BOX),$=e.getParameter(e.VIEWPORT),ee=(new zt).fromArray(Q),te=(new zt).fromArray($);function ne(t,n,i,r){const a=new Uint8Array(4),s=e.createTexture();e.bindTexture(t,s),e.texParameteri(t,e.TEXTURE_MIN_FILTER,e.NEAREST),e.texParameteri(t,e.TEXTURE_MAG_FILTER,e.NEAREST);for(let s=0;sn||r.height>n)&&(i=n/Math.max(r.width,r.height)),i<1){if("undefined"!=typeof HTMLImageElement&&e instanceof HTMLImageElement||"undefined"!=typeof HTMLCanvasElement&&e instanceof HTMLCanvasElement||"undefined"!=typeof ImageBitmap&&e instanceof ImageBitmap||"undefined"!=typeof VideoFrame&&e instanceof VideoFrame){const n=Math.floor(i*r.width),a=Math.floor(i*r.height);void 0===d&&(d=f(n,a));const s=t?f(n,a):d;return s.width=n,s.height=a,s.getContext("2d").drawImage(e,0,0,n,a),console.warn("THREE.WebGLRenderer: Texture has been resized from ("+r.width+"x"+r.height+") to ("+n+"x"+a+")."),s}return"data"in e&&console.warn("THREE.WebGLRenderer: Image in DataTexture is too big ("+r.width+"x"+r.height+")."),e}return e}function g(e){return e.generateMipmaps}function v(t){e.generateMipmap(t)}function _(t){return t.isWebGLCubeRenderTarget?e.TEXTURE_CUBE_MAP:t.isWebGL3DRenderTarget?e.TEXTURE_3D:t.isWebGLArrayRenderTarget||t.isCompressedArrayTexture?e.TEXTURE_2D_ARRAY:e.TEXTURE_2D}function x(n,i,r,a,s=!1){if(null!==n){if(void 0!==e[n])return e[n];console.warn("THREE.WebGLRenderer: Attempt to use non-existing WebGL internal format '"+n+"'")}let o=i;if(i===e.RED&&(r===e.FLOAT&&(o=e.R32F),r===e.HALF_FLOAT&&(o=e.R16F),r===e.UNSIGNED_BYTE&&(o=e.R8)),i===e.RED_INTEGER&&(r===e.UNSIGNED_BYTE&&(o=e.R8UI),r===e.UNSIGNED_SHORT&&(o=e.R16UI),r===e.UNSIGNED_INT&&(o=e.R32UI),r===e.BYTE&&(o=e.R8I),r===e.SHORT&&(o=e.R16I),r===e.INT&&(o=e.R32I)),i===e.RG&&(r===e.FLOAT&&(o=e.RG32F),r===e.HALF_FLOAT&&(o=e.RG16F),r===e.UNSIGNED_BYTE&&(o=e.RG8)),i===e.RG_INTEGER&&(r===e.UNSIGNED_BYTE&&(o=e.RG8UI),r===e.UNSIGNED_SHORT&&(o=e.RG16UI),r===e.UNSIGNED_INT&&(o=e.RG32UI),r===e.BYTE&&(o=e.RG8I),r===e.SHORT&&(o=e.RG16I),r===e.INT&&(o=e.RG32I)),i===e.RGB_INTEGER&&(r===e.UNSIGNED_BYTE&&(o=e.RGB8UI),r===e.UNSIGNED_SHORT&&(o=e.RGB16UI),r===e.UNSIGNED_INT&&(o=e.RGB32UI),r===e.BYTE&&(o=e.RGB8I),r===e.SHORT&&(o=e.RGB16I),r===e.INT&&(o=e.RGB32I)),i===e.RGBA_INTEGER&&(r===e.UNSIGNED_BYTE&&(o=e.RGBA8UI),r===e.UNSIGNED_SHORT&&(o=e.RGBA16UI),r===e.UNSIGNED_INT&&(o=e.RGBA32UI),r===e.BYTE&&(o=e.RGBA8I),r===e.SHORT&&(o=e.RGBA16I),r===e.INT&&(o=e.RGBA32I)),i===e.RGB&&r===e.UNSIGNED_INT_5_9_9_9_REV&&(o=e.RGB9_E5),i===e.RGBA){const t=s?je:Rt.getTransfer(a);r===e.FLOAT&&(o=e.RGBA32F),r===e.HALF_FLOAT&&(o=e.RGBA16F),r===e.UNSIGNED_BYTE&&(o=t===Xe?e.SRGB8_ALPHA8:e.RGBA8),r===e.UNSIGNED_SHORT_4_4_4_4&&(o=e.RGBA4),r===e.UNSIGNED_SHORT_5_5_5_1&&(o=e.RGB5_A1)}return o!==e.R16F&&o!==e.R32F&&o!==e.RG16F&&o!==e.RG32F&&o!==e.RGBA16F&&o!==e.RGBA32F||t.get("EXT_color_buffer_float"),o}function y(t,n){let i;return t?null===n||n===q||n===$?i=e.DEPTH24_STENCIL8:n===Z?i=e.DEPTH32F_STENCIL8:n===X&&(i=e.DEPTH24_STENCIL8,console.warn("DepthTexture: 16 bit depth attachment is not supported with stencil. Using 24-bit attachment.")):null===n||n===q||n===$?i=e.DEPTH_COMPONENT24:n===Z?i=e.DEPTH_COMPONENT32F:n===X&&(i=e.DEPTH_COMPONENT16),i}function S(e,t){return!0===g(e)||e.isFramebufferTexture&&e.minFilter!==z&&e.minFilter!==V?Math.log2(Math.max(t.width,t.height))+1:void 0!==e.mipmaps&&e.mipmaps.length>0?e.mipmaps.length:e.isCompressedTexture&&Array.isArray(e.image)?t.mipmaps.length:1}function w(e){const t=e.target;t.removeEventListener("dispose",w),function(e){const t=i.get(e);if(void 0===t.__webglInit)return;const n=e.source,r=u.get(n);if(r){const i=r[t.__cacheKey];i.usedTimes--,0===i.usedTimes&&M(e),0===Object.keys(r).length&&u.delete(n)}i.remove(e)}(t),t.isVideoTexture&&h.delete(t)}function b(t){const n=t.target;n.removeEventListener("dispose",b),function(t){const n=i.get(t);if(t.depthTexture&&(t.depthTexture.dispose(),i.remove(t.depthTexture)),t.isWebGLCubeRenderTarget)for(let t=0;t<6;t++){if(Array.isArray(n.__webglFramebuffer[t]))for(let i=0;i0&&a.__version!==t.version){const e=t.image;if(null===e)console.warn("THREE.WebGLRenderer: Texture marked for update but no image data found.");else{if(!1!==e.complete)return void L(a,t,r);console.warn("THREE.WebGLRenderer: Texture marked for update but image is incomplete")}}n.bindTexture(e.TEXTURE_2D,a.__webglTexture,e.TEXTURE0+r)}const A={[N]:e.REPEAT,[F]:e.CLAMP_TO_EDGE,[B]:e.MIRRORED_REPEAT},P={[z]:e.NEAREST,[k]:e.NEAREST_MIPMAP_NEAREST,[H]:e.NEAREST_MIPMAP_LINEAR,[V]:e.LINEAR,[G]:e.LINEAR_MIPMAP_NEAREST,[W]:e.LINEAR_MIPMAP_LINEAR},R={[qe]:e.NEVER,[tt]:e.ALWAYS,[Ze]:e.LESS,[Je]:e.LEQUAL,[Ke]:e.EQUAL,[et]:e.GEQUAL,[Qe]:e.GREATER,[$e]:e.NOTEQUAL};function C(n,a){if(a.type!==Z||!1!==t.has("OES_texture_float_linear")||a.magFilter!==V&&a.magFilter!==G&&a.magFilter!==H&&a.magFilter!==W&&a.minFilter!==V&&a.minFilter!==G&&a.minFilter!==H&&a.minFilter!==W||console.warn("THREE.WebGLRenderer: Unable to use linear filtering with floating point textures. OES_texture_float_linear not supported on this device."),e.texParameteri(n,e.TEXTURE_WRAP_S,A[a.wrapS]),e.texParameteri(n,e.TEXTURE_WRAP_T,A[a.wrapT]),n!==e.TEXTURE_3D&&n!==e.TEXTURE_2D_ARRAY||e.texParameteri(n,e.TEXTURE_WRAP_R,A[a.wrapR]),e.texParameteri(n,e.TEXTURE_MAG_FILTER,P[a.magFilter]),e.texParameteri(n,e.TEXTURE_MIN_FILTER,P[a.minFilter]),a.compareFunction&&(e.texParameteri(n,e.TEXTURE_COMPARE_MODE,e.COMPARE_REF_TO_TEXTURE),e.texParameteri(n,e.TEXTURE_COMPARE_FUNC,R[a.compareFunction])),!0===t.has("EXT_texture_filter_anisotropic")){if(a.magFilter===z)return;if(a.minFilter!==H&&a.minFilter!==W)return;if(a.type===Z&&!1===t.has("OES_texture_float_linear"))return;if(a.anisotropy>1||i.get(a).__currentAnisotropy){const s=t.get("EXT_texture_filter_anisotropic");e.texParameterf(n,s.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(a.anisotropy,r.getMaxAnisotropy())),i.get(a).__currentAnisotropy=a.anisotropy}}}function D(t,n){let i=!1;void 0===t.__webglInit&&(t.__webglInit=!0,n.addEventListener("dispose",w));const r=n.source;let a=u.get(r);void 0===a&&(a={},u.set(r,a));const o=function(e){const t=[];return t.push(e.wrapS),t.push(e.wrapT),t.push(e.wrapR||0),t.push(e.magFilter),t.push(e.minFilter),t.push(e.anisotropy),t.push(e.internalFormat),t.push(e.format),t.push(e.type),t.push(e.generateMipmaps),t.push(e.premultiplyAlpha),t.push(e.flipY),t.push(e.unpackAlignment),t.push(e.colorSpace),t.join()}(n);if(o!==t.__cacheKey){void 0===a[o]&&(a[o]={texture:e.createTexture(),usedTimes:0},s.memory.textures++,i=!0),a[o].usedTimes++;const r=a[t.__cacheKey];void 0!==r&&(a[t.__cacheKey].usedTimes--,0===r.usedTimes&&M(n)),t.__cacheKey=o,t.__webglTexture=a[o].texture}return i}function L(t,s,o){let l=e.TEXTURE_2D;(s.isDataArrayTexture||s.isCompressedArrayTexture)&&(l=e.TEXTURE_2D_ARRAY),s.isData3DTexture&&(l=e.TEXTURE_3D);const c=D(t,s),h=s.source;n.bindTexture(l,t.__webglTexture,e.TEXTURE0+o);const d=i.get(h);if(h.version!==d.__version||!0===c){n.activeTexture(e.TEXTURE0+o);const t=Rt.getPrimaries(Rt.workingColorSpace),i=s.colorSpace===Ve?null:Rt.getPrimaries(s.colorSpace),u=s.colorSpace===Ve||t===i?e.NONE:e.BROWSER_DEFAULT_WEBGL;e.pixelStorei(e.UNPACK_FLIP_Y_WEBGL,s.flipY),e.pixelStorei(e.UNPACK_PREMULTIPLY_ALPHA_WEBGL,s.premultiplyAlpha),e.pixelStorei(e.UNPACK_ALIGNMENT,s.unpackAlignment),e.pixelStorei(e.UNPACK_COLORSPACE_CONVERSION_WEBGL,u);let p=m(s.image,!1,r.maxTextureSize);p=ie(s,p);const f=a.convert(s.format,s.colorSpace),_=a.convert(s.type);let w,b=x(s.internalFormat,f,_,s.colorSpace,s.isVideoTexture);C(l,s);const M=s.mipmaps,T=!0!==s.isVideoTexture,E=void 0===d.__version||!0===c,A=h.dataReady,P=S(s,p);if(s.isDepthTexture)b=y(s.format===ne,s.type),E&&(T?n.texStorage2D(e.TEXTURE_2D,1,b,p.width,p.height):n.texImage2D(e.TEXTURE_2D,0,b,p.width,p.height,0,f,_,null));else if(s.isDataTexture)if(M.length>0){T&&E&&n.texStorage2D(e.TEXTURE_2D,P,b,M[0].width,M[0].height);for(let t=0,i=M.length;t0){const i=to(w.width,w.height,s.format,s.type);for(const r of s.layerUpdates){const a=w.data.subarray(r*i/w.data.BYTES_PER_ELEMENT,(r+1)*i/w.data.BYTES_PER_ELEMENT);n.compressedTexSubImage3D(e.TEXTURE_2D_ARRAY,t,0,0,r,w.width,w.height,1,f,a)}s.clearLayerUpdates()}else n.compressedTexSubImage3D(e.TEXTURE_2D_ARRAY,t,0,0,0,w.width,w.height,p.depth,f,w.data)}else n.compressedTexImage3D(e.TEXTURE_2D_ARRAY,t,b,w.width,w.height,p.depth,0,w.data,0,0);else console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()");else T?A&&n.texSubImage3D(e.TEXTURE_2D_ARRAY,t,0,0,0,w.width,w.height,p.depth,f,_,w.data):n.texImage3D(e.TEXTURE_2D_ARRAY,t,b,w.width,w.height,p.depth,0,f,_,w.data)}else{T&&E&&n.texStorage2D(e.TEXTURE_2D,P,b,M[0].width,M[0].height);for(let t=0,i=M.length;t0){const t=to(p.width,p.height,s.format,s.type);for(const i of s.layerUpdates){const r=p.data.subarray(i*t/p.data.BYTES_PER_ELEMENT,(i+1)*t/p.data.BYTES_PER_ELEMENT);n.texSubImage3D(e.TEXTURE_2D_ARRAY,0,0,0,i,p.width,p.height,1,f,_,r)}s.clearLayerUpdates()}else n.texSubImage3D(e.TEXTURE_2D_ARRAY,0,0,0,0,p.width,p.height,p.depth,f,_,p.data)}else n.texImage3D(e.TEXTURE_2D_ARRAY,0,b,p.width,p.height,p.depth,0,f,_,p.data);else if(s.isData3DTexture)T?(E&&n.texStorage3D(e.TEXTURE_3D,P,b,p.width,p.height,p.depth),A&&n.texSubImage3D(e.TEXTURE_3D,0,0,0,0,p.width,p.height,p.depth,f,_,p.data)):n.texImage3D(e.TEXTURE_3D,0,b,p.width,p.height,p.depth,0,f,_,p.data);else if(s.isFramebufferTexture){if(E)if(T)n.texStorage2D(e.TEXTURE_2D,P,b,p.width,p.height);else{let t=p.width,i=p.height;for(let r=0;r>=1,i>>=1}}else if(M.length>0){if(T&&E){const t=re(M[0]);n.texStorage2D(e.TEXTURE_2D,P,b,t.width,t.height)}for(let t=0,i=M.length;t>h),i=Math.max(1,r.height>>h);c===e.TEXTURE_3D||c===e.TEXTURE_2D_ARRAY?n.texImage3D(c,h,p,t,i,r.depth,0,d,u,null):n.texImage2D(c,h,p,t,i,0,d,u,null)}n.bindFramebuffer(e.FRAMEBUFFER,t),Q(r)?o.framebufferTexture2DMultisampleEXT(e.FRAMEBUFFER,l,c,m.__webglTexture,0,J(r)):(c===e.TEXTURE_2D||c>=e.TEXTURE_CUBE_MAP_POSITIVE_X&&c<=e.TEXTURE_CUBE_MAP_NEGATIVE_Z)&&e.framebufferTexture2D(e.FRAMEBUFFER,l,c,m.__webglTexture,h),n.bindFramebuffer(e.FRAMEBUFFER,null)}function U(t,n,i){if(e.bindRenderbuffer(e.RENDERBUFFER,t),n.depthBuffer){const r=n.depthTexture,a=r&&r.isDepthTexture?r.type:null,s=y(n.stencilBuffer,a),l=n.stencilBuffer?e.DEPTH_STENCIL_ATTACHMENT:e.DEPTH_ATTACHMENT,c=J(n);Q(n)?o.renderbufferStorageMultisampleEXT(e.RENDERBUFFER,c,s,n.width,n.height):i?e.renderbufferStorageMultisample(e.RENDERBUFFER,c,s,n.width,n.height):e.renderbufferStorage(e.RENDERBUFFER,s,n.width,n.height),e.framebufferRenderbuffer(e.FRAMEBUFFER,l,e.RENDERBUFFER,t)}else{const t=n.textures;for(let r=0;r{delete r.__boundDepthTexture,delete r.__depthDisposeCallback,e.removeEventListener("dispose",t)};e.addEventListener("dispose",t),r.__depthDisposeCallback=t}r.__boundDepthTexture=e}if(t.depthTexture&&!r.__autoAllocateDepthBuffer){if(a)throw new Error("target.depthTexture not supported in Cube render targets");!function(t,r){if(r&&r.isWebGLCubeRenderTarget)throw new Error("Depth Texture with cube render targets is not supported");if(n.bindFramebuffer(e.FRAMEBUFFER,t),!r.depthTexture||!r.depthTexture.isDepthTexture)throw new Error("renderTarget.depthTexture must be an instance of THREE.DepthTexture");const a=i.get(r.depthTexture);a.__renderTarget=r,a.__webglTexture&&r.depthTexture.image.width===r.width&&r.depthTexture.image.height===r.height||(r.depthTexture.image.width=r.width,r.depthTexture.image.height=r.height,r.depthTexture.needsUpdate=!0),E(r.depthTexture,0);const s=a.__webglTexture,l=J(r);if(r.depthTexture.format===te)Q(r)?o.framebufferTexture2DMultisampleEXT(e.FRAMEBUFFER,e.DEPTH_ATTACHMENT,e.TEXTURE_2D,s,0,l):e.framebufferTexture2D(e.FRAMEBUFFER,e.DEPTH_ATTACHMENT,e.TEXTURE_2D,s,0);else{if(r.depthTexture.format!==ne)throw new Error("Unknown depthTexture format");Q(r)?o.framebufferTexture2DMultisampleEXT(e.FRAMEBUFFER,e.DEPTH_STENCIL_ATTACHMENT,e.TEXTURE_2D,s,0,l):e.framebufferTexture2D(e.FRAMEBUFFER,e.DEPTH_STENCIL_ATTACHMENT,e.TEXTURE_2D,s,0)}}(r.__webglFramebuffer,t)}else if(a){r.__webglDepthbuffer=[];for(let i=0;i<6;i++)if(n.bindFramebuffer(e.FRAMEBUFFER,r.__webglFramebuffer[i]),void 0===r.__webglDepthbuffer[i])r.__webglDepthbuffer[i]=e.createRenderbuffer(),U(r.__webglDepthbuffer[i],t,!1);else{const n=t.stencilBuffer?e.DEPTH_STENCIL_ATTACHMENT:e.DEPTH_ATTACHMENT,a=r.__webglDepthbuffer[i];e.bindRenderbuffer(e.RENDERBUFFER,a),e.framebufferRenderbuffer(e.FRAMEBUFFER,n,e.RENDERBUFFER,a)}}else if(n.bindFramebuffer(e.FRAMEBUFFER,r.__webglFramebuffer),void 0===r.__webglDepthbuffer)r.__webglDepthbuffer=e.createRenderbuffer(),U(r.__webglDepthbuffer,t,!1);else{const n=t.stencilBuffer?e.DEPTH_STENCIL_ATTACHMENT:e.DEPTH_ATTACHMENT,i=r.__webglDepthbuffer;e.bindRenderbuffer(e.RENDERBUFFER,i),e.framebufferRenderbuffer(e.FRAMEBUFFER,n,e.RENDERBUFFER,i)}n.bindFramebuffer(e.FRAMEBUFFER,null)}const Y=[],K=[];function J(e){return Math.min(r.maxSamples,e.samples)}function Q(e){const n=i.get(e);return e.samples>0&&!0===t.has("WEBGL_multisampled_render_to_texture")&&!1!==n.__useRenderToTexture}function ie(e,t){const n=e.colorSpace,i=e.format,r=e.type;return!0===e.isCompressedTexture||!0===e.isVideoTexture||n!==We&&n!==Ve&&(Rt.getTransfer(n)===Xe?i===ee&&r===j||console.warn("THREE.WebGLTextures: sRGB encoded textures have to use RGBAFormat and UnsignedByteType."):console.error("THREE.WebGLTextures: Unsupported texture color space:",n)),t}function re(e){return"undefined"!=typeof HTMLImageElement&&e instanceof HTMLImageElement?(c.width=e.naturalWidth||e.width,c.height=e.naturalHeight||e.height):"undefined"!=typeof VideoFrame&&e instanceof VideoFrame?(c.width=e.displayWidth,c.height=e.displayHeight):(c.width=e.width,c.height=e.height),c}this.allocateTextureUnit=function(){const e=T;return e>=r.maxTextures&&console.warn("THREE.WebGLTextures: Trying to use "+e+" texture units while this GPU supports only "+r.maxTextures),T+=1,e},this.resetTextureUnits=function(){T=0},this.setTexture2D=E,this.setTexture2DArray=function(t,r){const a=i.get(t);t.version>0&&a.__version!==t.version?L(a,t,r):n.bindTexture(e.TEXTURE_2D_ARRAY,a.__webglTexture,e.TEXTURE0+r)},this.setTexture3D=function(t,r){const a=i.get(t);t.version>0&&a.__version!==t.version?L(a,t,r):n.bindTexture(e.TEXTURE_3D,a.__webglTexture,e.TEXTURE0+r)},this.setTextureCube=function(t,s){const o=i.get(t);t.version>0&&o.__version!==t.version?function(t,s,o){if(6!==s.image.length)return;const l=D(t,s),c=s.source;n.bindTexture(e.TEXTURE_CUBE_MAP,t.__webglTexture,e.TEXTURE0+o);const h=i.get(c);if(c.version!==h.__version||!0===l){n.activeTexture(e.TEXTURE0+o);const t=Rt.getPrimaries(Rt.workingColorSpace),i=s.colorSpace===Ve?null:Rt.getPrimaries(s.colorSpace),d=s.colorSpace===Ve||t===i?e.NONE:e.BROWSER_DEFAULT_WEBGL;e.pixelStorei(e.UNPACK_FLIP_Y_WEBGL,s.flipY),e.pixelStorei(e.UNPACK_PREMULTIPLY_ALPHA_WEBGL,s.premultiplyAlpha),e.pixelStorei(e.UNPACK_ALIGNMENT,s.unpackAlignment),e.pixelStorei(e.UNPACK_COLORSPACE_CONVERSION_WEBGL,d);const u=s.isCompressedTexture||s.image[0].isCompressedTexture,p=s.image[0]&&s.image[0].isDataTexture,f=[];for(let e=0;e<6;e++)f[e]=u||p?p?s.image[e].image:s.image[e]:m(s.image[e],!0,r.maxCubemapSize),f[e]=ie(s,f[e]);const _=f[0],y=a.convert(s.format,s.colorSpace),w=a.convert(s.type),b=x(s.internalFormat,y,w,s.colorSpace),M=!0!==s.isVideoTexture,T=void 0===h.__version||!0===l,E=c.dataReady;let A,P=S(s,_);if(C(e.TEXTURE_CUBE_MAP,s),u){M&&T&&n.texStorage2D(e.TEXTURE_CUBE_MAP,P,b,_.width,_.height);for(let t=0;t<6;t++){A=f[t].mipmaps;for(let i=0;i0&&P++;const t=re(f[0]);n.texStorage2D(e.TEXTURE_CUBE_MAP,P,b,t.width,t.height)}for(let t=0;t<6;t++)if(p){M?E&&n.texSubImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+t,0,0,0,f[t].width,f[t].height,y,w,f[t].data):n.texImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+t,0,b,f[t].width,f[t].height,0,y,w,f[t].data);for(let i=0;i1;if(d||(void 0===l.__webglTexture&&(l.__webglTexture=e.createTexture()),l.__version=r.version,s.memory.textures++),h){o.__webglFramebuffer=[];for(let t=0;t<6;t++)if(r.mipmaps&&r.mipmaps.length>0){o.__webglFramebuffer[t]=[];for(let n=0;n0){o.__webglFramebuffer=[];for(let t=0;t0&&!1===Q(t)){o.__webglMultisampledFramebuffer=e.createFramebuffer(),o.__webglColorRenderbuffer=[],n.bindFramebuffer(e.FRAMEBUFFER,o.__webglMultisampledFramebuffer);for(let n=0;n0)for(let i=0;i0)for(let n=0;n0)if(!1===Q(t)){const r=t.textures,a=t.width,s=t.height;let o=e.COLOR_BUFFER_BIT;const c=t.stencilBuffer?e.DEPTH_STENCIL_ATTACHMENT:e.DEPTH_ATTACHMENT,h=i.get(t),d=r.length>1;if(d)for(let t=0;to+c?(l.inputState.pinching=!1,this.dispatchEvent({type:"pinchend",handedness:e.handedness,target:this})):!l.inputState.pinching&&s<=o-c&&(l.inputState.pinching=!0,this.dispatchEvent({type:"pinchstart",handedness:e.handedness,target:this}))}else null!==o&&e.gripSpace&&(r=t.getPose(e.gripSpace,n),null!==r&&(o.matrix.fromArray(r.transform.matrix),o.matrix.decompose(o.position,o.rotation,o.scale),o.matrixWorldNeedsUpdate=!0,r.linearVelocity?(o.hasLinearVelocity=!0,o.linearVelocity.copy(r.linearVelocity)):o.hasLinearVelocity=!1,r.angularVelocity?(o.hasAngularVelocity=!0,o.angularVelocity.copy(r.angularVelocity)):o.hasAngularVelocity=!1));null!==s&&(i=t.getPose(e.targetRaySpace,n),null===i&&null!==r&&(i=r),null!==i&&(s.matrix.fromArray(i.transform.matrix),s.matrix.decompose(s.position,s.rotation,s.scale),s.matrixWorldNeedsUpdate=!0,i.linearVelocity?(s.hasLinearVelocity=!0,s.linearVelocity.copy(i.linearVelocity)):s.hasLinearVelocity=!1,i.angularVelocity?(s.hasAngularVelocity=!0,s.angularVelocity.copy(i.angularVelocity)):s.hasAngularVelocity=!1,this.dispatchEvent(wh)))}return null!==s&&(s.visible=null!==i),null!==o&&(o.visible=null!==r),null!==l&&(l.visible=null!==a),this}_getHandJoint(e,t){if(void 0===e.joints[t.jointName]){const n=new ua;n.matrixAutoUpdate=!1,n.visible=!1,e.joints[t.jointName]=n,e.add(n)}return e.joints[t.jointName]}}class Mh{constructor(){this.texture=null,this.mesh=null,this.depthNear=0,this.depthFar=0}init(e,t,n){if(null===this.texture){const i=new Bt;e.properties.get(i).__webglTexture=t.texture,t.depthNear==n.depthNear&&t.depthFar==n.depthFar||(this.depthNear=t.depthNear,this.depthFar=t.depthFar),this.texture=i}}getMesh(e){if(null!==this.texture&&null===this.mesh){const t=e.cameras[0].viewport,n=new er({vertexShader:"\nvoid main() {\n\n\tgl_Position = vec4( position, 1.0 );\n\n}",fragmentShader:"\nuniform sampler2DArray depthColor;\nuniform float depthWidth;\nuniform float depthHeight;\n\nvoid main() {\n\n\tvec2 coord = vec2( gl_FragCoord.x / depthWidth, gl_FragCoord.y / depthHeight );\n\n\tif ( coord.x >= 1.0 ) {\n\n\t\tgl_FragDepth = texture( depthColor, vec3( coord.x - 1.0, coord.y, 1 ) ).r;\n\n\t} else {\n\n\t\tgl_FragDepth = texture( depthColor, vec3( coord.x, coord.y, 0 ) ).r;\n\n\t}\n\n}",uniforms:{depthColor:{value:this.texture},depthWidth:{value:t.z},depthHeight:{value:t.w}}});this.mesh=new Yi(new Da(20,20),n)}return this.mesh}reset(){this.texture=null,this.mesh=null}getDepthTexture(){return this.texture}}class Th extends st{constructor(e,t){super();const n=this;let i=null,r=1,a=null,s="local-floor",o=1,l=null,c=null,h=null,d=null,u=null,p=null;const f=new Mh,m=t.getContextAttributes();let g=null,v=null;const _=[],x=[],y=new _t;let S=null;const w=new ar;w.viewport=new zt;const b=new ar;b.viewport=new zt;const M=[w,b],T=new Fs;let E=null,A=null;function P(e){const t=x.indexOf(e.inputSource);if(-1===t)return;const n=_[t];void 0!==n&&(n.update(e.inputSource,e.frame,l||a),n.dispatchEvent({type:e.type,data:e.inputSource}))}function R(){i.removeEventListener("select",P),i.removeEventListener("selectstart",P),i.removeEventListener("selectend",P),i.removeEventListener("squeeze",P),i.removeEventListener("squeezestart",P),i.removeEventListener("squeezeend",P),i.removeEventListener("end",R),i.removeEventListener("inputsourceschange",C);for(let e=0;e<_.length;e++){const t=x[e];null!==t&&(x[e]=null,_[e].disconnect(t))}E=null,A=null,f.reset(),e.setRenderTarget(g),u=null,d=null,h=null,i=null,v=null,O.stop(),n.isPresenting=!1,e.setPixelRatio(S),e.setSize(y.width,y.height,!1),n.dispatchEvent({type:"sessionend"})}function C(e){for(let t=0;t=0&&(x[i]=null,_[i].disconnect(n))}for(let t=0;t=x.length){x.push(n),i=e;break}if(null===x[e]){x[e]=n,i=e;break}}if(-1===i)break}const r=_[i];r&&r.connect(n)}}this.cameraAutoUpdate=!0,this.enabled=!1,this.isPresenting=!1,this.getController=function(e){let t=_[e];return void 0===t&&(t=new bh,_[e]=t),t.getTargetRaySpace()},this.getControllerGrip=function(e){let t=_[e];return void 0===t&&(t=new bh,_[e]=t),t.getGripSpace()},this.getHand=function(e){let t=_[e];return void 0===t&&(t=new bh,_[e]=t),t.getHandSpace()},this.setFramebufferScaleFactor=function(e){r=e,!0===n.isPresenting&&console.warn("THREE.WebXRManager: Cannot change framebuffer scale while presenting.")},this.setReferenceSpaceType=function(e){s=e,!0===n.isPresenting&&console.warn("THREE.WebXRManager: Cannot change reference space type while presenting.")},this.getReferenceSpace=function(){return l||a},this.setReferenceSpace=function(e){l=e},this.getBaseLayer=function(){return null!==d?d:u},this.getBinding=function(){return h},this.getFrame=function(){return p},this.getSession=function(){return i},this.setSession=async function(c){if(i=c,null!==i){if(g=e.getRenderTarget(),i.addEventListener("select",P),i.addEventListener("selectstart",P),i.addEventListener("selectend",P),i.addEventListener("squeeze",P),i.addEventListener("squeezestart",P),i.addEventListener("squeezeend",P),i.addEventListener("end",R),i.addEventListener("inputsourceschange",C),!0!==m.xrCompatible&&await t.makeXRCompatible(),S=e.getPixelRatio(),e.getSize(y),void 0===i.renderState.layers){const n={antialias:m.antialias,alpha:!0,depth:m.depth,stencil:m.stencil,framebufferScaleFactor:r};u=new XRWebGLLayer(i,t,n),i.updateRenderState({baseLayer:u}),e.setPixelRatio(1),e.setSize(u.framebufferWidth,u.framebufferHeight,!1),v=new Ht(u.framebufferWidth,u.framebufferHeight,{format:ee,type:j,colorSpace:e.outputColorSpace,stencilBuffer:m.stencil})}else{let n=null,a=null,s=null;m.depth&&(s=m.stencil?t.DEPTH24_STENCIL8:t.DEPTH_COMPONENT24,n=m.stencil?ne:te,a=m.stencil?$:q);const o={colorFormat:t.RGBA8,depthFormat:s,scaleFactor:r};h=new XRWebGLBinding(i,t),d=h.createProjectionLayer(o),i.updateRenderState({layers:[d]}),e.setPixelRatio(1),e.setSize(d.textureWidth,d.textureHeight,!1),v=new Ht(d.textureWidth,d.textureHeight,{format:ee,type:j,depthTexture:new pa(d.textureWidth,d.textureHeight,a,void 0,void 0,void 0,void 0,void 0,void 0,n),stencilBuffer:m.stencil,colorSpace:e.outputColorSpace,samples:m.antialias?4:0,resolveDepthBuffer:!1===d.ignoreDepthValues})}v.isXRRenderTarget=!0,this.setFoveation(o),l=null,a=await i.requestReferenceSpace(s),O.setContext(i),O.start(),n.isPresenting=!0,n.dispatchEvent({type:"sessionstart"})}},this.getEnvironmentBlendMode=function(){if(null!==i)return i.environmentBlendMode},this.getDepthTexture=function(){return f.getDepthTexture()};const D=new jt,L=new jt;function I(e,t){null===t?e.matrixWorld.copy(e.matrix):e.matrixWorld.multiplyMatrices(t.matrixWorld,e.matrix),e.matrixWorldInverse.copy(e.matrixWorld).invert()}this.updateCamera=function(e){if(null===i)return;let t=e.near,n=e.far;null!==f.texture&&(f.depthNear>0&&(t=f.depthNear),f.depthFar>0&&(n=f.depthFar)),T.near=b.near=w.near=t,T.far=b.far=w.far=n,E===T.near&&A===T.far||(i.updateRenderState({depthNear:T.near,depthFar:T.far}),E=T.near,A=T.far),w.layers.mask=2|e.layers.mask,b.layers.mask=4|e.layers.mask,T.layers.mask=w.layers.mask|b.layers.mask;const r=e.parent,a=T.cameras;I(T,r);for(let e=0;e0&&(e.alphaTest.value=i.alphaTest);const r=t.get(i),a=r.envMap,s=r.envMapRotation;a&&(e.envMap.value=a,Eh.copy(s),Eh.x*=-1,Eh.y*=-1,Eh.z*=-1,a.isCubeTexture&&!1===a.isRenderTargetTexture&&(Eh.y*=-1,Eh.z*=-1),e.envMapRotation.value.setFromMatrix4(Ah.makeRotationFromEuler(Eh)),e.flipEnvMap.value=a.isCubeTexture&&!1===a.isRenderTargetTexture?-1:1,e.reflectivity.value=i.reflectivity,e.ior.value=i.ior,e.refractionRatio.value=i.refractionRatio),i.lightMap&&(e.lightMap.value=i.lightMap,e.lightMapIntensity.value=i.lightMapIntensity,n(i.lightMap,e.lightMapTransform)),i.aoMap&&(e.aoMap.value=i.aoMap,e.aoMapIntensity.value=i.aoMapIntensity,n(i.aoMap,e.aoMapTransform))}return{refreshFogUniforms:function(t,n){n.color.getRGB(t.fogColor.value,Qi(e)),n.isFog?(t.fogNear.value=n.near,t.fogFar.value=n.far):n.isFogExp2&&(t.fogDensity.value=n.density)},refreshMaterialUniforms:function(e,r,a,s,o){r.isMeshBasicMaterial||r.isMeshLambertMaterial?i(e,r):r.isMeshToonMaterial?(i(e,r),function(e,t){t.gradientMap&&(e.gradientMap.value=t.gradientMap)}(e,r)):r.isMeshPhongMaterial?(i(e,r),function(e,t){e.specular.value.copy(t.specular),e.shininess.value=Math.max(t.shininess,1e-4)}(e,r)):r.isMeshStandardMaterial?(i(e,r),function(e,t){e.metalness.value=t.metalness,t.metalnessMap&&(e.metalnessMap.value=t.metalnessMap,n(t.metalnessMap,e.metalnessMapTransform)),e.roughness.value=t.roughness,t.roughnessMap&&(e.roughnessMap.value=t.roughnessMap,n(t.roughnessMap,e.roughnessMapTransform)),t.envMap&&(e.envMapIntensity.value=t.envMapIntensity)}(e,r),r.isMeshPhysicalMaterial&&function(e,t,i){e.ior.value=t.ior,t.sheen>0&&(e.sheenColor.value.copy(t.sheenColor).multiplyScalar(t.sheen),e.sheenRoughness.value=t.sheenRoughness,t.sheenColorMap&&(e.sheenColorMap.value=t.sheenColorMap,n(t.sheenColorMap,e.sheenColorMapTransform)),t.sheenRoughnessMap&&(e.sheenRoughnessMap.value=t.sheenRoughnessMap,n(t.sheenRoughnessMap,e.sheenRoughnessMapTransform))),t.clearcoat>0&&(e.clearcoat.value=t.clearcoat,e.clearcoatRoughness.value=t.clearcoatRoughness,t.clearcoatMap&&(e.clearcoatMap.value=t.clearcoatMap,n(t.clearcoatMap,e.clearcoatMapTransform)),t.clearcoatRoughnessMap&&(e.clearcoatRoughnessMap.value=t.clearcoatRoughnessMap,n(t.clearcoatRoughnessMap,e.clearcoatRoughnessMapTransform)),t.clearcoatNormalMap&&(e.clearcoatNormalMap.value=t.clearcoatNormalMap,n(t.clearcoatNormalMap,e.clearcoatNormalMapTransform),e.clearcoatNormalScale.value.copy(t.clearcoatNormalScale),1===t.side&&e.clearcoatNormalScale.value.negate())),t.dispersion>0&&(e.dispersion.value=t.dispersion),t.iridescence>0&&(e.iridescence.value=t.iridescence,e.iridescenceIOR.value=t.iridescenceIOR,e.iridescenceThicknessMinimum.value=t.iridescenceThicknessRange[0],e.iridescenceThicknessMaximum.value=t.iridescenceThicknessRange[1],t.iridescenceMap&&(e.iridescenceMap.value=t.iridescenceMap,n(t.iridescenceMap,e.iridescenceMapTransform)),t.iridescenceThicknessMap&&(e.iridescenceThicknessMap.value=t.iridescenceThicknessMap,n(t.iridescenceThicknessMap,e.iridescenceThicknessMapTransform))),t.transmission>0&&(e.transmission.value=t.transmission,e.transmissionSamplerMap.value=i.texture,e.transmissionSamplerSize.value.set(i.width,i.height),t.transmissionMap&&(e.transmissionMap.value=t.transmissionMap,n(t.transmissionMap,e.transmissionMapTransform)),e.thickness.value=t.thickness,t.thicknessMap&&(e.thicknessMap.value=t.thicknessMap,n(t.thicknessMap,e.thicknessMapTransform)),e.attenuationDistance.value=t.attenuationDistance,e.attenuationColor.value.copy(t.attenuationColor)),t.anisotropy>0&&(e.anisotropyVector.value.set(t.anisotropy*Math.cos(t.anisotropyRotation),t.anisotropy*Math.sin(t.anisotropyRotation)),t.anisotropyMap&&(e.anisotropyMap.value=t.anisotropyMap,n(t.anisotropyMap,e.anisotropyMapTransform))),e.specularIntensity.value=t.specularIntensity,e.specularColor.value.copy(t.specularColor),t.specularColorMap&&(e.specularColorMap.value=t.specularColorMap,n(t.specularColorMap,e.specularColorMapTransform)),t.specularIntensityMap&&(e.specularIntensityMap.value=t.specularIntensityMap,n(t.specularIntensityMap,e.specularIntensityMapTransform))}(e,r,o)):r.isMeshMatcapMaterial?(i(e,r),function(e,t){t.matcap&&(e.matcap.value=t.matcap)}(e,r)):r.isMeshDepthMaterial?i(e,r):r.isMeshDistanceMaterial?(i(e,r),function(e,n){const i=t.get(n).light;e.referencePosition.value.setFromMatrixPosition(i.matrixWorld),e.nearDistance.value=i.shadow.camera.near,e.farDistance.value=i.shadow.camera.far}(e,r)):r.isMeshNormalMaterial?i(e,r):r.isLineBasicMaterial?(function(e,t){e.diffuse.value.copy(t.color),e.opacity.value=t.opacity,t.map&&(e.map.value=t.map,n(t.map,e.mapTransform))}(e,r),r.isLineDashedMaterial&&function(e,t){e.dashSize.value=t.dashSize,e.totalSize.value=t.dashSize+t.gapSize,e.scale.value=t.scale}(e,r)):r.isPointsMaterial?function(e,t,i,r){e.diffuse.value.copy(t.color),e.opacity.value=t.opacity,e.size.value=t.size*i,e.scale.value=.5*r,t.map&&(e.map.value=t.map,n(t.map,e.uvTransform)),t.alphaMap&&(e.alphaMap.value=t.alphaMap,n(t.alphaMap,e.alphaMapTransform)),t.alphaTest>0&&(e.alphaTest.value=t.alphaTest)}(e,r,a,s):r.isSpriteMaterial?function(e,t){e.diffuse.value.copy(t.color),e.opacity.value=t.opacity,e.rotation.value=t.rotation,t.map&&(e.map.value=t.map,n(t.map,e.mapTransform)),t.alphaMap&&(e.alphaMap.value=t.alphaMap,n(t.alphaMap,e.alphaMapTransform)),t.alphaTest>0&&(e.alphaTest.value=t.alphaTest)}(e,r):r.isShadowMaterial?(e.color.value.copy(r.color),e.opacity.value=r.opacity):r.isShaderMaterial&&(r.uniformsNeedUpdate=!1)}}}function Rh(e,t,n,i){let r={},a={},s=[];const o=e.getParameter(e.MAX_UNIFORM_BUFFER_BINDINGS);function l(e,t,n,i){const r=e.value,a=t+"_"+n;if(void 0===i[a])return i[a]="number"==typeof r||"boolean"==typeof r?r:r.clone(),!0;{const e=i[a];if("number"==typeof r||"boolean"==typeof r){if(e!==r)return i[a]=r,!0}else if(!1===e.equals(r))return e.copy(r),!0}return!1}function c(e){const t={boundary:0,storage:0};return"number"==typeof e||"boolean"==typeof e?(t.boundary=4,t.storage=4):e.isVector2?(t.boundary=8,t.storage=8):e.isVector3||e.isColor?(t.boundary=16,t.storage=12):e.isVector4?(t.boundary=16,t.storage=16):e.isMatrix3?(t.boundary=48,t.storage=48):e.isMatrix4?(t.boundary=64,t.storage=64):e.isTexture?console.warn("THREE.WebGLRenderer: Texture samplers can not be part of an uniforms group."):console.warn("THREE.WebGLRenderer: Unsupported uniform value type.",e),t}function h(t){const n=t.target;n.removeEventListener("dispose",h);const i=s.indexOf(n.__bindingPointIndex);s.splice(i,1),e.deleteBuffer(r[n.id]),delete r[n.id],delete a[n.id]}return{bind:function(e,t){const n=t.program;i.uniformBlockBinding(e,n)},update:function(n,d){let u=r[n.id];void 0===u&&(function(e){const t=e.uniforms;let n=0;for(let e=0,i=t.length;e0&&(n+=16-i),e.__size=n,e.__cache={}}(n),u=function(t){const n=function(){for(let e=0;e{(new fs).setResponseType("arraybuffer").load(this._path+e,(e=>{this.parseData_(e),t(this._cubeTexture)}))}))}parseHeader_(e){const t=new DataView(e,0,30);this._size=t.getUint16(0),this._maxLod=t.getUint8(2),this._colorSpace=t.getUint16(3)?We:Ge,this._type=t.getUint16(5),this._format=t.getUint16(7),this._lightDirection.x=t.getFloat32(9),this._lightDirection.y=t.getFloat32(13),this._lightDirection.z=t.getFloat32(17)}parseBufferData_(e,t){let n=this._size;const i=Math.log2(this._size)+1;this._cubeTextures=[];for(let r=0;r{t.isMesh&&(e.add(t.geometry),e.add(t.material))}));for(const t of e)t.dispose()}}function Fh(e){const t=new _i;return t.color.setScalar(e),t}var Bh=Uint8Array,zh=Uint16Array,kh=Int32Array,Hh=new Bh([0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0,0,0,0]),Vh=new Bh([0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13,0,0]),Gh=new Bh([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),Wh=function(e,t){for(var n=new zh(31),i=0;i<31;++i)n[i]=t+=1<>1|(21845&Jh)<<1;Qh=(61680&(Qh=(52428&Qh)>>2|(13107&Qh)<<2))>>4|(3855&Qh)<<4,Kh[Jh]=((65280&Qh)>>8|(255&Qh)<<8)>>1}var $h=function(e,t,n){for(var i=e.length,r=0,a=new zh(t);r>l]=c}else for(s=new zh(i),r=0;r>15-e[r]);return s},ed=new Bh(288);for(Jh=0;Jh<144;++Jh)ed[Jh]=8;for(Jh=144;Jh<256;++Jh)ed[Jh]=9;for(Jh=256;Jh<280;++Jh)ed[Jh]=7;for(Jh=280;Jh<288;++Jh)ed[Jh]=8;var td=new Bh(32);for(Jh=0;Jh<32;++Jh)td[Jh]=5;var nd=$h(ed,9,1),id=$h(td,5,1),rd=function(e){for(var t=e[0],n=1;nt&&(t=e[n]);return t},ad=function(e,t,n){var i=t/8|0;return(e[i]|e[i+1]<<8)>>(7&t)&n},sd=function(e,t){var n=t/8|0;return(e[n]|e[n+1]<<8|e[n+2]<<16)>>(7&t)},od=["unexpected EOF","invalid block type","invalid length/literal","invalid distance","stream finished","no stream handler",,"no callback","invalid UTF-8 data","extra field too long","date not in range 1980-2099","filename too long","stream finishing","invalid zip data"],ld=function(e,t,n){var i=new Error(t||od[e]);if(i.code=e,Error.captureStackTrace&&Error.captureStackTrace(i,ld),!n)throw i;return i},cd=function(e,t,n,i){var r=e.length,a=i?i.length:0;if(!r||t.f&&!t.l)return n||new Bh(0);var s=!n,o=s||2!=t.i,l=t.i;s&&(n=new Bh(3*r));var c,h=function(e){var t=n.length;if(e>t){var i=new Bh(Math.max(2*t,e));i.set(n),n=i}},d=t.f||0,u=t.p||0,p=t.b||0,f=t.l,m=t.d,g=t.m,v=t.n,_=8*r;do{if(!f){d=ad(e,u,1);var x=ad(e,u+1,3);if(u+=3,!x){var y=e[(c=u,(D=4+((c+7)/8|0))-4)]|e[D-3]<<8,S=D+y;if(S>r){l&&ld(0);break}o&&h(p+y),n.set(e.subarray(D,S),p),t.b=p+=y,t.p=u=8*S,t.f=d;continue}if(1==x)f=nd,m=id,g=9,v=5;else if(2==x){var w=ad(e,u,31)+257,b=ad(e,u+10,15)+4,M=w+ad(e,u+5,31)+1;u+=14;for(var T=new Bh(M),E=new Bh(19),A=0;A>4)<16)T[A++]=D;else{var I=0,U=0;for(16==D?(U=3+ad(e,u,3),u+=2,I=T[A-1]):17==D?(U=3+ad(e,u,7),u+=3):18==D&&(U=11+ad(e,u,127),u+=7);U--;)T[A++]=I}}var O=T.subarray(0,w),N=T.subarray(w);g=rd(O),v=rd(N),f=$h(O,g,1),m=$h(N,v,1)}else ld(1);if(u>_){l&&ld(0);break}}o&&h(p+131072);for(var F=(1<>4;if((u+=15&I)>_){l&&ld(0);break}if(I||ld(2),k<256)n[p++]=k;else{if(256==k){z=u,f=null;break}var H=k-254;if(k>264){var V=Hh[A=k-257];H=ad(e,u,(1<>4;if(G||ld(3),u+=15&G,N=Zh[W],W>3&&(V=Vh[W],N+=sd(e,u)&(1<_){l&&ld(0);break}o&&h(p+131072);var j=p+H;if(pe.length)&&(n=e.length),new Bh(e.subarray(t,n))}(n,0,p):n.subarray(0,p)},hd=new Bh(0);function dd(e,t){return cd(e.subarray((n=e,i=t&&t.dictionary,(8!=(15&n[0])||n[0]>>4>7||(n[0]<<8|n[1])%31)&&ld(6,"invalid zlib data"),(n[1]>>5&1)==+!i&&ld(6,"invalid zlib data: "+(32&n[1]?"need":"unexpected")+" dictionary"),2+(n[1]>>3&4)),-4),{i:2},t&&t.out,t&&t.dictionary);var n,i}var ud="undefined"!=typeof TextDecoder&&new TextDecoder;try{ud.decode(hd,{stream:!0})}catch(e){}"function"==typeof queueMicrotask?queueMicrotask:"function"==typeof setTimeout&&setTimeout;class pd extends gs{constructor(e){super(e),this.type=K}parse(e){const t=65536,n=14,i=65537,r=Math.pow(2.7182818,2.2),a={l:0,c:0,lc:0};function s(e,t,n,i,r){for(;n>n&(1<>6}const h={c:0,lc:0};function d(e,t,n,i){e=e<<8|F(n,i),t+=8,h.c=e,h.lc=t}const u={c:0,lc:0};function p(e,t,n,i,r,a,s,o,l){if(e==t){i<8&&(d(n,i,r,a),n=h.c,i=h.lc);let e=n>>(i-=8);if(e=new Uint8Array([e])[0],o.value+e>l)return!1;const t=s[o.value-1];for(;e-- >0;)s[o.value++]=t}else{if(!(o.value32767?t-65536:t}const g={a:0,b:0};function v(e,t){const n=m(e),i=m(t),r=n+(1&i)+(i>>1),a=r,s=r-i;g.a=a,g.b=s}function _(e,t){const n=f(e),i=f(t),r=n-(i>>1)&65535,a=i+r-32768&65535;g.a=a,g.b=r}function x(e,t,n,i,r,a,s){const o=s<16384,l=n>r?r:n;let c,h,d=1;for(;d<=l;)d<<=1;for(d>>=1,c=d,d>>=1;d>=1;){h=0;const s=h+a*(r-c),l=a*d,u=a*c,p=i*d,f=i*c;let m,x,y,S;for(;h<=s;h+=u){let r=h;const a=h+i*(n-c);for(;r<=a;r+=f){const n=r+p,i=r+l,a=i+p;o?(v(e[r+t],e[i+t]),m=g.a,y=g.b,v(e[n+t],e[a+t]),x=g.a,S=g.b,v(m,x),e[r+t]=g.a,e[n+t]=g.b,v(y,S),e[i+t]=g.a,e[a+t]=g.b):(_(e[r+t],e[i+t]),m=g.a,y=g.b,_(e[n+t],e[a+t]),x=g.a,S=g.b,_(m,x),e[r+t]=g.a,e[n+t]=g.b,_(y,S),e[i+t]=g.a,e[a+t]=g.b)}if(n&d){const n=r+l;o?v(e[r+t],e[n+t]):_(e[r+t],e[n+t]),m=g.a,e[n+t]=g.b,e[r+t]=m}}if(r&d){let r=h;const a=h+i*(n-c);for(;r<=a;r+=f){const n=r+p;o?v(e[r+t],e[n+t]):_(e[r+t],e[n+t]),m=g.a,e[n+t]=g.b,e[r+t]=m}}c=d,d>>=1}return h}function y(e,t,r,f,m,g){const v=r.value,_=N(t,r),x=N(t,r);r.value+=4;const y=N(t,r);if(r.value+=4,_<0||_>=i||x<0||x>=i)throw new Error("Something wrong with HUF_ENCSIZE");const S=new Array(i),w=new Array(16384);if(function(e){for(let t=0;t<16384;t++)e[t]={},e[t].len=0,e[t].lit=0,e[t].p=null}(w),function(e,t,n,r,l,c){const h=t;let d=0,u=0;for(;r<=l;r++){if(h.value-t.value>n)return!1;s(6,d,u,e,h);const i=a.l;if(d=a.c,u=a.lc,c[r]=i,63==i){if(h.value-t.value>n)throw new Error("Something wrong with hufUnpackEncTable");s(8,d,u,e,h);let i=a.l+6;if(d=a.c,u=a.lc,r+i>l+1)throw new Error("Something wrong with hufUnpackEncTable");for(;i--;)c[r++]=0;r--}else if(i>=59){let e=i-59+2;if(r+e>l+1)throw new Error("Something wrong with hufUnpackEncTable");for(;e--;)c[r++]=0;r--}}!function(e){for(let e=0;e<=58;++e)o[e]=0;for(let t=0;t0;--e){const n=t+o[e]>>1;o[e]=t,t=n}for(let t=0;t0&&(e[t]=n|o[n]++<<6)}}(c)}(e,r,f-(r.value-v),_,x,S),y>8*(f-(r.value-v)))throw new Error("Something wrong with hufUncompress");!function(e,t,i,r){for(;t<=i;t++){const i=c(e[t]),a=l(e[t]);if(i>>a)throw new Error("Invalid table entry");if(a>n){const e=r[i>>a-n];if(e.len)throw new Error("Invalid table entry");if(e.lit++,e.p){const t=e.p;e.p=new Array(e.lit);for(let n=0;n0;s--){const s=r[(i<=n;){const a=t[g>>v-n&16383];if(a.len)v-=a.len,p(a.lit,s,g,v,i,r,f,m,_),g=u.c,v=u.lc;else{if(!a.p)throw new Error("hufDecode issues");let t;for(t=0;t=n&&c(e[a.p[t]])==(g>>v-n&(1<>=y,v-=y;v>0;){const e=t[g<a||(t[r++]=e[n++],r>a));)t[r++]=e[i++]}function b(e){let t=e.byteLength;const n=new Array;let i=0;const r=new DataView(e);for(;t>0;){const e=r.getInt8(i++);if(e<0){const a=-e;t-=a+1;for(let e=0;e>8==255?r+=255&i:(n[r]=i,r++),e.value++}function T(e){const t=.5*Math.cos(.7853975),n=.5*Math.cos(3.14159/16),i=.5*Math.cos(3.14159/8),r=.5*Math.cos(3*3.14159/16),a=.5*Math.cos(.981746875),s=.5*Math.cos(3*3.14159/8),o=.5*Math.cos(1.374445625),l=new Array(4),c=new Array(4),h=new Array(4),d=new Array(4);for(let u=0;u<8;++u){const p=8*u;l[0]=i*e[p+2],l[1]=s*e[p+2],l[2]=i*e[p+6],l[3]=s*e[p+6],c[0]=n*e[p+1]+r*e[p+3]+a*e[p+5]+o*e[p+7],c[1]=r*e[p+1]-o*e[p+3]-n*e[p+5]-a*e[p+7],c[2]=a*e[p+1]-n*e[p+3]+o*e[p+5]+r*e[p+7],c[3]=o*e[p+1]-a*e[p+3]+r*e[p+5]-n*e[p+7],h[0]=t*(e[p+0]+e[p+4]),h[3]=t*(e[p+0]-e[p+4]),h[1]=l[0]+l[3],h[2]=l[1]-l[2],d[0]=h[0]+h[1],d[1]=h[3]+h[2],d[2]=h[3]-h[2],d[3]=h[0]-h[1],e[p+0]=d[0]+c[0],e[p+1]=d[1]+c[1],e[p+2]=d[2]+c[2],e[p+3]=d[3]+c[3],e[p+4]=d[3]-c[3],e[p+5]=d[2]-c[2],e[p+6]=d[1]-c[1],e[p+7]=d[0]-c[0]}for(let u=0;u<8;++u)l[0]=i*e[16+u],l[1]=s*e[16+u],l[2]=i*e[48+u],l[3]=s*e[48+u],c[0]=n*e[8+u]+r*e[24+u]+a*e[40+u]+o*e[56+u],c[1]=r*e[8+u]-o*e[24+u]-n*e[40+u]-a*e[56+u],c[2]=a*e[8+u]-n*e[24+u]+o*e[40+u]+r*e[56+u],c[3]=o*e[8+u]-a*e[24+u]+r*e[40+u]-n*e[56+u],h[0]=t*(e[u]+e[32+u]),h[3]=t*(e[u]-e[32+u]),h[1]=l[0]+l[3],h[2]=l[1]-l[2],d[0]=h[0]+h[1],d[1]=h[3]+h[2],d[2]=h[3]-h[2],d[3]=h[0]-h[1],e[0+u]=d[0]+c[0],e[8+u]=d[1]+c[1],e[16+u]=d[2]+c[2],e[24+u]=d[3]+c[3],e[32+u]=d[3]-c[3],e[40+u]=d[2]-c[2],e[48+u]=d[1]-c[1],e[56+u]=d[0]-c[0]}function E(e){for(let t=0;t<64;++t){const n=e[0][t],i=e[1][t],r=e[2][t];e[0][t]=n+1.5747*r,e[1][t]=n-.1873*i-.4682*r,e[2][t]=n+1.8556*i}}function A(e,t,n){for(let a=0;a<64;++a)t[n+a]=Si.toHalfFloat((i=e[a])<=1?Math.sign(i)*Math.pow(Math.abs(i),2.2):Math.sign(i)*Math.pow(r,Math.abs(i)-1));var i}function P(e){return new DataView(e.array.buffer,e.offset.value,e.size)}function R(e){const t=e.viewer.buffer.slice(e.offset.value,e.offset.value+e.size),n=new Uint8Array(b(t)),i=new Uint8Array(n.length);return S(n),w(n,i),new DataView(i.buffer)}function C(e){const t=dd(e.array.slice(e.offset.value,e.offset.value+e.size)),n=new Uint8Array(t.length);return S(t),w(t,n),new DataView(n.buffer)}function D(e){const n=e.viewer,i={value:e.offset.value},r=new Uint16Array(e.columns*e.lines*(e.inputChannels.length*e.type)),a=new Uint8Array(8192);let s=0;const o=new Array(e.inputChannels.length);for(let t=0,n=e.inputChannels.length;t=8192)throw new Error("Something is wrong with PIZ_COMPRESSION BITMAP_SIZE");if(l<=c)for(let e=0;e>3]&1<<(7&r))&&(n[i++]=r);const r=i-1;for(;i0;){const e=U(t.buffer,n),i=B(t,n),r=i>>2&3,o=new Int8Array([(i>>4)-1])[0],l=B(t,n);a.push({name:e,index:o,type:l,compression:r}),s-=e.length+3}const o=te.channels,l=new Array(e.inputChannels.length);for(let t=0;t=0&&(c.idx[i.index]=t),e.offset=t)}}let h,d,u;if(r.acCompressedSize>0)switch(r.acCompression){case 0:h=new Uint16Array(r.totalAcUncompressedCount),y(e.array,t,n,r.acCompressedSize,h,r.totalAcUncompressedCount);break;case 1:const i=dd(e.array.slice(n.value,n.value+r.totalAcUncompressedCount));h=new Uint16Array(i.buffer),n.value+=r.totalAcUncompressedCount}if(r.dcCompressedSize>0){const t={array:e.array,offset:n,size:r.dcCompressedSize};d=new Uint16Array(C(t).buffer),n.value+=r.dcCompressedSize}r.rleRawSize>0&&(u=b(dd(e.array.slice(n.value,n.value+r.rleCompressedSize)).buffer),n.value+=r.rleCompressedSize);let p=0;const f=new Array(l.length);for(let e=0;e>10,n=1023&e;return(e>>15?-1:1)*(t?31===t?n?NaN:1/0:Math.pow(2,t-15)*(1+n/1024):n/1024*6103515625e-14)}function G(e,t){const n=e.getUint16(t.value,!0);return t.value+=2,n}function W(e,t){return V(G(e,t))}function j(e,t,n,i,r){return"string"===i||"stringvector"===i||"iccProfile"===i?function(e,t,n){const i=(new TextDecoder).decode(new Uint8Array(e).slice(t.value,t.value+n));return t.value=t.value+n,i}(t,n,r):"chlist"===i?function(e,t,n,i){const r=n.value,a=[];for(;n.value>4]}}(e,n):"lineOrder"===i?function(e,t){return["INCREASING_Y","DECREASING_Y","RANDOM_Y"][B(e,t)]}(e,n):"float"===i?k(e,n):"v2f"===i?function(e,t){return[k(e,t),k(e,t)]}(e,n):"v3f"===i?function(e,t){return[k(e,t),k(e,t),k(e,t)]}(e,n):"int"===i?O(e,n):"rational"===i?function(e,t){return[O(e,t),N(e,t)]}(e,n):"timecode"===i?function(e,t){return[N(e,t),N(e,t)]}(e,n):"preview"===i?(n.value+=r,"skipped"):void(n.value+=r)}function X(e,t,n,i){const r=new Array(e);for(let a=0;ae.width?e.width-a:e.blockWidth,e.lines=s+e.blockHeight>e.height?e.height-s:e.blockHeight;const o=e.columns*e.totalBytes,l=e.sizee.height?e.height-r:e.blockHeight;const a=e.columns*e.totalBytes,s=e.size=e.height)continue;const l=t*a,c=(e.height-1-o)*e.outLineWidth;for(let t=0;te:a.scanOrder=e=>a.height-1-e,4==a.outputChannels?(a.format=ee,a.colorSpace=We):(a.format=ie,a.colorSpace=Ve),e.spec.singleTile){a.blockHeight=e.tiles.ySize,a.blockWidth=e.tiles.xSize;const n=function(e,t,n){let i=0;switch(e.levelMode){case"ONE_LEVEL":i=1;break;case"MIPMAP_LEVELS":i=function(e,t){const n=Math.log2(e);return"ROUND_DOWN"==t?Math.floor(n):Math.ceil(n)}(Math.max(t,n),e.roundingMode)+1;break;case"RIPMAP_LEVELS":throw new Error("THREE.EXRLoader: RIPMAP_LEVELS tiles currently unsupported.")}return i}(e.tiles,a.width,a.height),r=X(n,a.width,e.tiles.xSize,e.tiles.roundingMode),s=X(n,a.height,e.tiles.ySize,e.tiles.roundingMode);a.tileCount=r[0]*s[0];for(let e=0;e(r=o.indexOf("\n"))&&a=e.byteLength||!(l=n(e)))&&t(1,"no header found"),(c=l.match(/^#\?(\S+)/))||t(3,"bad initial token"),o.valid|=1,o.programtype=c[1],o.string+=l+"\n";l=n(e),!1!==l;)if(o.string+=l+"\n","#"!==l.charAt(0)){if((c=l.match(i))&&(o.gamma=parseFloat(c[1])),(c=l.match(r))&&(o.exposure=parseFloat(c[1])),(c=l.match(a))&&(o.valid|=2,o.format=c[1]),(c=l.match(s))&&(o.valid|=4,o.height=parseInt(c[1],10),o.width=parseInt(c[2],10)),2&o.valid&&4&o.valid)break}else o.comments+=l+"\n";return 2&o.valid||t(3,"missing format specifier"),4&o.valid||t(3,"missing image size specifier"),o}(a),o=s.width,l=s.height,c=function(e,n,i){const r=n;if(r<8||r>32767||2!==e[0]||2!==e[1]||128&e[2])return new Uint8Array(e);r!==(e[2]<<8|e[3])&&t(3,"wrong scanline width");const a=new Uint8Array(4*n*i);a.length||t(4,"unable to allocate buffer space");let s=0,o=0;const l=4*r,c=new Uint8Array(4),h=new Uint8Array(l);let d=i;for(;d>0&&oe.byteLength&&t(1),c[0]=e[o++],c[1]=e[o++],c[2]=e[o++],c[3]=e[o++],2==c[0]&&2==c[1]&&(c[2]<<8|c[3])==r||t(3,"bad rgbe scanline format");let n,i=0;for(;i128;if(r&&(n-=128),(0===n||i+n>l)&&t(3,"bad scanline data"),r){const t=e[o++];for(let e=0;e0?this.environmentName:r),s=this.currentEnvironment!==a;return this.showBackground=null!==(i=null==t?void 0:t.showEnvironment)&&void 0!==i&&i,this.currentEnvironment=a,this.currentEnvironment&&(null==t?void 0:t.environmentRotation)&&(this.currentEnvironment.rotation=t.environmentRotation),this.currentEnvironment&&(null==t?void 0:t.environmentIntensity)&&(this.currentEnvironment.intensity=t.environmentIntensity),e.userData.showEnvironmentBackground=this.showBackground,e.userData.environmentDefinition=this.currentEnvironment,s}loadDefaultEnvironment(e,t,n){var i;const r=null!=n?n:"room environment",a=null!==(i=t&&t())&&void 0!==i?i:new md;this.environemtMap.set(r,new Uh(a)),e&&(this.environmentName=r),this.updateUI()}loadEnvmap(e,t,n){this.loadAndSetCubeTexture((t=>{this.environemtMap.set(e,new Uh(t)),n&&(this.environmentName=e),this.updateUI()}),t)}loadExr(e,t,n){this.loadExrAndSetTexture(((t,i)=>{this.environemtMap.set(e,new Uh(t,{textureData:i})),n&&(this.environmentName=e),this.updateUI()}),t)}loadHdr(e,t,n){this.loadHdrAndSetTexture(((t,i)=>{this.environemtMap.set(e,new Uh(t,{textureData:i})),n&&(this.environmentName=e),this.updateUI()}),t)}loadAndSetCubeTexture(e,t){t&&(this.envMapReader||(this.envMapReader=new Oh),this.envMapReader.load(t).then((t=>{t&&e(t)})))}loadExrAndSetTexture(e,t){t&&(this.exrLoader||(this.exrLoader=new pd),this.exrLoader.load(t,((t,n)=>{e(t,n)})))}loadHdrAndSetTexture(e,t){t&&(this.rgbeLoader||(this.rgbeLoader=new fd),this.rgbeLoader.load(t,((t,n)=>{e(t,n)})))}addGUI(e){this.uiFolder=e,this.updateUI()}updateUI(){if(this.uiFolder){const e=Array.from(this.environemtMap.keys());if(this.environmentController){let t="";e.forEach((e=>{t+=``})),this.environmentController.domElement.children[0].innerHTML=t,this.environmentController.setValue(this.environmentName),this.environmentController.updateDisplay()}else this.environmentController=this.uiFolder.add(this,"environmentName",e)}}}class vd extends Yi{constructor(){const e=vd.SkyShader,t=new er({name:e.name,uniforms:$i.clone(e.uniforms),vertexShader:e.vertexShader,fragmentShader:e.fragmentShader,side:1,depthWrite:!1});super(new Zi(1,1,1),t),this.isSky=!0}}vd.SkyShader={name:"SkyShader",uniforms:{turbidity:{value:2},rayleigh:{value:1},mieCoefficient:{value:.005},mieDirectionalG:{value:.8},sunPosition:{value:new jt},up:{value:new jt(0,1,0)}},vertexShader:"\n\t\tuniform vec3 sunPosition;\n\t\tuniform float rayleigh;\n\t\tuniform float turbidity;\n\t\tuniform float mieCoefficient;\n\t\tuniform vec3 up;\n\n\t\tvarying vec3 vWorldPosition;\n\t\tvarying vec3 vSunDirection;\n\t\tvarying float vSunfade;\n\t\tvarying vec3 vBetaR;\n\t\tvarying vec3 vBetaM;\n\t\tvarying float vSunE;\n\n\t\t// constants for atmospheric scattering\n\t\tconst float e = 2.71828182845904523536028747135266249775724709369995957;\n\t\tconst float pi = 3.141592653589793238462643383279502884197169;\n\n\t\t// wavelength of used primaries, according to preetham\n\t\tconst vec3 lambda = vec3( 680E-9, 550E-9, 450E-9 );\n\t\t// this pre-calcuation replaces older TotalRayleigh(vec3 lambda) function:\n\t\t// (8.0 * pow(pi, 3.0) * pow(pow(n, 2.0) - 1.0, 2.0) * (6.0 + 3.0 * pn)) / (3.0 * N * pow(lambda, vec3(4.0)) * (6.0 - 7.0 * pn))\n\t\tconst vec3 totalRayleigh = vec3( 5.804542996261093E-6, 1.3562911419845635E-5, 3.0265902468824876E-5 );\n\n\t\t// mie stuff\n\t\t// K coefficient for the primaries\n\t\tconst float v = 4.0;\n\t\tconst vec3 K = vec3( 0.686, 0.678, 0.666 );\n\t\t// MieConst = pi * pow( ( 2.0 * pi ) / lambda, vec3( v - 2.0 ) ) * K\n\t\tconst vec3 MieConst = vec3( 1.8399918514433978E14, 2.7798023919660528E14, 4.0790479543861094E14 );\n\n\t\t// earth shadow hack\n\t\t// cutoffAngle = pi / 1.95;\n\t\tconst float cutoffAngle = 1.6110731556870734;\n\t\tconst float steepness = 1.5;\n\t\tconst float EE = 1000.0;\n\n\t\tfloat sunIntensity( float zenithAngleCos ) {\n\t\t\tzenithAngleCos = clamp( zenithAngleCos, -1.0, 1.0 );\n\t\t\treturn EE * max( 0.0, 1.0 - pow( e, -( ( cutoffAngle - acos( zenithAngleCos ) ) / steepness ) ) );\n\t\t}\n\n\t\tvec3 totalMie( float T ) {\n\t\t\tfloat c = ( 0.2 * T ) * 10E-18;\n\t\t\treturn 0.434 * c * MieConst;\n\t\t}\n\n\t\tvoid main() {\n\n\t\t\tvec4 worldPosition = modelMatrix * vec4( position, 1.0 );\n\t\t\tvWorldPosition = worldPosition.xyz;\n\n\t\t\tgl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n\t\t\tgl_Position.z = gl_Position.w; // set z to camera.far\n\n\t\t\tvSunDirection = normalize( sunPosition );\n\n\t\t\tvSunE = sunIntensity( dot( vSunDirection, up ) );\n\n\t\t\tvSunfade = 1.0 - clamp( 1.0 - exp( ( sunPosition.y / 450000.0 ) ), 0.0, 1.0 );\n\n\t\t\tfloat rayleighCoefficient = rayleigh - ( 1.0 * ( 1.0 - vSunfade ) );\n\n\t\t\t// extinction (absorbtion + out scattering)\n\t\t\t// rayleigh coefficients\n\t\t\tvBetaR = totalRayleigh * rayleighCoefficient;\n\n\t\t\t// mie coefficients\n\t\t\tvBetaM = totalMie( turbidity ) * mieCoefficient;\n\n\t\t}",fragmentShader:"\n\t\tvarying vec3 vWorldPosition;\n\t\tvarying vec3 vSunDirection;\n\t\tvarying float vSunfade;\n\t\tvarying vec3 vBetaR;\n\t\tvarying vec3 vBetaM;\n\t\tvarying float vSunE;\n\n\t\tuniform float mieDirectionalG;\n\t\tuniform vec3 up;\n\n\t\t// constants for atmospheric scattering\n\t\tconst float pi = 3.141592653589793238462643383279502884197169;\n\n\t\tconst float n = 1.0003; // refractive index of air\n\t\tconst float N = 2.545E25; // number of molecules per unit volume for air at 288.15K and 1013mb (sea level -45 celsius)\n\n\t\t// optical length at zenith for molecules\n\t\tconst float rayleighZenithLength = 8.4E3;\n\t\tconst float mieZenithLength = 1.25E3;\n\t\t// 66 arc seconds -> degrees, and the cosine of that\n\t\tconst float sunAngularDiameterCos = 0.999956676946448443553574619906976478926848692873900859324;\n\n\t\t// 3.0 / ( 16.0 * pi )\n\t\tconst float THREE_OVER_SIXTEENPI = 0.05968310365946075;\n\t\t// 1.0 / ( 4.0 * pi )\n\t\tconst float ONE_OVER_FOURPI = 0.07957747154594767;\n\n\t\tfloat rayleighPhase( float cosTheta ) {\n\t\t\treturn THREE_OVER_SIXTEENPI * ( 1.0 + pow( cosTheta, 2.0 ) );\n\t\t}\n\n\t\tfloat hgPhase( float cosTheta, float g ) {\n\t\t\tfloat g2 = pow( g, 2.0 );\n\t\t\tfloat inverse = 1.0 / pow( 1.0 - 2.0 * g * cosTheta + g2, 1.5 );\n\t\t\treturn ONE_OVER_FOURPI * ( ( 1.0 - g2 ) * inverse );\n\t\t}\n\n\t\tvoid main() {\n\n\t\t\tvec3 direction = normalize( vWorldPosition - cameraPosition );\n\n\t\t\t// optical length\n\t\t\t// cutoff angle at 90 to avoid singularity in next formula.\n\t\t\tfloat zenithAngle = acos( max( 0.0, dot( up, direction ) ) );\n\t\t\tfloat inverse = 1.0 / ( cos( zenithAngle ) + 0.15 * pow( 93.885 - ( ( zenithAngle * 180.0 ) / pi ), -1.253 ) );\n\t\t\tfloat sR = rayleighZenithLength * inverse;\n\t\t\tfloat sM = mieZenithLength * inverse;\n\n\t\t\t// combined extinction factor\n\t\t\tvec3 Fex = exp( -( vBetaR * sR + vBetaM * sM ) );\n\n\t\t\t// in scattering\n\t\t\tfloat cosTheta = dot( direction, vSunDirection );\n\n\t\t\tfloat rPhase = rayleighPhase( cosTheta * 0.5 + 0.5 );\n\t\t\tvec3 betaRTheta = vBetaR * rPhase;\n\n\t\t\tfloat mPhase = hgPhase( cosTheta, mieDirectionalG );\n\t\t\tvec3 betaMTheta = vBetaM * mPhase;\n\n\t\t\tvec3 Lin = pow( vSunE * ( ( betaRTheta + betaMTheta ) / ( vBetaR + vBetaM ) ) * ( 1.0 - Fex ), vec3( 1.5 ) );\n\t\t\tLin *= mix( vec3( 1.0 ), pow( vSunE * ( ( betaRTheta + betaMTheta ) / ( vBetaR + vBetaM ) ) * Fex, vec3( 1.0 / 2.0 ) ), clamp( pow( 1.0 - dot( up, vSunDirection ), 5.0 ), 0.0, 1.0 ) );\n\n\t\t\t// nightsky\n\t\t\tfloat theta = acos( direction.y ); // elevation --\x3e y-axis, [-pi/2, pi/2]\n\t\t\tfloat phi = atan( direction.z, direction.x ); // azimuth --\x3e x-axis [-pi/2, pi/2]\n\t\t\tvec2 uv = vec2( phi, theta ) / vec2( 2.0 * pi, pi ) + vec2( 0.5, 0.0 );\n\t\t\tvec3 L0 = vec3( 0.1 ) * Fex;\n\n\t\t\t// composition + solar disc\n\t\t\tfloat sundisk = smoothstep( sunAngularDiameterCos, sunAngularDiameterCos + 0.00002, cosTheta );\n\t\t\tL0 += ( vSunE * 19000.0 * Fex ) * sundisk;\n\n\t\t\tvec3 texColor = ( Lin + L0 ) * 0.04 + vec3( 0.0, 0.0003, 0.00075 );\n\n\t\t\tvec3 retColor = pow( texColor, vec3( 1.0 / ( 1.2 + ( 1.2 * vSunfade ) ) ) );\n\n\t\t\tgl_FragColor = vec4( retColor, 1.0 );\n\n\t\t\t#include \n\t\t\t#include \n\n\t\t}"};class _d{constructor(e){this.sky=new vd,this.sky.name="Sky",this.parameters=Object.assign({visible:!0,distance:4e5,turbidity:10,rayleigh:2,mieCoefficient:.005,mieDirectionalG:.8,inclination:.6,azimuth:0},e),this.updateSky()}updateParameters(e){for(const t in e)this.parameters.hasOwnProperty(t)&&(this.parameters[t]=e[t])}updateSky(){this.sky.scale.setScalar(45e4),this.sky.frustumCulled=!1,this.sky.material.uniforms.turbidity.value=this.parameters.turbidity,this.sky.material.uniforms.rayleigh.value=this.parameters.rayleigh,this.sky.material.uniforms.mieCoefficient.value=this.parameters.mieCoefficient,this.sky.material.uniforms.mieDirectionalG.value=this.parameters.mieDirectionalG;const e=(t=this.parameters.distance,n=this.parameters.azimuth,i=this.parameters.inclination,(new jt).setFromSphericalCoords(t,Math.PI*(1-i),2*Math.PI*(1-n)));var t,n,i;this.sky.material.uniforms.sunPosition.value.copy(e),this.sky.visible=this.parameters.visible}addToScene(e){e.add(this.sky)}changeVisibility(e){this.parameters.visible!==e&&(this.updateParameters({visible:e}),this.updateSky())}}const xd="None",yd="GridPaper",Sd="Concrete",wd="Marble",bd="Granite",Md="VorocracksMarble",Td="Kraft",Ed="Line",Ad="Test";class Pd{get isSet(){return this.parameters.backgroundType!==xd}constructor(e){this._materialMap=new Map;const t=new Oi;t.setAttribute("position",new Ai([-1,3,0,-1,-1,0,3,-1,0],3)),t.setAttribute("uv",new Ai([0,2,0,0,2,0],2)),this.backgroundMesh=new Yi(t),this.backgroundMesh.name="Background",this.parameters=Object.assign({visible:!1,backgroundType:xd},e),this.updateBackground()}_updateParameters(e){for(const t in e)this.parameters.hasOwnProperty(t)&&(this.parameters[t]=e[t])}updateBackground(){this.backgroundMesh.visible=this.parameters.backgroundType!==xd,this.backgroundMaterial=this._getMaterial(),this.backgroundMesh.material=this.backgroundMaterial}update(e,t,n){this.backgroundMesh.visible&&this.backgroundMaterial&&(this.backgroundMaterial.uniforms.viewMatrixInverse.value.copy(n.matrixWorld),this.backgroundMaterial.uniforms.projectionMatrixInverse.value.copy(n.projectionMatrixInverse),this.backgroundMaterial.uniforms.iResolution.value.set(e,t))}addToScene(e){this.backgroundMesh!==e&&e.add(this.backgroundMesh)}hideBackground(){this.parameters.backgroundType!==xd&&(this.parameters.backgroundType=xd,this.updateBackground())}_getMaterial(){let e=this._materialMap.get(this.parameters.backgroundType);if(e)return e;let t=Cd,n={};switch(this.parameters.backgroundType){default:break;case Ad:t=Cd;break;case yd:t=Dd;break;case Sd:t=Ld,n={patternChoice:1};break;case wd:t=Ld,n={patternChoice:3};break;case bd:t=Ld,n={patternChoice:6};break;case Md:t=Id;break;case Td:t=Ud;break;case Ed:t=Od}return e=new er({name:"BackgroundShader",vertexShader:Rd,fragmentShader:t,defines:n,uniforms:{viewMatrixInverse:{value:new wn},projectionMatrixInverse:{value:new wn},scale:{value:8},iResolution:{value:new _t(1024,1024)}},side:2,depthWrite:!1}),this._materialMap.set(this.parameters.backgroundType,e),e}}const Rd="varying vec2 vertexUv;\nuniform mat4 viewMatrixInverse;\nuniform mat4 projectionMatrixInverse;\nuniform float scale;\n\nvoid main() {\n vec4 p = viewMatrixInverse * projectionMatrixInverse * vec4(position.xy, 0.0, 1.0);\n vertexUv = (p.xz / p.w * 0.5 + 0.5) / scale; \n gl_Position = vec4(position.xy, 1.0, 1.0);\n}",Cd="varying vec2 vertexUv;\nvoid main() {\n vec2 uv = fract(vertexUv);\n gl_FragColor = vec4(uv.x, uv.y, (1.0-uv.x) * (1.0 - uv.y), 1.0);\n}",Dd="varying vec2 vertexUv;\nuniform vec2 iResolution;\nfloat nsin(float a)\n{\n return (sin(a)+1.)/2.;\n}\nfloat rand(float n)\n{\n \treturn fract(cos(n*89.42)*343.42);\n}\nvec2 rand(vec2 n)\n{\n \treturn vec2(rand(n.x*23.62-300.0+n.y*34.35),rand(n.x*45.13+256.0+n.y*38.89)); \n}\n\n// returns (dx, dy, distance)\nvec3 worley(vec2 n,float s)\n{\n vec3 ret = vec3(s * 10.);\n // look in 9 cells (n, plus 8 surrounding)\n for(int x = -1;x<2;x++)\n {\n for(int y = -1;y<2;y++)\n {\n vec2 xy = vec2(x,y);// xy can be thought of as both # of cells distance to n, and \n vec2 cellIndex = floor(n/s) + xy;\n vec2 worleyPoint = rand(cellIndex);// random point in this cell (0-1)\n worleyPoint += xy - fract(n/s);// turn it into distance to n. ;\n float d = length(worleyPoint) * s;\n if(d < ret.z)\n ret = vec3(worleyPoint, d);\n }\n }\n return ret;\n}\n\nvec2 mouse = vec2(1.);// how do i initialize this??\n\nvec4 applyLighting(vec4 inpColor, vec2 uv, vec3 normal, vec3 LightPos, vec4 LightColor, vec4 AmbientColor)\n{\n // if(distance(uv.xy, LightPos.xy) < 0.01) return vec4(1.,0.,0.,1.);\n vec3 LightDir = vec3(LightPos.xy - uv, LightPos.z);\n vec3 N = normalize(normal);\n vec3 L = normalize(LightDir);\n vec3 Diffuse = (LightColor.rgb * LightColor.a) * max(dot(N, L), 0.0);\n vec3 Ambient = AmbientColor.rgb * AmbientColor.a;\n vec3 Intensity = Ambient + Diffuse;\n vec3 FinalColor = inpColor.rgb * Intensity;\n return vec4(FinalColor, inpColor.a);\n}\n\n// convert distance to alpha value (see https://www.shadertoy.com/view/ltBGzt)\nfloat dtoa(float d)\n{\n const float amount = 800.0;\n return clamp(1.0 / (clamp(d, 1.0/amount, 1.0)*amount), 0.,1.);\n}\n\n// distance to edge of grid line. real distance, and centered over its position.\nfloat grid_d(vec2 uv, vec2 gridSize, float gridLineWidth)\n{\n uv += gridLineWidth / 2.0;\n uv = mod(uv, gridSize);\n vec2 halfRemainingSpace = (gridSize - gridLineWidth) / 2.0;\n uv -= halfRemainingSpace + gridLineWidth;\n uv = abs(uv);\n uv = -(uv - halfRemainingSpace);\n return min(uv.x, uv.y);\n}\n// centered over lineposy\nfloat hline_d(vec2 uv, float lineposy, float lineWidth)\n{\n\treturn distance(uv.y, lineposy) - (lineWidth / 2.0);\n}\n// centered over lineposx\nfloat vline_d(vec2 uv, float lineposx, float lineWidth)\n{\n\treturn distance(uv.x, lineposx) - (lineWidth / 2.0);\n}\nfloat circle_d(vec2 uv, vec2 center, float radius)\n{\n\treturn length(uv - center) - radius;\n}\n\n// not exactly perfectly perfect, but darn close\nfloat pointRectDist(vec2 p, vec2 rectTL, vec2 rectBR)\n{\n float dx = max(max(rectTL.x - p.x, 0.), p.x - rectBR.x);\n float dy = max(max(rectTL.y - p.y, 0.), p.y - rectBR.y);\n return max(dx, dy);\n}\n\n\nvec2 getuv(vec2 fragCoord, vec2 newTL, vec2 newSize, out float distanceToVisibleArea, out float vignetteAmt)\n{\n vec2 ret = vec2(fragCoord.x / iResolution.x, (iResolution.y - fragCoord.y) / iResolution.y);// ret is now 0-1 in both dimensions\n \n // warp\n //ret = tvWarp(ret / 2.) * 2.;// scale it by 2.\n distanceToVisibleArea = pointRectDist(ret, vec2(0.0), vec2(1.));\n\n // vignette\n vec2 vignetteCenter = vec2(0.5, 0.5);\n\tvignetteAmt = 1.0 - distance(ret, vignetteCenter);\n vignetteAmt = 0.03 + pow(vignetteAmt, .25);// strength\n vignetteAmt = clamp(vignetteAmt, 0.,1.);\n \n \n ret *= newSize;// scale up to new dimensions\n float aspect = iResolution.x / iResolution.y;\n ret.x *= aspect;// orig aspect ratio\n float newWidth = newSize.x * aspect;\n return ret + vec2(newTL.x - (newWidth - newSize.x) / 2.0, newTL.y);\n}\n\nvec4 drawHole(vec4 inpColor, vec2 uv, vec2 pos)\n{\n vec4 circleWhiteColor = vec4(vec3(0.95), 1.);\n\tfloat d = circle_d(uv, pos, 0.055);\n return vec4(mix(inpColor.rgb, circleWhiteColor.rgb, circleWhiteColor.a * dtoa(d)), 1.);\n}\n\nvoid main()\n{\n vec4 fragColor;\n vec2 fragCoord = vertexUv.xy * iResolution.yy;\n float distanceToVisibleArea;\n float vignetteAmt;\n\tvec2 uv = getuv(fragCoord, vec2(-1.,1.), vec2(2., -2.), distanceToVisibleArea, vignetteAmt);\n float throwaway;\n //mouse = getuv(iMouse.xy, vec2(-1.,1.), vec2(2., -2.), throwaway, throwaway);\n\n fragColor = vec4(0.94, 0.96, 0.78, 1.0);// background\n float d;\n \n // grid\n vec4 gridColor = vec4(0.2,0.4,.9, 0.35);\n\td = grid_d(uv, vec2(0.10), 0.001);\n\tfragColor = vec4(mix(fragColor.rgb, gridColor.rgb, gridColor.a * dtoa(d)), 1.);\n \n // red h line\n //vec4 hlineColor = vec4(0.8,0.,.2, 0.55);\n\t//d = hline_d(uv, 0.60, 0.003);\n\t//fragColor = vec4(mix(fragColor.rgb, hlineColor.rgb, hlineColor.a * dtoa(d)), 1.);\n \n // red v line\n //vec4 vlineColor = vec4(0.8,0.,.2, 0.55);\n\t//d = vline_d(uv, -1.40, 0.003);\n\t//fragColor = vec4(mix(fragColor.rgb, vlineColor.rgb, vlineColor.a * dtoa(d)), 1.);\n\n \n // fractal worley crumpled paper effect\n float wsize = 0.8;\n const int iterationCount = 6;\n vec2 normal = vec2(0.);\n float influenceFactor = 1.0;\n for(int i = 0; i < iterationCount; ++ i)\n {\n vec3 w = worley(uv, wsize);\n\t\tnormal.xy += influenceFactor * w.xy;\n wsize *= 0.5;\n influenceFactor *= 0.9;\n }\n \n // lighting\n //vec3 lightPos = vec3(mouse, 8.);\n //vec4 lightColor = vec4(vec3(0.99),0.6);\n //vec4 ambientColor = vec4(vec3(0.99),0.5);\n\t//fragColor = applyLighting(fragColor, uv, vec3(normal, 4.0), lightPos, lightColor, ambientColor);\n\n // white circles\n //fragColor = drawHole(fragColor, uv, vec2(-1.6, 0.2));\n\t//fragColor = drawHole(fragColor, uv, vec2(-1.6, -.7));\n \n // post effects\n\t//fragColor.rgb *= vignetteAmt;\n gl_FragColor = fragColor;\n}",Ld="varying vec2 vertexUv;\nuniform vec2 iResolution;\nuniform float iTime;\n\n// Solid Colors\nvec3 red = vec3(1.0,0.0,0.0);\nvec3 green = vec3(0.0,1.0,0.0);\nvec3 blue = vec3(0.0,0.0,1.0);\nvec3 black = vec3(0.0,0.0,0.0);\nvec3 white = vec3(1.0,1.0,1.0);\n// Concrete\nvec3 concreteLite = vec3(0.909, 0.905, 0.917);\nvec3 concreteDark = vec3(0.760, 0.729, 0.647);\n// Lava\nvec3 lavaLite = vec3(0.686, 0.203, 0.160);\nvec3 lavaDark = vec3(0.580, 0.176, 0.117);\n// Marble\nvec3 marbleLite = vec3(0.988, 0.988, 0.988);\nvec3 marbleStainBlue1 = vec3(0.690, 0.760, 0.811);\nvec3 marbleStainBlue2 = vec3(0.647, 0.745, 0.803);\nvec3 marbleStainBlue3 = vec3(0.654, 0.756, 0.772);\n// Lava Lamp\nvec3 lavaLampBG = vec3(0.462, 0.266, 0.6);\nvec3 lavaLampLava = vec3(0.929, 0.203, 0.572);\n// Clouds\nvec3 sky = vec3(0.541, 0.729, 0.827);\nvec3 cloud = vec3(0.941, 0.945, 0.941);\n// Granite\nvec3 graniteBG = vec3(0.956, 0.952, 0.976);\nvec3 graniteGray = vec3(0.478, 0.474, 0.494);\nvec3 graniteBrown = vec3(0.4, 0.356, 0.341);\nvec3 graniteBlack = vec3(0.105, 0.121, 0.160);\n\n// Tartan\nvec3 tar1Blue = vec3(0.074, 0.349, 0.505);\nvec3 tar1Green = vec3(0.286, 0.541, 0.341);\nvec3 tar1White = vec3(1.0,1.0,1.0);\nvec3 tar1Black = vec3(0.0,0.0,0.0);\nvec3 tar1BG = vec3(0.062, 0.274, 0.109);\n\n// Tartan 2\nvec3 tar2BG = vec3(0.152, 0.160, 0.156);\nvec3 tar2Blue = vec3(0.176, 0.501, 0.674);\nvec3 tar2Orange = vec3(0.603, 0.407, 0.309);\n\n// Art Installation\nvec3 violet = vec3(0.662, 0.407, 0.870);\nvec3 yellow = vec3(0.968, 0.752, 0.556);\n\n\nfloat random (in vec2 uv) {\n return fract(sin(dot(uv.xy,\n vec2(12.9898,78.233)))*\n 43758.5453123);\n}\n\n// Based on Morgan McGuire @morgan3d\n// https://www.shadertoy.com/view/4dS3Wd\nfloat noise (in vec2 uv) {\n vec2 i = floor(uv);\n vec2 f = fract(uv);\n\n // Four corners in 2D of a tile\n float a = random(i);\n float b = random(i + vec2(1.0, 0.0));\n float c = random(i + vec2(0.0, 1.0));\n float d = random(i + vec2(1.0, 1.0));\n\n vec2 u = f * f * (3.0 - 2.0 * f);\n\n return mix(a, b, u.x) +\n (c - a)* u.y * (1.0 - u.x) +\n (d - b) * u.x * u.y;\n}\n\n#define OCTAVES 6\nfloat fbm (in vec2 uv) {\n // Initial values\n float value = 0.0;\n float amplitud = .5;\n float frequency = 0.;\n //\n // Loop of octaves\n for (int i = 0; i < OCTAVES; i++) {\n value += amplitud * noise(uv);\n uv *= 2.;\n amplitud *= .5;\n }\n return value;\n}\n\n// Simplex noise\nvec3 mod289(vec3 x) { return x - floor(x * (1.0 / 289.0)) * 289.0; }\nvec2 mod289(vec2 x) { return x - floor(x * (1.0 / 289.0)) * 289.0; }\nvec3 permute(vec3 x) { return mod289(((x*34.0)+1.0)*x); }\n\nfloat snoise(vec2 v) {\n const vec4 C = vec4(0.211324865405187, // (3.0-sqrt(3.0))/6.0\n 0.366025403784439, // 0.5*(sqrt(3.0)-1.0)\n -0.577350269189626, // -1.0 + 2.0 * C.x\n 0.024390243902439); // 1.0 / 41.0\n vec2 i = floor(v + dot(v, C.yy) );\n vec2 x0 = v - i + dot(i, C.xx);\n vec2 i1;\n i1 = (x0.x > x0.y) ? vec2(1.0, 0.0) : vec2(0.0, 1.0);\n vec4 x12 = x0.xyxy + C.xxzz;\n x12.xy -= i1;\n i = mod289(i); // Avoid truncation effects in permutation\n vec3 p = permute( permute( i.y + vec3(0.0, i1.y, 1.0 ))\n + i.x + vec3(0.0, i1.x, 1.0 ));\n\n vec3 m = max(0.5 - vec3(dot(x0,x0), dot(x12.xy,x12.xy), dot(x12.zw,x12.zw)), 0.0);\n m = m*m ;\n m = m*m ;\n vec3 x = 2.0 * fract(p * C.www) - 1.0;\n vec3 h = abs(x) - 0.5;\n vec3 ox = floor(x + 0.5);\n vec3 a0 = x - ox;\n m *= 1.79284291400159 - 0.85373472095314 * ( a0*a0 + h*h );\n vec3 g;\n g.x = a0.x * x0.x + h.x * x0.y;\n g.yz = a0.yz * x12.xz + h.yz * x12.yw;\n return 130.0 * dot(m, g);\n}\n\nfloat lavaLamp(vec2 uv,vec2 shapePos, float times){\n shapePos = vec2(shapePos.x*1.5,shapePos.y*0.3);\n uv -= shapePos;\n \n float angle = atan(uv.y,uv.x);\n float radius = cos(times*angle*0.5);\n return radius;\n}\n\nvec4 rectangle(vec2 uv, vec2 pos, float width, float height, vec3 color) {\n\tfloat t = 0.0;\n\tif ((uv.x > pos.x - width / 2.0) && (uv.x < pos.x + width / 2.0)\n\t\t&& (uv.y > pos.y - height / 2.0) && (uv.y < pos.y + height / 2.0)) {\n\t\tt = 1.0;\n\t}\n\treturn vec4(color, t);\n}\n\nvoid main()\n{\n vec4 fragColor;\n vec2 fragCoord = vertexUv.xy * iResolution.yy;\n\tvec2 uv = fragCoord.xy / iResolution.xy;\n\tfloat ratio = iResolution.x/iResolution.y;\n uv.x *= ratio;\n \n if (patternChoice == 1) // Concrete\n {\n vec3 value = concreteLite;\n \n value = mix(value, concreteDark,random(uv)*0.6);\n value = mix(value, black, random(uv)*0.35);\n \n vec3 stains = vec3(fbm((uv*5.)*2.))*.12;\n \n value = mix(value, concreteLite,(smoothstep(0.03,.12,stains) - smoothstep(.2,.3,stains))*0.3);\n \n\t fragColor = vec4(value, 1.0);\n }\n \n else if (patternChoice == 2) // Lava\n {\n\t\tvec3 value = black;\n \n vec3 stains = vec3(fbm((uv*1.7)*25.))*.75;\n \n float fade = sin(iTime * 5.)+2.5;\n \n value = mix(value, lavaLite, (smoothstep(0.05,0.1,stains) - smoothstep(.17, .22,stains) * fade));\n \n fragColor = vec4(value,1.0);\n }\n \n else if (patternChoice == 3) // Marble\n {\n vec3 value = marbleLite;\n \n vec3 stains = vec3(fbm((uv*1.2)*18.))*.113;\n vec3 stains2 = vec3(fbm((uv*5.)*1.5))*.12;\n \n vec3 stains3 = vec3(fbm((uv)*5.))*.12;\n vec3 stains4 = vec3(fbm((uv*2.)*2.5))*.12;\n \n value = mix(value, marbleStainBlue1,(smoothstep(0.065,0.1,stains) - smoothstep(0.1, 0.8,stains)));\n //value = mix(value, marbleStainBlue2,(smoothstep(0.065,0.1,stains2) - smoothstep(0.1, 0.8,stains2)));\n //value = mix(value, marbleStainBlue3,(smoothstep(0.09,0.1,stains2) - smoothstep(0.2, 0.5,stains2)));\n //value = mix(value, marbleStainBlue2,(smoothstep(0.07,0.1,stains3) - smoothstep(0.1, 0.8,stains3)));\n \n fragColor = vec4(value, 1.0);\n }\n \n else if (patternChoice == 4) // Lava Lamp\n {\n //float value = lavaLamp(uv,vec2(0.,0.5), 3.);\n //vec2 value = vec2(snoise(uv*3.-iTime));\n \t//vec3 color = red*vec3(value, 1.0);\n \n vec3 value = lavaLampBG;\n float lava = lavaLamp(uv*0.5,vec2(snoise(uv*4.-iTime)), 1.);\n \n vec3 color = lavaLampLava*lava;\n value += color;\n \n \n fragColor = vec4(value, 1.0);\n }\n \t\n else if (patternChoice == 5) // Clouds\n {\n uv *= 0.5;\n vec3 value = sky;\n \n vec3 clouds = vec3(fbm((uv*sin(iTime*0.25))*20.))*.12;\n \n value = mix(value, cloud,(smoothstep(0.05,0.1,clouds) - smoothstep(0.1, 0.2,clouds)));\n \n fragColor = vec4(value, 1.0);\n }\n \n else if (patternChoice == 6) // Granite\n {\n \tvec3 value = graniteBG;\n \n uv *= 2.;\n uv += 2.3;\n vec3 layer1 = vec3(fbm((uv*0.6)*18.))*.113;\n uv *= 0.2;\n uv += 0.5;\n vec3 layer2 = vec3(fbm((uv*0.8)*30.))*.117;\n uv *= 2.2;\n uv += 2.5;\n vec3 layer3 = vec3(fbm((uv*0.4)*15.))*.12;\n \n value = mix(value, graniteBlack,(smoothstep(0.04,0.1,layer1) - smoothstep(0.1, 0.8,layer1)));\n value = mix(value, graniteBrown,(smoothstep(0.04,0.1,layer2) - smoothstep(0.1, 0.8,layer2)));\n value = mix(value, graniteGray,(smoothstep(0.072,0.1,layer3) - smoothstep(0.1, 0.8,layer3)));\n \n fragColor = vec4(value, 1.0);\n }\n \n else if (patternChoice == 7) // Scottish Tartan 1\n {\n vec3 value = tar1BG; \n \n uv *= 2.;\n \tuv = fract(uv);\n \n float blackTile = 0.;\n float greenTile = 0.;\n float blueTile = 0.;\n float whiteTile = 0.;\n \n // Blue blocks\n // Horizontal\n \tblueTile += step(0.15, uv.x) - step(0.35, uv.x);\n \tblueTile += step(0.65, uv.x) - step(0.85, uv.x);\n // Vertical\n blueTile += step(0.15, uv.y) - step(0.35, uv.y);\n blueTile += step(0.68, uv.y) - step(0.85, uv.y);\n \n // White lines\n // Vertical\n whiteTile += step(0.0001, uv.x) - step(0.02, uv.x);\n whiteTile += step(0.49, uv.x) - step(0.51, uv.x);\n // Horizontal\n whiteTile += step(0.220, uv.y) - step(0.245, uv.y);\n \twhiteTile += step(0.755, uv.y) - step(0.775, uv.y);\n \n // Black lines\n // Vertical\n blackTile += step(0.10, uv.x) - step(0.11, uv.x);\n blackTile += step(0.12, uv.x) - step(0.13, uv.x);\n blackTile += step(0.14, uv.x) - step(0.15, uv.x);\n blackTile += step(0.18, uv.x) - step(0.19, uv.x);\n blackTile += step(0.2, uv.x) - step(0.21, uv.x);\n blackTile += step(0.29, uv.x) - step(0.3, uv.x);\n blackTile += step(0.31, uv.x) - step(0.32, uv.x);\n blackTile += step(0.35, uv.x) - step(0.36, uv.x);\n blackTile += step(0.37, uv.x) - step(0.38, uv.x);\n blackTile += step(0.39, uv.x) - step(0.4, uv.x);\n blackTile += step(0.59, uv.x) - step(0.6, uv.x);\n blackTile += step(0.61, uv.x) - step(0.62, uv.x);\n blackTile += step(0.63, uv.x) - step(0.64, uv.x);\n blackTile += step(0.68, uv.x) - step(0.69, uv.x);\n blackTile += step(0.7, uv.x) - step(0.71, uv.x);\n blackTile += step(0.77, uv.x) - step(0.78, uv.x);\n blackTile += step(0.8, uv.x) - step(0.81, uv.x);\n blackTile += step(0.85, uv.x) - step(0.86, uv.x);\n blackTile += step(0.87, uv.x) - step(0.88, uv.x);\n blackTile += step(0.89, uv.x) - step(0.9, uv.x);\n // Horizontal\n blackTile += step(0.07, uv.y) - step(0.08, uv.y);\n blackTile += step(0.05, uv.y) - step(0.06, uv.y);\n blackTile += step(0.39, uv.y) - step(0.4, uv.y);\n blackTile += step(0.41, uv.y) - step(0.42, uv.y);\n blackTile += step(0.59, uv.y) - step(0.6, uv.y);\n blackTile += step(0.61, uv.y) - step(0.62, uv.y);\n blackTile += step(0.90, uv.y) - step(0.91, uv.y);\n blackTile += step(0.92, uv.y) - step(0.93, uv.y);\n \n // Apply\n value = mix(value, tar1Blue, vec3(blueTile * noise(uv* 1000.)));\n value = mix(value, tar1White, vec3(whiteTile * noise(uv * 200.)));\n value = mix(value, tar1Black, vec3(blackTile * noise(uv * 200.)));\n \n fragColor = vec4(value, 1.0);\n }\n \n else if (patternChoice == 8) // Scottish Tartan 2\n {\n vec3 value = tar2BG; \n \n uv *= 2.;\n \tuv = fract(uv);\n \n float blackTile = 0.;\n float greenTile = 0.;\n float blueTile = 0.;\n float orangeTile = 0.;\n \n // Blue blocks\n // Horizontal\n \tblueTile += step(0.15, uv.x) - step(0.35, uv.x);\n \tblueTile += step(0.65, uv.x) - step(0.85, uv.x);\n // Vertical\n blueTile += step(0.15, uv.y) - step(0.35, uv.y);\n blueTile += step(0.68, uv.y) - step(0.85, uv.y);\n \n // Orange lines\n // Vertical\n orangeTile += step(0.0001, uv.x) - step(0.02, uv.x);\n orangeTile += step(0.49, uv.x) - step(0.51, uv.x);\n orangeTile += step(0.04, uv.x) - step(0.05, uv.x);\n orangeTile += step(0.97, uv.x) - step(0.98, uv.x);\n orangeTile += step(0.46, uv.x) - step(0.47, uv.x);\n orangeTile += step(0.53, uv.x) - step(0.54, uv.x);\n // Horizontal\n orangeTile += step(0.220, uv.y) - step(0.245, uv.y);\n \torangeTile += step(0.755, uv.y) - step(0.775, uv.y);\n orangeTile += step(0.200, uv.y) - step(0.210, uv.y);\n orangeTile += step(0.255, uv.y) - step(0.265, uv.y);\n orangeTile += step(0.730, uv.y) - step(0.740, uv.y);\n orangeTile += step(0.79, uv.y) - step(0.8, uv.y);\n \n // Apply\n value = mix(value, tar2Blue, vec3(blueTile * noise(uv* 1200.)));\n value = mix(value, tar2Orange, vec3(orangeTile * noise(uv * 200.)));\n \n fragColor = vec4(value, 1.0);\n }\n \n else if (patternChoice == 9) // Art Installation\n {\n vec2 uv2 = fragCoord.xy/iResolution.xy;\n uv2 -= 0.5;\n uv2.x *= 1.6;\n uv2.y *= 1.9;\n \n float dist = length(uv2);\n \n vec2 fragCo = fragCoord.xy;\n vec2 center = iResolution.xy * 0.5;\n float width = iResolution.x * 0.4;\n float height = iResolution.x * 0.2;\n \n vec3 value = mix(violet, yellow, dist);\n \n vec4 finalVal = vec4(value, 1.0);\n \n vec4 rect = rectangle(fragCo, center, width, height, violet);\n \n fragColor = mix(finalVal,rect,rect.a);\n fragColor = finalVal;\n }\n gl_FragColor = fragColor;\n}",Id="varying vec2 vertexUv;\nuniform vec2 iResolution;\nuniform float iTime;\n// variant of Vorocracks: https://shadertoy.com/view/lsVyRy\n// integrated with cracks here: https://www.shadertoy.com/view/Xd3fRN\n\n#define MM 0\n\n#define VARIANT 1 // 1: amplifies Voronoi cell jittering\n#if VARIANT\n float ofs = .5; // jitter Voronoi centers in -ofs ... 1.+ofs\n#else\n float ofs = 0.;\n#endif\n \n//int FAULT = 1; // 0: crest 1: fault\n\nfloat RATIO = 1., // stone length/width ratio\n /* STONE_slope = .3, // 0. .3 .3 -.3\n STONE_height = 1., // 1. 1. .6 .7\n profile = 1., // z = height + slope * dist ^ prof\n */ \n CRACK_depth = 3.,\n CRACK_zebra_scale = 1., // fractal shape of the fault zebra\n CRACK_zebra_amp = .67,\n CRACK_profile = 1., // fault vertical shape 1. .2 \n CRACK_slope = 50., // 10. 1.4\n CRACK_width = .0;\n \n\n// std int hash, inspired from https://www.shadertoy.com/view/XlXcW4\nvec3 hash3( uvec3 x ) \n{\n# define scramble x = ( (x>>8U) ^ x.yzx ) * 1103515245U // GLIB-C const\n scramble; scramble; scramble; \n return vec3(x) / float(0xffffffffU) + 1e-30; // <- eps to fix a windows/angle bug\n}\n\n// === Voronoi =====================================================\n// --- Base Voronoi. inspired by https://www.shadertoy.com/view/MslGD8\n\n#define hash22(p) fract( 18.5453 * sin( p * mat2(127.1,311.7,269.5,183.3)) )\n#define disp(p) ( -ofs + (1.+2.*ofs) * hash22(p) )\n\nvec3 voronoi( vec2 u ) // returns len + id\n{\n vec2 iu = floor(u), v;\n\tfloat m = 1e9,d;\n#if VARIANT\n for( int k=0; k < 25; k++ ) {\n vec2 p = iu + vec2(k%5-2,k/5-2),\n#else\n for( int k=0; k < 9; k++ ) {\n vec2 p = iu + vec2(k%3-1,k/3-1),\n#endif\n o = disp(p),\n \t r = p - u + o;\n\t\td = dot(r,r);\n if( d < m ) m = d, v = r;\n }\n\n return vec3( sqrt(m), v+u );\n}\n\n// --- Voronoi distance to borders. inspired by https://www.shadertoy.com/view/ldl3W8\nvec3 voronoiB( vec2 u ) // returns len + id\n{\n vec2 iu = floor(u), C, P;\n\tfloat m = 1e9,d;\n#if VARIANT\n for( int k=0; k < 25; k++ ) {\n vec2 p = iu + vec2(k%5-2,k/5-2),\n#else\n for( int k=0; k < 9; k++ ) {\n vec2 p = iu + vec2(k%3-1,k/3-1),\n#endif\n o = disp(p),\n \t r = p - u + o;\n\t\td = dot(r,r);\n if( d < m ) m = d, C = p-iu, P = r;\n }\n\n m = 1e9;\n \n for( int k=0; k < 25; k++ ) {\n vec2 p = iu+C + vec2(k%5-2,k/5-2),\n\t\t o = disp(p),\n r = p-u + o;\n\n if( dot(P-r,P-r)>1e-5 )\n m = min( m, .5*dot( (P+r), normalize(r-P) ) );\n }\n\n return vec3( m, P+u );\n}\n\n// === pseudo Perlin noise =============================================\n#define rot(a) mat2(cos(a),-sin(a),sin(a),cos(a))\nint MOD = 1; // type of Perlin noise\n \n// --- 2D\n#define hash21(p) fract(sin(dot(p,vec2(127.1,311.7)))*43758.5453123)\nfloat noise2(vec2 p) {\n vec2 i = floor(p);\n vec2 f = fract(p); f = f*f*(3.-2.*f); // smoothstep\n\n float v= mix( mix(hash21(i+vec2(0,0)),hash21(i+vec2(1,0)),f.x),\n mix(hash21(i+vec2(0,1)),hash21(i+vec2(1,1)),f.x), f.y);\n\treturn MOD==0 ? v\n\t : MOD==1 ? 2.*v-1.\n : MOD==2 ? abs(2.*v-1.)\n : 1.-abs(2.*v-1.);\n}\n\nfloat fbm2(vec2 p) {\n float v = 0., a = .5;\n mat2 R = rot(.37);\n\n for (int i = 0; i < 9; i++, p*=2.,a/=2.) \n p *= R,\n v += a * noise2(p);\n\n return v;\n}\n#define noise22(p) vec2(noise2(p),noise2(p+17.7))\nvec2 fbm22(vec2 p) {\n vec2 v = vec2(0);\n float a = .5;\n mat2 R = rot(.37);\n\n for (int i = 0; i < 6; i++, p*=2.,a/=2.) \n p *= R,\n v += a * noise22(p);\n\n return v;\n}\nvec2 mfbm22(vec2 p) { // multifractal fbm \n vec2 v = vec2(1);\n float a = .5;\n mat2 R = rot(.37);\n\n for (int i = 0; i < 6; i++, p*=2.,a/=2.) \n p *= R,\n //v *= 1.+noise22(p);\n v += v * a * noise22(p);\n\n return v-1.;\n}\n\n/*\n// --- 3D \n#define hash31(p) fract(sin(dot(p,vec3(127.1,311.7, 74.7)))*43758.5453123)\nfloat noise3(vec3 p) {\n vec3 i = floor(p);\n vec3 f = fract(p); f = f*f*(3.-2.*f); // smoothstep\n\n float v= mix( mix( mix(hash31(i+vec3(0,0,0)),hash31(i+vec3(1,0,0)),f.x),\n mix(hash31(i+vec3(0,1,0)),hash31(i+vec3(1,1,0)),f.x), f.y), \n mix( mix(hash31(i+vec3(0,0,1)),hash31(i+vec3(1,0,1)),f.x),\n mix(hash31(i+vec3(0,1,1)),hash31(i+vec3(1,1,1)),f.x), f.y), f.z);\n\treturn MOD==0 ? v\n\t : MOD==1 ? 2.*v-1.\n : MOD==2 ? abs(2.*v-1.)\n : 1.-abs(2.*v-1.);\n}\n\nfloat fbm3(vec3 p) {\n float v = 0., a = .5;\n mat2 R = rot(.37);\n\n for (int i = 0; i < 9; i++, p*=2.,a/=2.) \n p.xy *= R, p.yz *= R,\n v += a * noise3(p);\n\n return v;\n}\n*/\n \n// ======================================================\n\nvoid main()\n{\n vec4 O;\n vec2 U = vertexUv.xy * iResolution.yy;\n U *= 4./iResolution.y;\n U.x += iTime; // for demo\n // O = vec4( 1.-voronoiB(U).x,voronoi(U).x, 0,0 ); // for tests\n vec2 I = floor(U/2.); \n bool vert = mod(I.x+I.y,2.)==0.; //if (vert) U = U.yx;\n vec3 H0;\n O-=O;\n\n for(float i=0.; i{this.parse(e,t,i)}),n,i)}parse(e,t,n=()=>{}){this.decodeDracoFile(e,t,null,null,Ge,n).catch(n)}decodeDracoFile(e,t,n,i,r=We,a=()=>{}){const s={attributeIDs:n||this.defaultAttributeIDs,attributeTypes:i||this.defaultAttributeTypes,useUniqueIDs:!!n,vertexColorSpace:r};return this.decodeGeometry(e,s).then(t).catch(a)}decodeGeometry(e,t){const n=JSON.stringify(t);if(Nd.has(e)){const t=Nd.get(e);if(t.key===n)return t.promise;if(0===e.byteLength)throw new Error("THREE.DRACOLoader: Unable to re-decode a buffer with different settings. Buffer has already been transferred.")}let i;const r=this.workerNextTaskID++,a=e.byteLength,s=this._getWorker(r,a).then((n=>(i=n,new Promise(((n,a)=>{i._callbacks[r]={resolve:n,reject:a},i.postMessage({type:"decode",id:r,taskConfig:t,buffer:e},[e])}))))).then((e=>this._createGeometry(e.geometry)));return s.catch((()=>!0)).then((()=>{i&&r&&this._releaseTask(i,r)})),Nd.set(e,{key:n,promise:s}),s}_createGeometry(e){const t=new Oi;e.index&&t.setIndex(new Mi(e.index.array,1));for(let n=0;n{n.load(e,t,void 0,i)}))}preload(){return this._initDecoder(),this}_initDecoder(){if(this.decoderPending)return this.decoderPending;const e="object"!=typeof WebAssembly||"js"===this.decoderConfig.type,t=[];return e?t.push(this._loadLibrary("draco_decoder.js","text")):(t.push(this._loadLibrary("draco_wasm_wrapper.js","text")),t.push(this._loadLibrary("draco_decoder.wasm","arraybuffer"))),this.decoderPending=Promise.all(t).then((t=>{const n=t[0];e||(this.decoderConfig.wasmBinary=t[1]);const i=Bd.toString(),r=["/* draco decoder */",n,"","/* worker */",i.substring(i.indexOf("{")+1,i.lastIndexOf("}"))].join("\n");this.workerSourceURL=URL.createObjectURL(new Blob([r]))})),this.decoderPending}_getWorker(e,t){return this._initDecoder().then((()=>{if(this.workerPool.lengtht._taskLoad?-1:1}));const n=this.workerPool[this.workerPool.length-1];return n._taskCosts[e]=t,n._taskLoad+=t,n}))}_releaseTask(e,t){e._taskLoad-=e._taskCosts[t],delete e._callbacks[t],delete e._taskCosts[t]}debug(){console.log("Task load: ",this.workerPool.map((e=>e._taskLoad)))}dispose(){for(let e=0;e{const t=e.draco,s=new t.Decoder;try{const e=function(e,t,i,r){const a=r.attributeIDs,s=r.attributeTypes;let o,l;const c=t.GetEncodedGeometryType(i);if(c===e.TRIANGULAR_MESH)o=new e.Mesh,l=t.DecodeArrayToMesh(i,i.byteLength,o);else{if(c!==e.POINT_CLOUD)throw new Error("THREE.DRACOLoader: Unexpected geometry type.");o=new e.PointCloud,l=t.DecodeArrayToPointCloud(i,i.byteLength,o)}if(!l.ok()||0===o.ptr)throw new Error("THREE.DRACOLoader: Decoding failed: "+l.error_msg());const h={index:null,attributes:[]};for(const i in a){const l=self[s[i]];let c,d;if(r.useUniqueIDs)d=a[i],c=t.GetAttributeByUniqueId(o,d);else{if(d=t.GetAttributeId(o,e[a[i]]),-1===d)continue;c=t.GetAttribute(o,d)}const u=n(e,t,o,i,l,c);"color"===i&&(u.vertexColorSpace=r.vertexColorSpace),h.attributes.push(u)}return c===e.TRIANGULAR_MESH&&(h.index=function(e,t,n){const i=3*n.num_faces(),r=4*i,a=e._malloc(r);t.GetTrianglesUInt32Array(n,r,a);const s=new Uint32Array(e.HEAPF32.buffer,a,i).slice();return e._free(a),{array:s,itemSize:1}}(e,t,o)),e.destroy(o),h}(t,s,new Int8Array(i),a),o=e.attributes.map((e=>e.array.buffer));e.index&&o.push(e.index.array.buffer),self.postMessage({type:"decode",id:r.id,geometry:e},o)}catch(e){console.error(e),self.postMessage({type:"error",id:r.id,error:e.message})}finally{t.destroy(s)}}))}}}function zd(e,t){if(0===t)return console.warn("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Geometry already defined as triangles."),e;if(2===t||1===t){let n=e.getIndex();if(null===n){const t=[],i=e.getAttribute("position");if(void 0===i)return console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Undefined position attribute. Processing not possible."),e;for(let e=0;e=2.0 are supported.")));const l=new Cu(r,{path:t||this.resourcePath||"",crossOrigin:this.crossOrigin,requestHeader:this.requestHeader,manager:this.manager,ktx2Loader:this.ktx2Loader,meshoptDecoder:this.meshoptDecoder});l.fileLoader.setRequestHeader(this.requestHeader);for(let e=0;e=0&&void 0===s[t]&&console.warn('THREE.GLTFLoader: Unknown extension "'+t+'".')}}l.setExtensions(a),l.setPlugins(s),l.parse(n,i)}parseAsync(e,t){const n=this;return new Promise((function(i,r){n.parse(e,t,i,r)}))}}function Hd(){let e={};return{get:function(t){return e[t]},add:function(t,n){e[t]=n},remove:function(t){delete e[t]},removeAll:function(){e={}}}}const Vd={KHR_BINARY_GLTF:"KHR_binary_glTF",KHR_DRACO_MESH_COMPRESSION:"KHR_draco_mesh_compression",KHR_LIGHTS_PUNCTUAL:"KHR_lights_punctual",KHR_MATERIALS_CLEARCOAT:"KHR_materials_clearcoat",KHR_MATERIALS_DISPERSION:"KHR_materials_dispersion",KHR_MATERIALS_IOR:"KHR_materials_ior",KHR_MATERIALS_SHEEN:"KHR_materials_sheen",KHR_MATERIALS_SPECULAR:"KHR_materials_specular",KHR_MATERIALS_TRANSMISSION:"KHR_materials_transmission",KHR_MATERIALS_IRIDESCENCE:"KHR_materials_iridescence",KHR_MATERIALS_ANISOTROPY:"KHR_materials_anisotropy",KHR_MATERIALS_UNLIT:"KHR_materials_unlit",KHR_MATERIALS_VOLUME:"KHR_materials_volume",KHR_TEXTURE_BASISU:"KHR_texture_basisu",KHR_TEXTURE_TRANSFORM:"KHR_texture_transform",KHR_MESH_QUANTIZATION:"KHR_mesh_quantization",KHR_MATERIALS_EMISSIVE_STRENGTH:"KHR_materials_emissive_strength",EXT_MATERIALS_BUMP:"EXT_materials_bump",EXT_TEXTURE_WEBP:"EXT_texture_webp",EXT_TEXTURE_AVIF:"EXT_texture_avif",EXT_MESHOPT_COMPRESSION:"EXT_meshopt_compression",EXT_MESH_GPU_INSTANCING:"EXT_mesh_gpu_instancing"};class Gd{constructor(e){this.parser=e,this.name=Vd.KHR_LIGHTS_PUNCTUAL,this.cache={refs:{},uses:{}}}_markDefs(){const e=this.parser,t=this.parser.json.nodes||[];for(let n=0,i=t.length;n=0)throw new Error("THREE.GLTFLoader: setKTX2Loader must be called before loading KTX2 textures");return null}return t.loadTextureImage(e,r.source,a)}}class iu{constructor(e){this.parser=e,this.name=Vd.EXT_TEXTURE_WEBP,this.isSupported=null}loadTexture(e){const t=this.name,n=this.parser,i=n.json,r=i.textures[e];if(!r.extensions||!r.extensions[t])return null;const a=r.extensions[t],s=i.images[a.source];let o=n.textureLoader;if(s.uri){const e=n.options.manager.getHandler(s.uri);null!==e&&(o=e)}return this.detectSupport().then((function(r){if(r)return n.loadTextureImage(e,a.source,o);if(i.extensionsRequired&&i.extensionsRequired.indexOf(t)>=0)throw new Error("THREE.GLTFLoader: WebP required by asset but unsupported.");return n.loadTexture(e)}))}detectSupport(){return this.isSupported||(this.isSupported=new Promise((function(e){const t=new Image;t.src="data:image/webp;base64,UklGRiIAAABXRUJQVlA4IBYAAAAwAQCdASoBAAEADsD+JaQAA3AAAAAA",t.onload=t.onerror=function(){e(1===t.height)}}))),this.isSupported}}class ru{constructor(e){this.parser=e,this.name=Vd.EXT_TEXTURE_AVIF,this.isSupported=null}loadTexture(e){const t=this.name,n=this.parser,i=n.json,r=i.textures[e];if(!r.extensions||!r.extensions[t])return null;const a=r.extensions[t],s=i.images[a.source];let o=n.textureLoader;if(s.uri){const e=n.options.manager.getHandler(s.uri);null!==e&&(o=e)}return this.detectSupport().then((function(r){if(r)return n.loadTextureImage(e,a.source,o);if(i.extensionsRequired&&i.extensionsRequired.indexOf(t)>=0)throw new Error("THREE.GLTFLoader: AVIF required by asset but unsupported.");return n.loadTexture(e)}))}detectSupport(){return this.isSupported||(this.isSupported=new Promise((function(e){const t=new Image;t.src="data:image/avif;base64,AAAAIGZ0eXBhdmlmAAAAAGF2aWZtaWYxbWlhZk1BMUIAAADybWV0YQAAAAAAAAAoaGRscgAAAAAAAAAAcGljdAAAAAAAAAAAAAAAAGxpYmF2aWYAAAAADnBpdG0AAAAAAAEAAAAeaWxvYwAAAABEAAABAAEAAAABAAABGgAAABcAAAAoaWluZgAAAAAAAQAAABppbmZlAgAAAAABAABhdjAxQ29sb3IAAAAAamlwcnAAAABLaXBjbwAAABRpc3BlAAAAAAAAAAEAAAABAAAAEHBpeGkAAAAAAwgICAAAAAxhdjFDgQAMAAAAABNjb2xybmNseAACAAIABoAAAAAXaXBtYQAAAAAAAAABAAEEAQKDBAAAAB9tZGF0EgAKCBgABogQEDQgMgkQAAAAB8dSLfI=",t.onload=t.onerror=function(){e(1===t.height)}}))),this.isSupported}}class au{constructor(e){this.name=Vd.EXT_MESHOPT_COMPRESSION,this.parser=e}loadBufferView(e){const t=this.parser.json,n=t.bufferViews[e];if(n.extensions&&n.extensions[this.name]){const e=n.extensions[this.name],i=this.parser.getDependency("buffer",e.buffer),r=this.parser.options.meshoptDecoder;if(!r||!r.supported){if(t.extensionsRequired&&t.extensionsRequired.indexOf(this.name)>=0)throw new Error("THREE.GLTFLoader: setMeshoptDecoder must be called before loading compressed files");return null}return i.then((function(t){const n=e.byteOffset||0,i=e.byteLength||0,a=e.count,s=e.byteStride,o=new Uint8Array(t,n,i);return r.decodeGltfBufferAsync?r.decodeGltfBufferAsync(a,s,o,e.mode,e.filter).then((function(e){return e.buffer})):r.ready.then((function(){const t=new ArrayBuffer(a*s);return r.decodeGltfBuffer(new Uint8Array(t),a,s,o,e.mode,e.filter),t}))}))}return null}}class su{constructor(e){this.name=Vd.EXT_MESH_GPU_INSTANCING,this.parser=e}createNodeMesh(e){const t=this.parser.json,n=t.nodes[e];if(!n.extensions||!n.extensions[this.name]||void 0===n.mesh)return null;const i=t.meshes[n.mesh];for(const e of i.primitives)if(e.mode!==mu.TRIANGLES&&e.mode!==mu.TRIANGLE_STRIP&&e.mode!==mu.TRIANGLE_FAN&&void 0!==e.mode)return null;const r=n.extensions[this.name].attributes,a=[],s={};for(const e in r)a.push(this.parser.getDependency("accessor",r[e]).then((t=>(s[e]=t,s[e]))));return a.length<1?null:(a.push(this.parser.createNodeMesh(e)),Promise.all(a).then((e=>{const t=e.pop(),n=t.isGroup?t.children:[t],i=e[0].count,r=[];for(const e of n){const t=new wn,n=new jt,a=new Wt,o=new jt(1,1,1),l=new Fr(e.geometry,e.material,i);for(let e=0;e-1,a=r?e.match(/Firefox\/([0-9]+)\./)[1]:-1}"undefined"==typeof createImageBitmap||n&&i<17||r&&a<98?this.textureLoader=new vs(this.options.manager):this.textureLoader=new Ns(this.options.manager),this.textureLoader.setCrossOrigin(this.options.crossOrigin),this.textureLoader.setRequestHeader(this.options.requestHeader),this.fileLoader=new fs(this.options.manager),this.fileLoader.setResponseType("arraybuffer"),"use-credentials"===this.options.crossOrigin&&this.fileLoader.setWithCredentials(!0)}setExtensions(e){this.extensions=e}setPlugins(e){this.plugins=e}parse(e,t){const n=this,i=this.json,r=this.extensions;this.cache.removeAll(),this.nodeCache={},this._invokeAll((function(e){return e._markDefs&&e._markDefs()})),Promise.all(this._invokeAll((function(e){return e.beforeRoot&&e.beforeRoot()}))).then((function(){return Promise.all([n.getDependencies("scene"),n.getDependencies("animation"),n.getDependencies("camera")])})).then((function(t){const a={scene:t[0][i.scene||0],scenes:t[0],animations:t[1],cameras:t[2],asset:i.asset,parser:n,userData:{}};return bu(r,a,i),Mu(a,i),Promise.all(n._invokeAll((function(e){return e.afterRoot&&e.afterRoot(a)}))).then((function(){for(const e of a.scenes)e.updateMatrixWorld();e(a)}))})).catch(t)}_markDefs(){const e=this.json.nodes||[],t=this.json.skins||[],n=this.json.meshes||[];for(let n=0,i=t.length;n{const n=this.associations.get(e);null!=n&&this.associations.set(t,n);for(const[n,i]of e.children.entries())r(i,t.children[n])};return r(n,i),i.name+="_instance_"+e.uses[t]++,i}_invokeOne(e){const t=Object.values(this.plugins);t.push(this);for(let n=0;n=2&&p.setY(t,h[e*a+1]),a>=3&&p.setZ(t,h[e*a+2]),a>=4&&p.setW(t,h[e*a+3]),a>=5)throw new Error("THREE.GLTFLoader: Unsupported itemSize in sparse BufferAttribute.")}p.normalized=d}return p}))}loadTexture(e){const t=this.json,n=this.options,i=t.textures[e].source,r=t.images[i];let a=this.textureLoader;if(r.uri){const e=n.manager.getHandler(r.uri);null!==e&&(a=e)}return this.loadTextureImage(e,i,a)}loadTextureImage(e,t,n){const i=this,r=this.json,a=r.textures[e],s=r.images[t],o=(s.uri||s.bufferView)+":"+a.sampler;if(this.textureCache[o])return this.textureCache[o];const l=this.loadImageSource(t,n).then((function(t){t.flipY=!1,t.name=a.name||s.name||"",""===t.name&&"string"==typeof s.uri&&!1===s.uri.startsWith("data:image/")&&(t.name=s.uri);const n=(r.samplers||{})[a.sampler]||{};return t.magFilter=vu[n.magFilter]||V,t.minFilter=vu[n.minFilter]||W,t.wrapS=_u[n.wrapS]||N,t.wrapT=_u[n.wrapT]||N,t.generateMipmaps=!t.isCompressedTexture&&t.minFilter!==z&&t.minFilter!==V,i.associations.set(t,{textures:e}),t})).catch((function(){return null}));return this.textureCache[o]=l,l}loadImageSource(e,t){const n=this.json,i=this.options;if(void 0!==this.sourceCache[e])return this.sourceCache[e].then((e=>e.clone()));const r=n.images[e],a=self.URL||self.webkitURL;let s=r.uri||"",o=!1;if(void 0!==r.bufferView)s=this.getDependency("bufferView",r.bufferView).then((function(e){o=!0;const t=new Blob([e],{type:r.mimeType});return s=a.createObjectURL(t),s}));else if(void 0===r.uri)throw new Error("THREE.GLTFLoader: Image "+e+" is missing URI and bufferView");const l=Promise.resolve(s).then((function(e){return new Promise((function(n,r){let a=n;!0===t.isImageBitmapLoader&&(a=function(e){const t=new Bt(e);t.needsUpdate=!0,n(t)}),t.load(Os.resolveURL(e,i.path),a,void 0,r)}))})).then((function(e){var t;return!0===o&&a.revokeObjectURL(s),Mu(e,r),e.userData.mimeType=r.mimeType||((t=r.uri).search(/\.jpe?g($|\?)/i)>0||0===t.search(/^data\:image\/jpeg/)?"image/jpeg":t.search(/\.webp($|\?)/i)>0||0===t.search(/^data\:image\/webp/)?"image/webp":t.search(/\.ktx2($|\?)/i)>0||0===t.search(/^data\:image\/ktx2/)?"image/ktx2":"image/png"),e})).catch((function(e){throw console.error("THREE.GLTFLoader: Couldn't load texture",s),e}));return this.sourceCache[e]=l,l}assignTexture(e,t,n,i){const r=this;return this.getDependency("texture",n.index).then((function(a){if(!a)return null;if(void 0!==n.texCoord&&n.texCoord>0&&((a=a.clone()).channel=n.texCoord),r.extensions[Vd.KHR_TEXTURE_TRANSFORM]){const e=void 0!==n.extensions?n.extensions[Vd.KHR_TEXTURE_TRANSFORM]:void 0;if(e){const t=r.associations.get(a);a=r.extensions[Vd.KHR_TEXTURE_TRANSFORM].extendTexture(a,e),r.associations.set(a,t)}}return void 0!==i&&(a.colorSpace=i),e[t]=a,a}))}assignFinalMaterial(e){const t=e.geometry;let n=e.material;const i=void 0===t.attributes.tangent,r=void 0!==t.attributes.color,a=void 0===t.attributes.normal;if(e.isPoints){const e="PointsMaterial:"+n.uuid;let t=this.cache.get(e);t||(t=new aa,vi.prototype.copy.call(t,n),t.color.copy(n.color),t.map=n.map,t.sizeAttenuation=!1,this.cache.add(e,t)),n=t}else if(e.isLine){const e="LineBasicMaterial:"+n.uuid;let t=this.cache.get(e);t||(t=new jr,vi.prototype.copy.call(t,n),t.color.copy(n.color),t.map=n.map,this.cache.add(e,t)),n=t}if(i||r||a){let e="ClonedMaterial:"+n.uuid+":";i&&(e+="derivative-tangents:"),r&&(e+="vertex-colors:"),a&&(e+="flat-shading:");let t=this.cache.get(e);t||(t=n.clone(),r&&(t.vertexColors=!0),a&&(t.flatShading=!0),i&&(t.normalScale&&(t.normalScale.y*=-1),t.clearcoatNormalScale&&(t.clearcoatNormalScale.y*=-1)),this.cache.add(e,t),this.associations.set(t,this.associations.get(n))),n=t}e.material=n}getMaterialType(){return Fa}loadMaterial(e){const t=this,n=this.json,i=this.extensions,r=n.materials[e];let a;const s={},o=[];if((r.extensions||{})[Vd.KHR_MATERIALS_UNLIT]){const e=i[Vd.KHR_MATERIALS_UNLIT];a=e.getMaterialType(),o.push(e.extendParams(s,r,t))}else{const n=r.pbrMetallicRoughness||{};if(s.color=new fi(1,1,1),s.opacity=1,Array.isArray(n.baseColorFactor)){const e=n.baseColorFactor;s.color.setRGB(e[0],e[1],e[2],We),s.opacity=e[3]}void 0!==n.baseColorTexture&&o.push(t.assignTexture(s,"map",n.baseColorTexture,Ge)),s.metalness=void 0!==n.metallicFactor?n.metallicFactor:1,s.roughness=void 0!==n.roughnessFactor?n.roughnessFactor:1,void 0!==n.metallicRoughnessTexture&&(o.push(t.assignTexture(s,"metalnessMap",n.metallicRoughnessTexture)),o.push(t.assignTexture(s,"roughnessMap",n.metallicRoughnessTexture))),a=this._invokeOne((function(t){return t.getMaterialType&&t.getMaterialType(e)})),o.push(Promise.all(this._invokeAll((function(t){return t.extendMaterialParams&&t.extendMaterialParams(e,s)}))))}!0===r.doubleSided&&(s.side=2);const l=r.alphaMode||"OPAQUE";if("BLEND"===l?(s.transparent=!0,s.depthWrite=!1):(s.transparent=!1,"MASK"===l&&(s.alphaTest=void 0!==r.alphaCutoff?r.alphaCutoff:.5)),void 0!==r.normalTexture&&a!==_i&&(o.push(t.assignTexture(s,"normalMap",r.normalTexture)),s.normalScale=new _t(1,1),void 0!==r.normalTexture.scale)){const e=r.normalTexture.scale;s.normalScale.set(e,e)}if(void 0!==r.occlusionTexture&&a!==_i&&(o.push(t.assignTexture(s,"aoMap",r.occlusionTexture)),void 0!==r.occlusionTexture.strength&&(s.aoMapIntensity=r.occlusionTexture.strength)),void 0!==r.emissiveFactor&&a!==_i){const e=r.emissiveFactor;s.emissive=(new fi).setRGB(e[0],e[1],e[2],We)}return void 0!==r.emissiveTexture&&a!==_i&&o.push(t.assignTexture(s,"emissiveMap",r.emissiveTexture,Ge)),Promise.all(o).then((function(){const n=new a(s);return r.name&&(n.name=r.name),Mu(n,r),t.associations.set(n,{materials:e}),r.extensions&&bu(i,n,r),n}))}createUniqueName(e){const t=Ws.sanitizeNodeName(e||"");return t in this.nodeNamesUsed?t+"_"+ ++this.nodeNamesUsed[t]:(this.nodeNamesUsed[t]=0,t)}loadGeometries(e){const t=this,n=this.extensions,i=this.primitiveCache;function r(e){return n[Vd.KHR_DRACO_MESH_COMPRESSION].decodePrimitive(e,t).then((function(n){return Du(n,e,t)}))}const a=[];for(let n=0,s=e.length;n0&&Tu(d,r),d.name=t.createUniqueName(r.name||"mesh_"+e),Mu(d,r),h.extensions&&bu(i,d,h),t.assignFinalMaterial(d),l.push(d)}for(let n=0,i=l.length;n1?new ua:1===t.length?t[0]:new Zn,s!==t[0])for(let e=0,n=t.length;e{const t=new Map;for(const[e,n]of i.associations)(e instanceof vi||e instanceof Bt)&&t.set(e,n);return e.traverse((e=>{const n=i.associations.get(e);null!=n&&t.set(e,n)})),t})(r),r}))}_createAnimationTracks(e,t,n,i,r){const a=[],s=e.name?e.name:e.uuid,o=[];let l;switch(Su[r.path]===Su.weights?e.traverse((function(e){e.morphTargetInfluences&&o.push(e.name?e.name:e.uuid)})):o.push(s),Su[r.path]){case Su.weights:l=ts;break;case Su.rotation:l=is;break;case Su.position:case Su.scale:l=as;break;default:l=1===n.itemSize?ts:as}const c=void 0!==i.interpolation?wu[i.interpolation]:ke,h=this._getArrayFromAccessor(n);for(let e=0,n=o.length;eMath.PI&&(n-=zu),i<-Math.PI?i+=zu:i>Math.PI&&(i-=zu),this._spherical.theta=n<=i?Math.max(n,Math.min(i,this._spherical.theta)):this._spherical.theta>(n+i)/2?Math.max(n,this._spherical.theta):Math.min(i,this._spherical.theta)),this._spherical.phi=Math.max(this.minPolarAngle,Math.min(this.maxPolarAngle,this._spherical.phi)),this._spherical.makeSafe(),!0===this.enableDamping?this.target.addScaledVector(this._panOffset,this.dampingFactor):this.target.add(this._panOffset),this.target.sub(this.cursor),this.target.clampLength(this.minTargetRadius,this.maxTargetRadius),this.target.add(this.cursor);let r=!1;if(this.zoomToCursor&&this._performCursorZoom||this.object.isOrthographicCamera)this._spherical.radius=this._clampDistance(this._spherical.radius);else{const e=this._spherical.radius;this._spherical.radius=this._clampDistance(this._spherical.radius*this._scale),r=e!=this._spherical.radius}if(Bu.setFromSpherical(this._spherical),Bu.applyQuaternion(this._quatInverse),t.copy(this.target).add(Bu),this.object.lookAt(this.target),!0===this.enableDamping?(this._sphericalDelta.theta*=1-this.dampingFactor,this._sphericalDelta.phi*=1-this.dampingFactor,this._panOffset.multiplyScalar(1-this.dampingFactor)):(this._sphericalDelta.set(0,0,0),this._panOffset.set(0,0,0)),this.zoomToCursor&&this._performCursorZoom){let e=null;if(this.object.isPerspectiveCamera){const t=Bu.length();e=this._clampDistance(t*this._scale);const n=t-e;this.object.position.addScaledVector(this._dollyDirection,n),this.object.updateMatrixWorld(),r=!!n}else if(this.object.isOrthographicCamera){const t=new jt(this._mouse.x,this._mouse.y,0);t.unproject(this.object);const n=this.object.zoom;this.object.zoom=Math.max(this.minZoom,Math.min(this.maxZoom,this.object.zoom/this._scale)),this.object.updateProjectionMatrix(),r=n!==this.object.zoom;const i=new jt(this._mouse.x,this._mouse.y,0);i.unproject(this.object),this.object.position.sub(i).add(t),this.object.updateMatrixWorld(),e=Bu.length()}else console.warn("WARNING: OrbitControls.js encountered an unknown camera type - zoom to cursor disabled."),this.zoomToCursor=!1;null!==e&&(this.screenSpacePanning?this.target.set(0,0,-1).transformDirection(this.object.matrix).multiplyScalar(e).add(this.object.position):(Ou.origin.copy(this.object.position),Ou.direction.set(0,0,-1).transformDirection(this.object.matrix),Math.abs(this.object.up.dot(Ou.direction))Hu||8*(1-this._lastQuaternion.dot(this.object.quaternion))>Hu||this._lastTargetPosition.distanceToSquared(this.target)>Hu)&&(this.dispatchEvent(Lu),this._lastPosition.copy(this.object.position),this._lastQuaternion.copy(this.object.quaternion),this._lastTargetPosition.copy(this.target),!0)}_getAutoRotationAngle(e){return null!==e?zu/60*this.autoRotateSpeed*e:zu/60/60*this.autoRotateSpeed}_getZoomScale(e){const t=Math.abs(.01*e);return Math.pow(.95,this.zoomSpeed*t)}_rotateLeft(e){this._sphericalDelta.theta-=e}_rotateUp(e){this._sphericalDelta.phi-=e}_panLeft(e,t){Bu.setFromMatrixColumn(t,0),Bu.multiplyScalar(-e),this._panOffset.add(Bu)}_panUp(e,t){!0===this.screenSpacePanning?Bu.setFromMatrixColumn(t,1):(Bu.setFromMatrixColumn(t,0),Bu.crossVectors(this.object.up,Bu)),Bu.multiplyScalar(e),this._panOffset.add(Bu)}_pan(e,t){const n=this.domElement;if(this.object.isPerspectiveCamera){const i=this.object.position;Bu.copy(i).sub(this.target);let r=Bu.length();r*=Math.tan(this.object.fov/2*Math.PI/180),this._panLeft(2*e*r/n.clientHeight,this.object.matrix),this._panUp(2*t*r/n.clientHeight,this.object.matrix)}else this.object.isOrthographicCamera?(this._panLeft(e*(this.object.right-this.object.left)/this.object.zoom/n.clientWidth,this.object.matrix),this._panUp(t*(this.object.top-this.object.bottom)/this.object.zoom/n.clientHeight,this.object.matrix)):(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - pan disabled."),this.enablePan=!1)}_dollyOut(e){this.object.isPerspectiveCamera||this.object.isOrthographicCamera?this._scale/=e:(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled."),this.enableZoom=!1)}_dollyIn(e){this.object.isPerspectiveCamera||this.object.isOrthographicCamera?this._scale*=e:(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled."),this.enableZoom=!1)}_updateZoomParameters(e,t){if(!this.zoomToCursor)return;this._performCursorZoom=!0;const n=this.domElement.getBoundingClientRect(),i=e-n.left,r=t-n.top,a=n.width,s=n.height;this._mouse.x=i/a*2-1,this._mouse.y=-r/s*2+1,this._dollyDirection.set(this._mouse.x,this._mouse.y,1).unproject(this.object).sub(this.object.position).normalize()}_clampDistance(e){return Math.max(this.minDistance,Math.min(this.maxDistance,e))}_handleMouseDownRotate(e){this._rotateStart.set(e.clientX,e.clientY)}_handleMouseDownDolly(e){this._updateZoomParameters(e.clientX,e.clientX),this._dollyStart.set(e.clientX,e.clientY)}_handleMouseDownPan(e){this._panStart.set(e.clientX,e.clientY)}_handleMouseMoveRotate(e){this._rotateEnd.set(e.clientX,e.clientY),this._rotateDelta.subVectors(this._rotateEnd,this._rotateStart).multiplyScalar(this.rotateSpeed);const t=this.domElement;this._rotateLeft(zu*this._rotateDelta.x/t.clientHeight),this._rotateUp(zu*this._rotateDelta.y/t.clientHeight),this._rotateStart.copy(this._rotateEnd),this.update()}_handleMouseMoveDolly(e){this._dollyEnd.set(e.clientX,e.clientY),this._dollyDelta.subVectors(this._dollyEnd,this._dollyStart),this._dollyDelta.y>0?this._dollyOut(this._getZoomScale(this._dollyDelta.y)):this._dollyDelta.y<0&&this._dollyIn(this._getZoomScale(this._dollyDelta.y)),this._dollyStart.copy(this._dollyEnd),this.update()}_handleMouseMovePan(e){this._panEnd.set(e.clientX,e.clientY),this._panDelta.subVectors(this._panEnd,this._panStart).multiplyScalar(this.panSpeed),this._pan(this._panDelta.x,this._panDelta.y),this._panStart.copy(this._panEnd),this.update()}_handleMouseWheel(e){this._updateZoomParameters(e.clientX,e.clientY),e.deltaY<0?this._dollyIn(this._getZoomScale(e.deltaY)):e.deltaY>0&&this._dollyOut(this._getZoomScale(e.deltaY)),this.update()}_handleKeyDown(e){let t=!1;switch(e.code){case this.keys.UP:e.ctrlKey||e.metaKey||e.shiftKey?this.enableRotate&&this._rotateUp(zu*this.rotateSpeed/this.domElement.clientHeight):this.enablePan&&this._pan(0,this.keyPanSpeed),t=!0;break;case this.keys.BOTTOM:e.ctrlKey||e.metaKey||e.shiftKey?this.enableRotate&&this._rotateUp(-zu*this.rotateSpeed/this.domElement.clientHeight):this.enablePan&&this._pan(0,-this.keyPanSpeed),t=!0;break;case this.keys.LEFT:e.ctrlKey||e.metaKey||e.shiftKey?this.enableRotate&&this._rotateLeft(zu*this.rotateSpeed/this.domElement.clientHeight):this.enablePan&&this._pan(this.keyPanSpeed,0),t=!0;break;case this.keys.RIGHT:e.ctrlKey||e.metaKey||e.shiftKey?this.enableRotate&&this._rotateLeft(-zu*this.rotateSpeed/this.domElement.clientHeight):this.enablePan&&this._pan(-this.keyPanSpeed,0),t=!0}t&&(e.preventDefault(),this.update())}_handleTouchStartRotate(e){if(1===this._pointers.length)this._rotateStart.set(e.pageX,e.pageY);else{const t=this._getSecondPointerPosition(e),n=.5*(e.pageX+t.x),i=.5*(e.pageY+t.y);this._rotateStart.set(n,i)}}_handleTouchStartPan(e){if(1===this._pointers.length)this._panStart.set(e.pageX,e.pageY);else{const t=this._getSecondPointerPosition(e),n=.5*(e.pageX+t.x),i=.5*(e.pageY+t.y);this._panStart.set(n,i)}}_handleTouchStartDolly(e){const t=this._getSecondPointerPosition(e),n=e.pageX-t.x,i=e.pageY-t.y,r=Math.sqrt(n*n+i*i);this._dollyStart.set(0,r)}_handleTouchStartDollyPan(e){this.enableZoom&&this._handleTouchStartDolly(e),this.enablePan&&this._handleTouchStartPan(e)}_handleTouchStartDollyRotate(e){this.enableZoom&&this._handleTouchStartDolly(e),this.enableRotate&&this._handleTouchStartRotate(e)}_handleTouchMoveRotate(e){if(1==this._pointers.length)this._rotateEnd.set(e.pageX,e.pageY);else{const t=this._getSecondPointerPosition(e),n=.5*(e.pageX+t.x),i=.5*(e.pageY+t.y);this._rotateEnd.set(n,i)}this._rotateDelta.subVectors(this._rotateEnd,this._rotateStart).multiplyScalar(this.rotateSpeed);const t=this.domElement;this._rotateLeft(zu*this._rotateDelta.x/t.clientHeight),this._rotateUp(zu*this._rotateDelta.y/t.clientHeight),this._rotateStart.copy(this._rotateEnd)}_handleTouchMovePan(e){if(1===this._pointers.length)this._panEnd.set(e.pageX,e.pageY);else{const t=this._getSecondPointerPosition(e),n=.5*(e.pageX+t.x),i=.5*(e.pageY+t.y);this._panEnd.set(n,i)}this._panDelta.subVectors(this._panEnd,this._panStart).multiplyScalar(this.panSpeed),this._pan(this._panDelta.x,this._panDelta.y),this._panStart.copy(this._panEnd)}_handleTouchMoveDolly(e){const t=this._getSecondPointerPosition(e),n=e.pageX-t.x,i=e.pageY-t.y,r=Math.sqrt(n*n+i*i);this._dollyEnd.set(0,r),this._dollyDelta.set(0,Math.pow(this._dollyEnd.y/this._dollyStart.y,this.zoomSpeed)),this._dollyOut(this._dollyDelta.y),this._dollyStart.copy(this._dollyEnd);const a=.5*(e.pageX+t.x),s=.5*(e.pageY+t.y);this._updateZoomParameters(a,s)}_handleTouchMoveDollyPan(e){this.enableZoom&&this._handleTouchMoveDolly(e),this.enablePan&&this._handleTouchMovePan(e)}_handleTouchMoveDollyRotate(e){this.enableZoom&&this._handleTouchMoveDolly(e),this.enableRotate&&this._handleTouchMoveRotate(e)}_addPointer(e){this._pointers.push(e.pointerId)}_removePointer(e){delete this._pointerPositions[e.pointerId];for(let t=0;te&&(i.scale.set(1e-10,1e-10,1e-10),i.visible=!1),"Y"===i.name&&Math.abs(_p.copy(Ep).applyQuaternion(t).dot(this.eye))>e&&(i.scale.set(1e-10,1e-10,1e-10),i.visible=!1),"Z"===i.name&&Math.abs(_p.copy(Ap).applyQuaternion(t).dot(this.eye))>e&&(i.scale.set(1e-10,1e-10,1e-10),i.visible=!1),"XY"===i.name&&Math.abs(_p.copy(Ap).applyQuaternion(t).dot(this.eye)).9&&(i.visible=!1)),"Y"===this.axis&&(rp.setFromEuler(vp.set(0,0,Math.PI/2)),i.quaternion.copy(t).multiply(rp),Math.abs(_p.copy(Ep).applyQuaternion(t).dot(this.eye))>.9&&(i.visible=!1)),"Z"===this.axis&&(rp.setFromEuler(vp.set(0,Math.PI/2,0)),i.quaternion.copy(t).multiply(rp),Math.abs(_p.copy(Ap).applyQuaternion(t).dot(this.eye))>.9&&(i.visible=!1)),"XYZE"===this.axis&&(rp.setFromEuler(vp.set(0,Math.PI/2,0)),_p.copy(this.rotationAxis),i.quaternion.setFromRotationMatrix(yp.lookAt(xp,_p,Ep)),i.quaternion.multiply(rp),i.visible=this.dragging),"E"===this.axis&&(i.visible=!1)):"START"===i.name?(i.position.copy(this.worldPositionStart),i.visible=this.dragging):"END"===i.name?(i.position.copy(this.worldPosition),i.visible=this.dragging):"DELTA"===i.name?(i.position.copy(this.worldPositionStart),i.quaternion.copy(this.worldQuaternionStart),np.set(1e-10,1e-10,1e-10).add(this.worldPositionStart).sub(this.worldPosition).multiplyScalar(-1),np.applyQuaternion(this.worldQuaternionStart.clone().invert()),i.scale.copy(np),i.visible=this.dragging):(i.quaternion.copy(t),this.dragging?i.position.copy(this.worldPositionStart):i.position.copy(this.worldPosition),this.axis&&(i.visible=-1!==this.axis.search(i.name)))}super.updateMatrixWorld(e)}}class Ip extends Yi{constructor(){super(new Da(1e5,1e5,2,2),new _i({visible:!1,wireframe:!0,side:2,transparent:!0,opacity:.1,toneMapped:!1})),this.isTransformControlsPlane=!0,this.type="TransformControlsPlane"}updateMatrixWorld(e){let t=this.space;switch(this.position.copy(this.worldPosition),"scale"===this.mode&&(t="local"),Pp.copy(Tp).applyQuaternion("local"===t?this.worldQuaternion:wp),Rp.copy(Ep).applyQuaternion("local"===t?this.worldQuaternion:wp),Cp.copy(Ap).applyQuaternion("local"===t?this.worldQuaternion:wp),_p.copy(Rp),this.mode){case"translate":case"scale":switch(this.axis){case"X":_p.copy(this.eye).cross(Pp),bp.copy(Pp).cross(_p);break;case"Y":_p.copy(this.eye).cross(Rp),bp.copy(Rp).cross(_p);break;case"Z":_p.copy(this.eye).cross(Cp),bp.copy(Cp).cross(_p);break;case"XY":bp.copy(Cp);break;case"YZ":bp.copy(Pp);break;case"XZ":_p.copy(Cp),bp.copy(Rp);break;case"XYZ":case"E":bp.set(0,0,0)}break;default:bp.set(0,0,0)}0===bp.length()?this.quaternion.copy(this.cameraQuaternion):(Mp.lookAt(np.set(0,0,0),bp,_p),this.quaternion.setFromRotationMatrix(Mp)),super.updateMatrixWorld(e)}}class Up{constructor(e,t,n){this.renderer=e,this.canvas=n||this.renderer.domElement,this.camera=t,this.orbitControls=new Vu(t,this.canvas)}addTransformControl(e,t){const n=new hp(this.camera,this.canvas);return n.addEventListener("dragging-changed",(e=>{this.orbitControls.enabled=!e.value})),n.attach(e),t.add(n.getHelper()),n}update(){this.orbitControls.update()}}class Op extends Yi{constructor(e,t){super(new Da(1,1,10,10),new Ba({color:Op.alphaMap?0:16777215,transparent:!0,depthWrite:!1,polygonOffset:!0,name:"ShadowGroundPlaneMaterial"})),this.name="ShadowGroundPlane",this.userData.isFloor=!0,this.renderOrder=1,this.receiveShadow=!1,this.layers.disableAll(),t&&this.updateMaterial(t),this.setShadowMap(e)}setVisibility(e){this.visible=e,this.setVisibilityLayers(e)}setVisibilityLayers(e){e?this.layers.enableAll():this.layers.disableAll()}setDepthWrite(e){const t=this.material;t.depthWrite=e,t.transparent=!e,t.needsUpdate=!0,this.setVisibility(e)}setReceiveShadow(e){this.receiveShadow=e,this.setVisibility(e)}setShadowMap(e){const t=this.material;Op.alphaMap?(t.alphaMap=e,t.map=null,t.color.set(0)):(t.alphaMap=null,t.map=e,t.color.set(16777215)),t.needsUpdate=!0}updateMaterial(e){const t=this.material;e.opacity&&t.opacity!==e.opacity&&(t.opacity=e.opacity),e.polygonOffset&&t.polygonOffsetFactor!==e.polygonOffset&&(t.polygonOffset=!0,t.polygonOffsetFactor=e.polygonOffset,t.polygonOffsetUnits=e.polygonOffset),t.needsUpdate=!0}}Op.alphaMap=!0;class Np extends _o{get renderPassManager(){return this._renderPassManager}get renderCacheManager(){return this._renderPassManager.renderCacheManager}get scene(){return this._renderPassManager.scene}get camera(){return this._renderPassManager.camera}get gBufferTextures(){return this._renderPassManager.gBufferRenderPass}get passRenderer(){return this._renderPassManager.passRenderer}constructor(e){super(),this._renderPassManager=e}render(e,t,n,i,r){this.renderPass(e)}}const Fp="inputRgbNormal",Bp="floatBufferNormal",zp="separateBuffer",kp="normalVectorAlpha",Hp=(e,t)=>{const n=Vp(e,t);let i="vec4[SAMPLES](";for(let t=0;t{const n=[];for(let i=0;i\n\t\t#include \n\n\t\t#ifndef FRAGMENT_OUTPUT\n\t\t#define FRAGMENT_OUTPUT vec4(vec3(ao), 1.)\n\t\t#endif\n\n\t\tconst vec4 sampleKernel[SAMPLES] = SAMPLE_VECTORS;\n\n\t\tvec3 getViewPosition(const in vec2 screenPosition, const in float depth) {\n\t\t\tvec4 clipSpacePosition = vec4(vec3(screenPosition, depth) * 2.0 - 1.0, 1.0);\n\t\t\tvec4 viewSpacePosition = cameraProjectionMatrixInverse * clipSpacePosition;\n\t\t\treturn viewSpacePosition.xyz / viewSpacePosition.w;\n\t\t}\n\n\t\tfloat getDepth(const vec2 uv) { \n\t\t\t#if DEPTH_BUFFER_ANTIALIAS == 1\n\t\t\t\tvec2 size = vec2(textureSize(tDepth, 0));\n\t\t\t\tivec2 p = ivec2(uv * size);\n\t\t\t\tfloat d0 = texelFetch(tDepth, p, 0).DEPTH_SWIZZLING;\n\t\t\t\tvec2 depth = vec2(d0, 1.0);\n\t\t\t\tfloat d1 = texelFetch(tDepth, p + ivec2(1, 0), 0).DEPTH_SWIZZLING;\n\t\t\t\tdepth += vec2(d1, 1.0) * step(abs(d1 - d0), 0.1);\n\t\t\t\tfloat d2 = texelFetch(tDepth, p - ivec2(1, 0), 0).DEPTH_SWIZZLING;\n\t\t\t\tdepth += vec2(d2, 1.0) * step(abs(d2 - d0), 0.1);\n\t\t\t\tfloat d3 = texelFetch(tDepth, p + ivec2(0, 1), 0).DEPTH_SWIZZLING;\n\t\t\t\tdepth += vec2(d3, 1.0) * step(abs(d3 - d0), 0.1);\n\t\t\t\tfloat d4 = texelFetch(tDepth, p - ivec2(0, 1), 0).DEPTH_SWIZZLING;\n\t\t\t\tdepth += vec2(d4, 1.0) * step(abs(d4 - d0), 0.1);\n\t\t\t\treturn depth.x / depth.y;\n \t#else\n \treturn textureLod(tDepth, uv.xy, 0.0).DEPTH_SWIZZLING;\n \t#endif\n\t\t}\n\n\t\tfloat fetchDepth(const ivec2 uv) { \n\t\t\treturn texelFetch(tDepth, uv.xy, 0).DEPTH_SWIZZLING;\n\t\t}\n\n\t\tfloat getViewZ(const in float depth) {\n\t\t\t#if PERSPECTIVE_CAMERA == 1\n\t\t\t\treturn perspectiveDepthToViewZ(depth, cameraNear, cameraFar);\n\t\t\t#else\n\t\t\t\treturn orthographicDepthToViewZ(depth, cameraNear, cameraFar);\n\t\t\t#endif\n\t\t}\n\n\t\tvec3 computeNormalFromDepth(const vec2 uv) {\n vec2 size = vec2(textureSize(tDepth, 0));\n ivec2 p = ivec2(uv * size);\n float c0 = fetchDepth(p);\n float l2 = fetchDepth(p - ivec2(2, 0));\n float l1 = fetchDepth(p - ivec2(1, 0));\n float r1 = fetchDepth(p + ivec2(1, 0));\n float r2 = fetchDepth(p + ivec2(2, 0));\n float b2 = fetchDepth(p - ivec2(0, 2));\n float b1 = fetchDepth(p - ivec2(0, 1));\n float t1 = fetchDepth(p + ivec2(0, 1));\n float t2 = fetchDepth(p + ivec2(0, 2));\n float dl = abs((2.0 * l1 - l2) - c0);\n float dr = abs((2.0 * r1 - r2) - c0);\n float db = abs((2.0 * b1 - b2) - c0);\n float dt = abs((2.0 * t1 - t2) - c0);\n vec3 ce = getViewPosition(uv, c0).xyz;\n vec3 dpdx = (dl < dr) ? ce - getViewPosition((uv - vec2(1.0 / size.x, 0.0)), l1).xyz\n : -ce + getViewPosition((uv + vec2(1.0 / size.x, 0.0)), r1).xyz;\n vec3 dpdy = (db < dt) ? ce - getViewPosition((uv - vec2(0.0, 1.0 / size.y)), b1).xyz\n : -ce + getViewPosition((uv + vec2(0.0, 1.0 / size.y)), t1).xyz;\n return normalize(cross(dpdx, dpdy));\n\t\t}\n\n\t\tvec3 getViewNormal(const vec2 uv) {\n\t\t\t#if NORMAL_VECTOR_TYPE == 2\n\t\t\t\treturn normalize(textureLod(tNormal, uv, 0.).rgb);\n\t\t\t#elif NORMAL_VECTOR_TYPE == 1\n\t\t\t\treturn unpackRGBToNormal(textureLod(tNormal, uv, 0.).rgb);\n\t\t\t#else\n\t\t\t\treturn computeNormalFromDepth(uv);\n\t\t\t#endif\n\t\t}\n\n\t\tvec3 getAntiAliasedViewNormal(const in vec2 screenPosition) {\n\t\t\t#if NORMAL_VECTOR_TYPE == 2\n\t\t\t\t#if NORMAL_VECTOR_ANTIALIAS == 1\n\t\t\t\t\tvec2 uv = screenPosition;\n\t\t\t\t\tvec2 size = vec2(textureSize(tNormal, 0));\n\t\t\t\t\tivec2 p = ivec2(screenPosition * size);\n\t\t\t\t\tfloat c0 = texelFetch(tNormal, p, 0).a;\n\t\t\t\t\tfloat l2 = texelFetch(tNormal, p - ivec2(2, 0), 0).a;\n\t\t\t\t\tfloat l1 = texelFetch(tNormal, p - ivec2(1, 0), 0).a;\n\t\t\t\t\tfloat r1 = texelFetch(tNormal, p + ivec2(1, 0), 0).a;\n\t\t\t\t\tfloat r2 = texelFetch(tNormal, p + ivec2(2, 0), 0).a;\n\t\t\t\t\tfloat b2 = texelFetch(tNormal, p - ivec2(0, 2), 0).a;\n\t\t\t\t\tfloat b1 = texelFetch(tNormal, p - ivec2(0, 1), 0).a;\n\t\t\t\t\tfloat t1 = texelFetch(tNormal, p + ivec2(0, 1), 0).a;\n\t\t\t\t\tfloat t2 = texelFetch(tNormal, p + ivec2(0, 2), 0).a;\n\t\t\t\t\tfloat dl = abs((2.0 * l1 - l2) - c0);\n\t\t\t\t\tfloat dr = abs((2.0 * r1 - r2) - c0);\n\t\t\t\t\tfloat db = abs((2.0 * b1 - b2) - c0);\n\t\t\t\t\tfloat dt = abs((2.0 * t1 - t2) - c0);\n\t\t\t\t\tvec3 ce = getViewPosition(uv, c0).xyz;\n\t\t\t\t\tvec3 dpdx = (dl < dr) ? ce - getViewPosition((uv - vec2(1.0 / size.x, 0.0)), l1).xyz\n\t\t\t\t\t\t\t\t\t\t : -ce + getViewPosition((uv + vec2(1.0 / size.x, 0.0)), r1).xyz;\n\t\t\t\t\tvec3 dpdy = (db < dt) ? ce - getViewPosition((uv - vec2(0.0, 1.0 / size.y)), b1).xyz\n\t\t\t\t\t\t\t\t\t\t : -ce + getViewPosition((uv + vec2(0.0, 1.0 / size.y)), t1).xyz;\n\t\t\t\t\treturn normalize(cross(dpdx, dpdy));\n\t\t\t\t#elif NORMAL_VECTOR_ANTIALIAS == 2\n\t\t\t\t\tvec2 size = vec2(textureSize(tNormal, 0));\n\t\t\t\t\tivec2 p = ivec2(screenPosition * size);\n\t\t\t\t\tvec3 normalVector = texelFetch(tNormal, p, 0).xyz;\n\t\t\t\t\tnormalVector += texelFetch(tNormal, p + ivec2(1, 0), 0).xyz;\n\t\t\t\t\tnormalVector += texelFetch(tNormal, p - ivec2(1, 0), 0).xyz;\n\t\t\t\t\tnormalVector += texelFetch(tNormal, p + ivec2(0, 1), 0).xyz;\n\t\t\t\t\tnormalVector += texelFetch(tNormal, p - ivec2(0, 1), 0).xyz;\n\t\t\t\t\treturn normalize(normalVector);\n\t\t\t\t#else\n\t\t\t\t\treturn texture2D(tNormal, screenPosition).xyz;\n\t\t\t\t#endif\n\t\t\t#elif NORMAL_VECTOR_TYPE == 1\n\t\t\t\treturn unpackRGBToNormal(textureLod(tNormal, screenPosition, 0.).rgb);\n\t\t\t#else\n\t\t\t\treturn computeNormalFromDepth(screenPosition);\n\t\t\t#endif\n\t\t }\n\n\t\tvec3 getSceneUvAndDepth(vec3 sampleViewPos) {\n\t\t\tvec4 sampleClipPos = cameraProjectionMatrix * vec4(sampleViewPos, 1.);\n\t\t\tvec2 sampleUv = sampleClipPos.xy / sampleClipPos.w * 0.5 + 0.5;\n\t\t\tfloat sampleSceneDepth = getDepth(sampleUv);\n\t\t\treturn vec3(sampleUv, sampleSceneDepth);\n\t\t}\n\n\t\tfloat sinusToPlane(vec3 pointOnPlane, vec3 planeNormal, vec3 point) {\n\t\t\tvec3 delta = point - pointOnPlane;\n\t\t\tfloat sinV = dot(planeNormal, normalize(delta));\n\t\t\treturn sinV;\n\t\t}\n\n\t\tfloat getFallOff(float delta, float falloffDistance) {\n\t\t\tfloat fallOff = smoothstep(0., 1., 1. - distanceFallOff * abs(delta) / falloffDistance);\n\t\t\treturn fallOff;\n\t\t}\n\t\t\n\t\tvoid main() {\n\t\t\tfloat depth = getDepth(vUv.xy);\n\t\t\tif (depth >= 1.0) {\n\t\t\t\tdiscard;\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tvec3 viewPos = getViewPosition(vUv, depth);\n\t\t\tvec3 viewNormal = getAntiAliasedViewNormal(vUv);\n\n\t\t\tfloat radiusToUse = radius;\n\t\t\tfloat distanceFalloffToUse = thickness;\n\t\t\t#if SCREEN_SPACE_RADIUS == 1\n\t\t\t float radiusScale = getViewPosition(vec2(0.5 + float(SCREEN_SPACE_RADIUS_SCALE) / resolution.x, 0.0), depth).x;\n\t\t\t\tradiusToUse *= radiusScale;\n\t\t\t\tdistanceFalloffToUse *= radiusScale;\n\t\t\t#endif\n\n\t\t\t#if SCENE_CLIP_BOX == 1\n\t\t\t\tvec3 worldPos = (cameraWorldMatrix * vec4(viewPos, 1.0)).xyz;\n \t\t\tfloat boxDistance = length(max(vec3(0.0), max(sceneBoxMin - worldPos, worldPos - sceneBoxMax)));\n\t\t\t\tif (boxDistance > radiusToUse) {\n\t\t\t\t\tdiscard;\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t#endif\n\t\t\t\n\t\t\tvec2 noiseResolution = vec2(textureSize(tNoise, 0));\n\t\t\tvec2 noiseUv = vUv * resolution / noiseResolution;\n\t\t\tvec4 noiseTexel = textureLod(tNoise, noiseUv, 0.0);\n\t\t\tvec3 randomVec = noiseTexel.xyz * 2.0 - 1.0;\n\n\t\t\t#if NV_ALIGNED_SAMPLES == 1\n \t\t\t\tvec3 tangent = normalize(randomVec - viewNormal * dot(randomVec, viewNormal));\n \t\t\tvec3 bitangent = cross(viewNormal, tangent);\n \t\t\tmat3 kernelMatrix = mat3(tangent, bitangent, viewNormal);\n\t\t\t#else\n\t\t\t\tvec3 tangent = normalize(vec3(randomVec.xy, 0.));\n\t\t\t\tvec3 bitangent = vec3(-tangent.y, tangent.x, 0.);\n\t\t\t\tmat3 kernelMatrix = mat3(tangent, bitangent, vec3(0., 0., 1.));\n\t\t\t#endif\n\n\t\t#if AO_ALGORITHM == 4\n\t\t\tconst int DIRECTIONS = SAMPLES < 30 ? 3 : 5;\n\t\t\tconst int STEPS = (SAMPLES + DIRECTIONS - 1) / DIRECTIONS;\n\t\t#elif AO_ALGORITHM == 3\n\t\t\tconst int DIRECTIONS = SAMPLES < 16 ? 3 : 5;\n\t\t\tconst int STEPS = (SAMPLES + DIRECTIONS - 1) / DIRECTIONS;\n\t\t#else\n\t\t\tconst int DIRECTIONS = SAMPLES;\n\t\t\tconst int STEPS = 1;\n\t\t#endif\n\n\t\t\tfloat ao = 0.0, totalWeight = 0.0;\n\t\t\tfor (int i = 0; i < DIRECTIONS; ++i) {\n\n\t\t\t#if AO_ALGORITHM == 4\n\t\t\t\tfloat angle = float(i) / float(DIRECTIONS) * PI;\n\t\t\t\tvec4 sampleDir = vec4(cos(angle), sin(angle), 0., 0.5 + 0.5 * noiseTexel.w); \n\t\t\t#elif AO_ALGORITHM == 3\n\t\t\t\tfloat angle = float(i) / float(DIRECTIONS) * 2. * PI;\n\t\t\t\tvec4 sampleDir = vec4(cos(angle), sin(angle), 0., 0.5 + 0.5 * noiseTexel.w); \n\t\t\t#else\n\t\t\t\tvec4 sampleDir = sampleKernel[i];\n\t\t\t#endif\n\t\t\t\tsampleDir.xyz = normalize(kernelMatrix * sampleDir.xyz);\n\n\t\t\t\tvec3 viewDir = normalize(-viewPos.xyz);\n\t\t\t\tvec3 sliceBitangent = normalize(cross(sampleDir.xyz, viewDir));\n\t\t\t\tvec3 sliceTangent = cross(sliceBitangent, viewDir);\n\t\t\t\tvec3 normalInSlice = normalize(viewNormal - sliceBitangent * dot(viewNormal, sliceBitangent));\n\t\t\t\t\n\t\t\t#if (AO_ALGORITHM == 3 || AO_ALGORITHM == 4)\n\t\t\t\tvec3 tangentToNormalInSlice = cross(normalInSlice, sliceBitangent);\n\t\t\t\t#if AO_ALGORITHM == 4\n\t\t\t\t\tvec2 cosHorizons = vec2(dot(viewDir, tangentToNormalInSlice), dot(viewDir, -tangentToNormalInSlice));\n\t\t\t\t#else\n\t\t\t\t\tvec2 cosHorizons = vec2(dot(viewDir, tangentToNormalInSlice));\n\t\t\t\t#endif\n\t\t\t\tfor (int j = 0; j < STEPS; ++j) {\n\t\t\t\t\tvec3 sampleViewOffset = sampleDir.xyz * radiusToUse * sampleDir.w * pow(float(j + 1) / float(STEPS), distanceExponent);\n\t\t\t\t\tvec3 sampleViewPos = viewPos + sampleViewOffset;\n\t\t\t#else\n\t\t\t\t\tvec3 sampleViewPos = viewPos + sampleDir.xyz * radiusToUse * pow(sampleDir.w, distanceExponent);\n\t\t\t#endif\t\n\n\t\t\t\t\tvec3 sampleSceneUvDepth = getSceneUvAndDepth(sampleViewPos);\n\t\t\t\t\tvec3 sampleSceneViewPos = getViewPosition(sampleSceneUvDepth.xy, sampleSceneUvDepth.z);\n\t\t\t\t\tfloat sceneSampleDist = abs(sampleSceneViewPos.z);\n\t\t\t\t\tfloat sampleDist = abs(sampleViewPos.z);\n\t\t\t\t\t\n\t\t\t\t#if (AO_ALGORITHM == 3 || AO_ALGORITHM == 4)\n\t\t\t\t\t// HBAO || GTAO\n\t\t\t\t\tvec3 viewDelta = sampleSceneViewPos - viewPos;\n\t\t\t\t\tif (abs(viewDelta.z) < thickness) {\n\t\t\t\t\t\tvec2 clipRangeCheck = step(0., sampleSceneUvDepth.xy) * step(sampleSceneUvDepth.xy, vec2(1.));\n\t\t\t\t\t\tfloat sampleCosHorizon = dot(viewDir, normalize(viewDelta));\n\t\t\t\t\t\tcosHorizons.x += max(0., (sampleCosHorizon - cosHorizons.x) * mix(1., 2. / float(j + 2), distanceFallOff) * clipRangeCheck.x * clipRangeCheck.y);\n\t\t\t\t\t}\t\t\n\t\t\t\t\t#if AO_ALGORITHM == 4\n\t\t\t\t\t\tsampleSceneUvDepth = getSceneUvAndDepth(viewPos - sampleViewOffset);\n\t\t\t\t\t\tsampleSceneViewPos = getViewPosition(sampleSceneUvDepth.xy, sampleSceneUvDepth.z);\n\t\t\t\t\t\tviewDelta = sampleSceneViewPos - viewPos;\n\t\t\t\t\t\tif (abs(viewDelta.z) < thickness) {\n\t\t\t\t\t\t\tvec2 clipRangeCheck = step(0., sampleSceneUvDepth.xy) * step(sampleSceneUvDepth.xy, vec2(1.));\n\t\t\t\t\t\t\tfloat sampleCosHorizon = dot(viewDir, normalize(viewDelta));\n\t\t\t\t\t\t\tcosHorizons.y += max(0., (sampleCosHorizon - cosHorizons.y) * mix(1., 2. / float(j + 2), distanceFallOff) * clipRangeCheck.x * clipRangeCheck.y);\t\n\t\t\t\t\t\t}\n\t\t\t\t\t#endif\n\t\t\t\t#elif AO_ALGORITHM == 2\n\t\t\t\t\t// N8AO\n\t\t\t\t\tfloat weight = dot(viewNormal, sampleDir.xyz);\n\t\t\t\t\tfloat occlusion = weight * step(sceneSampleDist + bias, sampleDist);\n\t\t\t\t#elif AO_ALGORITHM == 1\n\t\t\t\t\t// SAO\n\t\t\t\t\tvec3 viewDelta = sampleSceneViewPos - viewPos;\n\t\t\t\t\tfloat minResolution = 0.; // ?\n\t\t\t\t\tfloat scaledViewDist = length( viewDelta ) / scale;\n\t\t\t\t\tfloat weight = 1.;\n\t\t\t\t\tfloat occlusion = max(0., (dot(viewNormal, viewDelta) - minResolution) / scaledViewDist - bias) / (1. + scaledViewDist * scaledViewDist );\n\t\t\t\t#else\n\t\t\t\t\t// SSAO\n\t\t\t\t\tfloat weight = 1.;\n\t\t\t\t\tfloat occlusion = step(sceneSampleDist + bias, sampleDist);\n\t\t\t\t#endif\n\n\t\t#if AO_ALGORITHM == 4\t\n\t\t\t\t}\n\t\t\t\t// GTAO\n\t\t\t\tvec2 sinHorizons = sqrt(1. - cosHorizons * cosHorizons);\n\t\t\t\tfloat nx = dot(normalInSlice, sliceTangent);\n\t\t\t\tfloat ny = dot(normalInSlice, viewDir);\n\t\t\t\tfloat nxb = 1. / 2. * (acos(cosHorizons.y) - acos(cosHorizons.x) + sinHorizons.x * cosHorizons.x - sinHorizons.y * cosHorizons.y);\n\t\t\t\tfloat nyb = 1. / 2. * (2. - cosHorizons.x * cosHorizons.x - cosHorizons.y * cosHorizons.y);\n\t\t\t\tfloat occlusion = nx * nxb + ny * nyb;\n\t\t\t\tao += occlusion;\n\t\t\t}\n\t\t\tao = clamp(ao / float(DIRECTIONS), 0., 1.);\t\n\t\t#elif AO_ALGORITHM == 3\n\t\t\t\t}\n\t\t\t\ttotalWeight += 1.;\n\t\t\t\tao += max(0., cosHorizons.x - max(0., cosHorizons.y));\n\t\t\t}\n\t\t\tao /= totalWeight + 1. - step(0., totalWeight);\n\t\t\tao = clamp(1. - ao, 0., 1.);\n\t\t#else\n\n\t\t\t\tfloat fallOff = getFallOff(sceneSampleDist - sampleDist, distanceFalloffToUse);\n\t\t\t\tocclusion *= fallOff;\n\t\t\t\tvec2 diff = (vUv - sampleSceneUvDepth.xy) * resolution;\n\t\t\t\tocclusion *= step(1., dot(diff, diff));\n\t\t\t\tvec2 clipRangeCheck = step(0., sampleSceneUvDepth.xy) * step(sampleSceneUvDepth.xy, vec2(1.));\n\t\t\t\tocclusion *= clipRangeCheck.x * clipRangeCheck.y;\n\t\t\t\tweight *= clipRangeCheck.x * clipRangeCheck.y;\n\t\t\t\ttotalWeight += weight;\n\t\t\t\tao += occlusion;\n\t\t\t}\n\t\t\tao /= totalWeight + 1. - step(0., totalWeight);\n\t\t\tao = clamp(1. - ao, 0., 1.);\n\t\t#endif\t\n\n\t\t#if SCENE_CLIP_BOX == 1\n\t\t\tao = mix(ao, 1., smoothstep(0., radiusToUse, boxDistance));\n\t\t#endif\n\t\t#if AO_ALGORITHM != 1\n\t\t\tao = pow(ao, scale);\n\t\t#endif\n\t\t\tgl_FragColor = FRAGMENT_OUTPUT;\n\t\t}"},Wp={resolutionScale:1,algorithm:0,samples:32,radius:.25,distanceExponent:2,thickness:.5,distanceFallOff:.5,scale:1,bias:.01,screenSpaceRadius:!1};class jp{get texture(){var e;return this._renderTarget?null===(e=this._renderTarget)||void 0===e?void 0:e.texture:null}constructor(e,t,n,i,r){this.needsUpdate=!0,this.parameters=Object.assign({},Wp),this._width=0,this._height=0,this._samples=0,this._gBufferAntiAliasing=!1,this._normalVectorSourceType=Bp,this._depthValueSourceType=kp,this._modulateRedChannel=!1,this.depthTexture=null,this.normalTexture=null,this._noiseTexture=null,this._renderTarget=null,this._passRenderer=new Ro,this._sceneClipBox=new qt(new jt(-1,-1,-1),new jt(1,1,1)),this._sceneScale=1,this._width=e,this._height=t,this._samples=n,this._gBufferAntiAliasing=i,this._normalVectorSourceType=(null==r?void 0:r.normalVectorSourceType)||Bp,this._depthValueSourceType=(null==r?void 0:r.depthValueSourceType)||kp,this._modulateRedChannel=(null==r?void 0:r.modulateRedChannel)||!1,(null==r?void 0:r.aoParameters)&&(this.parameters=r.aoParameters),r&&this.updateTextures(r)}_getNoiseTexture(e=64){if(!this._noiseTexture){const t=new wo,n=new Uint8Array(e*e*4);for(let i=0;i{const t=new wo,n=Math.floor(e)%2==0?Math.floor(e)+1:Math.floor(e),i=(e=>{const t=Math.floor(e)%2==0?Math.floor(e)+1:Math.floor(e),n=t*t,i=Array(n).fill(0);let r=Math.floor(t/2),a=t-1;for(let e=1;e<=n;)-1===r&&a===t?(a=t-2,r=0):(a===t&&(a=0),r<0&&(r=t-1)),0===i[r*t+a]?(i[r*t+a]=e++,a++,r--):(a-=2,r++);return i})(n),r=i.length,a=new Uint8Array(4*r);for(let n=0;n{const r=Zp(e,t,n,i);let a="vec3[SAMPLES](";for(let t=0;t{const r=[];for(let a=0;a\n#include \n\n#if LUMINANCE_WEIGHTED == 1 \n\n#ifndef LUMINANCE_TYPE\n#define LUMINANCE_TYPE float\n#endif\n#ifndef SAMPLE_LUMINANCE\n#define SAMPLE_LUMINANCE dot(vec3(0.2125, 0.7154, 0.0721), a)\n#endif\n#define WEIGHT_TYPE LUMINANCE_TYPE\n\n#else\n#define WEIGHT_TYPE float\n#endif\n\n#ifndef FRAGMENT_OUTPUT\n#define FRAGMENT_OUTPUT vec4(vec3(denoised), 1.)\n#endif\n\nLUMINANCE_TYPE getLuminance(const in vec3 a) {\n return SAMPLE_LUMINANCE;\n}\n\nconst vec3 poissonDisk[SAMPLES] = SAMPLE_VECTORS;\n\nvec3 getViewPosition(const in vec2 screenPosition, const in float depth) {\n vec4 clipSpacePosition = vec4(vec3(screenPosition, depth) * 2.0 - 1.0, 1.0);\n vec4 viewSpacePosition = cameraProjectionMatrixInverse * clipSpacePosition;\n return viewSpacePosition.xyz / viewSpacePosition.w;\n}\n\nfloat getDepth(const vec2 uv) {\n#if DEPTH_VALUE_SOURCE == 1 \n return textureLod(tDepth, uv.xy, 0.0).a;\n#else\n return textureLod(tDepth, uv.xy, 0.0).r;\n#endif\n}\n\nfloat fetchDepth(const ivec2 uv) {\n#if DEPTH_VALUE_SOURCE == 1 \n return texelFetch(tDepth, uv.xy, 0).a;\n#else\n return texelFetch(tDepth, uv.xy, 0).r;\n#endif\n}\n\nvec3 computeNormalFromDepth(const vec2 uv) {\n vec2 size = vec2(textureSize(tDepth, 0));\n ivec2 p = ivec2(uv * size);\n float c0 = fetchDepth(p);\n float l2 = fetchDepth(p - ivec2(2, 0));\n float l1 = fetchDepth(p - ivec2(1, 0));\n float r1 = fetchDepth(p + ivec2(1, 0));\n float r2 = fetchDepth(p + ivec2(2, 0));\n float b2 = fetchDepth(p - ivec2(0, 2));\n float b1 = fetchDepth(p - ivec2(0, 1));\n float t1 = fetchDepth(p + ivec2(0, 1));\n float t2 = fetchDepth(p + ivec2(0, 2));\n float dl = abs((2.0 * l1 - l2) - c0);\n float dr = abs((2.0 * r1 - r2) - c0);\n float db = abs((2.0 * b1 - b2) - c0);\n float dt = abs((2.0 * t1 - t2) - c0);\n vec3 ce = getViewPosition(uv, c0).xyz;\n vec3 dpdx = (dl < dr) ? ce - getViewPosition((uv - vec2(1.0 / size.x, 0.0)), l1).xyz\n : -ce + getViewPosition((uv + vec2(1.0 / size.x, 0.0)), r1).xyz;\n vec3 dpdy = (db < dt) ? ce - getViewPosition((uv - vec2(0.0, 1.0 / size.y)), b1).xyz\n : -ce + getViewPosition((uv + vec2(0.0, 1.0 / size.y)), t1).xyz;\n return normalize(cross(dpdx, dpdy));\n}\n\nvec3 getViewNormal(const vec2 uv) {\n#if NORMAL_VECTOR_TYPE == 2\n return normalize(textureLod(tNormal, uv, 0.).rgb);\n#elif NORMAL_VECTOR_TYPE == 1\n return unpackRGBToNormal(textureLod(tNormal, uv, 0.).rgb);\n#else\n return computeNormalFromDepth(uv);\n#endif\n}\n\nvoid denoiseSample(in vec3 center, in vec3 viewNormal, in vec3 viewPos, in vec2 sampleUv, inout vec3 denoised, inout WEIGHT_TYPE totalWeight) {\n vec4 sampleTexel = textureLod(tDiffuse, sampleUv, 0.0);\n float sampleDepth = getDepth(sampleUv);\n vec3 sampleNormal = getViewNormal(sampleUv);\n vec3 neighborColor = sampleTexel.rgb;\n vec3 viewPosSample = getViewPosition(sampleUv, sampleDepth);\n \n float normalDiff = dot(viewNormal, sampleNormal);\n float normalSimilarity = pow(max(normalDiff, 0.), normalPhi);\n float depthDiff = abs(dot(normalize(viewPos - viewPosSample), viewNormal));\n float depthSimilarity = max(1. - depthDiff / depthPhi, 0.);\n #if LUMINANCE_WEIGHTED == 1 \n LUMINANCE_TYPE lumaDiff = abs(getLuminance(neighborColor) - getLuminance(center));\n LUMINANCE_TYPE lumaSimilarity = max(1. - lumaDiff / lumaPhi, 0.);\n LUMINANCE_TYPE w = lumaSimilarity * depthSimilarity * normalSimilarity;\n #else\n WEIGHT_TYPE w = depthSimilarity * normalSimilarity;\n #endif\n\n denoised += w * neighborColor;\n totalWeight += w;\n}\n\nvoid main() {\n float depth = fetchDepth(ivec2(vec2(textureSize(tDepth, 0)) * vUv.xy));\t\n vec3 viewNormal = getViewNormal(vUv);\t\n if (depth == 1. || dot(viewNormal, viewNormal) == 0.) {\n discard;\n return;\n }\n vec4 texel = textureLod(tDiffuse, vUv, 0.0);\n vec3 center = texel.rgb;\n vec3 viewPos = getViewPosition(vUv, depth);\n\n #if SCENE_CLIP_BOX == 1\n vec3 worldPos = (cameraWorldMatrix * vec4(viewPos, 1.0)).xyz;\n float boxDistance = length(max(vec3(0.0), max(sceneBoxMin - worldPos, worldPos - sceneBoxMax)));\n if (boxDistance > radius * 2.) {\n discard;\n return;\n }\n\t\t#endif\n\n vec2 noiseResolution = vec2(textureSize(tNoise, 0));\n vec2 noiseUv = vUv * resolution / noiseResolution;\n vec4 noiseTexel = textureLod(tNoise, noiseUv, 0.0);\n vec2 noiseVec = vec2(sin(noiseTexel[iteration % 4] * 2. * PI), cos(noiseTexel[iteration % 4] * 2. * PI));\n #if SAMPLE_DISTRIBUTION == 1\n vec3 randomVec = normalize(vec3(noiseVec.xy, 0.));\n vec3 tangent = normalize(randomVec - viewNormal * dot(randomVec, viewNormal));\n vec3 bitangent = cross(viewNormal, tangent);\n mat3 kernelMatrix = mat3(tangent, bitangent, viewNormal);\n #else\n mat2 rotationMatrix = mat2(noiseVec.x, -noiseVec.y, noiseVec.x, noiseVec.y);\n #endif\n\n WEIGHT_TYPE totalWeight = WEIGHT_TYPE(1.);\n vec3 denoised = texel.rgb;\n for (int i = 0; i < SAMPLES; i++) {\n vec3 sampleDir = poissonDisk[i];\n #if SAMPLE_DISTRIBUTION == 1\n vec3 offsetViewPos = viewPos + normalize(kernelMatrix * vec3(sampleDir.xy, 0.)) * sampleDir.z * radius * radius;\n vec4 samplePointNDC = cameraProjectionMatrix * vec4(offsetViewPos, 1.0); \n vec2 sampleUv = (samplePointNDC.xy / samplePointNDC.w * 0.5 + 0.5);\n #else\n vec2 offset = rotationMatrix * sampleDir.xy * (1. + sampleDir.z * (radius - 1.));\n offset *= mix(vec2(1.0), sqrt(1.0 - viewNormal.xy * viewNormal.xy), float(iteration) / float(noOfIterations-1));\n offset *= max(1.0, 1.0 / length(offset));\n vec2 sampleUv = vUv + offset / resolution;\n #endif\n denoiseSample(center, viewNormal, viewPos, sampleUv, denoised, totalWeight);\n }\n\n denoised /= totalWeight + 1.0 - step(0.0, totalWeight);\n gl_FragColor = FRAGMENT_OUTPUT;\n}"},Jp={iterations:2,samples:16,rings:2.89,radiusExponent:1.3,radius:4,lumaPhi:10,depthPhi:2.5,normalPhi:.5,nvOrientatedSamples:!1};class Qp{get texture(){return this.parameters.iterations>0&&this._renderTargets.length>0?this._renderTargets[this._outputRenderTargetIndex].texture:this._inputTexture}set inputTexture(e){this._inputTexture=e}constructor(e,t,n,i){this.needsUpdate=!0,this.parameters=Object.assign({},Jp),this._width=0,this._height=0,this._samples=0,this._normalVectorSourceType=Bp,this._depthValueSourceType=kp,this._inputTexture=null,this.depthTexture=null,this.normalTexture=null,this._noiseTexture=null,this._renderTargets=[],this._outputRenderTargetIndex=0,this._passRenderer=new Ro,this._rgInputTexture=!1,this._luminanceWeighted=!0,this._width=e,this._height=t,this._samples=n,this._normalVectorSourceType=(null==i?void 0:i.normalVectorSourceType)||Bp,this._depthValueSourceType=(null==i?void 0:i.depthValueSourceType)||kp,this._inputTexture=(null==i?void 0:i.inputTexture)||null,this.depthTexture=(null==i?void 0:i.depthTexture)||null,this.normalTexture=(null==i?void 0:i.normalTexture)||null,this._rgInputTexture=(null==i?void 0:i.rgInputTexture)||!1,this._luminanceWeighted=!0===(null==i?void 0:i.luminanceWeighted),this._luminanceType=(null==i?void 0:i.luminanceType)||"vec3",this._sampleLuminance=(null==i?void 0:i.sampleLuminance)||"a",this._fragmentOutput=(null==i?void 0:i.fragmentOutput)||"vec4(denoised.xyz, 1.)",(null==i?void 0:i.poissonDenoisePassParameters)&&(this.parameters=i.poissonDenoisePassParameters),i&&this.updateTextures(i)}_getNoiseTexture(e=64){if(!this._noiseTexture){const t=new wo,n=new Uint8Array(e*e*4);for(let i=0;ie.dispose()))}setSize(e,t){this._width=e,this._height=t,this._renderTargets.forEach((n=>n.setSize(e,t))),this.needsUpdate=!0}updateBounds(e){this._sceneClipBox=(new qt).copy(e),this.needsUpdate=!0}updateParameters(e){for(const t in e)this.parameters.hasOwnProperty(t)&&(this.parameters[t]=e[t],this.needsUpdate=!0)}updateTextures(e){e.inputTexture&&(this._inputTexture=e.inputTexture,this.needsUpdate=!0),e.depthTexture&&(this.depthTexture=e.depthTexture,this.needsUpdate=!0),e.normalTexture&&(this.normalTexture=e.normalTexture,this.needsUpdate=!0)}render(e,t){const n=this._getMaterial(t,this.needsUpdate);this.needsUpdate=!1;const i=this._getRenderTargets();n.uniforms.iteration.value=this.parameters.iterations;for(let t=0;t.001,r=e===ef&&t>.001&&t<.999;return{fadeInPoissonShadow:i,fadeInHardShadow:r,onlyHardShadow:e===ef&&!r,progressiveDenoise:!i&&!r&&n>1&&n<=this.parameters.progressiveDenoiseIterations+1}}renderPass(e){if(!this._setRenderState())return;const t=this._getRenderConditions(this.shadowAndAoPassSettings.shadowFadeInBlurType,this.shadowAndAoPassSettings.shadowFadeInMix,this.shadowAndAoPassSettings.noOStaticFrames);let n=!1;!t.onlyHardShadow&&this.shadowAndAoPassSettings.shadowBlurType===nf&&this._evaluateIfUpdateIsNeeded(this.camera)&&(this._renderShadowAndAo(e,this.scene,this.camera,this.shadowAndAoPassSettings.shadowMapTexture),n=!0);let i=t.onlyHardShadow?this.shadowAndAoPassSettings.shadowMapTexture:this.denoiseRenderTargetTexture;t.fadeInPoissonShadow&&(i=this._renderDynamicShadow(e,this.aoAndSoftShadowRenderTarget.texture,this.shadowAndAoPassSettings.shadowMapTexture,this.shadowAndAoPassSettings.shadowFadeInMix),n=!0),n?i=this._renderDenoise(e,this.camera,t.fadeInPoissonShadow,!1):t.progressiveDenoise&&(i=this._renderDenoise(e,this.camera,!1,!0)),t.fadeInHardShadow&&(i=this._renderDynamicShadow(e,this.denoiseRenderTargetTexture,this.shadowAndAoPassSettings.shadowMapTexture,this.shadowAndAoPassSettings.shadowFadeInMix)),this._finalTexture=i,this._onlyHardShadow=t.onlyHardShadow,this.renderToRenderTarget&&this.renderToTarget(e)}_setRenderState(){return!(!this.parameters.enabled||!(null!==this.parameters.ao.algorithm||this.parameters.shadowIntensity>=.01)||(this.needsUpdate&&(this._aoPass&&(this._aoPass.needsUpdate=!0),this._poissonDenoisePass&&(this._poissonDenoisePass.needsUpdate=!0)),0))}_evaluateIfUpdateIsNeeded(e){e.updateProjectionMatrix();const t=this.parameters.alwaysUpdate||this.needsUpdate||null!=e&&this._cameraUpdate.changed(e);return this.needsUpdate=!1,t}_renderShadowAndAo(e,t,n,i){var r;const a=null!==this.parameters.ao.algorithm&&this.parameters.aoIntensity>.01;a||null===(r=this._aoPass)||void 0===r||r.clear(e,this.aoAndSoftShadowRenderTarget),this._renderSoftShadow(e,n,i),a&&this._renderAo(e,t,n)}_renderAo(e,t,n){const i=this.gBufferTextures.depthBufferTexture,r=this.gBufferTextures.gBufferTexture,a=this._aoAndSoftShadowRenderTarget,s=e.autoClear;e.autoClear=!1;const o=this.aoRenderPass;o.depthTexture=i,o.normalTexture=r,o.render(e,n,t,a),e.autoClear=s}_renderSoftShadow(e,t,n){const i=this.softShadowPass;i.parameters.radius=this.parameters.shadow.shadowRadius,i.inputTexture=n,this.softShadowPass.renderToTarget(e,t,this.aoAndSoftShadowRenderTarget)}_renderDynamicShadow(e,t,n,i=1){const r=i<.999;return r&&(this._copyMaterial.update({texture:t,blending:0,colorTransform:ro,colorBase:co,multiplyChannels:0}),this.passRenderer.renderScreenSpace(e,this._copyMaterial,this.fadeRenderTarget)),i>.001&&(this._blendMaterial.update({texture:n,blending:r?5:0,colorTransform:(new wn).set(0,0,0,1,1,0,0,0,0,0,0,1,0,0,0,r?i:1),multiplyChannels:0}),this.passRenderer.renderScreenSpace(e,this._blendMaterial,this.fadeRenderTarget)),this.fadeRenderTarget.texture}_renderDenoise(e,t,n,i){const r=this.denoisePass;return r.inputTexture=n?this.fadeRenderTarget.texture:i?r.texture:this.aoAndSoftShadowRenderTarget.texture,r.render(e,t),r.texture}renderToTarget(e){const t=this._onlyHardShadow?this.parameters.shadowIntensity:this.parameters.aoIntensity,n=this._onlyHardShadow?0:this.parameters.shadowIntensity;this.passRenderer.renderScreenSpace(e,this._blendAoAndShadowMaterial.update({texture:this._finalTexture,blending:5,aoIntensity:t,shadowIntensity:n}),e.getRenderTarget())}}af.shadowTransform=(new wn).set(0,1,0,0,0,1,0,0,0,1,0,0,0,0,0,1);class sf{get isOutlinePassActivated(){return this.outlinePassActivated}get outlinePass(){return this._renderPassManager.outlinePass}constructor(e,t,n){this._effectComposer=null,this.outlinePassActivated=!1,this._renderPassManager=e,this._effectComposer=t,this.parameters=Object.assign({enabled:!0,edgeStrength:2,edgeGlow:1,edgeThickness:2,pulsePeriod:0,usePatternTexture:!1,visibleEdgeColor:16777215,hiddenEdgeColor:16777215},n)}updateParameters(e){for(const t in e)this.parameters.hasOwnProperty(t)&&(this.parameters[t]=e[t])}applyParameters(){this.outlinePass&&(this.outlinePass.edgeStrength=this.parameters.edgeStrength,this.outlinePass.edgeGlow=this.parameters.edgeGlow,this.outlinePass.edgeThickness=this.parameters.edgeThickness,this.outlinePass.pulsePeriod=this.parameters.pulsePeriod,this.outlinePass.usePatternTexture=this.parameters.usePatternTexture,this.outlinePass.visibleEdgeColor.set(this.parameters.visibleEdgeColor),this.outlinePass.hiddenEdgeColor.set(this.parameters.hiddenEdgeColor))}activateOutline(e,t){var n;if(!this.parameters.enabled)return void this.deactivateOutline();const i=(null===(n=this.outlinePass)||void 0===n?void 0:n.renderCamera)&&t.isPerspectiveCamera!==this.outlinePass.renderCamera.isPerspectiveCamera;this.outlinePass&&(this.outlinePass.renderScene=e,this.outlinePass.renderCamera=t),!i&&this.outlinePassActivated||(!i&&this.outlinePass||this._renderPassManager.createOutlinePass(),this.applyParameters(),this._effectComposer&&this._effectComposer.addPass(this.outlinePass),this.outlinePassActivated=!0)}deactivateOutline(){this.outlinePassActivated&&(this.outlinePass&&this._effectComposer&&this._effectComposer.removePass(this.outlinePass),this.outlinePassActivated=!1)}updateOutline(e,t,n){n.length>0?(this.activateOutline(e,t),this.outlinePass&&(this.outlinePass.selectedObjects=n)):this.deactivateOutline()}}const of=(e,t)=>{for(const n in t)try{t[n].constructor===Object?e[n]=of(e[n],t[n]):e[n]=t[n]}catch(i){e[n]=t[n]}return e},lf="default",cf={shadowType:"PCFSoftShadowMap",shAndAoPassParameters:{aoIntensity:.3,shadow:{shadowRadius:.1},ao:{algorithm:0,samples:32,radius:.02,distanceExponent:2,thickness:.1,distanceFallOff:1,bias:.01},poissonDenoise:{iterations:2,samples:16,rings:2.89,radius:4,radiusExponent:1.3,depthPhi:2.5,normalPhi:.5}},groundReflectionParameters:{brightness:.5}},hf=e=>Math.max(0,Math.min(1,e));class df{constructor(e){this.needsUpdate=!0,this._cache=null,this._cache=e}dispose(){var e;null===(e=this._cache)||void 0===e||e.dispose()}clear(){var e;null===(e=this._cache)||void 0===e||e.clear(),this.needsUpdate=!0}update(e){this.needsUpdate&&this._cache&&(e.traverse((e=>{var t,n,i;e.isLine||e.isPoints?null===(t=this._cache)||void 0===t||t.addLineOrPoint(e):e.isMesh?null===(n=this._cache)||void 0===n||n.addMesh(e):null===(i=this._cache)||void 0===i||i.addObject(e)})),this.needsUpdate=!1)}onBeforeRender(){var e;null===(e=this._cache)||void 0===e||e.onBeforeRender()}onAfterRender(){var e;null===(e=this._cache)||void 0===e||e.onAfterRender()}}class uf{constructor(){this._cacheMap=new Map}dispose(){this._cacheMap.forEach((e=>{e.dispose()}))}registerCache(e,t){this._cacheMap.set(e,new df(t))}clearCache(){this._cacheMap.forEach((e=>{e.clear()}))}clearObjectCache(e){const t=this._cacheMap.get(e);t&&t.clear()}onBeforeRender(e,t){const n=this._cacheMap.get(e);n&&(n.update(t),n.onBeforeRender())}onAfterRender(e){const t=this._cacheMap.get(e);t&&t.onAfterRender()}render(e,t,n){const i=this._cacheMap.get(e);i&&(i.update(t),i.onBeforeRender()),n(),i&&i.onAfterRender()}}class pf{constructor(e){this._visibilityCache=new Map,this._isObjectInvisible=e}dispose(){this._visibilityCache.clear()}clear(){this._visibilityCache.clear()}addLineOrPoint(e){this._visibilityCache.set(e,e.visible)}addMesh(e){this._isObjectInvisible&&this._isObjectInvisible(e)&&this._visibilityCache.set(e,e.visible)}addObject(e){this._isObjectInvisible&&this._isObjectInvisible(e)&&this._visibilityCache.set(e,e.visible)}onBeforeRender(){this._visibilityCache.forEach(((e,t)=>{t.visible=!1}))}onAfterRender(){this._visibilityCache.forEach(((e,t)=>{t.visible=e}))}}class ff{constructor(e){this._depthWriteCache=new Set,this._doNotWriteDepth=e}dispose(){this._depthWriteCache.clear()}clear(){this._depthWriteCache.clear()}addLineOrPoint(e){}addObject(e){}addMesh(e){this._doNotWriteDepth&&this._doNotWriteDepth(e)&&e.material instanceof Fa&&e.material.depthWrite&&this._depthWriteCache.add(e.material)}onBeforeRender(){this._depthWriteCache.forEach((e=>{e.depthWrite=!1}))}onAfterRender(){this._depthWriteCache.forEach((e=>{e.depthWrite=!0}))}}class mf{constructor(){this._objectCache=new Map}clear(){this._objectCache.clear()}onBeforeRender(){this._objectCache.forEach(((e,t)=>{t instanceof Yi&&(t.material!==e.originalObjectData.material&&t.material!==e.updateObjectData.material&&(e.originalObjectData.material=t.material),t.receiveShadow!==e.originalObjectData.receiveShadow&&(e.originalObjectData.receiveShadow=t.receiveShadow),t.castShadow!==e.originalObjectData.castShadow&&(e.originalObjectData.castShadow=t.castShadow),t.visible!==e.originalObjectData.visible&&(e.originalObjectData.visible=t.visible)),this._updateObject(t,e.updateObjectData)}))}onAfterRender(){this._objectCache.forEach(((e,t)=>{this._updateObject(t,e.originalObjectData)}))}addToCache(e,t){this._objectCache.set(e,{originalObjectData:{visible:e.visible,castShadow:e.castShadow,receiveShadow:e instanceof Yi?e.receiveShadow:void 0,material:e instanceof Yi?e.material:void 0},updateObjectData:t})}_updateObject(e,t){void 0!==t.visible&&(e.visible=t.visible),void 0!==t.castShadow&&(e.castShadow=t.castShadow),e instanceof Yi&&void 0!==t.receiveShadow&&(e.receiveShadow=t.receiveShadow),e instanceof Yi&&void 0!==t.material&&(e.material=t.material)}}class gf extends Np{get shadowGroundPlane(){var e;let t=this._sharedShadowGroundPlane;return t||(null!==(e=this._shadowGroundPlane)&&void 0!==e||(this._shadowGroundPlane=new Op(this.renderTarget.texture,this.parameters)),t=this._shadowGroundPlane),t.parent!==this._groundGroup&&this._groundGroup.add(t),t}constructor(e,t,n,i){var r,a;super(e),this.limitPlaneSize=!0,this.needsUpdate=!0,this.noNeedOfUpdateCount=0,this._blurScale=1,this._shadowScale=1,this._groundGroup=n,this.shadowMapSize=null!==(r=i.shadowMapSize)&&void 0!==r?r:2048,this.parameters=this._getDefaultParameters(i),this._groundShadowFar=this.parameters.cameraFar,this._renderer=t,null===(a=this.renderCacheManager)||void 0===a||a.registerCache(this,new pf((e=>e.isMesh&&!(e=>{var t;if(!e.isMesh)return!1;if(!e.castShadow&&!(null===(t=e.userData)||void 0===t?void 0:t.meshId))return!1;const n=e.material;return!n.transparent||n.opacity>.5})(e)||void 0!==e.name&&["Ground","Floor"].includes(e.name)))),this.renderTarget=new Ht(this.shadowMapSize,this.shadowMapSize),this.renderTarget.texture.generateMipmaps=!1,this._renderTargetBlur=new Ht(this.shadowMapSize,this.shadowMapSize),this._renderTargetBlur.texture.generateMipmaps=!1,this._sharedShadowGroundPlane=null==i?void 0:i.sharedShadowGroundPlane,this.shadowGroundPlane.setShadowMap(this.renderTarget.texture),this.shadowGroundPlane.updateMaterial(this.parameters),this._groundContactCamera=new vf,this._groundGroup.add(this._groundContactCamera),this._depthMaterial=new Va,this._depthMaterial.userData.fadeoutBias={value:this.parameters.fadeoutBias},this._depthMaterial.userData.fadeoutFalloff={value:this.parameters.fadeoutFalloff},this._depthMaterial.onBeforeCompile=e=>{e.uniforms.fadeoutBias=this._depthMaterial.userData.fadeoutBias,e.uniforms.fadeoutFalloff=this._depthMaterial.userData.fadeoutFalloff,e.fragmentShader=`\n uniform float fadeoutBias;\n uniform float fadeoutFalloff;\n ${e.fragmentShader.replace("gl_FragColor = vec4( vec3( 1.0 - fragCoordZ ), opacity );",Op.alphaMap?"gl_FragColor = vec4(clamp(pow(1.0 + fadeoutBias - fragCoordZ, 1.0/(1.0-fadeoutFalloff)), 0.0, 1.0));":"gl_FragColor = vec4(vec3(0.0), clamp(pow(1.0 + fadeoutBias - fragCoordZ, 1.0/(1.0-fadeoutFalloff)), 0.0, 1.0));")}\n `},this._depthMaterial.side=2,this._depthMaterial.depthTest=!0,this._depthMaterial.depthWrite=!0,this._blurPass=new Co(go,Object.assign(Object.assign({},i),{passRenderer:this.renderPassManager.passRenderer})),this.updatePlaneAndShadowCamera()}_getDefaultParameters(e){return Object.assign({enabled:!0,cameraHelper:!1,alwaysUpdate:!1,fadeIn:!1,blurMin:.001,blurMax:.1,fadeoutFalloff:.9,fadeoutBias:.03,opacity:.5,maximumPlaneSize:40,planeSize:10,cameraFar:3,hardLayers:null,softLayers:null,polygonOffset:2,excludeGroundObjects:!0},e)}dispose(){this.renderTarget.dispose(),this._renderTargetBlur.dispose(),this._blurPass.dispose(),this._depthMaterial.dispose()}updateParameters(e){for(const t in e)this.parameters.hasOwnProperty(t)&&(this.parameters[t]=e[t]);void 0!==e.cameraFar&&(this._groundShadowFar=this.parameters.cameraFar)}applyParameters(){this.shadowGroundPlane.updateMaterial(this.parameters),this._groundContactCamera.updateCameraHelper(this.parameters.cameraHelper),this._groundContactCamera.far!==this.parameters.cameraFar&&this.updatePlaneAndShadowCamera();const e=this.parameters.fadeoutFalloff;this._depthMaterial.userData.fadeoutFalloff.value!==e&&(this._depthMaterial.userData.fadeoutFalloff.value=this.parameters.fadeoutFalloff);const t=this.parameters.fadeoutBias/this._groundContactCamera.far;this._depthMaterial.userData.fadeoutBias.value!==t&&(this._depthMaterial.userData.fadeoutBias.value=t),this.needsUpdate=!0}setScale(e,t){this._blurScale=e,this._shadowScale=null!=t?t:e,this.needsUpdate=!0}updateBounds(e,t){var n;this._groundShadowFar=this.parameters.cameraFar,this._groundShadowFarthis.parameters.maximumPlaneSize?(this.parameters.planeSize=this.parameters.maximumPlaneSize,this._groundGroup.position.set(0,null!=t?t:0,0)):this._groundGroup.position.set(e.center.x,null!=t?t:0,e.center.z),this._groundGroup.updateMatrixWorld(),this.updatePlaneAndShadowCamera()}updatePlaneAndShadowCamera(){const e=this.parameters.planeSize;this.shadowGroundPlane.scale.x=e,this.shadowGroundPlane.scale.y=e,this._groundContactCamera.updateCameraFormPlaneSize(e,this._groundShadowFar),this.needsUpdate=!0}setGroundVisibilityLayers(e){this.shadowGroundPlane.setVisibilityLayers(e)}renderPass(e){if(this._groundContactCamera.updateCameraHelper(this.parameters.cameraHelper,this.scene),!this.parameters.enabled)return void(this.needsUpdate&&(this.needsUpdate=!1,this.passRenderer.clear(e,this.renderTarget,0,1)));if(this.shadowGroundPlane.visible=this.parameters.enabled,this.parameters.alwaysUpdate||this.needsUpdate)this.noNeedOfUpdateCount=0;else if(this.noNeedOfUpdateCount++,this.noNeedOfUpdateCount>=10)return;this.needsUpdate=!1,this.shadowGroundPlane.material.opacity=this.parameters.alwaysUpdate||!this.parameters.fadeIn?this.parameters.opacity:this.parameters.opacity*(this.noNeedOfUpdateCount+2)/12;const t=this._renderer.getClearAlpha();this._renderer.setClearAlpha(0),this._groundGroup.visible=!1,this.shadowGroundPlane.visible=!1,this._groundContactCamera.setCameraHelperVisibility(!1),0===this.noNeedOfUpdateCount?(this._renderGroundContact(this.scene),this._renderBlur()):1===this.noNeedOfUpdateCount&&this._renderBlur(),this._renderReduceBandingBlur(),this._renderer.setRenderTarget(null),this._renderer.setClearAlpha(t),this._groundGroup.visible=!0,this.shadowGroundPlane.visible=this.parameters.enabled,this._groundContactCamera.setCameraHelperVisibility(this.parameters.cameraHelper)}_renderGroundContact(e){const t=e.background;e.background=null,e.overrideMaterial=this._depthMaterial,this._renderer.setRenderTarget(this.renderTarget),this._renderer.clear();const n=this._renderer.autoClear;this._renderer.autoClear=!1,this.parameters.hardLayers&&(this._groundContactCamera.layers.mask=this.parameters.hardLayers.mask,this._groundContactCamera.updateCameraFarPlane(10),this._depthMaterial.userData.fadeoutBias.value=.99,this._renderer.render(e,this._groundContactCamera),this._groundContactCamera.updateCameraFarPlane(this._groundShadowFar),this._depthMaterial.userData.fadeoutBias.value=this.parameters.fadeoutBias/this._groundShadowFar),this._groundContactCamera.layers.enableAll(),this.parameters.softLayers&&(this._groundContactCamera.layers.mask=this.parameters.softLayers.mask),this.renderCacheManager?this.renderCacheManager.render(this,e,(()=>{this._renderer.render(e,this._groundContactCamera)})):this._renderer.render(e,this._groundContactCamera),this._renderer.autoClear=n,e.overrideMaterial=null,e.background=t}_renderBlur(){this._renderBlurPass(this._blurScale*this.parameters.blurMin/this.parameters.planeSize,this._blurScale*this.parameters.blurMax/this.parameters.planeSize)}_renderReduceBandingBlur(){const e=.01*this._blurScale/this.parameters.planeSize;this._renderBlurPass(e,e)}_renderBlurPass(e,t){this._blurPass.render(this._renderer,[this.renderTarget,this._renderTargetBlur,this.renderTarget],[e,e],[t,t])}}gf.addTestMesh=!1;class vf extends Cs{constructor(){super(-1,1,-1,1,-1,1),this.rotation.x=Math.PI}updateCameraFormPlaneSize(e,t){var n;this.left=-e/2,this.right=e/2,this.top=-e/2,this.bottom=e/2,this.near=0,this.far=t,this.updateProjectionMatrix(),null===(n=this.cameraHelper)||void 0===n||n.update()}updateCameraFarPlane(e){var t;this.far=e,this.updateProjectionMatrix(),null===(t=this.cameraHelper)||void 0===t||t.update()}updateCameraHelper(e,t){var n,i,r;e?(this.cameraHelper=null!==(n=this.cameraHelper)&&void 0!==n?n:new Qs(this),this.cameraHelper.visible=!0,null==t||t.add(this.cameraHelper)):(null===(i=this.cameraHelper)||void 0===i?void 0:i.parent)&&(null===(r=this.cameraHelper)||void 0===r||r.removeFromParent())}setCameraHelperVisibility(e){this.cameraHelper&&(this.cameraHelper.visible=e)}}class _f extends er{constructor(e){var t;super({defines:Object.assign(Object.assign(Object.assign({},_f._normalAndDepthShader.defines),{FLOAT_BUFFER:(null==e?void 0:e.floatBufferType)?1:0,LINEAR_DEPTH:(null==e?void 0:e.linearDepth)?1:0})),uniforms:$i.clone(_f._normalAndDepthShader.uniforms),vertexShader:_f._normalAndDepthShader.vertexShader,fragmentShader:_f._normalAndDepthShader.fragmentShader,blending:null!==(t=null==e?void 0:e.blending)&&void 0!==t?t:0}),this.update(e)}update(e){if(void 0!==(null==e?void 0:e.camera)){const t=(null==e?void 0:e.camera)||(null==e?void 0:e.camera);this.uniforms.cameraNear.value=t.near,this.uniforms.cameraFar.value=t.far}return this}}_f._normalAndDepthShader={uniforms:{cameraNear:{value:.1},cameraFar:{value:1}},defines:{FLOAT_BUFFER:0,LINEAR_DEPTH:0},vertexShader:"varying vec3 vNormal;\n#if LINEAR_DEPTH == 1\n varying float vZ; \n#endif\n\n void main() {\n vNormal = normalMatrix * normal;\n vec4 viewPosition = modelViewMatrix * vec4(position, 1.0);\n #if LINEAR_DEPTH == 1\n vZ = viewPosition.z; \n #endif\n gl_Position = projectionMatrix * viewPosition;\n }",fragmentShader:"varying vec3 vNormal;\n#if LINEAR_DEPTH == 1\n varying float vZ; \n uniform float cameraNear;\n uniform float cameraFar;\n#endif\n\n void main() {\n #if FLOAT_BUFFER == 1\n vec3 normal = normalize(vNormal);\n #else\n vec3 normal = normalize(vNormal) * 0.5 + 0.5;\n #endif\n #if LINEAR_DEPTH == 1\n float depth = (-vZ - cameraNear) / (cameraFar - cameraNear);\n #else\n float depth = gl_FragCoord.z;\n #endif\n gl_FragColor = vec4(normal, depth);\n }"};class xf extends Np{set groundDepthWrite(e){this._gBufferMaterialCache&&(this._gBufferMaterialCache.groundDepthWrite=e)}get isFloatGBufferWithRgbNormalAlphaDepth(){return this.floatRgbNormalAlphaDepth}get gBufferTexture(){return this.depthNormalRenderTarget.texture}get depthBufferTexture(){return this.copyToSeparateDepthBuffer&&this.floatRgbNormalAlphaDepth?this.separateDeptRenderTarget.texture:this.depthNormalRenderTarget.depthTexture}get textureWithDepthValue(){return this.floatRgbNormalAlphaDepth?this.depthNormalRenderTarget.texture:this.depthNormalRenderTarget.depthTexture}updateGBufferRenderMaterial(e){var t;return this._gBufferRenderMaterial=null!==(t=this._gBufferRenderMaterial)&&void 0!==t?t:this.floatRgbNormalAlphaDepth?new _f({blending:0,floatBufferType:!0,linearDepth:!1}):new ka({blending:0}),this._gBufferRenderMaterial instanceof _f&&this._gBufferRenderMaterial.update({camera:e}),this._gBufferRenderMaterial}get depthNormalRenderTarget(){if(!this._depthNormalRenderTarget)if(this.floatRgbNormalAlphaDepth)this._depthNormalRenderTarget=new Ht(this._width*this.parameters.depthNormalScale,this._height*this.parameters.depthNormalScale,{minFilter:this._targetMinificationTextureFilter,magFilter:this._targetMagnificationTextureFilter,type:Z,samples:this._samples});else{const e=new pa(this._width*this.parameters.depthNormalScale,this._height*this.parameters.depthNormalScale);e.format=ne,e.type=$,this._depthNormalRenderTarget=new Ht(this._width*this.parameters.depthNormalScale,this._height*this.parameters.depthNormalScale,{minFilter:this._targetMinificationTextureFilter,magFilter:this._targetMagnificationTextureFilter,depthTexture:e})}return this._depthNormalRenderTarget}get separateDeptRenderTarget(){return this._separateDeptRenderTarget||(this._separateDeptRenderTarget=new Ht(this._width*this.parameters.depthNormalScale,this._height*this.parameters.depthNormalScale,{minFilter:this._targetMinificationTextureFilter,magFilter:this._targetMagnificationTextureFilter,type:Z,samples:0})),this._separateDeptRenderTarget}constructor(e,t){var n,i,r,a,s,o,l,c,h;super(e),this.floatRgbNormalAlphaDepth=!1,this.linearDepth=!1,this.copyToSeparateDepthBuffer=!1,this.needsUpdate=!0,this.drawGround=!0,this.floatRgbNormalAlphaDepth=null!==(i=null===(n=null==t?void 0:t.capabilities)||void 0===n?void 0:n.isWebGL2)&&void 0!==i&&i,this.renderCacheManager&&(this._gBufferMaterialCache=new yf,this.renderCacheManager.registerCache(this,this._gBufferMaterialCache)),this.parameters={depthNormalScale:null!==(r=null==t?void 0:t.depthNormalScale)&&void 0!==r?r:1},this._targetMinificationTextureFilter=null!==(a=null==t?void 0:t.textureMinificationFilter)&&void 0!==a?a:z,this._targetMagnificationTextureFilter=null!==(s=null==t?void 0:t.textureMagnificationFilter)&&void 0!==s?s:z,this._width=null!==(o=null==t?void 0:t.width)&&void 0!==o?o:1024,this._height=null!==(l=null==t?void 0:t.height)&&void 0!==l?l:1024,this._samples=null!==(c=null==t?void 0:t.samples)&&void 0!==c?c:0,this._shared=null!==(h=null==t?void 0:t.shared)&&void 0!==h&&h}dispose(){var e,t;super.dispose(),null===(e=this._gBufferRenderMaterial)||void 0===e||e.dispose(),null===(t=this._depthNormalRenderTarget)||void 0===t||t.dispose()}setSize(e,t){var n;this._width=e,this._height=t,null===(n=this._depthNormalRenderTarget)||void 0===n||n.setSize(this._width*this.parameters.depthNormalScale,this._height*this.parameters.depthNormalScale)}renderPass(e){this._shared&&!this.needsUpdate||(this.needsUpdate=!1,this.renderPassManager.setGroundVisibility(this.drawGround),this.renderCacheManager?this.renderCacheManager.render(this,this.scene,(()=>{this._renderGBuffer(e,this.scene,this.camera)})):this._renderGBuffer(e,this.scene,this.camera),this.renderPassManager.setGroundVisibility(!1),this.floatRgbNormalAlphaDepth&&this.copyToSeparateDepthBuffer&&this._copyDepthToSeparateDepthTexture(e,this.depthNormalRenderTarget))}_renderGBuffer(e,t,n){this.passRenderer.renderWithOverrideMaterial(e,t,n,this.updateGBufferRenderMaterial(n),this.depthNormalRenderTarget,7829503,1)}getCopyMaterial(e){var t;return null!==(t=this._copyMaterial)&&void 0!==t||(this._copyMaterial=new mo),this._copyMaterial.update(e)}_copyDepthToSeparateDepthTexture(e,t){this.passRenderer.renderScreenSpace(e,this.getCopyMaterial({texture:t.texture,blending:0,colorTransform:so,colorBase:ho,multiplyChannels:0,uvTransform:uo}),this.separateDeptRenderTarget)}}class yf extends mf{set groundDepthWrite(e){this._groundDepthWrite=e}constructor(){super(),this._groundDepthWrite=!0}dispose(){}addLineOrPoint(e){this.addToCache(e,{visible:!1})}addMesh(e){e.userData.isFloor?this.addToCache(e,{visible:this._groundDepthWrite}):e.visible&&(e.material instanceof vi&&(e.material.transparent&&e.material.opacity<.7||e.material.alphaTest>0)||e.material instanceof Ba&&e.material.transmission>0)&&this.addToCache(e,{visible:!1})}addObject(e){}}class Sf extends Np{get reflectionRenderTarget(){var e;return this._reflectionRenderTarget=null!==(e=this._reflectionRenderTarget)&&void 0!==e?e:this._newRenderTarget(!0),this._reflectionRenderTarget}get intensityRenderTarget(){var e;return this._intensityRenderTarget=null!==(e=this._intensityRenderTarget)&&void 0!==e?e:this._newRenderTarget(!1),this._intensityRenderTarget}get blurRenderTarget(){var e;return this._blurRenderTarget=null!==(e=this._blurRenderTarget)&&void 0!==e?e:this._newRenderTarget(!1),this._blurRenderTarget}constructor(e,t,n,i,r){super(e),this.reflectionFadeInScale=1,this._width=t,this._height=n,this._samples=null!=i?i:1,this.parameters=Object.assign({enabled:!1,intensity:.25,fadeOutDistance:1,fadeOutExponent:4,brightness:1,blurHorizontal:3,blurVertical:6,blurAscent:0,groundLevel:0,groundReflectionScale:1,renderTargetDownScale:4},r),this._copyMaterial=new mo({},fo,!0,!0),this._updateCopyMaterial(null),this._reflectionIntensityMaterial=new wf({width:this._width/this.parameters.renderTargetDownScale,height:this._height/this.parameters.renderTargetDownScale}),this._blurPass=new Co(go,Object.assign(Object.assign({},r),{passRenderer:this.renderPassManager.passRenderer}))}_newRenderTarget(e){const t=this._width/this.parameters.renderTargetDownScale,n=this._height/this.parameters.renderTargetDownScale,i={};if(e){const e=new pa(t,n);i.depthTexture=e,i.samples=this._samples}else i.samples=1;return new Ht(t,n,Object.assign({format:ee},i))}dispose(){var e,t,n;super.dispose(),null===(e=this._reflectionRenderTarget)||void 0===e||e.dispose(),null===(t=this._intensityRenderTarget)||void 0===t||t.dispose(),null===(n=this._blurRenderTarget)||void 0===n||n.dispose(),this._copyMaterial.dispose()}setSize(e,t){var n,i,r,a;this._width=e,this._height=t,null===(n=this._reflectionRenderTarget)||void 0===n||n.setSize(this._width/this.parameters.renderTargetDownScale,this._height/this.parameters.renderTargetDownScale),null===(i=this._intensityRenderTarget)||void 0===i||i.setSize(this._width/this.parameters.renderTargetDownScale,this._height/this.parameters.renderTargetDownScale),null===(r=this._blurRenderTarget)||void 0===r||r.setSize(this._width/this.parameters.renderTargetDownScale,this._height/this.parameters.renderTargetDownScale),null===(a=this._reflectionIntensityMaterial)||void 0===a||a.update({width:this._width/this.parameters.renderTargetDownScale,height:this._height/this.parameters.renderTargetDownScale})}updateParameters(e){for(const t in e)this.parameters.hasOwnProperty(t)&&(this.parameters[t]=e[t])}updateBounds(e,t){this.parameters.groundLevel=e,this.parameters.groundReflectionScale=t}_updateCopyMaterial(e,t=1){var n;const i=this.parameters.intensity*t,r=this.parameters.brightness;this._copyMaterial.update({texture:null!==(n=null==e?void 0:e.texture)&&void 0!==n?n:void 0,colorTransform:(new wn).set(r,0,0,0,0,r,0,0,0,0,r,0,0,0,0,i),multiplyChannels:0,uvTransform:po}),this._copyMaterial.depthTest=!0,this._copyMaterial.depthWrite=!1}renderPass(e){if(!(this.parameters.enabled&&this.camera instanceof ar))return;const t=this._createGroundReflectionCamera(this.camera);this.renderCacheManager.render("inivisibleGround",this.scene,(()=>{this._renderGroundReflection(e,this.scene,t,this.reflectionRenderTarget)})),this._renderGroundReflectionIntensity(e,t,this.intensityRenderTarget),(this.parameters.blurHorizontal>0||this.parameters.blurVertical>0)&&this.blurReflection(e,this.camera,[this.intensityRenderTarget,this.blurRenderTarget,this.intensityRenderTarget]),this._updateCopyMaterial(this.intensityRenderTarget,this.reflectionFadeInScale),this.passRenderer.renderScreenSpace(e,this._copyMaterial,e.getRenderTarget())}_renderGroundReflection(e,t,n,i){const r=e.getRenderTarget();i&&(e.setRenderTarget(i),this.passRenderer.clear(e,i,0,0)),e.render(t,n),i&&e.setRenderTarget(r)}_renderGroundReflectionIntensity(e,t,n){const i=e.getRenderTarget();e.setRenderTarget(n),this.passRenderer.renderScreenSpace(e,this._reflectionIntensityMaterial.update({texture:this.reflectionRenderTarget.texture,depthTexture:this.reflectionRenderTarget.depthTexture,camera:t,groundLevel:this.parameters.groundLevel,fadeOutDistance:this.parameters.fadeOutDistance*this.parameters.groundReflectionScale,fadeOutExponent:this.parameters.fadeOutExponent}),e.getRenderTarget()),e.setRenderTarget(i)}blurReflection(e,t,n){const i=new jt(t.matrixWorld.elements[4],t.matrixWorld.elements[5],t.matrixWorld.elements[6]),r=this.parameters.blurHorizontal/this._width,a=this.parameters.blurVertical/this._height*Math.abs(i.dot(new jt(0,0,1)));this._blurPass.render(e,n,[4*r,4*a],[4*r*(1+this.parameters.blurAscent),4*a*(1+this.parameters.blurAscent)])}_createGroundReflectionCamera(e){const t=e.clone(),n=t;return n._offset&&(n._offset={left:n._offset.left,top:1-n._offset.bottom,right:n._offset.right,bottom:1-n._offset.top}),t.position.set(e.position.x,-e.position.y+2*this.parameters.groundLevel,e.position.z),t.rotation.set(-e.rotation.x,e.rotation.y,-e.rotation.z),t.updateMatrixWorld(),t.updateProjectionMatrix(),t}}class wf extends er{constructor(e){super({defines:Object.assign({},wf.shader.defines),uniforms:$i.clone(wf.shader.uniforms),vertexShader:wf.shader.vertexShader,fragmentShader:wf.shader.fragmentShader,blending:0}),this.update(e)}update(e){var t,n;if(void 0!==(null==e?void 0:e.texture)&&(this.uniforms.tDiffuse.value=null==e?void 0:e.texture),void 0!==(null==e?void 0:e.depthTexture)&&(this.uniforms.tDepth.value=null==e?void 0:e.depthTexture),(null==e?void 0:e.width)||(null==e?void 0:e.height)){const i=null!==(t=null==e?void 0:e.width)&&void 0!==t?t:this.uniforms.resolution.value.x,r=null!==(n=null==e?void 0:e.height)&&void 0!==n?n:this.uniforms.resolution.value.y;this.uniforms.resolution.value.set(i,r)}if(void 0!==(null==e?void 0:e.camera)){const t=(null==e?void 0:e.camera)||(null==e?void 0:e.camera);this.uniforms.cameraNear.value=t.near,this.uniforms.cameraFar.value=t.far,this.uniforms.cameraProjectionMatrix.value.copy(t.projectionMatrix),this.uniforms.cameraInverseProjectionMatrix.value.copy(t.projectionMatrixInverse),this.uniforms.inverseViewMatrix.value.copy(t.matrixWorld)}return void 0!==(null==e?void 0:e.groundLevel)&&(this.uniforms.groundLevel.value=null==e?void 0:e.groundLevel),void 0!==(null==e?void 0:e.fadeOutDistance)&&(this.uniforms.fadeOutDistance.value=null==e?void 0:e.fadeOutDistance),void 0!==(null==e?void 0:e.fadeOutExponent)&&(this.uniforms.fadeOutExponent.value=null==e?void 0:e.fadeOutExponent),this}}wf.shader={uniforms:{tDiffuse:{value:null},tDepth:{value:null},resolution:{value:new _t},cameraNear:{value:.1},cameraFar:{value:1},cameraProjectionMatrix:{value:new wn},cameraInverseProjectionMatrix:{value:new wn},inverseViewMatrix:{value:new wn},groundLevel:{value:0},fadeOutDistance:{value:1},fadeOutExponent:{value:1}},defines:{PERSPECTIVE_CAMERA:1,LINEAR_TO_SRGB:0,PREMULTIPLIED_ALPHA:1},vertexShader:"\n varying vec2 vUv;\n void main() {\n vUv = uv;\n gl_Position = projectionMatrix * modelViewMatrix * vec4(position, 1.0);\n }",fragmentShader:"\n uniform sampler2D tDiffuse;\n uniform sampler2D tDepth;\n uniform vec2 resolution;\n uniform float cameraNear;\n uniform float cameraFar;\n uniform mat4 cameraProjectionMatrix;\n uniform mat4 cameraInverseProjectionMatrix;\n uniform mat4 inverseViewMatrix;\n uniform float groundLevel;\n uniform float fadeOutDistance;\n uniform float fadeOutExponent;\n varying vec2 vUv;\n\n #include \n\n float getDepth(const in vec2 screenPosition) {\n return texture2D(tDepth, screenPosition).x;\n }\n\n float getLinearDepth(const in vec2 screenPosition) {\n #if PERSPECTIVE_CAMERA == 1\n float fragCoordZ = texture2D(tDepth, screenPosition).x;\n float viewZ = perspectiveDepthToViewZ(fragCoordZ, cameraNear, cameraFar);\n return viewZToOrthographicDepth(viewZ, cameraNear, cameraFar);\n #else\n return texture2D(tDepth, screenPosition).x;\n #endif\n }\n\n float getViewZ(const in float depth) {\n #if PERSPECTIVE_CAMERA == 1\n return perspectiveDepthToViewZ(depth, cameraNear, cameraFar);\n #else\n return 0.0;//orthographicDepthToViewZ(depth, cameraNear, cameraFar);\n #endif\n }\n\n vec3 getViewPosition(const in vec2 screenPosition, const in float depth, const in float viewZ ) {\n float clipW = cameraProjectionMatrix[2][3] * viewZ + cameraProjectionMatrix[3][3];\n vec4 clipPosition = vec4((vec3(screenPosition, depth) - 0.5) * 2.0, 1.0);\n clipPosition *= clipW;\n return (cameraInverseProjectionMatrix * clipPosition).xyz;\n }\n\n void main() {\n float verticalBias = 1.5 / resolution.y;\n vec2 uv = vUv.xy + vec2(0.0, verticalBias);\n float depth = getDepth(uv);\n float viewZ = getViewZ(depth);\n vec4 worldPosition = inverseViewMatrix * vec4(getViewPosition(uv, depth, viewZ), 1.0);\n float distance = worldPosition.y - groundLevel;\n vec2 diffuseTextureSize = vec2(textureSize(tDiffuse, 0 ));\n vec4 fragColor = texelFetch(tDiffuse, ivec2(uv * diffuseTextureSize), 0).rgba;\n #if LINEAR_TO_SRGB == 1\n fragColor.rgb = mix(fragColor.rgb * 12.92, 1.055 * pow(fragColor.rgb, vec3(0.41666)) - 0.055, step(0.0031308, fragColor.rgb));\n #endif\n float fadeOutAlpha = pow(clamp(1.0 - distance / fadeOutDistance, 0.0, 1.0), fadeOutExponent);\n fragColor.a *= fadeOutAlpha * step(depth, 0.9999);\n #if PREMULTIPLIED_ALPHA == 1\n gl_FragColor = vec4(fragColor.rgb * fragColor.a, fragColor.a);\n #else\n gl_FragColor = fragColor;\n #endif\n }"};class bf extends $r{constructor(e,t){const n=new Oi;n.setAttribute("position",new Ai([1,1,0,-1,1,0,-1,-1,0,1,-1,0,1,1,0],3)),n.computeBoundingSphere(),super(n,new jr({fog:!1})),this.light=e,this.color=t,this.type="RectAreaLightHelper";const i=new Oi;i.setAttribute("position",new Ai([1,1,0,-1,1,0,-1,-1,0,1,1,0,-1,-1,0,1,-1,0],3)),i.computeBoundingSphere(),this.add(new Yi(i,new _i({side:1,fog:!1})))}updateMatrixWorld(){if(this.scale.set(.5*this.light.width,.5*this.light.height,1),void 0!==this.color)this.material.color.set(this.color),this.children[0].material.color.set(this.color);else{this.material.color.copy(this.light.color).multiplyScalar(this.light.intensity);const e=this.material.color,t=Math.max(e.r,e.g,e.b);t>1&&e.multiplyScalar(1/t),this.children[0].material.color.copy(this.material.color)}this.matrixWorld.extractRotation(this.light.matrixWorld).scale(this.scale).copyPosition(this.light.matrixWorld),this.children[0].matrixWorld.copy(this.matrixWorld)}dispose(){this.geometry.dispose(),this.material.dispose(),this.children[0].geometry.dispose(),this.children[0].material.dispose()}}class Mf extends Ha{constructor(e){super(e),this.customProgramCacheKey=this._customProgramCacheKey,this.onBeforeCompile=this._onBeforeCompile}static setShadowParameters(e,t,n,i,r,a,s){this._enableGroundBoundary=e,Mf._distributionProperties.set(t,n,i,r),Mf._shadowFadeOut.set(a,s)}static setBoundingBox(e){Mf._sceneBoxMin.copy(e.min),Mf._sceneBoxMax.copy(e.max)}_customProgramCacheKey(){return Mf._enableGroundBoundary?"GROUND_BOUNDARY":"NO_GROUND_BOUNDARY"}_onBeforeCompile(e,t){e.vertexShader=Tf,e.fragmentShader=Ef,e.defines=Object.assign(Object.assign(Object.assign({},e.defines),{DYNAMIC_SHADOW_RADIUS:"",GROUND_BOUNDARY:Mf._enableGroundBoundary?1:0}));const n=e.uniforms;n&&(n.distributionProperties={value:Mf._distributionProperties},n.shadowFadeOut={value:Mf._shadowFadeOut},n.sceneBoxMin={value:Mf._sceneBoxMin},n.sceneBoxMax={value:Mf._sceneBoxMax})}}Mf._enableGroundBoundary=!1,Mf._shadowFadeOut=new _t(.1,20),Mf._sceneBoxMin=new jt(-1,-1,-1),Mf._sceneBoxMax=new jt(1,1,1),Mf._distributionProperties=new zt(1,1,1,1);const Tf="\n#define LAMBERT\n\nvarying vec3 vViewPosition;\nvarying vec3 vWorldPosition;\n\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n\nvoid main() {\n #include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\n\tvViewPosition = - mvPosition.xyz;\n\n\t#include \n\t#include \n\n#if defined( USE_ENVMAP ) || defined( DISTANCE ) || defined ( USE_SHADOWMAP ) || defined ( USE_TRANSMISSION ) || NUM_SPOT_LIGHT_COORDS > 0\n vWorldPosition = worldPosition.xyz;\n#else\n vWorldPosition = (modelMatrix * vec4(transformed, 1.)).xyz;\n#endif\n}\n",Ef="\n#define LAMBERT\n\nuniform vec3 diffuse;\nuniform float opacity;\n\nvarying vec3 vViewPosition;\nvarying vec3 vWorldPosition;\n\n#ifdef DYNAMIC_SHADOW_RADIUS\n uniform vec2 shadowFadeOut;\n #define fadeOutDistance shadowFadeOut.x\n #define fadeOutBlur shadowFadeOut.y\n uniform vec3 sceneBoxMin;\n uniform vec3 sceneBoxMax;\n#endif\nuniform vec4 distributionProperties;\n#define directionalDependency distributionProperties.x\n#define directionalExponent distributionProperties.y\n#define groundBoundary distributionProperties.z\n#define groundMapScale distributionProperties.w\n\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n\nvec2 getShadowDynamicScale() {\n vec2 dynamicScale = vec2(0.0, 1.0);\n#ifdef DYNAMIC_SHADOW_RADIUS\n if (fadeOutDistance > 0.0) {\n vec3 boxDistanceVec = max(vec3(0.0), max(sceneBoxMin - vWorldPosition, vWorldPosition - sceneBoxMax));\n float boxDistance = length(boxDistanceVec);\n float shadowBase = clamp(boxDistance / fadeOutDistance, 0.0, 1.0);\n dynamicScale = vec2(shadowBase, 1.0 - shadowBase);\n }\n#endif\n return dynamicScale;\n}\n\nfloat getShadowDynamicRadius(sampler2D shadowMap, float shadowBias, float shadowRadius, vec4 shadowCoord, vec2 shadowScale) {\n float dynamicRadius = shadowRadius;\n#ifdef DYNAMIC_SHADOW_RADIUS\n shadowCoord.xyz /= shadowCoord.w;\n shadowCoord.z += shadowBias;\n bool inFrustum = shadowCoord.x >= 0.0 && shadowCoord.x <= 1.0 && shadowCoord.y >= 0.0 && shadowCoord.y <= 1.0;\n bool frustumTest = inFrustum && shadowCoord.z <= 1.0;\n if (frustumTest && fadeOutDistance > 0.0) {\n dynamicRadius = shadowRadius + fadeOutBlur * max(0.0, shadowScale.x);\n }\n#endif\n return dynamicRadius;\n}\n\nvoid main() {\n\n\t#include \n\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\n\t// accumulation\n\n\tvec3 geometryPosition = - vViewPosition;\n vec3 geometryNormal = normal;\n vec3 geometryViewDir = ( isOrthographic ) ? vec3( 0, 0, 1 ) : normalize( vViewPosition );\n\n vec3 accumulatedShadowLight = vec3(0.0);\n vec3 directionDependentShadowLight = vec3(1.0);\n float groundDistance = clamp((vWorldPosition.y - sceneBoxMin.y) * 100.0, 0.0, 1.0);\n vec2 dynamicScale = getShadowDynamicScale();\n\n #if ( NUM_DIR_LIGHTS > 0 )\n DirectionalLight directionalLight;\n #if defined( USE_SHADOWMAP ) && NUM_DIR_LIGHT_SHADOWS > 0\n DirectionalLightShadow directionalLightShadow;\n #endif\n\n IncidentLight directLight;\n vec3 incidentLightSum = vec3(0.0);\n vec3 incidentShadowLight = vec3(0.0);\n float groundShadowFactor = 1.;\n float shadowFactor;\n float dynamicRadius;\n float dotNL;\n\n #pragma unroll_loop_start\n for ( int i = 0 ; i < NUM_DIR_LIGHTS; i ++ ) {\n directionalLight = directionalLights[ i ];\n getDirectionalLightInfo( directionalLight, directLight );\n\n #if defined( USE_SHADOWMAP ) && ( GROUND_BOUNDARY == 1 && UNROLLED_LOOP_INDEX == 0 )\n\n directionalLightShadow = directionalLightShadows[ i ];\n dynamicRadius = fadeOutDistance * groundMapScale;\n groundShadowFactor = groundDistance < 0.5 ? getShadow( directionalShadowMap[ i ], directionalLightShadow.shadowMapSize, directionalLightShadow.shadowIntensity, directionalLightShadow.shadowBias, dynamicRadius, vDirectionalShadowCoord[ i ] ) : 1.0;\n\n #elif defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_DIR_LIGHT_SHADOWS )\n\n directionalLightShadow = directionalLightShadows[ i ];\n dynamicRadius = getShadowDynamicRadius(directionalShadowMap[i], directionalLightShadow.shadowBias, directionalLightShadow.shadowRadius, vDirectionalShadowCoord[i], dynamicScale);\n shadowFactor = ( directLight.visible && receiveShadow ) ? getShadow( directionalShadowMap[ i ], directionalLightShadow.shadowMapSize, directionalLightShadow.shadowIntensity, directionalLightShadow.shadowBias, dynamicRadius, vDirectionalShadowCoord[ i ] ) : 1.0; \n accumulatedShadowLight += directLight.color * shadowFactor * saturate(min(dotNL * 10.0 + 0.9, 1.0));\n dotNL = dot(dot(geometryNormal, geometryPosition) >= 0.0 ? -geometryNormal : geometryNormal, directLight.direction);\n incidentLightSum += directLight.color;\n incidentShadowLight += directLight.color * mix(1.0, shadowFactor, pow(clamp(dotNL, 0.0, 1.0), directionalExponent));\n \n #endif\n }\n #pragma unroll_loop_end\n\n directionDependentShadowLight = incidentShadowLight / ( incidentLightSum + 1. - step(0., incidentLightSum) );\n #else\n accumulatedShadowLight = vec3(1.0);\n #endif \n\n\t// modulation\n\n\tvec3 outgoingLight = mix(accumulatedShadowLight, directionDependentShadowLight, max(directionalDependency, 1.0 - groundDistance));\n #if GROUND_BOUNDARY == 1\n float groundWeight = 1. - groundShadowFactor + groundDistance - (1. - groundShadowFactor) * groundDistance;\n outgoingLight = mix(vec3(1.), outgoingLight, mix(dynamicScale.y, groundWeight, groundBoundary));\n #else\n outgoingLight = mix(vec3(1.), outgoingLight, dynamicScale.y);\n #endif\n\n\t#include \n\t#include \n}\n",Af="DirectionalLightShadow",Pf={alwaysUpdate:!1,enableShadowMap:!0,enableGroundBoundary:!0,layers:null,shadowLightSourceType:Af,maximumNumberOfLightSources:-1,directionalDependency:1,directionalExponent:1,groundBoundary:1,fadeOutDistance:.1,fadeOutBlur:5};class Rf extends Np{get shadowTexture(){return this._shadowRenderTarget.texture}set shadowOnGround(e){this._shadowMapPassOverrideMaterialCache.shadowOnGround=e}constructor(e,t,n){var i,r,a;super(e),this.needsUpdate=!1,this.drawGround=!0,this.shadowTypeNeedsUpdate=!0,this.shadowConfiguration=new Uf,this._shadowLightSources=[],this._shadowScale=1,this._groundMapScale=1,this._cameraUpdate=new Po,this._viewportSize=new _t(t.x,t.y),this._samples=null!==(i=null==n?void 0:n.samples)&&void 0!==i?i:0,this._shadowMapSize=null!==(r=null==n?void 0:n.shadowMapSize)&&void 0!==r?r:1024,this.parameters=this._getScreenSpaceShadowMapParameters(n),this.castShadow=this.parameters.enableShadowMap,this._shadowMapPassOverrideMaterialCache=new If,null===(a=this.renderCacheManager)||void 0===a||a.registerCache(this,this._shadowMapPassOverrideMaterialCache);const s=this._samples;this._shadowRenderTarget=new Ht(this._viewportSize.x,this._viewportSize.y,{samples:s,format:ie,magFilter:z,minFilter:z})}_getScreenSpaceShadowMapParameters(e){return Object.assign(Object.assign({},Pf),e)}dispose(){super.dispose(),this._shadowLightSources.forEach((e=>e.dispose())),this._shadowRenderTarget.dispose(),this._shadowMapPassOverrideMaterialCache.dispose()}updateParameters(e){for(const t in e)this.parameters.hasOwnProperty(t)&&(this.parameters[t]=e[t])}updateBounds(e,t){var n;const i=this._shadowScale;if(this._shadowScale=t,Math.abs(i-this._shadowScale)>1e-5&&(this.shadowTypeNeedsUpdate=!0),this._shadowLightSources.forEach((t=>t.updateBounds(e))),this._shadowLightSources.length>0){const e=null===(n=this._shadowLightSources[0].getShadowLight().shadow)||void 0===n?void 0:n.camera;e instanceof Cs&&(this._groundMapScale=2*this._shadowMapSize/(Math.abs(e.right-e.left)+Math.abs(e.top-e.bottom)))}else this._groundMapScale=1;this._shadowMapPassOverrideMaterialCache.setBoundingBox(e.bounds)}forceShadowUpdate(){this._shadowLightSources.forEach((e=>e.forceShadowUpdate())),this.needsUpdate=!0}getShadowLightSources(){return this._shadowLightSources.map((e=>e.getShadowLight()))}findShadowLightSource(e){var t;return null===(t=this._shadowLightSources.find((t=>t.getOriginalLight()===e)))||void 0===t?void 0:t.getShadowLight()}addRectAreaLight(e,t){const n=new Nf(e,{shadowMapSize:this._shadowMapSize,shadowLightSourceType:this.parameters.shadowLightSourceType});this._shadowLightSources.push(n),n.addTo(t),n.updatePositionAndTarget(),this.needsUpdate=!0}updateRectAreaLights(e,t){const n=this._shadowLightSources;this._shadowLightSources=this._createShadowLightSourceArray(!1);for(const i of n){if(i instanceof Nf){const t=i.getRectAreaLight();e.includes(t)&&(i.updatePositionAndTarget(),this._shadowLightSources.push(i))}i.removeFrom(t),i.dispose()}e.forEach((e=>{this._shadowLightSources.find((t=>t instanceof Nf&&t.getRectAreaLight()===e))||this.addRectAreaLight(e,t)})),this.needsUpdate=!0,this.shadowTypeNeedsUpdate=!0}createShadowFromLightSources(e,t){for(const t of this._shadowLightSources)t.removeFrom(e),t.dispose();this._shadowLightSources=this._createShadowLightSourceArray(!0);const n=1/(t.length>0?Math.max(...t.map((e=>e.maxIntensity))):1);this._addShadowFromLightSources(t,n),this._shadowLightSources.forEach((t=>{t.addTo(e),t.updatePositionAndTarget()})),this.needsUpdate=!0,this.shadowTypeNeedsUpdate=!0}_addShadowFromLightSources(e,t){e.forEach((e=>{const n=e.maxIntensity*t;if(n>=.1&&e.position.z>=0){const t=new jt(e.position.x,e.position.z,e.position.y).multiplyScalar(7),i=new Ff(t,n,{shadowMapSize:this._shadowMapSize,shadowLightSourceType:this.parameters.shadowLightSourceType});this._shadowLightSources.push(i)}}))}_createShadowLightSourceArray(e){const t=[];if(e){const e=new Bf(new jt(0,7,0),{shadowMapSize:this._shadowMapSize});t.push(e)}return this.parameters.enableGroundBoundary=e,t}setSize(e,t){this._viewportSize=new _t(e,t),this._shadowRenderTarget.setSize(this._viewportSize.x,this._viewportSize.y)}updatePositionAndTarget(){this._shadowLightSources.forEach((e=>e.updatePositionAndTarget()))}renderPass(e){if(!(this.needsUpdate||this.parameters.alwaysUpdate||this._cameraUpdate.changed(this.camera)))return;this.needsUpdate=!1,this.shadowTypeNeedsUpdate&&(this.shadowTypeNeedsUpdate=!1,this.needsUpdate=!0,this._updateShadowType(e));const t=this.scene.background,n=this.scene.environment,i=this.camera.layers.mask;this.scene.environment=null,this.scene.background=null,this.parameters.layers&&(this.camera.layers.mask=this.parameters.layers.mask),this.renderPassManager.setGroundVisibility(this.drawGround),this._renderSimpleShadowMapFromShadowLightSources(e,this.scene,this.camera),this.renderPassManager.setGroundVisibility(!1),this.camera.layers.mask=i,this.scene.environment=n,this.scene.background=t}_renderSimpleShadowMapFromShadowLightSources(e,t,n){var i;this._shadowMapPassOverrideMaterialCache.setShadowParameters(this.parameters.enableGroundBoundary,this.parameters.directionalDependency,this.parameters.directionalExponent,this.parameters.groundBoundary,this._groundMapScale,this.parameters.fadeOutDistance*this._shadowScale,this.parameters.fadeOutBlur);const r=this._getSortedShadowLightSources();0===r.length?this.passRenderer.clear(e,this._shadowRenderTarget,16777215,1):(this._setShadowLightSourcesIntensity(r),null===(i=this.renderCacheManager)||void 0===i||i.render(this,t,(()=>{this.passRenderer.render(e,t,n,this._shadowRenderTarget,16777215,1)})),this._shadowLightSources.forEach((e=>e.finishRenderShadow())))}_getSortedShadowLightSources(){const e=[];return this._shadowLightSources.forEach((t=>e.push(...t.prepareRenderShadow()))),e.sort(((e,t)=>e.light.castShadow&&!t.light.castShadow||e.groundShadow&&!t.groundShadow?-1:!e.light.castShadow&&t.light.castShadow||!e.groundShadow&&t.groundShadow?1:t.intensity-e.intensity)),e}_setShadowLightSourcesIntensity(e){let t=0;const n=this.parameters.maximumNumberOfLightSources;let i=0;e.forEach((e=>{(n<0||i{var r;!this.parameters.enableGroundBoundary&&e.groundShadow||!(n<0||ie._updateShadowType(this.shadowConfiguration.currentConfiguration,this._shadowScale)))}switchType(e){return!!this.shadowConfiguration.switchType(e)&&(this.needsUpdate=!0,this.shadowTypeNeedsUpdate=!0,!0)}}const Cf="unlit",Df="emissive",Lf="shadow";class If extends mf{set shadowOnGround(e){this._shadowOnGround=e}constructor(){super(),this._boundingBoxSet=!1,this._shadowOnGround=!0,this._shadowObjectMaterial=this._createShadowMaterial("default"),this._unlitMaterial=this._createShadowMaterial(Cf),this._emissiveMaterial=this._createShadowMaterial(Df),this._receiveShadowMaterial=this._createShadowMaterial(Lf)}dispose(){this._shadowObjectMaterial.dispose(),this._unlitMaterial.dispose(),this._emissiveMaterial.dispose(),this._receiveShadowMaterial.dispose()}setShadowParameters(e,t,n,i,r,a,s){Mf.setShadowParameters(e,t,n,i,r,a,s)}setBoundingBox(e){this._boundingBoxSet=!0,Mf.setBoundingBox(e)}_createShadowMaterial(e){let t;return t=e===Df||e===Cf?new _i({color:16777215,side:2}):e===Lf?new Na({side:2}):If.useModifiedMaterial?this._createCustomerShadowMaterial():new za({color:16777215,shininess:0,polygonOffsetFactor:0,polygonOffsetUnits:0,side:2}),t}_createCustomerShadowMaterial(){return new Mf({side:2})}addLineOrPoint(e){this.addToCache(e,{visible:!1})}addMesh(e){e.visible&&this._setMeshMaterialAndVisibility(e)}addObject(e){e.isLight&&!e.userData.shadowLightSource&&this.addToCache(e,{visible:!1})}_setMeshMaterialAndVisibility(e){e.userData.isFloor?this._setMeshShadowFloorMaterial(e):!e.material||!e.receiveShadow||Array.isArray(e.material)||!0===e.material.transparent&&e.material.opacity<.9?e.material&&e.material.transparent&&e.material.opacity<.9?this.addToCache(e,{visible:!1}):e.receiveShadow?this.addToCache(e,{castShadow:!1,material:this._receiveShadowMaterial}):this.addToCache(e,{visible:!1}):this._setShadowMaterialForOpaqueObject(e)}_setShadowMaterialForOpaqueObject(e){const t=e.material;t instanceof jr||t instanceof _i?this.addToCache(e,{material:this._unlitMaterial}):t instanceof Fa?this._setMeshShadowStandardMaterial(e,t):this.addToCache(e,{material:e.receiveShadow?this._shadowObjectMaterial:this._unlitMaterial})}_setMeshShadowStandardMaterial(e,t){const n=t.emissiveIntensity>0&&(t.emissive.r>0||t.emissive.g>0||t.emissive.b>0);this.addToCache(e,{castShadow:!n&&e.castShadow,material:n?this._emissiveMaterial:e.receiveShadow?this._shadowObjectMaterial:this._unlitMaterial})}_setMeshShadowFloorMaterial(e){this._boundingBoxSet&&this._shadowOnGround?this.addToCache(e,{visible:!0,castShadow:!1,receiveShadow:!0,material:this._shadowObjectMaterial}):this.addToCache(e,{visible:!1})}}If.useModifiedMaterial=!0;class Uf{constructor(){var e;this.types=new Map([["off",Uf._noShadow],["BasicShadowMap",Uf._basicShadow],["PCFShadowMap",Uf._pcfShadow],["PCFSoftShadowMap",Uf._pcfSoftShadow],["VSMShadowMap",Uf._vcmShadow]]),this.shadowType="PCFShadowMap",this.currentConfiguration=null!==(e=this.types.get(this.shadowType))&&void 0!==e?e:Uf._defaultType}switchType(e){var t;return!!this.types.has(e)&&(this.currentConfiguration=null!==(t=this.types.get(e))&&void 0!==t?t:Uf._defaultType,!0)}}Uf._noShadow={castShadow:!1,type:1,bias:0,normalBias:0,radius:0},Uf._basicShadow={castShadow:!0,type:0,bias:-5e-5,normalBias:.005,radius:0},Uf._pcfShadow={castShadow:!0,type:1,bias:-5e-5,normalBias:.01,radius:4},Uf._pcfSoftShadow={castShadow:!0,type:2,bias:-5e-5,normalBias:.01,radius:1},Uf._vcmShadow={castShadow:!0,type:3,bias:1e-4,normalBias:0,radius:15},Uf._defaultType=Uf._pcfShadow;class Of{constructor(e,t){var n,i;this._isVisibleBackup=!0,this._castShadowBackup=!0,this._shadowMapSize=null!==(n=null==t?void 0:t.shadowMapSize)&&void 0!==n?n:1024,this._blurSamples=null!==(i=null==t?void 0:t.blurSamples)&&void 0!==i?i:8,this._shadowLightSource=e,this._shadowLightSource.visible=!1,this._shadowLightSource.castShadow=!0,this._shadowLightSource.shadow&&(this._shadowLightSource.shadow.mapSize=new _t(this._shadowMapSize,this._shadowMapSize),this._shadowLightSource.shadow.blurSamples=this._blurSamples,this._shadowLightSource.shadow.autoUpdate=!1),this._shadowLightSource.userData.shadowLightSource=this}getPosition(){return this._shadowLightSource.position}getShadowLight(){return this._shadowLightSource}getOriginalLight(){return null}dispose(){this._shadowLightSource.dispose()}addTo(e){e.add(this._shadowLightSource)}removeFrom(e){e.remove(this._shadowLightSource)}updatePositionAndTarget(){this._updateShadowPositionAndTarget(this.getPosition(),new jt(0,0,0))}updateBounds(e){if(this._shadowLightSource instanceof Ms){const t=this._shadowLightSource.shadow.camera,n=e.bounds.clone().applyMatrix4(t.matrixWorldInverse),i=Math.max(.001,Math.min(-n.min.z,-n.max.z)),r=Math.max(-n.min.z,-n.max.z),a=Math.max(Math.abs(n.min.x),Math.abs(n.max.x)),s=Math.max(Math.abs(n.min.y),Math.abs(n.max.y)),o=Math.atan2(1.05*Math.hypot(s,a),i);t.aspect=1,t.near=i,t.far=r,this._shadowLightSource.angle=o}else if(this._shadowLightSource.shadow){const t=this._shadowLightSource.shadow.camera;e.updateCameraViewVolumeFromBounds(t);const n=t;n.far+=n.far-n.near,n.updateProjectionMatrix()}this._shadowLightSource.shadow&&(this._shadowLightSource.shadow.needsUpdate=!0)}forceShadowUpdate(){this._shadowLightSource.shadow&&(this._shadowLightSource.shadow.needsUpdate=!0)}_updateShadowPositionAndTarget(e,t){var n,i,r;if(this._shadowLightSource instanceof Ms){const n=t.clone().sub(e),i=n.length();n.normalize();const r=t.clone().sub(n.clone().multiplyScalar(4*i));this._shadowLightSource.shadow.camera.position.copy(r),this._shadowLightSource.shadow.camera.position.copy(r),this._shadowLightSource.shadow.camera.lookAt(t),this._shadowLightSource.position.copy(r),this._shadowLightSource.lookAt(t)}else this._shadowLightSource.position.copy(e),this._shadowLightSource.lookAt(t),null===(n=this._shadowLightSource.shadow)||void 0===n||n.camera.position.copy(e),null===(i=this._shadowLightSource.shadow)||void 0===i||i.camera.lookAt(t);null===(r=this._shadowLightSource.shadow)||void 0===r||r.camera.updateMatrixWorld(),this._shadowLightSource.updateMatrixWorld()}_updateShadowType(e,t){const n=this._shadowLightSource.shadow;n&&(n.bias=e.bias,n.normalBias=e.normalBias*t,n.radius=e.radius,n.needsUpdate=!0)}prepareRenderShadow(){return[]}finishRenderShadow(){}}class Nf extends Of{constructor(e,t){let n;switch(null==t?void 0:t.shadowLightSourceType){default:case Af:n=new Ls(16777215,1);break;case"SpotLightShadow":n=new Ms(16777215,1,0,Math.PI/4,0)}n.position.copy(e.position),n.lookAt(0,0,0),super(n,t),this._rectAreaLight=e,this._rectAreaLight.userData.shadowLightSource=this,(null==t?void 0:t.addHelper)&&(this._rectLightHelper=new bf(this._rectAreaLight),this._rectLightHelper.material.depthWrite=!1,this._rectAreaLight.add(this._rectLightHelper))}getPosition(){return this._rectAreaLight.position}getRectAreaLight(){return this._rectAreaLight}getOriginalLight(){return this._rectAreaLight}prepareRenderShadow(){return this._isVisibleBackup=this._rectAreaLight.visible,this._castShadowBackup=this._shadowLightSource.castShadow,this._shadowLightSource.visible=this._rectAreaLight.visible,this._rectAreaLight.visible=!1,this._shadowLightSource.visible?[{light:this._shadowLightSource,intensity:this._rectAreaLight.intensity,groundShadow:!1}]:[]}finishRenderShadow(){this._shadowLightSource.visible=!1,this._shadowLightSource.castShadow=this._castShadowBackup,this._rectAreaLight.visible=this._isVisibleBackup}}class Ff extends Of{constructor(e,t,n){const i=new Ls(16777215,t);i.position.copy(e),i.lookAt(0,0,0),i.updateMatrix(),i.castShadow=!0,super(i,n),this._position=e.clone(),this._intensity=t}getPosition(){return this._position}prepareRenderShadow(){return this._castShadowBackup=this._shadowLightSource.castShadow,this._shadowLightSource.visible=!0,[{light:this._shadowLightSource,intensity:this._intensity,groundShadow:!1}]}finishRenderShadow(){this._shadowLightSource.castShadow=this._castShadowBackup,this._shadowLightSource.visible=!1}}class Bf extends Of{constructor(e,t){const n=new Ls(16777215,1);n.position.copy(e),n.lookAt(0,0,0),n.updateMatrix(),n.castShadow=!0,super(n,t),this._position=e.clone()}getPosition(){return this._position}prepareRenderShadow(){return this._castShadowBackup=this._shadowLightSource.castShadow,this._shadowLightSource.visible=!0,[{light:this._shadowLightSource,intensity:1,groundShadow:!0}]}finishRenderShadow(){this._shadowLightSource.castShadow=this._castShadowBackup,this._shadowLightSource.visible=!1}}const zf={name:"CopyShader",uniforms:{tDiffuse:{value:null},opacity:{value:1}},vertexShader:"\n\n\t\tvarying vec2 vUv;\n\n\t\tvoid main() {\n\n\t\t\tvUv = uv;\n\t\t\tgl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n\n\t\t}",fragmentShader:"\n\n\t\tuniform float opacity;\n\n\t\tuniform sampler2D tDiffuse;\n\n\t\tvarying vec2 vUv;\n\n\t\tvoid main() {\n\n\t\t\tvec4 texel = texture2D( tDiffuse, vUv );\n\t\t\tgl_FragColor = opacity * texel;\n\n\n\t\t}"},kf={name:"FXAAShader",uniforms:{tDiffuse:{value:null},resolution:{value:new _t(1/1024,1/512)}},vertexShader:"\n\n\t\tvarying vec2 vUv;\n\n\t\tvoid main() {\n\n\t\t\tvUv = uv;\n\t\t\tgl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n\n\t\t}",fragmentShader:"\n\n\t\t// FXAA algorithm from NVIDIA, C# implementation by Jasper Flick, GLSL port by Dave Hoskins\n\t\t// http://developer.download.nvidia.com/assets/gamedev/files/sdk/11/FXAA_WhitePaper.pdf\n\t\t// https://catlikecoding.com/unity/tutorials/advanced-rendering/fxaa/\n\n\t\tuniform sampler2D tDiffuse;\n\t\tuniform vec2 resolution;\n\t\tvarying vec2 vUv;\n\n\t\t#define EDGE_STEP_COUNT 6\n\t\t#define EDGE_GUESS 8.0\n\t\t#define EDGE_STEPS 1.0, 1.5, 2.0, 2.0, 2.0, 4.0\n\t\tconst float edgeSteps[EDGE_STEP_COUNT] = float[EDGE_STEP_COUNT]( EDGE_STEPS );\n\n\t\tfloat _ContrastThreshold = 0.0312;\n\t\tfloat _RelativeThreshold = 0.063;\n\t\tfloat _SubpixelBlending = 1.0;\n\n\t\tvec4 Sample( sampler2D tex2D, vec2 uv ) {\n\n\t\t\treturn texture( tex2D, uv );\n\n\t\t}\n\n\t\tfloat SampleLuminance( sampler2D tex2D, vec2 uv ) {\n\n\t\t\treturn dot( Sample( tex2D, uv ).rgb, vec3( 0.3, 0.59, 0.11 ) );\n\n\t\t}\n\n\t\tfloat SampleLuminance( sampler2D tex2D, vec2 texSize, vec2 uv, float uOffset, float vOffset ) {\n\n\t\t\tuv += texSize * vec2(uOffset, vOffset);\n\t\t\treturn SampleLuminance(tex2D, uv);\n\n\t\t}\n\n\t\tstruct LuminanceData {\n\n\t\t\tfloat m, n, e, s, w;\n\t\t\tfloat ne, nw, se, sw;\n\t\t\tfloat highest, lowest, contrast;\n\n\t\t};\n\n\t\tLuminanceData SampleLuminanceNeighborhood( sampler2D tex2D, vec2 texSize, vec2 uv ) {\n\n\t\t\tLuminanceData l;\n\t\t\tl.m = SampleLuminance( tex2D, uv );\n\t\t\tl.n = SampleLuminance( tex2D, texSize, uv, 0.0, 1.0 );\n\t\t\tl.e = SampleLuminance( tex2D, texSize, uv, 1.0, 0.0 );\n\t\t\tl.s = SampleLuminance( tex2D, texSize, uv, 0.0, -1.0 );\n\t\t\tl.w = SampleLuminance( tex2D, texSize, uv, -1.0, 0.0 );\n\n\t\t\tl.ne = SampleLuminance( tex2D, texSize, uv, 1.0, 1.0 );\n\t\t\tl.nw = SampleLuminance( tex2D, texSize, uv, -1.0, 1.0 );\n\t\t\tl.se = SampleLuminance( tex2D, texSize, uv, 1.0, -1.0 );\n\t\t\tl.sw = SampleLuminance( tex2D, texSize, uv, -1.0, -1.0 );\n\n\t\t\tl.highest = max( max( max( max( l.n, l.e ), l.s ), l.w ), l.m );\n\t\t\tl.lowest = min( min( min( min( l.n, l.e ), l.s ), l.w ), l.m );\n\t\t\tl.contrast = l.highest - l.lowest;\n\t\t\treturn l;\n\n\t\t}\n\n\t\tbool ShouldSkipPixel( LuminanceData l ) {\n\n\t\t\tfloat threshold = max( _ContrastThreshold, _RelativeThreshold * l.highest );\n\t\t\treturn l.contrast < threshold;\n\n\t\t}\n\n\t\tfloat DeterminePixelBlendFactor( LuminanceData l ) {\n\n\t\t\tfloat f = 2.0 * ( l.n + l.e + l.s + l.w );\n\t\t\tf += l.ne + l.nw + l.se + l.sw;\n\t\t\tf *= 1.0 / 12.0;\n\t\t\tf = abs( f - l.m );\n\t\t\tf = clamp( f / l.contrast, 0.0, 1.0 );\n\n\t\t\tfloat blendFactor = smoothstep( 0.0, 1.0, f );\n\t\t\treturn blendFactor * blendFactor * _SubpixelBlending;\n\n\t\t}\n\n\t\tstruct EdgeData {\n\n\t\t\tbool isHorizontal;\n\t\t\tfloat pixelStep;\n\t\t\tfloat oppositeLuminance, gradient;\n\n\t\t};\n\n\t\tEdgeData DetermineEdge( vec2 texSize, LuminanceData l ) {\n\n\t\t\tEdgeData e;\n\t\t\tfloat horizontal =\n\t\t\t\tabs( l.n + l.s - 2.0 * l.m ) * 2.0 +\n\t\t\t\tabs( l.ne + l.se - 2.0 * l.e ) +\n\t\t\t\tabs( l.nw + l.sw - 2.0 * l.w );\n\t\t\tfloat vertical =\n\t\t\t\tabs( l.e + l.w - 2.0 * l.m ) * 2.0 +\n\t\t\t\tabs( l.ne + l.nw - 2.0 * l.n ) +\n\t\t\t\tabs( l.se + l.sw - 2.0 * l.s );\n\t\t\te.isHorizontal = horizontal >= vertical;\n\n\t\t\tfloat pLuminance = e.isHorizontal ? l.n : l.e;\n\t\t\tfloat nLuminance = e.isHorizontal ? l.s : l.w;\n\t\t\tfloat pGradient = abs( pLuminance - l.m );\n\t\t\tfloat nGradient = abs( nLuminance - l.m );\n\n\t\t\te.pixelStep = e.isHorizontal ? texSize.y : texSize.x;\n\t\t\t\n\t\t\tif (pGradient < nGradient) {\n\n\t\t\t\te.pixelStep = -e.pixelStep;\n\t\t\t\te.oppositeLuminance = nLuminance;\n\t\t\t\te.gradient = nGradient;\n\n\t\t\t} else {\n\n\t\t\t\te.oppositeLuminance = pLuminance;\n\t\t\t\te.gradient = pGradient;\n\n\t\t\t}\n\n\t\t\treturn e;\n\n\t\t}\n\n\t\tfloat DetermineEdgeBlendFactor( sampler2D tex2D, vec2 texSize, LuminanceData l, EdgeData e, vec2 uv ) {\n\n\t\t\tvec2 uvEdge = uv;\n\t\t\tvec2 edgeStep;\n\t\t\tif (e.isHorizontal) {\n\n\t\t\t\tuvEdge.y += e.pixelStep * 0.5;\n\t\t\t\tedgeStep = vec2( texSize.x, 0.0 );\n\n\t\t\t} else {\n\n\t\t\t\tuvEdge.x += e.pixelStep * 0.5;\n\t\t\t\tedgeStep = vec2( 0.0, texSize.y );\n\n\t\t\t}\n\n\t\t\tfloat edgeLuminance = ( l.m + e.oppositeLuminance ) * 0.5;\n\t\t\tfloat gradientThreshold = e.gradient * 0.25;\n\n\t\t\tvec2 puv = uvEdge + edgeStep * edgeSteps[0];\n\t\t\tfloat pLuminanceDelta = SampleLuminance( tex2D, puv ) - edgeLuminance;\n\t\t\tbool pAtEnd = abs( pLuminanceDelta ) >= gradientThreshold;\n\n\t\t\tfor ( int i = 1; i < EDGE_STEP_COUNT && !pAtEnd; i++ ) {\n\n\t\t\t\tpuv += edgeStep * edgeSteps[i];\n\t\t\t\tpLuminanceDelta = SampleLuminance( tex2D, puv ) - edgeLuminance;\n\t\t\t\tpAtEnd = abs( pLuminanceDelta ) >= gradientThreshold;\n\n\t\t\t}\n\n\t\t\tif ( !pAtEnd ) {\n\n\t\t\t\tpuv += edgeStep * EDGE_GUESS;\n\n\t\t\t}\n\n\t\t\tvec2 nuv = uvEdge - edgeStep * edgeSteps[0];\n\t\t\tfloat nLuminanceDelta = SampleLuminance( tex2D, nuv ) - edgeLuminance;\n\t\t\tbool nAtEnd = abs( nLuminanceDelta ) >= gradientThreshold;\n\n\t\t\tfor ( int i = 1; i < EDGE_STEP_COUNT && !nAtEnd; i++ ) {\n\n\t\t\t\tnuv -= edgeStep * edgeSteps[i];\n\t\t\t\tnLuminanceDelta = SampleLuminance( tex2D, nuv ) - edgeLuminance;\n\t\t\t\tnAtEnd = abs( nLuminanceDelta ) >= gradientThreshold;\n\n\t\t\t}\n\n\t\t\tif ( !nAtEnd ) {\n\n\t\t\t\tnuv -= edgeStep * EDGE_GUESS;\n\n\t\t\t}\n\n\t\t\tfloat pDistance, nDistance;\n\t\t\tif ( e.isHorizontal ) {\n\n\t\t\t\tpDistance = puv.x - uv.x;\n\t\t\t\tnDistance = uv.x - nuv.x;\n\n\t\t\t} else {\n\t\t\t\t\n\t\t\t\tpDistance = puv.y - uv.y;\n\t\t\t\tnDistance = uv.y - nuv.y;\n\n\t\t\t}\n\n\t\t\tfloat shortestDistance;\n\t\t\tbool deltaSign;\n\t\t\tif ( pDistance <= nDistance ) {\n\n\t\t\t\tshortestDistance = pDistance;\n\t\t\t\tdeltaSign = pLuminanceDelta >= 0.0;\n\n\t\t\t} else {\n\n\t\t\t\tshortestDistance = nDistance;\n\t\t\t\tdeltaSign = nLuminanceDelta >= 0.0;\n\n\t\t\t}\n\n\t\t\tif ( deltaSign == ( l.m - edgeLuminance >= 0.0 ) ) {\n\n\t\t\t\treturn 0.0;\n\n\t\t\t}\n\n\t\t\treturn 0.5 - shortestDistance / ( pDistance + nDistance );\n\n\t\t}\n\n\t\tvec4 ApplyFXAA( sampler2D tex2D, vec2 texSize, vec2 uv ) {\n\n\t\t\tLuminanceData luminance = SampleLuminanceNeighborhood( tex2D, texSize, uv );\n\t\t\tif ( ShouldSkipPixel( luminance ) ) {\n\n\t\t\t\treturn Sample( tex2D, uv );\n\n\t\t\t}\n\n\t\t\tfloat pixelBlend = DeterminePixelBlendFactor( luminance );\n\t\t\tEdgeData edge = DetermineEdge( texSize, luminance );\n\t\t\tfloat edgeBlend = DetermineEdgeBlendFactor( tex2D, texSize, luminance, edge, uv );\n\t\t\tfloat finalBlend = max( pixelBlend, edgeBlend );\n\n\t\t\tif (edge.isHorizontal) {\n\n\t\t\t\tuv.y += edge.pixelStep * finalBlend;\n\n\t\t\t} else {\n\n\t\t\t\tuv.x += edge.pixelStep * finalBlend;\n\n\t\t\t}\n\n\t\t\treturn Sample( tex2D, uv );\n\n\t\t}\n\n\t\tvoid main() {\n\n\t\t\tgl_FragColor = ApplyFXAA( tDiffuse, resolution.xy, vUv );\n\t\t\t\n\t\t}"};class Hf extends Np{constructor(e,t,n,i,r,a){var s;super(e),this.patternTexture=null,this.clearBackground=!1,this.renderScene=n,this.renderCamera=i,this.selectedObjects=void 0!==r?r:[],this.visibleEdgeColor=new fi(1,1,1),this.hiddenEdgeColor=new fi(.1,.04,.02),this.edgeGlow=0,this.usePatternTexture=!1,this.edgeThickness=1,this.edgeStrength=3,this.downSampleRatio=(null==a?void 0:a.downSampleRatio)||2,this.pulsePeriod=0,this.edgeDetectionFxaa=(null==a?void 0:a.edgeDetectionFxaa)||!1,this._visibilityCache=new Map,this.resolution=void 0!==t?new _t(t.x,t.y):new _t(256,256);const o=Math.round(this.resolution.x/this.downSampleRatio),l=Math.round(this.resolution.y/this.downSampleRatio);this.renderTargetMaskBuffer=new Ht(this.resolution.x,this.resolution.y),this.renderTargetMaskBuffer.texture.name="OutlinePass.mask",this.renderTargetMaskBuffer.texture.generateMipmaps=!1,this.prepareMaskMaterial=this._getPrepareMaskMaterial(null===(s=this.gBufferTextures)||void 0===s?void 0:s.isFloatGBufferWithRgbNormalAlphaDepth),this.prepareMaskMaterial.side=2,this.prepareMaskMaterial.fragmentShader=function(e,t){const n=t.isPerspectiveCamera?"perspective":"orthographic";return e.replace(/DEPTH_TO_VIEW_Z/g,n+"DepthToViewZ")}(this.prepareMaskMaterial.fragmentShader,this.renderCamera),this.edgeDetectionFxaa&&(this.fxaaRenderMaterial=new er(kf),this.fxaaRenderMaterial.uniforms.tDiffuse.value=this.renderTargetMaskBuffer.texture,this.fxaaRenderMaterial.uniforms.resolution.value.set(1/this.resolution.x,1/this.resolution.y),this.renderTargetFxaaBuffer=new Ht(this.resolution.x,this.resolution.y),this.renderTargetFxaaBuffer.texture.name="OutlinePass.fxaa",this.renderTargetFxaaBuffer.texture.generateMipmaps=!1),this.renderTargetMaskDownSampleBuffer=new Ht(o,l),this.renderTargetMaskDownSampleBuffer.texture.name="OutlinePass.depthDownSample",this.renderTargetMaskDownSampleBuffer.texture.generateMipmaps=!1,this.renderTargetBlurBuffer1=new Ht(o,l),this.renderTargetBlurBuffer1.texture.name="OutlinePass.blur1",this.renderTargetBlurBuffer1.texture.generateMipmaps=!1,this.renderTargetBlurBuffer2=new Ht(Math.round(o/2),Math.round(l/2)),this.renderTargetBlurBuffer2.texture.name="OutlinePass.blur2",this.renderTargetBlurBuffer2.texture.generateMipmaps=!1,this.edgeDetectionMaterial=this._getEdgeDetectionMaterial(),this.renderTargetEdgeBuffer1=new Ht(o,l),this.renderTargetEdgeBuffer1.texture.name="OutlinePass.edge1",this.renderTargetEdgeBuffer1.texture.generateMipmaps=!1,this.renderTargetEdgeBuffer2=new Ht(Math.round(o/2),Math.round(l/2)),this.renderTargetEdgeBuffer2.texture.name="OutlinePass.edge2",this.renderTargetEdgeBuffer2.texture.generateMipmaps=!1,this.separableBlurMaterial1=this._getSeperableBlurMaterial(4),this.separableBlurMaterial1.uniforms.texSize.value.set(o,l),this.separableBlurMaterial1.uniforms.kernelRadius.value=1,this.separableBlurMaterial2=this._getSeperableBlurMaterial(4),this.separableBlurMaterial2.uniforms.texSize.value.set(Math.round(o/2),Math.round(l/2)),this.separableBlurMaterial2.uniforms.kernelRadius.value=4,this.overlayMaterial=this._getOverlayMaterial();const c=zf;this.copyUniforms=$i.clone(c.uniforms),this.copyUniforms.opacity.value=1,this.materialCopy=new er({uniforms:this.copyUniforms,vertexShader:c.vertexShader,fragmentShader:c.fragmentShader,blending:0,depthTest:!1,depthWrite:!1,transparent:!0}),this.enabled=!0,this.needsSwap=!1,this.oldClearColor=new fi,this.oldClearAlpha=1,this.fsQuad=new So(void 0),this.tempPulseColor1=new fi,this.tempPulseColor2=new fi,this.textureMatrix=new wn}dispose(){var e,t;super.dispose(),this.renderTargetMaskBuffer.dispose(),null===(e=this.renderTargetFxaaBuffer)||void 0===e||e.dispose(),this.renderTargetMaskDownSampleBuffer.dispose(),this.renderTargetBlurBuffer1.dispose(),this.renderTargetBlurBuffer2.dispose(),this.renderTargetEdgeBuffer1.dispose(),this.renderTargetEdgeBuffer2.dispose(),this.prepareMaskMaterial.dispose(),null===(t=this.fxaaRenderMaterial)||void 0===t||t.dispose(),this.edgeDetectionMaterial.dispose(),this.separableBlurMaterial1.dispose(),this.separableBlurMaterial2.dispose(),this.overlayMaterial.dispose(),this.materialCopy.dispose(),this.fsQuad.dispose()}setSize(e,t){var n,i;this.renderTargetMaskBuffer.setSize(e,t);let r=Math.round(e/this.downSampleRatio),a=Math.round(t/this.downSampleRatio);this.renderTargetMaskDownSampleBuffer.setSize(r,a),this.renderTargetBlurBuffer1.setSize(r,a),this.renderTargetEdgeBuffer1.setSize(r,a),this.separableBlurMaterial1.uniforms.texSize.value.set(r,a),r=Math.round(r/2),a=Math.round(a/2),this.renderTargetBlurBuffer2.setSize(r,a),this.renderTargetEdgeBuffer2.setSize(r,a),this.separableBlurMaterial2.uniforms.texSize.value.set(r,a),null===(n=this.fxaaRenderMaterial)||void 0===n||n.uniforms.resolution.value.set(1/this.resolution.x,1/this.resolution.y),null===(i=this.renderTargetFxaaBuffer)||void 0===i||i.setSize(e,t)}_canBeHighlighted(e){return e.isMesh||Hf.highlightLines&&e.isLine}_changeVisibilityOfSelectedObjects(e){const t=this._visibilityCache;this.selectedObjects.forEach((n=>n.traverse((n=>{this._canBeHighlighted(n)&&(!0===e?n.visible=t.get(n):(t.set(n,n.visible),n.visible=e))}))))}_changeVisibilityOfNonSelectedObjects(e){const t=this._visibilityCache,n=[];this.selectedObjects.forEach((e=>e.traverse((e=>{this._canBeHighlighted(e)&&n.push(e)})))),this.renderScene.traverse((i=>{if(this._canBeHighlighted(i)||i.isSprite){if(!1===n.some((e=>e.id===i.id))){const n=i.visible;!1!==e&&!0!==t.get(i)||(i.visible=e),t.set(i,n)}}else i.isPoints&&(!0===e?i.visible=t.get(i):(t.set(i,i.visible),i.visible=e))}))}_updateTextureMatrix(){this.textureMatrix.set(.5,0,0,.5,0,.5,0,.5,0,0,.5,.5,0,0,0,1),this.textureMatrix.multiply(this.renderCamera.projectionMatrix),this.textureMatrix.multiply(this.renderCamera.matrixWorldInverse)}render(e,t,n,i,r){if(this.selectedObjects.length>0){e.getClearColor(this.oldClearColor),this.oldClearAlpha=e.getClearAlpha();const t=e.autoClear;this.clearBackground&&(e.setClearColor(0,255),e.clear(!0,!1,!1)),e.autoClear=!1,r&&e.state.buffers.stencil.setTest(!1),e.setClearColor(16777215,1),this._changeVisibilityOfSelectedObjects(!1);const i=this.renderScene.background;this.renderScene.background=null,this._changeVisibilityOfSelectedObjects(!0),this._visibilityCache.clear(),this._updateTextureMatrix(),this._changeVisibilityOfNonSelectedObjects(!1),this.renderScene.overrideMaterial=this.prepareMaskMaterial,this.prepareMaskMaterial.uniforms.cameraNearFar.value.set(this.renderCamera.near,this.renderCamera.far),this.prepareMaskMaterial.uniforms.depthTexture.value=this.gBufferTextures.textureWithDepthValue,this.prepareMaskMaterial.uniforms.textureMatrix.value=this.textureMatrix,e.setRenderTarget(this.renderTargetMaskBuffer),e.clear(),e.render(this.renderScene,this.renderCamera),this.renderScene.overrideMaterial=null,this._changeVisibilityOfNonSelectedObjects(!0),this._visibilityCache.clear(),this.renderScene.background=i;let a=this.renderTargetMaskBuffer;if(this.edgeDetectionFxaa&&this.fxaaRenderMaterial&&this.renderTargetFxaaBuffer&&(this.fxaaRenderMaterial.uniforms.tDiffuse.value=this.renderTargetMaskBuffer.texture,this.fsQuad.material=this.fxaaRenderMaterial,e.setRenderTarget(this.renderTargetFxaaBuffer),e.clear(),this.fsQuad.render(e),a=this.renderTargetFxaaBuffer),this.fsQuad.material=this.materialCopy,this.copyUniforms.tDiffuse.value=a.texture,e.setRenderTarget(this.renderTargetMaskDownSampleBuffer),e.clear(),this.fsQuad.render(e),this.tempPulseColor1.copy(this.visibleEdgeColor),this.tempPulseColor2.copy(this.hiddenEdgeColor),this.pulsePeriod>0){const e=.625+.75*Math.cos(.01*performance.now()/this.pulsePeriod)/2;this.tempPulseColor1.multiplyScalar(e),this.tempPulseColor2.multiplyScalar(e)}this.fsQuad.material=this.edgeDetectionMaterial,this.edgeDetectionMaterial.uniforms.maskTexture.value=this.renderTargetMaskDownSampleBuffer.texture,this.edgeDetectionMaterial.uniforms.texSize.value.set(this.renderTargetMaskDownSampleBuffer.width,this.renderTargetMaskDownSampleBuffer.height),this.edgeDetectionMaterial.uniforms.visibleEdgeColor.value=this.tempPulseColor1,this.edgeDetectionMaterial.uniforms.hiddenEdgeColor.value=this.tempPulseColor2,e.setRenderTarget(this.renderTargetEdgeBuffer1),e.clear(),this.fsQuad.render(e),this.fsQuad.material=this.separableBlurMaterial1,this.separableBlurMaterial1.uniforms.colorTexture.value=this.renderTargetEdgeBuffer1.texture,this.separableBlurMaterial1.uniforms.direction.value=Hf.BlurDirectionX,this.separableBlurMaterial1.uniforms.kernelRadius.value=this.edgeThickness,e.setRenderTarget(this.renderTargetBlurBuffer1),e.clear(),this.fsQuad.render(e),this.separableBlurMaterial1.uniforms.colorTexture.value=this.renderTargetBlurBuffer1.texture,this.separableBlurMaterial1.uniforms.direction.value=Hf.BlurDirectionY,e.setRenderTarget(this.renderTargetEdgeBuffer1),e.clear(),this.fsQuad.render(e),this.fsQuad.material=this.separableBlurMaterial2,this.separableBlurMaterial2.uniforms.colorTexture.value=this.renderTargetEdgeBuffer1.texture,this.separableBlurMaterial2.uniforms.direction.value=Hf.BlurDirectionX,e.setRenderTarget(this.renderTargetBlurBuffer2),e.clear(),this.fsQuad.render(e),this.separableBlurMaterial2.uniforms.colorTexture.value=this.renderTargetBlurBuffer2.texture,this.separableBlurMaterial2.uniforms.direction.value=Hf.BlurDirectionY,e.setRenderTarget(this.renderTargetEdgeBuffer2),e.clear(),this.fsQuad.render(e),this.fsQuad.material=this.overlayMaterial,this.overlayMaterial.uniforms.maskTexture.value=a.texture,this.overlayMaterial.uniforms.edgeTexture1.value=this.renderTargetEdgeBuffer1.texture,this.overlayMaterial.uniforms.edgeTexture2.value=this.renderTargetEdgeBuffer2.texture,this.overlayMaterial.uniforms.patternTexture.value=this.patternTexture,this.overlayMaterial.uniforms.edgeStrength.value=this.edgeStrength,this.overlayMaterial.uniforms.edgeGlow.value=this.edgeGlow,this.overlayMaterial.uniforms.usePatternTexture.value=this.usePatternTexture,r&&e.state.buffers.stencil.setTest(!0),e.setRenderTarget(n),this.fsQuad.render(e),e.setClearColor(this.oldClearColor,this.oldClearAlpha),e.autoClear=t}this.renderToScreen&&n&&(this.fsQuad.material=this.materialCopy,this.copyUniforms.tDiffuse.value=n.texture,e.setRenderTarget(null),this.fsQuad.render(e))}renderPass(e){this.render(e,null,null,0,!1)}_getPrepareMaskMaterial(e){return new er({uniforms:{depthTexture:{value:null},cameraNearFar:{value:new _t(.5,.5)},textureMatrix:{value:null}},defines:{FLOAT_ALPHA_DEPTH:e?1:0},vertexShader:"#include \n\t\t\t\t#include \n\n\t\t\t\tvarying vec4 projTexCoord;\n\t\t\t\tvarying vec4 vPosition;\n\t\t\t\tuniform mat4 textureMatrix;\n\n\t\t\t\tvoid main() {\n\n\t\t\t\t\t#include \n\t\t\t\t\t#include \n\t\t\t\t\t#include \n\t\t\t\t\t#include \n\t\t\t\t\t#include \n\n\t\t\t\t\tvPosition = mvPosition;\n\n\t\t\t\t\tvec4 worldPosition = vec4( transformed, 1.0 );\n\n\t\t\t\t\t#ifdef USE_INSTANCING\n\n\t\t\t\t\t\tworldPosition = instanceMatrix * worldPosition;\n\n\t\t\t\t\t#endif\n\t\t\t\t\t\n\t\t\t\t\tworldPosition = modelMatrix * worldPosition;\n\n\t\t\t\t\tprojTexCoord = textureMatrix * worldPosition;\n\n\t\t\t\t}",fragmentShader:"#include \n\t\t\t\tvarying vec4 vPosition;\n\t\t\t\tvarying vec4 projTexCoord;\n\t\t\t\tuniform sampler2D depthTexture;\n\t\t\t\tuniform vec2 cameraNearFar;\n\n\t\t\t\tvoid main() {\n\n #if FLOAT_ALPHA_DEPTH == 1\n\t\t\t\t\t float depth = texture2DProj( depthTexture, projTexCoord ).w;\n #else\n float depth = unpackRGBAToDepth(texture2DProj( depthTexture, projTexCoord ));\n #endif\n\t\t\t\t\tfloat viewZ = - DEPTH_TO_VIEW_Z( depth, cameraNearFar.x, cameraNearFar.y );\n\t\t\t\t\tfloat depthTest = (-vPosition.z > viewZ) ? 1.0 : 0.0;\n\t\t\t\t\tgl_FragColor = vec4(0.0, depthTest, 1.0, 1.0);\n\n\t\t\t\t}"})}_getEdgeDetectionMaterial(){return new er({uniforms:{maskTexture:{value:null},texSize:{value:new _t(.5,.5)},visibleEdgeColor:{value:new jt(1,1,1)},hiddenEdgeColor:{value:new jt(1,1,1)}},vertexShader:"varying vec2 vUv;\n\n\t\t\t\tvoid main() {\n\t\t\t\t\tvUv = uv;\n\t\t\t\t\tgl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n\t\t\t\t}",fragmentShader:"varying vec2 vUv;\n\n\t\t\t\tuniform sampler2D maskTexture;\n\t\t\t\tuniform vec2 texSize;\n\t\t\t\tuniform vec3 visibleEdgeColor;\n\t\t\t\tuniform vec3 hiddenEdgeColor;\n\n\t\t\t\tvoid main() {\n\t\t\t\t\tvec2 invSize = 1.0 / texSize;\n\t\t\t\t\tvec4 uvOffset = vec4(1.0, 0.0, 0.0, 1.0) * vec4(invSize, invSize);\n\t\t\t\t\tvec4 c1 = texture2D( maskTexture, vUv + uvOffset.xy);\n\t\t\t\t\tvec4 c2 = texture2D( maskTexture, vUv - uvOffset.xy);\n\t\t\t\t\tvec4 c3 = texture2D( maskTexture, vUv + uvOffset.yw);\n\t\t\t\t\tvec4 c4 = texture2D( maskTexture, vUv - uvOffset.yw);\n\t\t\t\t\tfloat diff1 = (c1.r - c2.r)*0.5;\n\t\t\t\t\tfloat diff2 = (c3.r - c4.r)*0.5;\n\t\t\t\t\tfloat d = length( vec2(diff1, diff2) );\n\t\t\t\t\tfloat a1 = min(c1.g, c2.g);\n\t\t\t\t\tfloat a2 = min(c3.g, c4.g);\n\t\t\t\t\tfloat visibilityFactor = min(a1, a2);\n\t\t\t\t\tvec3 edgeColor = 1.0 - visibilityFactor > 0.001 ? visibleEdgeColor : hiddenEdgeColor;\n\t\t\t\t\tgl_FragColor = vec4(edgeColor, 1.0) * vec4(d);\n\t\t\t\t}"})}_getSeperableBlurMaterial(e){return new er({defines:{MAX_RADIUS:e},uniforms:{colorTexture:{value:null},texSize:{value:new _t(.5,.5)},direction:{value:new _t(.5,.5)},kernelRadius:{value:1}},vertexShader:"varying vec2 vUv;\n\n\t\t\t\tvoid main() {\n\t\t\t\t\tvUv = uv;\n\t\t\t\t\tgl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n\t\t\t\t}",fragmentShader:"#include \n\t\t\t\tvarying vec2 vUv;\n\t\t\t\tuniform sampler2D colorTexture;\n\t\t\t\tuniform vec2 texSize;\n\t\t\t\tuniform vec2 direction;\n\t\t\t\tuniform float kernelRadius;\n\n\t\t\t\tfloat gaussianPdf(in float x, in float sigma) {\n\t\t\t\t\treturn 0.39894 * exp( -0.5 * x * x/( sigma * sigma))/sigma;\n\t\t\t\t}\n\n\t\t\t\tvoid main() {\n\t\t\t\t\tvec2 invSize = 1.0 / texSize;\n\t\t\t\t\tfloat sigma = kernelRadius/2.0;\n\t\t\t\t\tfloat weightSum = gaussianPdf(0.0, sigma);\n\t\t\t\t\tvec4 diffuseSum = texture2D( colorTexture, vUv) * weightSum;\n\t\t\t\t\tvec2 delta = direction * invSize * kernelRadius/float(MAX_RADIUS);\n\t\t\t\t\tvec2 uvOffset = delta;\n\t\t\t\t\tfor( int i = 1; i <= MAX_RADIUS; i ++ ) {\n\t\t\t\t\t\tfloat x = kernelRadius * float(i) / float(MAX_RADIUS);\n\t\t\t\t\t\tfloat w = gaussianPdf(x, sigma);\n\t\t\t\t\t\tvec4 sample1 = texture2D( colorTexture, vUv + uvOffset);\n\t\t\t\t\t\tvec4 sample2 = texture2D( colorTexture, vUv - uvOffset);\n\t\t\t\t\t\tdiffuseSum += ((sample1 + sample2) * w);\n\t\t\t\t\t\tweightSum += (2.0 * w);\n\t\t\t\t\t\tuvOffset += delta;\n\t\t\t\t\t}\n\t\t\t\t\tgl_FragColor = diffuseSum/weightSum;\n\t\t\t\t}"})}_getOverlayMaterial(){return new er({uniforms:{maskTexture:{value:null},edgeTexture1:{value:null},edgeTexture2:{value:null},patternTexture:{value:null},edgeStrength:{value:1},edgeGlow:{value:1},usePatternTexture:{value:0}},vertexShader:"varying vec2 vUv;\n\n\t\t\t\tvoid main() {\n\t\t\t\t\tvUv = uv;\n\t\t\t\t\tgl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n\t\t\t\t}",fragmentShader:"varying vec2 vUv;\n\n\t\t\t\tuniform sampler2D maskTexture;\n\t\t\t\tuniform sampler2D edgeTexture1;\n\t\t\t\tuniform sampler2D edgeTexture2;\n\t\t\t\tuniform sampler2D patternTexture;\n\t\t\t\tuniform float edgeStrength;\n\t\t\t\tuniform float edgeGlow;\n\t\t\t\tuniform bool usePatternTexture;\n\n\t\t\t\tvoid main() {\n\t\t\t\t\tvec4 edgeValue1 = texture2D(edgeTexture1, vUv);\n\t\t\t\t\tvec4 edgeValue2 = texture2D(edgeTexture2, vUv);\n\t\t\t\t\tvec4 maskColor = texture2D(maskTexture, vUv);\n\t\t\t\t\tvec4 patternColor = texture2D(patternTexture, 6.0 * vUv);\n\t\t\t\t\tfloat visibilityFactor = 1.0 - maskColor.g > 0.0 ? 1.0 : 0.5;\n\t\t\t\t\tvec4 edgeValue = edgeValue1 + edgeValue2 * edgeGlow;\n\t\t\t\t\tvec4 finalColor = edgeStrength * maskColor.r * edgeValue;\n\t\t\t\t\tif(usePatternTexture)\n\t\t\t\t\t\tfinalColor += + visibilityFactor * (1.0 - maskColor.r) * (1.0 - patternColor.r);\n\t\t\t\t\tgl_FragColor = finalColor;\n }",blending:2,depthTest:!1,depthWrite:!1,transparent:!0})}}Hf.BlurDirectionX=new _t(1,0),Hf.BlurDirectionY=new _t(0,1),Hf.highlightLines=!0;const Vf={tDiffuse:{value:null}},Gf="\n varying vec2 vUv;\n \n void main() {\n vUv = uv;\n gl_Position = (projectionMatrix * modelViewMatrix * vec4(position, 1.0)).xyww;\n }",Wf="\n uniform highp sampler2D tDiffuse;\n varying vec2 vUv;\n \n void main() {\n vec4 textureColor = texture2D(tDiffuse, vUv);\n float aoPassDepth = dot(textureColor.wz, vec2(1.0/1024.0));\n gl_FragColor = vec4(vec3(aoPassDepth * aoPassDepth), 1.0);\n }";class jf extends er{constructor(e){super({uniforms:$i.clone(Vf),vertexShader:Gf,fragmentShader:Wf,transparent:!0,depthTest:!1,depthWrite:!1,blendSrc:v,blendDst:c,blendEquation:s,blendSrcAlpha:m,blendDstAlpha:c,blendEquationAlpha:s}),this._intensity=new _t(1,1),this.update(e)}update(e){return void 0!==(null==e?void 0:e.texture)&&(this.uniforms.tDiffuse.value=e.texture),void 0!==(null==e?void 0:e.blending)&&(this.blending=e.blending),this}}class Xf extends Np{constructor(e){super(e),this.debugOutput="",this._environmentMapDecodeMaterial=new Wo(!0,!1),this._environmentMapDecodeMaterial.blending=0,this._environmentMapDecodeMaterial.depthTest=!1}dispose(){var e,t,n;null===(e=this._depthRenderMaterial)||void 0===e||e.dispose(),null===(t=this._copyMaterial)||void 0===t||t.dispose(),null===(n=this._srgbToLinearCopyMaterial)||void 0===n||n.dispose()}getCopyMaterial(e){var t;return this._copyMaterial=null!==(t=this._copyMaterial)&&void 0!==t?t:new mo,this._copyMaterial.update(e)}getBlendAoAndShadowMaterial(e){var t;return this._blendAoAndShadowMaterial=null!==(t=this._blendAoAndShadowMaterial)&&void 0!==t?t:new Yp({blending:0}),this._blendAoAndShadowMaterial.update(e)}getBlendAoPassDepthMaterial(e){var t;return this._blendAoPassDepthMaterial=null!==(t=this._blendAoPassDepthMaterial)&&void 0!==t?t:new jf({blending:0}),this._blendAoPassDepthMaterial.update(e)}getSrgbToLinearCopyMaterial(e){var t;return this._srgbToLinearCopyMaterial=null!==(t=this._copyMaterial)&&void 0!==t?t:new mo({},fo,!0,!0),this._srgbToLinearCopyMaterial.update(e)}_getDepthRenderMaterial(e){var t;return this._depthRenderMaterial=null!==(t=this._depthRenderMaterial)&&void 0!==t?t:new vo({depthTexture:this.gBufferTextures.textureWithDepthValue,depthFilter:this.gBufferTextures.isFloatGBufferWithRgbNormalAlphaDepth?new zt(0,0,0,1):new zt(1,0,0,0)}),this._depthRenderMaterial.update({camera:e})}renderPass(e){var t,n,i,r,a,s;switch(this.debugOutput){default:break;case"lineardepth":this.passRenderer.renderScreenSpace(e,this._getDepthRenderMaterial(this.camera),null);break;case"g-normal":this.gBufferTextures.isFloatGBufferWithRgbNormalAlphaDepth?this.passRenderer.renderScreenSpace(e,this.getCopyMaterial({texture:null===(t=this.gBufferTextures)||void 0===t?void 0:t.gBufferTexture,blending:0,colorTransform:(new wn).set(.5,0,0,0,0,.5,0,0,0,0,.5,0,0,0,0,0),colorBase:new zt(.5,.5,.5,1),multiplyChannels:0,uvTransform:uo}),null):this.passRenderer.renderScreenSpace(e,this.getCopyMaterial({texture:null===(n=this.gBufferTextures)||void 0===n?void 0:n.gBufferTexture,blending:0,colorTransform:ao,colorBase:ho,multiplyChannels:0,uvTransform:uo}),null);break;case"g-depth":this.gBufferTextures.isFloatGBufferWithRgbNormalAlphaDepth?this.passRenderer.renderScreenSpace(e,this.getCopyMaterial({texture:null===(i=this.gBufferTextures)||void 0===i?void 0:i.gBufferTexture,blending:0,colorTransform:so,colorBase:ho,multiplyChannels:0,uvTransform:uo}),null):this.passRenderer.renderScreenSpace(e,this.getCopyMaterial({texture:null===(r=this.gBufferTextures)||void 0===r?void 0:r.depthBufferTexture,blending:0,colorTransform:oo,colorBase:ho,multiplyChannels:0,uvTransform:uo}),null);break;case"ssao":this.passRenderer.renderScreenSpace(e,this.getCopyMaterial({texture:this.renderPassManager.shadowAndAoPass.aoAndSoftShadowRenderTarget.texture,blending:0,colorTransform:lo,colorBase:co,multiplyChannels:0,uvTransform:uo}),null);break;case"ssaodenoise":this.passRenderer.renderScreenSpace(e,this.getCopyMaterial({texture:this.renderPassManager.shadowAndAoPass.denoiseRenderTargetTexture,blending:0,colorTransform:lo,colorBase:co,multiplyChannels:0,uvTransform:uo}),null);break;case"shadowmap":this.passRenderer.renderScreenSpace(e,this.getCopyMaterial({texture:this.renderPassManager.screenSpaceShadowMapPass.shadowTexture,blending:0,colorTransform:lo,colorBase:co,multiplyChannels:0,uvTransform:uo}),null);break;case"shadowsoft":this.passRenderer.renderScreenSpace(e,this.getCopyMaterial({texture:this.renderPassManager.shadowAndAoPass.aoAndSoftShadowRenderTarget.texture,blending:0,colorTransform:af.shadowTransform,colorBase:co,multiplyChannels:0,uvTransform:uo}),null);break;case"shadowdenoise":this.passRenderer.renderScreenSpace(e,this.getCopyMaterial({texture:this.renderPassManager.shadowAndAoPass.denoiseRenderTargetTexture,blending:0,colorTransform:af.shadowTransform,colorBase:co,multiplyChannels:0,uvTransform:uo}),null);break;case"shadowfadein":this.passRenderer.renderScreenSpace(e,this.getCopyMaterial({texture:this.renderPassManager.shadowAndAoPass.fadeRenderTarget.texture,blending:0,colorTransform:af.shadowTransform,colorBase:co,multiplyChannels:0,uvTransform:uo}),null);break;case"shadowandao":this.passRenderer.renderScreenSpace(e,this.getBlendAoAndShadowMaterial({texture:this.renderPassManager.shadowAndAoPass.denoiseRenderTargetTexture,blending:0,aoIntensity:this.renderPassManager.shadowAndAoPass.parameters.aoIntensity,shadowIntensity:this.renderPassManager.shadowAndAoPass.parameters.shadowIntensity}),null);break;case"shadowandaodepth":this.passRenderer.renderScreenSpace(e,this.getBlendAoPassDepthMaterial({texture:this.renderPassManager.shadowAndAoPass.denoiseRenderTargetTexture,blending:0}),null);break;case"materialao":this.passRenderer.renderScreenSpace(e,this.getCopyMaterial({texture:this.renderPassManager.aoPassMapTexture,blending:0,colorTransform:ro,colorBase:co,multiplyChannels:0,uvTransform:uo}),null);break;case"groundreflection":this.passRenderer.renderScreenSpace(e,this.getSrgbToLinearCopyMaterial({texture:this.renderPassManager.groundReflectionPass.reflectionRenderTarget.texture,blending:0,colorTransform:ro,colorBase:co,multiplyChannels:0,uvTransform:po}),null);break;case"groundreflectionfinal":this.passRenderer.renderScreenSpace(e,this.getSrgbToLinearCopyMaterial({texture:this.renderPassManager.groundReflectionPass.intensityRenderTarget.texture,blending:0,colorTransform:ro,colorBase:co,multiplyChannels:0,uvTransform:po}),null);break;case"bakedgroundshadow":this.passRenderer.renderScreenSpace(e,this.getCopyMaterial({texture:this.renderPassManager.bakedGroundContactShadowPass.renderTarget.texture,blending:0,colorTransform:ro,colorBase:co,multiplyChannels:0,uvTransform:uo}),null);break;case"environmentmap":this._environmentMapDecodeMaterial.setSourceTexture(this.scene.environment),this.passRenderer.renderScreenSpace(e,this._environmentMapDecodeMaterial,null);break;case"lightsourcedetection":if(null===(a=this.scene.userData)||void 0===a?void 0:a.environmentDefinition){const t=this.renderPassManager.aspect,n=new Cs(-1,1,1/t,-1/t,-1,1),i=null===(s=this.scene.userData)||void 0===s?void 0:s.environmentDefinition.createDebugScene(e,this.scene,this.renderPassManager.screenSpaceShadowMapPass.parameters.maximumNumberOfLightSources);i.background=new fi(16777215),e.render(i,n)}}}}class Yf extends Np{constructor(e){super(e),this.drawGround=!0,this.drawWithDebugMaterial=!1,this.grayDebugMaterial=new Fa({color:12632256,side:2,envMapIntensity:.4})}dispose(){super.dispose(),this.grayDebugMaterial.dispose()}renderPass(e){this.renderCacheManager.onBeforeRender("floorDepthWrite",this.scene),this.renderPassManager.setGroundVisibility(this.drawGround),this.drawWithDebugMaterial?this.renderCacheManager.render("debug",this.scene,(()=>{this.passRenderer.renderWithOverrideMaterial(e,this.scene,this.camera,this.grayDebugMaterial,null,0,1)})):e.render(this.scene,this.camera),this.renderPassManager.setGroundVisibility(!1),this.renderCacheManager.onAfterRender("floorDepthWrite")}}class qf{constructor(){this.weightedAoPassAntiAliasing=!1,this.applyAoAndShadowToAlpha=!1,this._aoPassMapUniform={value:null},this._aoPassMapScaleUniform={value:1},this._aoPassMapIntensityUniform={value:1},this._shPassMapIntensityUniform={value:1},this._reflectionPassMapUniform={value:null},this._reflectionPassMapScaleUniform={value:1},this._reflectionPassMapIntensityUniform={value:0},this.applyReflectionPassMap=!1}set aoPassMap(e){this._aoPassMapUniform.value=e}set aoPassMapScale(e){this._aoPassMapScaleUniform.value=e}set aoPassMapIntensity(e){this._aoPassMapIntensityUniform.value=e}set shPassMapIntensity(e){this._shPassMapIntensityUniform.value=e}set reflectionPassMap(e){this._reflectionPassMapUniform.value=e}set reflectionPassMapScale(e){this._reflectionPassMapScaleUniform.value=e}set reflectionPassMapIntensity(e){this._reflectionPassMapIntensityUniform.value=e}static addPlugin(e){if(void 0!==e.userData.postProcessingMaterialPlugin)return e.userData.postProcessingMaterialPlugin instanceof qf?e.userData.postProcessingMaterialPlugin:null;const t=new qf;return e.userData.postProcessingMaterialPlugin=t,e.onBeforeCompile=(e,n)=>t._onBeforeCompile(e,n),e.customProgramCacheKey=()=>t._customProgramCacheKey(),t}_isEnabled(){return void 0!==this._aoPassMapUniform.value&&null!==this._aoPassMapUniform.value}_customProgramCacheKey(){let e="";return this._isEnabled()&&(e+="aoPassMap"+(this.applyAoAndShadowToAlpha?"Alpha":"")),this.applyReflectionPassMap&&(e+="reflectionPassMap"),e}_onBeforeCompile(e,t){if(this._isEnabled()||this.applyReflectionPassMap){let t=this.applyAoAndShadowToAlpha?"#define USE_APPLY_AO_AND_SHADOW_TO_ALPHA\n":"";t+=this.applyReflectionPassMap?"#define USE_REFLECTION_PASS_MAP\n":"",t+=this.weightedAoPassAntiAliasing?"#define WEIGHTED_AO_PASS_ANTIALIASING\n":"",t+=Zf,e.fragmentShader=e.fragmentShader.replace("#include ",t),e.fragmentShader=e.fragmentShader.replace("#include ",Kf),this._initUniforms(e)}}_initUniforms(e){e&&(e.uniforms.tAoPassMap=this._aoPassMapUniform,e.uniforms.aoPassMapScale=this._aoPassMapScaleUniform,e.uniforms.aoPassMapIntensity=this._aoPassMapIntensityUniform,e.uniforms.shPassMapIntensity=this._shPassMapIntensityUniform,e.uniforms.tReflectionPassMap=this._reflectionPassMapUniform,e.uniforms.reflectionPassMapScale=this._reflectionPassMapScaleUniform,e.uniforms.reflectionPassMapIntensity=this._reflectionPassMapIntensityUniform)}}const Zf="\n#ifdef USE_AOMAP\n\n\tuniform sampler2D aoMap;\n\tuniform float aoMapIntensity;\n\n#endif\n\n\tuniform highp sampler2D tAoPassMap;\n uniform float aoPassMapScale;\n uniform float aoPassMapIntensity;\n uniform float shPassMapIntensity;\n uniform sampler2D tReflectionPassMap;\n uniform float reflectionPassMapScale;\n uniform float reflectionPassMapIntensity;\n",Kf="\n#ifndef AOPASSMAP_SWIZZLE\n\t#define AOPASSMAP_SWIZZLE rg\n#endif\n\nfloat ambientOcclusion = 1.0;\nfloat shadowValue = 1.0;\n\t\n#ifdef USE_AOMAP\n\n\t// reads channel R, compatible with a combined OcclusionRoughnessMetallic (RGB) texture\n\tambientOcclusion = texture2D( aoMap, vAoMapUv ).r;\n ambientOcclusion = ( ambientOcclusion - 1.0 ) * aoMapIntensity + 1.0;\n\n#endif\n\n vec4 aoAndShadowMap = texelFetch( tAoPassMap, ivec2( gl_FragCoord.xy * aoPassMapScale ), 0 );\n vec2 aoAndShadow = aoAndShadowMap.rg;\n float depthDelta = abs( dot(aoAndShadowMap.wz, vec2(1.0/1024.0)) - gl_FragCoord.z );\n const ivec2 aoOffsetArray[8] = ivec2[8](\n ivec2(1, 0), ivec2(-1, 0), ivec2(0, 1), ivec2(0, -1), ivec2(1, 1), ivec2(-1, 1), ivec2(1, -1), ivec2(-1, -1));\n #ifdef WEIGHTED_AO_PASS_ANTIALIASING \n aoAndShadow *= 100.0;\n float deltaAoPassWeight = 100.0; \n for (int aoOffsetI = 0; aoOffsetI < 8; aoOffsetI++) {\n aoAndShadowMap = texelFetch( tAoPassMap, ivec2( gl_FragCoord.xy * aoPassMapScale ) + aoOffsetArray[aoOffsetI], 0 );\n float testDepthDelta = abs( dot(aoAndShadowMap.wz, vec2(1.0/1024.0)) - gl_FragCoord.z );\n float aoPassSampleWeight = (depthDelta * 100.0 + 0.01) / (testDepthDelta * 100.0 + 0.01);\n deltaAoPassWeight += aoPassSampleWeight;\n aoAndShadow += aoAndShadowMap.rg * aoPassSampleWeight;\n }\n aoAndShadow /= deltaAoPassWeight;\n #else\n for (int aoOffsetI = 0; aoOffsetI < 8; aoOffsetI++) {\n aoAndShadowMap = texelFetch( tAoPassMap, ivec2( gl_FragCoord.xy * aoPassMapScale ) + aoOffsetArray[aoOffsetI], 0 );\n float testDepthDelta = abs( dot(aoAndShadowMap.wz, vec2(1.0/1024.0)) - gl_FragCoord.z );\n if (testDepthDelta < depthDelta) {\n aoAndShadow = aoAndShadowMap.rg;\n depthDelta = testDepthDelta;\n }\n }\n #endif \n \n float aoPassMapValue = aoPassMapIntensity < 0.0 ? 1.0 : max(0.0, (aoAndShadow.r - 1.0) * aoPassMapIntensity + 1.0);\n shadowValue = shPassMapIntensity < 0.0 ? 1.0 : max(0.0, (aoAndShadow.g - 1.0) * shPassMapIntensity + 1.0);\n\n #ifdef USE_REFLECTION_PASS_MAP\n\n ivec2 reflectionPassMapSize = textureSize( tReflectionPassMap, 0 );\n vec2 reflectionPassMapUv = vec2( gl_FragCoord.x * reflectionPassMapScale, float(reflectionPassMapSize.y) - gl_FragCoord.y * reflectionPassMapScale );\n vec4 reflectionPassMapColor = texture2D( tReflectionPassMap, reflectionPassMapUv / vec2(reflectionPassMapSize) );\n if (reflectionPassMapColor.a > 0.0) reflectionPassMapColor.rgb /= reflectionPassMapColor.a;\n vec3 diffuseReflectionPassMapColor = reflectionPassMapColor.rgb * material.diffuseColor;\n reflectedLight.indirectDiffuse += diffuseReflectionPassMapColor * reflectionPassMapColor.a * reflectionPassMapIntensity;\n //reflectedLight.indirectDiffuse = mix(reflectedLight.indirectDiffuse, diffuseReflectionPassMapColor, reflectionPassMapColor.a * reflectionPassMapIntensity);\n\n #endif\n\n #if defined ( USE_APPLY_AO_AND_SHADOW_TO_ALPHA )\n diffuseColor.a = 1.0 - (1.0 - diffuseColor.a) * aoPassMapValue * shadowValue;\n #else\n ambientOcclusion = min( ambientOcclusion, aoPassMapValue );\n #endif\n\n\treflectedLight.indirectDiffuse *= ambientOcclusion * shadowValue;\n \n\t#if defined( USE_CLEARCOAT ) \n\t\tclearcoatSpecularIndirect *= ambientOcclusion * shadowValue;\n\t#endif\n\n\t#if defined( USE_SHEEN ) \n\t\tsheenSpecularIndirect *= ambientOcclusion * shadowValue;\n\t#endif\n\n\t#if defined( USE_ENVMAP ) && defined( STANDARD )\n\n\t\tfloat dotNV = saturate( dot( geometryNormal, geometryViewDir ) );\n \n float specularOcclusion = computeSpecularOcclusion( dotNV, ambientOcclusion * shadowValue, material.roughness );\n\t\treflectedLight.indirectSpecular *= specularOcclusion;\n\n #ifdef USE_REFLECTION_PASS_MAP\n reflectedLight.indirectSpecular += material.specularColor * reflectionPassMapColor.rgb * reflectionPassMapColor.a * reflectionPassMapIntensity * specularOcclusion;\n #endif \n \n\t#endif\n";class Jf{get passRenderer(){return this._passRenderer}get scene(){return this._scene}get camera(){return this._camera}get aspect(){return this._sceneRenderer.width/this._sceneRenderer.height}get cameraChanged(){return this._cameraChanged}get noOStaticFrames(){return this._noOStaticFrames}get renderCacheManager(){return this._sceneRenderer.renderCacheManager}get parameters(){return this._sceneRenderer.parameters}get sceneRenderPass(){return this._sceneRenderPass}get bakedGroundContactShadowPass(){return this._bakedGroundContactShadowPass}get gBufferRenderPass(){return this._gBufferRenderPass}get groundReflectionPass(){return this._groundReflectionPass}get screenSpaceShadowMapPass(){return this._screenSpaceShadowMapPass}get shadowAndAoPass(){return this._shadowAndAoPass}get outlinePass(){return this._outlinePass}get outlineRenderer(){return this._sceneRenderer.outlineRenderer}get debugPass(){var e;return null!==(e=this._debugPass)&&void 0!==e||(this._debugPass=new Xf(this)),this._debugPass}get debugOutput(){return this._sceneRenderer.debugOutput}constructor(e){this.materialsNeedUpdate=!0,this._passRenderer=new Ro,this._outlinePass=null,this._debugPass=null,this._cameraUpdate=new Po,this._cameraChanged=!0,this._noUpdateNeededCount=0,this._noOStaticFrames=0,this._maxSamples=1,this._passUpdateStates={updateGroundReflection:!1,updateGBuffer:!1,updateScreenSpaceShadow:!1,updateShadowAndAoPass:!1,updateOutlinePass:!1,updateDebugPass:!1},this.aoPassMapTexture=null,this._sceneRenderer=e,this._maxSamples=Ao(this._sceneRenderer.renderer),this._sceneRenderPass=new Yf(this),this._bakedGroundContactShadowPass=new gf(this,this._sceneRenderer.renderer,this._sceneRenderer.groundGroup,{sharedShadowGroundPlane:this._sceneRenderer.shadowAndAoGroundPlane}),this._gBufferRenderPass=new xf(this,{shared:!0,capabilities:this._sceneRenderer.renderer.capabilities,width:this._sceneRenderer.width,height:this._sceneRenderer.height,samples:1}),this._groundReflectionPass=new Sf(this,this._sceneRenderer.width,this._sceneRenderer.height,this._maxSamples,{}),this._screenSpaceShadowMapPass=new Rf(this,new _t(this._sceneRenderer.width,this._sceneRenderer.height),{samples:1,alwaysUpdate:!1}),this._shadowAndAoPass=new af(this,this._sceneRenderer.width,this._sceneRenderer.height,1)}dispose(){var e;this._sceneRenderPass.dispose(),this._bakedGroundContactShadowPass.dispose(),this._gBufferRenderPass.dispose(),this._groundReflectionPass.dispose(),this._screenSpaceShadowMapPass.dispose(),this._shadowAndAoPass.dispose(),null===(e=this._outlinePass)||void 0===e||e.dispose()}setSize(e,t){var n;this._gBufferRenderPass.setSize(e,t),this._groundReflectionPass.setSize(e,t),this._screenSpaceShadowMapPass.setSize(e,t),this._shadowAndAoPass.setSize(e,t),null===(n=this._outlinePass)||void 0===n||n.setSize(e,t)}createOutlinePass(){return this._outlinePass||(this._outlinePass=new Hf(this,new _t(this._sceneRenderer.width,this._sceneRenderer.height),this.scene,this.camera,[],{downSampleRatio:2,edgeDetectionFxaa:!0})),this._outlinePass}setGroundVisibility(e){this._sceneRenderer.shadowAndAoGroundPlane.setVisibility(e)}updatePasses(e,t,n){this._scene=t,this._camera=n,this._cameraChanged=this._cameraUpdate.changed(n);const i=this._evaluateIfShadowAndAoUpdateIsNeeded();this._updateSceneRenderPass(),this._updateBakedGroundContactShadowPass(),this._updateGBufferPass(i),this._updateGroundReflectionPass(i),this._updateScreenSpaceShadowPass(i),this._updateShadowAndAoPass(i),this._updateOutlinePass(),this._updateDebugPass()}_evaluateIfShadowAndAoUpdateIsNeeded(){const e=this._shadowAndAoPass.parameters.alwaysUpdate||this._screenSpaceShadowMapPass.needsUpdate||this._screenSpaceShadowMapPass.shadowTypeNeedsUpdate;let t=(this._shadowAndAoPass.parameters.enabled||this._groundReflectionPass.parameters.enabled)&&this._cameraChanged,n=1;return t&&(this._noUpdateNeededCount=0,this._noOStaticFrames=0),e||(this._noUpdateNeededCount++,t=this._noUpdateNeededCount>=this.parameters.effectSuspendFrames,n=Math.max(0,Math.min(1,(this._noUpdateNeededCount-this.parameters.effectSuspendFrames)/this.parameters.effectFadeInFrames))),e||1!==n||this._noOStaticFrames++,t=e||t,{needsUpdate:t,shadowOnCameraChange:!t||n<.99?this.parameters.shadowOnCameraChange:$p,intensityScale:n}}_dynamicChanges(e){return e.needsUpdate||e.shadowOnCameraChange!==$p}_updateSceneRenderPass(){this._sceneRenderPass.drawWithDebugMaterial=!1}_updateBakedGroundContactShadowPass(){const e=this._bakedGroundContactShadowPass.limitPlaneSize;this._bakedGroundContactShadowPass.limitPlaneSize=this._bakedGroundContactShadowPass.parameters.enabled,(e!==this._bakedGroundContactShadowPass.limitPlaneSize||this._bakedGroundContactShadowPass.needsUpdate)&&this._bakedGroundContactShadowPass.updateBounds(this._sceneRenderer.boundingVolume,this._sceneRenderer.groundLevel),this._sceneRenderPass.drawGround=this._bakedGroundContactShadowPass.parameters.enabled||this._shadowAndAoPass.parameters.applyToMaterial}_updateGBufferPass(e){this._passUpdateStates.updateGBuffer=!1,this._gBufferRenderPass.needsUpdate=e.needsUpdate||e.shadowOnCameraChange===tf,this.gBufferRenderPass.drawGround=this._sceneRenderer.boundingVolumeSet&&this._shadowAndAoPass.parameters.aoOnGround}_updateGroundReflectionPass(e){this._passUpdateStates.updateGroundReflection=!1,this._groundReflectionPass.parameters.enabled&&this._dynamicChanges(e)&&(!this.parameters.suspendGroundReflection||e.needsUpdate)&&(this._groundReflectionPass.reflectionFadeInScale=this.parameters.suspendGroundReflection?e.intensityScale:1,this._passUpdateStates.updateGroundReflection=!0)}_updateScreenSpaceShadowPass(e){this._dynamicChanges(e)?(this._screenSpaceShadowMapPass.parameters.alwaysUpdate=this._shadowAndAoPass.parameters.alwaysUpdate,this._screenSpaceShadowMapPass.drawGround=this._shadowAndAoPass.parameters.shadowOnGround,this._passUpdateStates.updateScreenSpaceShadow=this._shadowAndAoPass.parameters.shadowIntensity>0,this._passUpdateStates.updateScreenSpaceShadow=!0,this._passUpdateStates.updateGBuffer=!0):this._passUpdateStates.updateScreenSpaceShadow=!1}_updateShadowAndAoPass(e){this._dynamicChanges(e)?(this._shadowAndAoPass.shadowAndAoPassSettings={shadowMapTexture:this._screenSpaceShadowMapPass.shadowTexture,shadowBlurType:e.needsUpdate?nf:e.shadowOnCameraChange,shadowFadeInBlurType:e.shadowOnCameraChange,shadowFadeInMix:1-e.intensityScale,noOStaticFrames:this.noOStaticFrames},this._passUpdateStates.updateShadowAndAoPass=!0,this._passUpdateStates.updateGBuffer=!0):this._passUpdateStates.updateShadowAndAoPass=!1}_updateOutlinePass(){this.outlineRenderer.outlinePassActivated&&this.outlineRenderer.outlinePass?(this.outlineRenderer.outlinePass.renderToScreen=!1,this.outlineRenderer.outlinePass.clearBackground=!1,this._passUpdateStates.updateOutlinePass=!0,this._passUpdateStates.updateGBuffer=!0):this._passUpdateStates.updateOutlinePass=!1}_updateDebugPass(){if(this.debugOutput&&""!==this.debugOutput&&"off"!==this.debugOutput){if("outline"===this.debugOutput&&this.outlineRenderer.outlinePass)return this.outlineRenderer.outlinePass.clearBackground=!0,void(this._passUpdateStates.updateDebugPass=!1);if("color"===this.debugOutput||"grayscale"===this.debugOutput)return this._passUpdateStates.updateGroundReflection=!1,this._passUpdateStates.updateGBuffer=!1,this._passUpdateStates.updateScreenSpaceShadow=!1,this._passUpdateStates.updateShadowAndAoPass=!1,this._passUpdateStates.updateOutlinePass=!1,this._passUpdateStates.updateDebugPass=!1,void(this._sceneRenderPass.drawWithDebugMaterial="grayscale"===this.debugOutput);this.debugPass.debugOutput=this.debugOutput,this._passUpdateStates.updateDebugPass=!0}else this._passUpdateStates.updateDebugPass=!1}_updateMaterials(e,t){if(!this.materialsNeedUpdate||!this._shadowAndAoPass.parameters.applyToMaterial)return;this.aoPassMapTexture=this._shadowAndAoPass.denoiseRenderTargetTexture;const n=e.getPixelRatio();this.materialsNeedUpdate=!1,t.traverse((e=>{if(e.isMesh){const t=e.material;t instanceof Fa&&this._updateMaterial(e,t,n)}}))}_updateMaterial(e,t,n){const i=qf.addPlugin(t);i&&(this._updatePlugInAo(i,e,t,n),this._updatePlugInReflection(i,e),t.needsUpdate=!1)}_updatePlugInAo(e,t,n,i){const r=this._shadowAndAoPass.parameters.enabled&&this._shadowAndAoPass.parameters.applyToMaterial&&null!==this.aoPassMapTexture&&("ShadowGroundPlaneMaterial"===n.name||t.receiveShadow&&(!n.transparent||n.alphaTest>=.9)),a=r&&this._shadowAndAoPass.parameters.aoIntensity>.01,s=r&&this._screenSpaceShadowMapPass.enabled&&this._shadowAndAoPass.parameters.shadowIntensity>.01;e.applyAoAndShadowToAlpha="ShadowGroundPlaneMaterial"===n.name,e.aoPassMapIntensity=a?2*this._shadowAndAoPass.parameters.aoIntensity:-1,e.shPassMapIntensity=s?2*this._shadowAndAoPass.parameters.shadowIntensity:-1,e.aoPassMapScale=1/i,e.aoPassMap=this.aoPassMapTexture}_updatePlugInReflection(e,t){const n=this._groundReflectionPass.intensityRenderTarget.texture,i=t.userData.isPlanFloor&&this._groundReflectionPass.parameters.enabled&&(null!==n||void 0!==n),r=this._groundReflectionPass.parameters.intensity;e.applyReflectionPassMap=i,e.reflectionPassMapIntensity=i?Math.pow(r,.25):0,e.reflectionPassMapScale=1/(this._groundReflectionPass.parameters.renderTargetDownScale*devicePixelRatio),e.reflectionPassMap=i?n:null}renderPasses(e,t){var n,i;e.setRenderTarget(null),this._bakedGroundContactShadowPass.renderPass(e),this._passUpdateStates.updateGBuffer&&this._gBufferRenderPass.renderPass(e),this._passUpdateStates.updateScreenSpaceShadow&&this._screenSpaceShadowMapPass.renderPass(e),this._passUpdateStates.updateShadowAndAoPass&&this._shadowAndAoPass.renderPass(e),this._updateMaterials(e,t),this._sceneRenderPass.renderPass(e),this._passUpdateStates.updateGroundReflection&&this._groundReflectionPass.renderPass(e),this._passUpdateStates.updateShadowAndAoPass&&!this._shadowAndAoPass.parameters.applyToMaterial&&this._shadowAndAoPass.renderToTarget(e),this._passUpdateStates.updateOutlinePass&&(null===(n=this._outlinePass)||void 0===n||n.renderPass(e)),this._passUpdateStates.updateDebugPass&&(null===(i=this._debugPass)||void 0===i||i.renderPass(e))}}const Qf="highest",$f="high",em="medium";class tm{get sceneRenderPass(){return this._renderPassManager.sceneRenderPass}get bakedGroundContactShadowPass(){return this._renderPassManager.bakedGroundContactShadowPass}get gBufferRenderPass(){return this._renderPassManager.gBufferRenderPass}get groundReflectionPass(){return this._renderPassManager.groundReflectionPass}get screenSpaceShadowMapPass(){return this._renderPassManager.screenSpaceShadowMapPass}get shadowAndAoPass(){return this._renderPassManager.shadowAndAoPass}get debugPass(){return this._renderPassManager.debugPass}get shadowAndAoGroundPlane(){return this._shadowAndAoGroundPlane}constructor(e,t,n){this.debugOutput="off",this.outputColorSpace="",this.toneMapping="",this.environmentLights=!1,this.enableObjectSelection=!0,this.groundLevel=0,this.uiInteractionMode=!1,this.width=0,this.height=0,this.boundingVolume=new Eo,this.boundingVolumeSet=!1,this.renderCacheManager=new uf,this.selectedObjects=[],this.groundGroup=new ua,this._shadingType=lf,this._qualityLevel=Qf,this._qualityMap=new Map,this._customShadingParameters=null,this.width=t,this.height=n,this.renderer=e,this.renderCacheManager.registerCache("inivisibleGround",new pf((e=>e===this.groundGroup))),this.renderCacheManager.registerCache("debug",new pf),this.renderCacheManager.registerCache("floorDepthWrite",new ff((e=>{var t;return null===(t=e.userData)||void 0===t?void 0:t.isFloor}))),this._shadowAndAoGroundPlane=new Op(null),this.groundGroup.rotateX(-Math.PI/2),this._renderPassManager=new Jf(this),this.outlineRenderer=new sf(this._renderPassManager,null,{}),this.parameters={gBufferRenderTargetParameters:this.gBufferRenderPass.parameters,bakedGroundContactShadowParameters:this.bakedGroundContactShadowPass.parameters,screenSpaceShadowMapParameters:this.screenSpaceShadowMapPass.parameters,shAndAoPassParameters:this.shadowAndAoPass.parameters,groundReflectionParameters:this.groundReflectionPass.parameters,outlineParameters:this.outlineRenderer.parameters,effectSuspendFrames:0,effectFadeInFrames:0,suspendGroundReflection:!1,shadowOnCameraChange:$p},this._addEventListeners(this.renderer)}_addEventListeners(e){e.domElement.addEventListener("webglcontextlost",(()=>{console.log("webglcontextlost")})),e.domElement.addEventListener("webglcontextrestored",(()=>{console.log("webglcontextrestored"),this._forceEnvironmentMapUpdate(this.renderer)}))}dispose(){var e;null===(e=this._copyMaterial)||void 0===e||e.dispose(),this._renderPassManager.dispose(),this.renderer.dispose()}setSize(e,t){this.width=e,this.height=t,this._renderPassManager.setSize(e,t),this.renderer.setSize(e,t)}getQualityLevel(){return this._qualityLevel}setShadingType(e){this._shadingType!==e&&(this._shadingType=e,this.applyCurrentParameters())}setQualityLevel(e){this._qualityLevel!==e&&(this._qualityMap.has(this._qualityLevel)&&(this._qualityLevel=e),this.applyCurrentParameters())}setQualityMap(e){this._qualityMap=e,this.applyCurrentParameters()}setCustomShadingParameters(e){this._customShadingParameters=e,this.applyCurrentParameters(),this.requestUpdateOfPasses()}setQualityMapAndShadingParameters(e,t){this._qualityMap=e,this._customShadingParameters=t,this.applyCurrentParameters(),this.requestUpdateOfPasses()}applyCurrentParameters(){const e=[];this._qualityMap.has(this._qualityLevel)&&e.push(this._qualityMap.get(this._qualityLevel));const t=(n=this._shadingType)&&n!==lf&&"bright"===n?cf:null;var n;t&&e.push(t);const i=this.uiInteractionMode?{groundReflectionParameters:{enabled:!1}}:null;if(i&&e.push(i),this._customShadingParameters&&e.push((e=>{const t={shAndAoPassParameters:{ao:{},shadow:{}},groundReflectionParameters:{},bakedGroundContactShadowParameters:{}};return((e,t)=>{void 0!==t.aoIntensity&&(e.shAndAoPassParameters.aoIntensity=hf(t.aoIntensity)),void 0!==t.aoExtent&&(e.shAndAoPassParameters.ao.radius=.3*hf(t.aoExtent),e.shAndAoPassParameters.ao.thickness=.1+.2*hf(t.aoExtent))})(t,e),((e,t)=>{t.shBakedOnGround?(e.bakedGroundContactShadowParameters.enabled=!0,e.shAndAoPassParameters.shadowIntensity=0,void 0!==t.shadowIntensity&&(e.bakedGroundContactShadowParameters.opacity=hf(t.shadowIntensity)),void 0!==t.shadowIntensity&&(e.bakedGroundContactShadowParameters.blurMax=.1*hf(t.shadowIntensity),e.bakedGroundContactShadowParameters.blurMin=.01*e.bakedGroundContactShadowParameters.blurMax)):(void 0!==t.shBakedOnGround&&(e.bakedGroundContactShadowParameters.enabled=!1),void 0!==t.shadowIntensity&&(e.shAndAoPassParameters.shadowIntensity=hf(t.shadowIntensity)),void 0!==t.shadowSoftening&&(e.shAndAoPassParameters.shadow.shadowRadius=.001+.2*hf(t.shadowSoftening)))})(t,e),((e,t)=>{void 0!==t.grReflectIntensity&&(e.groundReflectionParameters.enabled=t.grReflectIntensity>0,e.groundReflectionParameters.intensity=hf(t.grReflectIntensity)),void 0!==t.grReflectFadeOut&&(e.groundReflectionParameters.fadeOutDistance=4*(1-hf(t.grReflectFadeOut)))})(t,e),t})(this._customShadingParameters)),e.length>0){const t=((...e)=>{if(0===e.length)return null;if(1===e.length)return e[0];let t=e[0];for(let n=1;n0&&(this.environmentLights=!1),this.screenSpaceShadowMapPass.updateRectAreaLights(e,t),this.shadowAndAoPass.needsUpdate=!0}createShadowFromLightSources(e,t){this.environmentLights=!0,this.screenSpaceShadowMapPass.createShadowFromLightSources(e,t),this.shadowAndAoPass.needsUpdate=!0}selectObjects(e){this.selectedObjects=e}updateBounds(e,t){this.clearCache();const n=e.clone();n.min.y>this.groundLevel&&(n.min.y=this.groundLevel),this.boundingVolumeSet=!0,this.gBufferRenderPass.groundDepthWrite=this.shadowAndAoPass.parameters.aoOnGround,this.boundingVolume.updateFromBox(n);const i=this.boundingVolume.size,r=(i.x+i.y+i.z)/3,a=Math.min(i.x,i.y,i.z),s=Math.max(i.x,i.y,i.z),o=a<.5?a/.5:i.z>5?i.z/5:1;this.bakedGroundContactShadowPass.setScale(t?r:o,r),this.groundReflectionPass.updateBounds(this.groundLevel,Math.min(1,s)),this.screenSpaceShadowMapPass.updateBounds(this.boundingVolume,r),this.shadowAndAoPass.updateBounds(this.boundingVolume,t?r:Math.min(1,2*s))}updateNearAndFarPlaneOfPerspectiveCamera(e,t){const n=this.boundingVolume.getNearAndFarForPerspectiveCamera(e.position,3);e.near=Math.max(1e-5,.9*n[0]),e.far=Math.max(null!=t?t:e.near,n[1]),e.updateProjectionMatrix()}_forceEnvironmentMapUpdate(e){const t=e.userData;if(null==t?void 0:t.environmentTexture){const e=t.environmentTexture;t.environmentTexture=void 0,e.dispose()}}_updateEnvironment(e,t){var n,i;if(!(null===(n=t.userData)||void 0===n?void 0:n.environmentDefinition))return;e.userData||(e.userData={});const r=e.userData;if(r&&((null===(i=t.userData)||void 0===i?void 0:i.environmentDefinition.needsUpdate)||!r.environmentTexture||r.environmentDefinition!==t.userData.environmentDefinition)){const n=t.userData.environmentDefinition;if(r.environmentDefinition=n,r.environmentTexture=n.createNewEnvironment(e),t.userData.shadowFromEnvironment){const e=n.maxNoOfLightSources;void 0!==e&&(this.screenSpaceShadowMapPass.parameters.maximumNumberOfLightSources=e),this.createShadowFromLightSources(t,n.lightSources)}}t.environment=null==r?void 0:r.environmentTexture,t.userData.showEnvironmentBackground?t.background=t.environment:t.background===t.environment&&(t.background=null)}render(e,t){e.add(this.groundGroup),this._updateEnvironment(this.renderer,e),this.outlineRenderer.updateOutline(e,t,this.enableObjectSelection?this.selectedObjects:[]),this._renderPassManager.updatePasses(this.renderer,e,t),this._renderPassManager.renderPasses(this.renderer,e),e.remove(this.groundGroup)}}class nm extends Zn{constructor(e=document.createElement("div")){super(),this.isCSS2DObject=!0,this.element=e,this.element.style.position="absolute",this.element.style.userSelect="none",this.element.setAttribute("draggable",!1),this.center=new _t(.5,.5),this.addEventListener("removed",(function(){this.traverse((function(e){e.element instanceof e.element.ownerDocument.defaultView.Element&&null!==e.element.parentNode&&e.element.remove()}))}))}copy(e,t){return super.copy(e,t),this.element=e.element.cloneNode(!0),this.center=e.center,this}}const im=new jt,rm=new wn,am=new wn,sm=new jt,om=new jt;class lm extends ua{constructor(e,t,n){super(),this.arrowNeedsUpdate=!0,this.labelTextClientWidth=0,this.startPosition=e.clone(),this.endPosition=t.clone(),this.parameters=Object.assign({shaftPixelWidth:10,shaftPixelOffset:3,arrowPixelWidth:30,arrowPixelHeight:50,color:0,labelClass:"label",deviceRatio:1,autoLabelTextUpdate:!0,autoLabelRotationUpdate:!0},n),this.startShaftMaterial=new cm,this.startShaft=new Yi(new Da(2,1).translate(0,.5,0),this.startShaftMaterial),this.startShaft.onBeforeRender=(e,t,n,i,r,a)=>{this.updateShaftMaterial(!0,e,n,r)},this.add(this.startShaft),this.endShaftMaterial=new cm,this.endShaft=new Yi(new Da(2,1).translate(0,.5,0),this.endShaftMaterial),this.endShaft.onBeforeRender=(e,t,n,i,r,a)=>{this.updateShaftMaterial(!1,e,n,r)},this.add(this.endShaft),this.startArrowMaterial=new hm,this.startArrow=new Yi(new Da(2,1).translate(0,.5,0),this.startArrowMaterial),this.startArrow.onBeforeRender=(e,t,n,i,r,a)=>{this.updateArrowMaterial(!0,e,n,r)},this.add(this.startArrow),this.endArrowMaterial=new hm,this.endArrow=new Yi(new Da(2,1).translate(0,.5,0),this.endArrowMaterial),this.endArrow.onBeforeRender=(e,t,n,i,r,a)=>{this.updateArrowMaterial(!1,e,n,r)},this.add(this.endArrow),this.arrowLabel=this.createArrowLabel("0.000",this.parameters),this.add(this.arrowLabel),this.updateArrow()}createArrowLabel(e,t){var n,i,r,a,s,o;const l=document.createElement("div"),c=document.createElement("div");l.appendChild(c),c.className=null!==(n=t.labelClass)&&void 0!==n?n:"",c.textContent=e,c.style.backgroundColor="transparent",c.style.color=new fi(null!==(i=t.color)&&void 0!==i?i:0).getStyle();const h=new nm(l);return h.position.set(0,0,0),h.center.set(null!==(a=null===(r=t.origin)||void 0===r?void 0:r.x)&&void 0!==a?a:.5,null!==(o=null===(s=t.origin)||void 0===s?void 0:s.y)&&void 0!==o?o:.5),h.layers.set(0),h}setPosition(e,t,n=0,i=0){const r=t.clone().sub(e).normalize();this.startPosition.copy(e.clone().add(r.clone().multiplyScalar(n))),this.endPosition.copy(t.clone().add(r.clone().multiplyScalar(-i))),this.arrowNeedsUpdate=!0}setAngle(e){const t=`${e.toFixed(0)}deg`;this.arrowLabel.element.children[0].style.rotate=t}setLabel(e){const t=this.arrowLabel.element.children[0];t.textContent=e,this.labelTextClientWidth=t.clientWidth*this.parameters.deviceRatio}updateArrow(){const e=this.startPosition.clone().applyMatrix4(this.matrixWorld),t=this.endPosition.clone().applyMatrix4(this.matrixWorld),n=t.clone().sub(e),i=n.length();n.multiplyScalar(1/i);const r=new jt(0,1,0).cross(n),a=Math.acos(new jt(0,1,0).dot(n));this.setModelMatrix(this.startShaft,e,i,r,a),this.setModelMatrix(this.endShaft,t,i,r,a),this.setModelMatrix(this.startArrow,e,1,r,a),this.setModelMatrix(this.endArrow,t,1,r,a+Math.PI)}updateArrowLabel(e,t){var n,i;const r=this.startPosition.distanceTo(this.endPosition).toFixed(3),a=this.startPosition.clone().applyMatrix4(this.matrixWorld).applyMatrix4(t.matrixWorldInverse).applyMatrix4(t.projectionMatrix),s=this.endPosition.clone().applyMatrix4(this.matrixWorld).applyMatrix4(t.matrixWorldInverse).applyMatrix4(t.projectionMatrix),o=s.clone().add(a).multiplyScalar(.5).applyMatrix4(t.projectionMatrixInverse).applyMatrix4(t.matrixWorld);this.arrowLabel.position.copy(o);const l=e.getRenderTarget(),c=null!==(n=null==l?void 0:l.width)&&void 0!==n?n:e.domElement.clientWidth,h=null!==(i=null==l?void 0:l.height)&&void 0!==i?i:e.domElement.clientHeight,d=s.clone().sub(a),u=180*Math.atan2(-d.y,d.x*c/h)/Math.PI;this.parameters.autoLabelRotationUpdate&&this.setAngle(u),this.parameters.autoLabelTextUpdate&&this.setLabel(r)}setModelMatrix(e,t,n,i,r){e.scale.set(1,1,1),e.rotation.set(0,0,0),e.position.set(0,0,0),e.applyMatrix4((new wn).makeScale(1,.5*n,1)),e.applyMatrix4((new wn).makeRotationAxis(i,r)),e.applyMatrix4((new wn).makeTranslation(t.x,t.y,t.z))}updateShaftMaterial(e,t,n,i){var r,a;if(this.updateMatrixWorld(),i instanceof cm){const s=t.getRenderTarget(),o=new _t;t.getSize(o);const l=null!==(r=null==s?void 0:s.width)&&void 0!==r?r:o.x,c=null!==(a=null==s?void 0:s.height)&&void 0!==a?a:o.y,h=this.startPosition.clone().applyMatrix4(this.matrixWorld),d=this.endPosition.clone().applyMatrix4(this.matrixWorld);i.update({width:l,height:c,camera:n,start:e?h:d,end:e?d:h,shaftPixelWidth:this.parameters.shaftPixelWidth,shaftPixelOffset:this.parameters.shaftPixelOffset,arrowPixelSize:new _t(this.parameters.arrowPixelWidth,this.parameters.arrowPixelHeight),labelPixelWidth:this.labelTextClientWidth,color:this.parameters.color})}this.arrowNeedsUpdate&&(this.arrowNeedsUpdate=!1,this.updateArrowLabel(t,n),this.updateArrow())}updateArrowMaterial(e,t,n,i){var r,a;if(this.updateMatrixWorld(),i instanceof hm){const s=t.getRenderTarget(),o=null!==(r=null==s?void 0:s.width)&&void 0!==r?r:t.domElement.clientWidth,l=null!==(a=null==s?void 0:s.height)&&void 0!==a?a:t.domElement.clientHeight,c=this.startPosition.clone().applyMatrix4(this.matrixWorld),h=this.endPosition.clone().applyMatrix4(this.matrixWorld);i.update({width:o,height:l,camera:n,start:e?c:h,end:e?h:c,arrowPixelSize:new _t(this.parameters.arrowPixelWidth,this.parameters.arrowPixelHeight),color:this.parameters.color})}this.arrowNeedsUpdate&&(this.arrowNeedsUpdate=!1,this.updateArrowLabel(t,n),this.updateArrow())}}class cm extends er{constructor(e){super({defines:Object.assign({},cm.shader.defines),uniforms:$i.clone(cm.shader.uniforms),vertexShader:cm.shader.vertexShader,fragmentShader:cm.shader.fragmentShader,side:2,blending:0}),this.update(e)}update(e){var t,n;if((null==e?void 0:e.width)||(null==e?void 0:e.height)){const i=null!==(t=null==e?void 0:e.width)&&void 0!==t?t:this.uniforms.resolution.value.x,r=null!==(n=null==e?void 0:e.height)&&void 0!==n?n:this.uniforms.resolution.value.y;this.uniforms.resolution.value.set(i,r)}return void 0!==(null==e?void 0:e.start)&&this.uniforms.start.value.copy(e.start),void 0!==(null==e?void 0:e.end)&&this.uniforms.end.value.copy(e.end),void 0!==(null==e?void 0:e.shaftPixelWidth)&&(this.uniforms.shaftPixelWidth.value=e.shaftPixelWidth),void 0!==(null==e?void 0:e.shaftPixelOffset)&&(this.uniforms.shaftPixelOffset.value=e.shaftPixelOffset),void 0!==(null==e?void 0:e.arrowPixelSize)&&this.uniforms.arrowPixelSize.value.copy(e.arrowPixelSize),void 0!==(null==e?void 0:e.labelPixelWidth)&&(this.uniforms.labelPixelWidth.value=e.labelPixelWidth),void 0!==(null==e?void 0:e.color)&&(this.uniforms.color.value=new fi(e.color)),this}}cm.shader={uniforms:{resolution:{value:new _t},start:{value:new jt},end:{value:new jt},shaftPixelWidth:{value:10},shaftPixelOffset:{value:10},arrowPixelSize:{value:new _t},labelPixelWidth:{value:0},color:{value:new fi}},defines:{RADIUS_RATIO:.5},vertexShader:"varying vec2 centerPixel;\nvarying vec2 posPixel;\nvarying vec2 arrowDir;\n\nuniform vec2 resolution;\nuniform vec3 start;\nuniform vec3 end;\nuniform float shaftPixelWidth;\nuniform float shaftPixelOffset;\nuniform vec2 arrowPixelSize;\nuniform float labelPixelWidth;\n\nvec2 pixelToNdcScale(vec4 hVec) {\n return vec2(2.0 * hVec.w) / resolution.xy;\n}\n\nvoid main() {\n vec4 viewPos = modelViewMatrix * vec4(0.0, 0.0, position.z, 1.0);\n gl_Position = projectionMatrix * viewPos;\n vec4 clipStart = projectionMatrix * viewMatrix * vec4(start, 1.0);\n vec4 clipEnd = projectionMatrix * viewMatrix * vec4(end, 1.0);\n vec2 clipDir = normalize((clipEnd.xy / clipEnd.w - clipStart.xy / clipStart.w) * resolution.xy);\n vec4 shaftEnd = vec4(clipEnd.xy / clipEnd.w * clipStart.w, clipStart.zw);\n shaftEnd.xy -= clipDir * (labelPixelWidth * 0.5 + shaftPixelOffset) * pixelToNdcScale(gl_Position);\n gl_Position.xy = mix(clipStart.xy / clipStart.w, shaftEnd.xy / shaftEnd.w, position.y * 0.5) * gl_Position.w;\n gl_Position.xy += vec2(-clipDir.y, clipDir.x) * position.x * shaftPixelWidth * 0.5 * pixelToNdcScale(gl_Position);\n\n vec4 clipCenter = clipStart;\n float d = arrowPixelSize.y * (1.0 + RADIUS_RATIO) - length(arrowPixelSize * vec2(0.5, RADIUS_RATIO));\n clipCenter.xy += clipDir * (d + shaftPixelOffset + shaftPixelWidth * 0.5) * pixelToNdcScale(gl_Position);\n centerPixel = (clipCenter.xy / gl_Position.w * 0.5 + 0.5) * resolution;\n posPixel = (gl_Position.xy / gl_Position.w * 0.5 + 0.5) * resolution;\n arrowDir = clipDir;\n}",fragmentShader:"varying vec2 centerPixel;\nvarying vec2 posPixel;\nvarying vec2 arrowDir;\n\nuniform float shaftPixelWidth;\nuniform vec3 color;\n\nvoid main() {\n if (dot(arrowDir, posPixel - centerPixel) < 0.0 && length(posPixel - centerPixel) > shaftPixelWidth * 0.5)\n discard;\n gl_FragColor = vec4(color, 1.0);\n}"};class hm extends er{constructor(e){super({defines:Object.assign({},hm.shader.defines),uniforms:$i.clone(hm.shader.uniforms),vertexShader:hm.shader.vertexShader,fragmentShader:hm.shader.fragmentShader,side:2,blending:0}),this.update(e)}update(e){var t,n;if((null==e?void 0:e.width)||(null==e?void 0:e.height)){const i=null!==(t=null==e?void 0:e.width)&&void 0!==t?t:this.uniforms.resolution.value.x,r=null!==(n=null==e?void 0:e.height)&&void 0!==n?n:this.uniforms.resolution.value.y;this.uniforms.resolution.value.set(i,r)}return void 0!==(null==e?void 0:e.start)&&this.uniforms.start.value.copy(e.start),void 0!==(null==e?void 0:e.end)&&this.uniforms.end.value.copy(e.end),void 0!==(null==e?void 0:e.arrowPixelSize)&&this.uniforms.arrowPixelSize.value.copy(e.arrowPixelSize),void 0!==(null==e?void 0:e.color)&&(this.uniforms.color.value=new fi(e.color)),this}}hm.shader={uniforms:{resolution:{value:new _t},start:{value:new jt},end:{value:new jt},arrowPixelSize:{value:new _t},color:{value:new fi}},defines:{RADIUS_RATIO:.5},vertexShader:"varying vec2 arrowUv;\nvarying vec2 centerPixel;\nvarying vec2 posPixel;\n\nuniform vec2 resolution;\nuniform vec3 start;\nuniform vec3 end;\nuniform vec2 arrowPixelSize;\n\nvec2 pixelToNdcScale(vec4 hVec) {\n return vec2(2.0 * hVec.w) / resolution.xy;\n}\n\nvoid main() {\n vec4 viewPos = modelViewMatrix * vec4(0.0, 0.0, position.z, 1.0);\n gl_Position = projectionMatrix * viewPos;\n vec4 clipStart = projectionMatrix * viewMatrix * vec4(start, 1.0);\n vec4 clipEnd = projectionMatrix * viewMatrix * vec4(end, 1.0);\n vec2 clipDir = normalize((clipEnd.xy / clipEnd.w - clipStart.xy / clipStart.w) * resolution.xy);\n gl_Position.xy += clipDir * position.y * arrowPixelSize.y * pixelToNdcScale(gl_Position);\n gl_Position.xy += vec2(-clipDir.y, clipDir.x) * position.x * arrowPixelSize.x * 0.5 * pixelToNdcScale(gl_Position);\n\n arrowUv = position.xy;\n\n vec4 clipCenter = clipStart;\n clipCenter.xy += clipDir * arrowPixelSize.y * (1.0 + RADIUS_RATIO) * pixelToNdcScale(gl_Position);\n centerPixel = (clipCenter.xy / gl_Position.w * 0.5 + 0.5) * resolution;\n posPixel = (gl_Position.xy / gl_Position.w * 0.5 + 0.5) * resolution;\n}",fragmentShader:"varying vec2 arrowUv;\nvarying vec2 centerPixel;\nvarying vec2 posPixel;\n\nuniform vec2 resolution;\nuniform vec2 arrowPixelSize;\nuniform vec3 color;\n\nvoid main() {\n if (abs(arrowUv.x) > abs(arrowUv.y))\n discard;\n if (length(posPixel - centerPixel) < length(arrowPixelSize * vec2(0.5, RADIUS_RATIO)))\n discard;\n gl_FragColor = vec4(color, 1.0);\n}"};const dm="all_around",um="front";class pm extends Ih{constructor(e={}){super(),this._parameters={},this._parameters=e}generateScene(e,t){const n=new fm(Object.assign(Object.assign({},this._parameters),{lightIntensity:e*(this._parameters.lightIntensity||1),topLightIntensity:e*(this._parameters.topLightIntensity||1),sidLightIntensity:e*(this._parameters.sidLightIntensity||1)}));return n.rotation.y=t,n}}class fm extends hr{constructor(e={}){var t;super(),this._type=null!==(t=null==e?void 0:e.type)&&void 0!==t?t:dm,this._topLightIntensity=(null==e?void 0:e.topLightIntensity)||(null==e?void 0:e.lightIntensity)||1,this._sideLightIntensity=(null==e?void 0:e.sidLightIntensity)||(null==e?void 0:e.lightIntensity)||1,this._sideReflectorIntensity=(null==e?void 0:e.sidLightIntensity)||(null==e?void 0:e.lightIntensity)||1;const n=this._type===um?.3:0;this._ambientLightIntensity=(null==e?void 0:e.ambientLightIntensity)||n,this._colorVariation=(null==e?void 0:e.colorVariation)||.5,this._lightGeometry=new Zi,this._lightGeometry.deleteAttribute("uv"),this._reflectorLightGeometry=new Pa(.7,.4,2,32),this._reflectorLightGeometry.deleteAttribute("uv"),this.generateScene(this)}generateScene(e){switch(this._type){default:case dm:this._createAllAroundSceneLight(e);break;case um:this._createFrontSceneLight(e)}}dispose(){const e=new Set;this.traverse((t=>{t.isMesh&&(e.add(t.geometry),e.add(t.material))}));for(const t of e)t.dispose()}_createAllAroundSceneLight(e){const t=this._ambientLightIntensity;this.background=new fi(t,t,t),this._createTopLight(e,6,1);for(let t=0;t<6;t++){const n=t*Math.PI*2/6,i=Math.sin(n),r=Math.cos(n);t%2==0?this._createReflector(e,new _t(i,r),3,1,.8,.2):this._createSideLight(e,new _t(i,r),(t-1)/2,15,1.1,.33,1)}}_createFrontSceneLight(e){const t=this._ambientLightIntensity;this.background=new fi(t,t,t),this._createTopLight(e,6,.7);for(let t=0;t<6;t++){const n=t*Math.PI*2/6,i=Math.sin(n),r=Math.cos(n);if(0===t){this._createReflector(e,new _t(i,r),1.1,.6,.8,-.4);for(let n=0;n<2;n++){const i=(t-.3+.6*n)*Math.PI*2/6,r=Math.sin(i),a=Math.cos(i);this._createSideLight(e,new _t(r,a),(t-1)/2,50,1.2,.7,.8)}}else this._createReflector(e,new _t(i,r),1.1,.7,1.4,0)}}_createAreaLightMaterial(e,t,n){const i=new _i;return i.color.set(e,null!=t?t:e,null!=n?n:e),i}_createTopLight(e,t,n){const i=new Yi(this._lightGeometry,this._createAreaLightMaterial(t*this._topLightIntensity));i.position.set(0,20,0),i.scale.set(5*n,.1,5*n),e.add(i)}_createSideLight(e,t,n,i,r,a,s){for(let o=0;o<3;o++){const l=i*this._sideLightIntensity,c=new Yi(this._lightGeometry,this._createAreaLightMaterial((o+n)%3==0?l:l*(1-this._colorVariation),(o+n)%3==1?l:l*(1-this._colorVariation),(o+n)%3==2?l:l*(1-this._colorVariation))),h=(1===o?-t.y:2===o?t.y:0)/Math.sqrt(2),d=0===o?0:1,u=(1===o?t.x:2===o?-t.x:0)/Math.sqrt(2);c.position.set(t.x*s*15+1.1*h*r,15*a+1.1*d*r,t.y*s*15+1.1*u*r),c.rotation.set(0,Math.atan2(t.x,t.y),0),c.scale.setScalar(r),e.add(c)}}_createReflector(e,t,n,i,r,a){const s=new Yi(this._reflectorLightGeometry,this._createAreaLightMaterial(n*this._sideReflectorIntensity));s.position.set(15*t.x,10*a,15*t.y),s.scale.set(10*i,10*r,10*i),e.add(s)}}const mm={effectSuspendFrames:0,effectFadeInFrames:0,suspendGroundReflection:!1,shadowOnCameraChange:nf},gm={effectSuspendFrames:5,effectFadeInFrames:5,suspendGroundReflection:!1,shadowOnCameraChange:tf},vm={effectSuspendFrames:5,effectFadeInFrames:5,suspendGroundReflection:!0,shadowOnCameraChange:ef},_m={enabled:!0,aoOnGround:!0,shadowOnGround:!0,aoIntensity:1,shadowIntensity:1,ao:{algorithm:4,samples:16,radius:.5,distanceExponent:2,thickness:1,distanceFallOff:1,scale:1,bias:.01,screenSpaceRadius:!1}},xm={enableGroundBoundary:!1,directionalDependency:1,directionalExponent:1,groundBoundary:1,fadeOutDistance:.2,fadeOutBlur:5},ym=new Map([[Qf,Object.assign(Object.assign({},mm),{shAndAoPassParameters:_m,screenSpaceShadowMapParameters:xm,groundReflectionParameters:{enabled:!0},bakedGroundContactShadowParameters:{enabled:!1}})],[$f,Object.assign(Object.assign({},gm),{shAndAoPassParameters:_m,screenSpaceShadowMapParameters:xm,groundReflectionParameters:{enabled:!0},bakedGroundContactShadowParameters:{enabled:!1}})],[em,Object.assign(Object.assign({},vm),{shAndAoPassParameters:_m,screenSpaceShadowMapParameters:xm,groundReflectionParameters:{enabled:!1},bakedGroundContactShadowParameters:{enabled:!1}})],["low",{shAndAoPassParameters:{enabled:!1,aoOnGround:!1,shadowOnGround:!1},groundReflectionParameters:{enabled:!1},bakedGroundContactShadowParameters:{enabled:!0}}]]);class Sm extends Yi{constructor(e,t,n,i=128){if(t<=0||n<=0||i<=0)throw new Error("GroundedSkybox height, radius, and resolution must be positive.");const r=new Ia(n,2*i,i);r.scale(1,1,-1);const a=r.getAttribute("position"),s=new jt;for(let e=0;e{const t=e.materialId;return{materialId:e.materialId,name:t}})),a=Object.assign({},...r.map((e=>({[e.name]:e.materialId}))));this.materialFolder.add(this,"materialId",a).onChange((e=>this.updateMaterialPropertiesUI(e))),this.updateMaterialPropertiesUI(this.materialId)}updateMaterialPropertiesUI(e){var t,n,i,r,a,s,o,l,c,h;if(this.materialId=e,!this.materialFolder)return;this.materialProperties&&(this.materialFolder.removeFolder(this.materialProperties),this.materialProperties=void 0);const d=this.materials.find((t=>t.materialId===e));if(!d)return;const u=d.material;if(!u)return;const p={color:null!==(n=null===(t=u.color)||void 0===t?void 0:t.getHex())&&void 0!==n?n:16777215,specularColor:null!==(r=null===(i=u.color)||void 0===i?void 0:i.getHex())&&void 0!==r?r:16777215,emissive:null!==(s=null===(a=u.emissive)||void 0===a?void 0:a.getHex())&&void 0!==s?s:16777215,sheenColor:null!==(l=null===(o=u.emissive)||void 0===o?void 0:o.getHex())&&void 0!==l?l:16777215,attenuationColor:null!==(h=null===(c=u.emissive)||void 0===c?void 0:c.getHex())&&void 0!==h?h:16777215};let f="properties";d.material.userData&&(d.material.userData.diffuseMap&&(f+=d.material.userData.diffuseMapHasAlpha?" RGBA":" RGB"),d.material.userData.normalMap&&(f+=" XYZ"),d.material.userData.ormMap&&(f+=" ORM")),this.materialProperties=this.materialFolder.addFolder(f),this.materialProperties.addColor(p,"color").onChange(Mm.handleColorChange(u.color,!0)),this.materialProperties.add(u,"opacity",0,1).onChange((e=>{const t=e<1;t!==u.transparent&&(u.transparent=t,u.needsUpdate=!0)}));try{this.materialProperties.add(u,"metalness",0,1),this.materialProperties.add(u,"roughness",0,1),this.materialProperties.add(u,"transmission",0,1),this.materialProperties.add(u,"ior",1,2.333),this.materialProperties.add(u,"specularIntensity",0,1),this.materialProperties.addColor(p,"specularColor").onChange(Mm.handleColorChange(u.specularColor,!0)),this.materialProperties.add(u,"reflectivity",0,1),this.materialProperties.add(u,"clearcoat",0,1),this.materialProperties.add(u,"clearcoatRoughness",0,1),this.materialProperties.add(u,"sheen",0,1),this.materialProperties.add(u,"sheenRoughness",0,1),this.materialProperties.addColor(p,"sheenColor").onChange(Mm.handleColorChange(u.sheenColor,!0)),this.materialProperties.add(u,"emissiveIntensity",0,1),this.materialProperties.addColor(p,"emissive").onChange(Mm.handleColorChange(u.emissive,!0)),this.materialProperties.add(u,"attenuationDistance",0,50),this.materialProperties.addColor(p,"attenuationColor").onChange(Mm.handleColorChange(u.attenuationColor,!0)),this.materialProperties.add(u,"thickness",0,50)}catch(e){console.log(e)}}static handleColorChange(e,t=!1){return n=>{"string"==typeof n&&(n=n.replace("#","0x")),e.setHex(n),!0===t&&e.convertSRGBToLinear()}}}var Tm=function(){var e=0,t=document.createElement("div");function n(e){return t.appendChild(e.dom),e}function i(n){for(var i=0;i=a+1e3&&(o.update(1e3*s/(e-a),100),a=e,s=0,c)){var t=performance.memory;c.update(t.usedJSHeapSize/1048576,t.jsHeapSizeLimit/1048576)}return e},update:function(){r=this.end()},domElement:t,setMode:i}};Tm.Panel=function(e,t,n){var i=1/0,r=0,a=Math.round,s=a(window.devicePixelRatio||1),o=80*s,l=48*s,c=3*s,h=2*s,d=3*s,u=15*s,p=74*s,f=30*s,m=document.createElement("canvas");m.width=o,m.height=l,m.style.cssText="width:80px;height:48px";var g=m.getContext("2d");return g.font="bold "+9*s+"px Helvetica,Arial,sans-serif",g.textBaseline="top",g.fillStyle=n,g.fillRect(0,0,o,l),g.fillStyle=t,g.fillText(e,c,h),g.fillRect(d,u,p,f),g.fillStyle=n,g.globalAlpha=.9,g.fillRect(d,u,p,f),{dom:m,update:function(l,v){i=Math.min(i,l),r=Math.max(r,l),g.fillStyle=n,g.globalAlpha=1,g.fillRect(0,0,o,u),g.fillStyle=t,g.fillText(a(l)+" "+e+" ("+a(i)+"-"+a(r)+")",c,h),g.drawImage(m,d+s,u,p-s,f,d,u,p-s,f),g.fillRect(d+p-s,u,s,f),g.fillStyle=n,g.globalAlpha=.9,g.fillRect(d+p-s,u,s,a((1-l/v)*f))}}};const Em=Tm;function Am(e,t){var n=e.__state.conversionName.toString(),i=Math.round(e.r),r=Math.round(e.g),a=Math.round(e.b),s=e.a,o=Math.round(e.h),l=e.s.toFixed(1),c=e.v.toFixed(1);if(t||"THREE_CHAR_HEX"===n||"SIX_CHAR_HEX"===n){for(var h=e.hex.toString(16);h.length<6;)h="0"+h;return"#"+h}return"CSS_RGB"===n?"rgb("+i+","+r+","+a+")":"CSS_RGBA"===n?"rgba("+i+","+r+","+a+","+s+")":"HEX"===n?"0x"+e.hex.toString(16):"RGB_ARRAY"===n?"["+i+","+r+","+a+"]":"RGBA_ARRAY"===n?"["+i+","+r+","+a+","+s+"]":"RGB_OBJ"===n?"{r:"+i+",g:"+r+",b:"+a+"}":"RGBA_OBJ"===n?"{r:"+i+",g:"+r+",b:"+a+",a:"+s+"}":"HSV_OBJ"===n?"{h:"+o+",s:"+l+",v:"+c+"}":"HSVA_OBJ"===n?"{h:"+o+",s:"+l+",v:"+c+",a:"+s+"}":"unknown format"}var Pm=Array.prototype.forEach,Rm=Array.prototype.slice,Cm={BREAK:{},extend:function(e){return this.each(Rm.call(arguments,1),(function(t){(this.isObject(t)?Object.keys(t):[]).forEach(function(n){this.isUndefined(t[n])||(e[n]=t[n])}.bind(this))}),this),e},defaults:function(e){return this.each(Rm.call(arguments,1),(function(t){(this.isObject(t)?Object.keys(t):[]).forEach(function(n){this.isUndefined(e[n])&&(e[n]=t[n])}.bind(this))}),this),e},compose:function(){var e=Rm.call(arguments);return function(){for(var t=Rm.call(arguments),n=e.length-1;n>=0;n--)t=[e[n].apply(this,t)];return t[0]}},each:function(e,t,n){if(e)if(Pm&&e.forEach&&e.forEach===Pm)e.forEach(t,n);else if(e.length===e.length+0){var i,r=void 0;for(r=0,i=e.length;r1?Cm.toArray(arguments):arguments[0];return Cm.each(Dm,(function(t){if(t.litmus(e))return Cm.each(t.conversions,(function(t,n){if(Lm=t.read(e),!1===Im&&!1!==Lm)return Im=Lm,Lm.conversionName=n,Lm.conversion=t,Cm.BREAK})),Cm.BREAK})),Im},Om=void 0,Nm={hsv_to_rgb:function(e,t,n){var i=Math.floor(e/60)%6,r=e/60-Math.floor(e/60),a=n*(1-t),s=n*(1-r*t),o=n*(1-(1-r)*t),l=[[n,o,a],[s,n,a],[a,n,o],[a,s,n],[o,a,n],[n,a,s]][i];return{r:255*l[0],g:255*l[1],b:255*l[2]}},rgb_to_hsv:function(e,t,n){var i=Math.min(e,t,n),r=Math.max(e,t,n),a=r-i,s=void 0;return 0===r?{h:NaN,s:0,v:0}:(s=e===r?(t-n)/a:t===r?2+(n-e)/a:4+(e-t)/a,(s/=6)<0&&(s+=1),{h:360*s,s:a/r,v:r/255})},rgb_to_hex:function(e,t,n){var i=this.hex_with_component(0,2,e);return i=this.hex_with_component(i,1,t),this.hex_with_component(i,0,n)},component_from_hex:function(e,t){return e>>8*t&255},hex_with_component:function(e,t,n){return n<<(Om=8*t)|e&~(255<-1?t.length-t.indexOf(".")-1:0}var tg=function(e){function t(e,n,i){Bm(this,t);var r=Vm(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,e,n)),a=i||{};return r.__min=a.min,r.__max=a.max,r.__step=a.step,Cm.isUndefined(r.__step)?0===r.initialValue?r.__impliedStep=1:r.__impliedStep=Math.pow(10,Math.floor(Math.log(Math.abs(r.initialValue))/Math.LN10))/10:r.__impliedStep=r.__step,r.__precision=eg(r.__impliedStep),r}return Hm(t,e),zm(t,[{key:"setValue",value:function(e){var n=e;return void 0!==this.__min&&nthis.__max&&(n=this.__max),void 0!==this.__step&&n%this.__step!=0&&(n=Math.round(n/this.__step)*this.__step),km(t.prototype.__proto__||Object.getPrototypeOf(t.prototype),"setValue",this).call(this,n)}},{key:"min",value:function(e){return this.__min=e,this}},{key:"max",value:function(e){return this.__max=e,this}},{key:"step",value:function(e){return this.__step=e,this.__impliedStep=e,this.__precision=eg(e),this}}]),t}(Xm),ng=function(e){function t(e,n,i){Bm(this,t);var r=Vm(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,e,n,i));r.__truncationSuspended=!1;var a=r,s=void 0;function o(){a.__onFinishChange&&a.__onFinishChange.call(a,a.getValue())}function l(e){var t=s-e.clientY;a.setValue(a.getValue()+t*a.__impliedStep),s=e.clientY}function c(){Km.unbind(window,"mousemove",l),Km.unbind(window,"mouseup",c),o()}return r.__input=document.createElement("input"),r.__input.setAttribute("type","text"),Km.bind(r.__input,"change",(function(){var e=parseFloat(a.__input.value);Cm.isNaN(e)||a.setValue(e)})),Km.bind(r.__input,"blur",(function(){o()})),Km.bind(r.__input,"mousedown",(function(e){Km.bind(window,"mousemove",l),Km.bind(window,"mouseup",c),s=e.clientY})),Km.bind(r.__input,"keydown",(function(e){13===e.keyCode&&(a.__truncationSuspended=!0,this.blur(),a.__truncationSuspended=!1,o())})),r.updateDisplay(),r.domElement.appendChild(r.__input),r}return Hm(t,e),zm(t,[{key:"updateDisplay",value:function(){var e,n,i;return this.__input.value=this.__truncationSuspended?this.getValue():(e=this.getValue(),n=this.__precision,i=Math.pow(10,n),Math.round(e*i)/i),km(t.prototype.__proto__||Object.getPrototypeOf(t.prototype),"updateDisplay",this).call(this)}}]),t}(tg);function ig(e,t,n,i,r){return i+(e-t)/(n-t)*(r-i)}var rg=function(e){function t(e,n,i,r,a){Bm(this,t);var s=Vm(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,e,n,{min:i,max:r,step:a})),o=s;function l(e){e.preventDefault();var t=o.__background.getBoundingClientRect();return o.setValue(ig(e.clientX,t.left,t.right,o.__min,o.__max)),!1}function c(){Km.unbind(window,"mousemove",l),Km.unbind(window,"mouseup",c),o.__onFinishChange&&o.__onFinishChange.call(o,o.getValue())}function h(e){var t=e.touches[0].clientX,n=o.__background.getBoundingClientRect();o.setValue(ig(t,n.left,n.right,o.__min,o.__max))}function d(){Km.unbind(window,"touchmove",h),Km.unbind(window,"touchend",d),o.__onFinishChange&&o.__onFinishChange.call(o,o.getValue())}return s.__background=document.createElement("div"),s.__foreground=document.createElement("div"),Km.bind(s.__background,"mousedown",(function(e){document.activeElement.blur(),Km.bind(window,"mousemove",l),Km.bind(window,"mouseup",c),l(e)})),Km.bind(s.__background,"touchstart",(function(e){1===e.touches.length&&(Km.bind(window,"touchmove",h),Km.bind(window,"touchend",d),h(e))})),Km.addClass(s.__background,"slider"),Km.addClass(s.__foreground,"slider-fg"),s.updateDisplay(),s.__background.appendChild(s.__foreground),s.domElement.appendChild(s.__background),s}return Hm(t,e),zm(t,[{key:"updateDisplay",value:function(){var e=(this.getValue()-this.__min)/(this.__max-this.__min);return this.__foreground.style.width=100*e+"%",km(t.prototype.__proto__||Object.getPrototypeOf(t.prototype),"updateDisplay",this).call(this)}}]),t}(tg),ag=function(e){function t(e,n,i){Bm(this,t);var r=Vm(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,e,n)),a=r;return r.__button=document.createElement("div"),r.__button.innerHTML=void 0===i?"Fire":i,Km.bind(r.__button,"click",(function(e){return e.preventDefault(),a.fire(),!1})),Km.addClass(r.__button,"button"),r.domElement.appendChild(r.__button),r}return Hm(t,e),zm(t,[{key:"fire",value:function(){this.__onChange&&this.__onChange.call(this),this.getValue().call(this.object),this.__onFinishChange&&this.__onFinishChange.call(this,this.getValue())}}]),t}(Xm),sg=function(e){function t(e,n){Bm(this,t);var i=Vm(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,e,n));i.__color=new Gm(i.getValue()),i.__temp=new Gm(0);var r=i;i.domElement=document.createElement("div"),Km.makeSelectable(i.domElement,!1),i.__selector=document.createElement("div"),i.__selector.className="selector",i.__saturation_field=document.createElement("div"),i.__saturation_field.className="saturation-field",i.__field_knob=document.createElement("div"),i.__field_knob.className="field-knob",i.__field_knob_border="2px solid ",i.__hue_knob=document.createElement("div"),i.__hue_knob.className="hue-knob",i.__hue_field=document.createElement("div"),i.__hue_field.className="hue-field",i.__input=document.createElement("input"),i.__input.type="text",i.__input_textShadow="0 1px 1px ",Km.bind(i.__input,"keydown",(function(e){13===e.keyCode&&d.call(this)})),Km.bind(i.__input,"blur",d),Km.bind(i.__selector,"mousedown",(function(){Km.addClass(this,"drag").bind(window,"mouseup",(function(){Km.removeClass(r.__selector,"drag")}))})),Km.bind(i.__selector,"touchstart",(function(){Km.addClass(this,"drag").bind(window,"touchend",(function(){Km.removeClass(r.__selector,"drag")}))}));var a,s=document.createElement("div");function o(e){p(e),Km.bind(window,"mousemove",p),Km.bind(window,"touchmove",p),Km.bind(window,"mouseup",c),Km.bind(window,"touchend",c)}function l(e){f(e),Km.bind(window,"mousemove",f),Km.bind(window,"touchmove",f),Km.bind(window,"mouseup",h),Km.bind(window,"touchend",h)}function c(){Km.unbind(window,"mousemove",p),Km.unbind(window,"touchmove",p),Km.unbind(window,"mouseup",c),Km.unbind(window,"touchend",c),u()}function h(){Km.unbind(window,"mousemove",f),Km.unbind(window,"touchmove",f),Km.unbind(window,"mouseup",h),Km.unbind(window,"touchend",h),u()}function d(){var e=Um(this.value);!1!==e?(r.__color.__state=e,r.setValue(r.__color.toOriginal())):this.value=r.__color.toString()}function u(){r.__onFinishChange&&r.__onFinishChange.call(r,r.__color.toOriginal())}function p(e){-1===e.type.indexOf("touch")&&e.preventDefault();var t=r.__saturation_field.getBoundingClientRect(),n=e.touches&&e.touches[0]||e,i=n.clientX,a=n.clientY,s=(i-t.left)/(t.right-t.left),o=1-(a-t.top)/(t.bottom-t.top);return o>1?o=1:o<0&&(o=0),s>1?s=1:s<0&&(s=0),r.__color.v=o,r.__color.s=s,r.setValue(r.__color.toOriginal()),!1}function f(e){-1===e.type.indexOf("touch")&&e.preventDefault();var t=r.__hue_field.getBoundingClientRect(),n=1-((e.touches&&e.touches[0]||e).clientY-t.top)/(t.bottom-t.top);return n>1?n=1:n<0&&(n=0),r.__color.h=360*n,r.setValue(r.__color.toOriginal()),!1}return Cm.extend(i.__selector.style,{width:"122px",height:"102px",padding:"3px",backgroundColor:"#222",boxShadow:"0px 1px 3px rgba(0,0,0,0.3)"}),Cm.extend(i.__field_knob.style,{position:"absolute",width:"12px",height:"12px",border:i.__field_knob_border+(i.__color.v<.5?"#fff":"#000"),boxShadow:"0px 1px 3px rgba(0,0,0,0.5)",borderRadius:"12px",zIndex:1}),Cm.extend(i.__hue_knob.style,{position:"absolute",width:"15px",height:"2px",borderRight:"4px solid #fff",zIndex:1}),Cm.extend(i.__saturation_field.style,{width:"100px",height:"100px",border:"1px solid #555",marginRight:"3px",display:"inline-block",cursor:"pointer"}),Cm.extend(s.style,{width:"100%",height:"100%",background:"none"}),lg(s,"top","rgba(0,0,0,0)","#000"),Cm.extend(i.__hue_field.style,{width:"15px",height:"100px",border:"1px solid #555",cursor:"ns-resize",position:"absolute",top:"3px",right:"3px"}),(a=i.__hue_field).style.background="",a.style.cssText+="background: -moz-linear-gradient(top, #ff0000 0%, #ff00ff 17%, #0000ff 34%, #00ffff 50%, #00ff00 67%, #ffff00 84%, #ff0000 100%);",a.style.cssText+="background: -webkit-linear-gradient(top, #ff0000 0%,#ff00ff 17%,#0000ff 34%,#00ffff 50%,#00ff00 67%,#ffff00 84%,#ff0000 100%);",a.style.cssText+="background: -o-linear-gradient(top, #ff0000 0%,#ff00ff 17%,#0000ff 34%,#00ffff 50%,#00ff00 67%,#ffff00 84%,#ff0000 100%);",a.style.cssText+="background: -ms-linear-gradient(top, #ff0000 0%,#ff00ff 17%,#0000ff 34%,#00ffff 50%,#00ff00 67%,#ffff00 84%,#ff0000 100%);",a.style.cssText+="background: linear-gradient(top, #ff0000 0%,#ff00ff 17%,#0000ff 34%,#00ffff 50%,#00ff00 67%,#ffff00 84%,#ff0000 100%);",Cm.extend(i.__input.style,{outline:"none",textAlign:"center",color:"#fff",border:0,fontWeight:"bold",textShadow:i.__input_textShadow+"rgba(0,0,0,0.7)"}),Km.bind(i.__saturation_field,"mousedown",o),Km.bind(i.__saturation_field,"touchstart",o),Km.bind(i.__field_knob,"mousedown",o),Km.bind(i.__field_knob,"touchstart",o),Km.bind(i.__hue_field,"mousedown",l),Km.bind(i.__hue_field,"touchstart",l),i.__saturation_field.appendChild(s),i.__selector.appendChild(i.__field_knob),i.__selector.appendChild(i.__saturation_field),i.__selector.appendChild(i.__hue_field),i.__hue_field.appendChild(i.__hue_knob),i.domElement.appendChild(i.__input),i.domElement.appendChild(i.__selector),i.updateDisplay(),i}return Hm(t,e),zm(t,[{key:"updateDisplay",value:function(){var e=Um(this.getValue());if(!1!==e){var t=!1;Cm.each(Gm.COMPONENTS,(function(n){if(!Cm.isUndefined(e[n])&&!Cm.isUndefined(this.__color.__state[n])&&e[n]!==this.__color.__state[n])return t=!0,{}}),this),t&&Cm.extend(this.__color.__state,e)}Cm.extend(this.__temp.__state,this.__color.__state),this.__temp.a=1;var n=this.__color.v<.5||this.__color.s>.5?255:0,i=255-n;Cm.extend(this.__field_knob.style,{marginLeft:100*this.__color.s-7+"px",marginTop:100*(1-this.__color.v)-7+"px",backgroundColor:this.__temp.toHexString(),border:this.__field_knob_border+"rgb("+n+","+n+","+n+")"}),this.__hue_knob.style.marginTop=100*(1-this.__color.h/360)+"px",this.__temp.s=1,this.__temp.v=1,lg(this.__saturation_field,"left","#fff",this.__temp.toHexString()),this.__input.value=this.__color.toString(),Cm.extend(this.__input.style,{backgroundColor:this.__color.toHexString(),color:"rgb("+n+","+n+","+n+")",textShadow:this.__input_textShadow+"rgba("+i+","+i+","+i+",.7)"})}}]),t}(Xm),og=["-moz-","-o-","-webkit-","-ms-",""];function lg(e,t,n,i){e.style.background="",Cm.each(og,(function(r){e.style.cssText+="background: "+r+"linear-gradient("+t+", "+n+" 0%, "+i+" 100%); "}))}var cg=function(e,t){var n=e[t];return Cm.isArray(arguments[2])||Cm.isObject(arguments[2])?new Qm(e,t,arguments[2]):Cm.isNumber(n)?Cm.isNumber(arguments[2])&&Cm.isNumber(arguments[3])?Cm.isNumber(arguments[4])?new rg(e,t,arguments[2],arguments[3],arguments[4]):new rg(e,t,arguments[2],arguments[3]):Cm.isNumber(arguments[4])?new ng(e,t,{min:arguments[2],max:arguments[3],step:arguments[4]}):new ng(e,t,{min:arguments[2],max:arguments[3]}):Cm.isString(n)?new $m(e,t):Cm.isFunction(n)?new ag(e,t,""):Cm.isBoolean(n)?new Jm(e,t):null},hg=window.requestAnimationFrame||window.webkitRequestAnimationFrame||window.mozRequestAnimationFrame||window.oRequestAnimationFrame||window.msRequestAnimationFrame||function(e){setTimeout(e,1e3/60)},dg=function(){function e(){Bm(this,e),this.backgroundElement=document.createElement("div"),Cm.extend(this.backgroundElement.style,{backgroundColor:"rgba(0,0,0,0.8)",top:0,left:0,display:"none",zIndex:"1000",opacity:0,WebkitTransition:"opacity 0.2s linear",transition:"opacity 0.2s linear"}),Km.makeFullscreen(this.backgroundElement),this.backgroundElement.style.position="fixed",this.domElement=document.createElement("div"),Cm.extend(this.domElement.style,{position:"fixed",display:"none",zIndex:"1001",opacity:0,WebkitTransition:"-webkit-transform 0.2s ease-out, opacity 0.2s linear",transition:"transform 0.2s ease-out, opacity 0.2s linear"}),document.body.appendChild(this.backgroundElement),document.body.appendChild(this.domElement);var t=this;Km.bind(this.backgroundElement,"click",(function(){t.hide()}))}return zm(e,[{key:"show",value:function(){var e=this;this.backgroundElement.style.display="block",this.domElement.style.display="block",this.domElement.style.opacity=0,this.domElement.style.webkitTransform="scale(1.1)",this.layout(),Cm.defer((function(){e.backgroundElement.style.opacity=1,e.domElement.style.opacity=1,e.domElement.style.webkitTransform="scale(1)"}))}},{key:"hide",value:function(){var e=this,t=function t(){e.domElement.style.display="none",e.backgroundElement.style.display="none",Km.unbind(e.domElement,"webkitTransitionEnd",t),Km.unbind(e.domElement,"transitionend",t),Km.unbind(e.domElement,"oTransitionEnd",t)};Km.bind(this.domElement,"webkitTransitionEnd",t),Km.bind(this.domElement,"transitionend",t),Km.bind(this.domElement,"oTransitionEnd",t),this.backgroundElement.style.opacity=0,this.domElement.style.opacity=0,this.domElement.style.webkitTransform="scale(1.1)"}},{key:"layout",value:function(){this.domElement.style.left=window.innerWidth/2-Km.getWidth(this.domElement)/2+"px",this.domElement.style.top=window.innerHeight/2-Km.getHeight(this.domElement)/2+"px"}}]),e}();!function(e,t){var n=t||document,i=document.createElement("style");i.type="text/css",i.innerHTML=e;var r=n.getElementsByTagName("head")[0];try{r.appendChild(i)}catch(e){}}(function(e){if(e&&"undefined"!=typeof window){var t=document.createElement("style");return t.setAttribute("type","text/css"),t.innerHTML=e,document.head.appendChild(t),e}}(".dg ul{list-style:none;margin:0;padding:0;width:100%;clear:both}.dg.ac{position:fixed;top:0;left:0;right:0;height:0;z-index:0}.dg:not(.ac) .main{overflow:hidden}.dg.main{-webkit-transition:opacity .1s linear;-o-transition:opacity .1s linear;-moz-transition:opacity .1s linear;transition:opacity .1s linear}.dg.main.taller-than-window{overflow-y:auto}.dg.main.taller-than-window .close-button{opacity:1;margin-top:-1px;border-top:1px solid #2c2c2c}.dg.main ul.closed .close-button{opacity:1 !important}.dg.main:hover .close-button,.dg.main .close-button.drag{opacity:1}.dg.main .close-button{-webkit-transition:opacity .1s linear;-o-transition:opacity .1s linear;-moz-transition:opacity .1s linear;transition:opacity .1s linear;border:0;line-height:19px;height:20px;cursor:pointer;text-align:center;background-color:#000}.dg.main .close-button.close-top{position:relative}.dg.main .close-button.close-bottom{position:absolute}.dg.main .close-button:hover{background-color:#111}.dg.a{float:right;margin-right:15px;overflow-y:visible}.dg.a.has-save>ul.close-top{margin-top:0}.dg.a.has-save>ul.close-bottom{margin-top:27px}.dg.a.has-save>ul.closed{margin-top:0}.dg.a .save-row{top:0;z-index:1002}.dg.a .save-row.close-top{position:relative}.dg.a .save-row.close-bottom{position:fixed}.dg li{-webkit-transition:height .1s ease-out;-o-transition:height .1s ease-out;-moz-transition:height .1s ease-out;transition:height .1s ease-out;-webkit-transition:overflow .1s linear;-o-transition:overflow .1s linear;-moz-transition:overflow .1s linear;transition:overflow .1s linear}.dg li:not(.folder){cursor:auto;height:27px;line-height:27px;padding:0 4px 0 5px}.dg li.folder{padding:0;border-left:4px solid rgba(0,0,0,0)}.dg li.title{cursor:pointer;margin-left:-4px}.dg .closed li:not(.title),.dg .closed ul li,.dg .closed ul li>*{height:0;overflow:hidden;border:0}.dg .cr{clear:both;padding-left:3px;height:27px;overflow:hidden}.dg .property-name{cursor:default;float:left;clear:left;width:40%;overflow:hidden;text-overflow:ellipsis}.dg .cr.function .property-name{width:100%}.dg .c{float:left;width:60%;position:relative}.dg .c input[type=text]{border:0;margin-top:4px;padding:3px;width:100%;float:right}.dg .has-slider input[type=text]{width:30%;margin-left:0}.dg .slider{float:left;width:66%;margin-left:-5px;margin-right:0;height:19px;margin-top:4px}.dg .slider-fg{height:100%}.dg .c input[type=checkbox]{margin-top:7px}.dg .c select{margin-top:5px}.dg .cr.function,.dg .cr.function .property-name,.dg .cr.function *,.dg .cr.boolean,.dg .cr.boolean *{cursor:pointer}.dg .cr.color{overflow:visible}.dg .selector{display:none;position:absolute;margin-left:-9px;margin-top:23px;z-index:10}.dg .c:hover .selector,.dg .selector.drag{display:block}.dg li.save-row{padding:0}.dg li.save-row .button{display:inline-block;padding:0px 6px}.dg.dialogue{background-color:#222;width:460px;padding:15px;font-size:13px;line-height:15px}#dg-new-constructor{padding:10px;color:#222;font-family:Monaco, monospace;font-size:10px;border:0;resize:none;box-shadow:inset 1px 1px 1px #888;word-wrap:break-word;margin:12px 0;display:block;width:440px;overflow-y:scroll;height:100px;position:relative}#dg-local-explain{display:none;font-size:11px;line-height:17px;border-radius:3px;background-color:#333;padding:8px;margin-top:10px}#dg-local-explain code{font-size:10px}#dat-gui-save-locally{display:none}.dg{color:#eee;font:11px 'Lucida Grande', sans-serif;text-shadow:0 -1px 0 #111}.dg.main::-webkit-scrollbar{width:5px;background:#1a1a1a}.dg.main::-webkit-scrollbar-corner{height:0;display:none}.dg.main::-webkit-scrollbar-thumb{border-radius:5px;background:#676767}.dg li:not(.folder){background:#1a1a1a;border-bottom:1px solid #2c2c2c}.dg li.save-row{line-height:25px;background:#dad5cb;border:0}.dg li.save-row select{margin-left:5px;width:108px}.dg li.save-row .button{margin-left:5px;margin-top:1px;border-radius:2px;font-size:9px;line-height:7px;padding:4px 4px 5px 4px;background:#c5bdad;color:#fff;text-shadow:0 1px 0 #b0a58f;box-shadow:0 -1px 0 #b0a58f;cursor:pointer}.dg li.save-row .button.gears{background:#c5bdad url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAsAAAANCAYAAAB/9ZQ7AAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAQJJREFUeNpiYKAU/P//PwGIC/ApCABiBSAW+I8AClAcgKxQ4T9hoMAEUrxx2QSGN6+egDX+/vWT4e7N82AMYoPAx/evwWoYoSYbACX2s7KxCxzcsezDh3evFoDEBYTEEqycggWAzA9AuUSQQgeYPa9fPv6/YWm/Acx5IPb7ty/fw+QZblw67vDs8R0YHyQhgObx+yAJkBqmG5dPPDh1aPOGR/eugW0G4vlIoTIfyFcA+QekhhHJhPdQxbiAIguMBTQZrPD7108M6roWYDFQiIAAv6Aow/1bFwXgis+f2LUAynwoIaNcz8XNx3Dl7MEJUDGQpx9gtQ8YCueB+D26OECAAQDadt7e46D42QAAAABJRU5ErkJggg==) 2px 1px no-repeat;height:7px;width:8px}.dg li.save-row .button:hover{background-color:#bab19e;box-shadow:0 -1px 0 #b0a58f}.dg li.folder{border-bottom:0}.dg li.title{padding-left:16px;background:#000 url(data:image/gif;base64,R0lGODlhBQAFAJEAAP////Pz8////////yH5BAEAAAIALAAAAAAFAAUAAAIIlI+hKgFxoCgAOw==) 6px 10px no-repeat;cursor:pointer;border-bottom:1px solid rgba(255,255,255,0.2)}.dg .closed li.title{background-image:url(data:image/gif;base64,R0lGODlhBQAFAJEAAP////Pz8////////yH5BAEAAAIALAAAAAAFAAUAAAIIlGIWqMCbWAEAOw==)}.dg .cr.boolean{border-left:3px solid #806787}.dg .cr.color{border-left:3px solid}.dg .cr.function{border-left:3px solid #e61d5f}.dg .cr.number{border-left:3px solid #2FA1D6}.dg .cr.number input[type=text]{color:#2FA1D6}.dg .cr.string{border-left:3px solid #1ed36f}.dg .cr.string input[type=text]{color:#1ed36f}.dg .cr.function:hover,.dg .cr.boolean:hover{background:#111}.dg .c input[type=text]{background:#303030;outline:none}.dg .c input[type=text]:hover{background:#3c3c3c}.dg .c input[type=text]:focus{background:#494949;color:#fff}.dg .c .slider{background:#303030;cursor:ew-resize}.dg .c .slider-fg{background:#2FA1D6;max-width:100%}.dg .c .slider:hover{background:#3c3c3c}.dg .c .slider:hover .slider-fg{background:#44abda}\n"));var ug="Default",pg=function(){try{return!!window.localStorage}catch(e){return!1}}(),fg=void 0,mg=!0,gg=void 0,vg=!1,_g=[],xg=function e(t){var n=this,i=t||{};this.domElement=document.createElement("div"),this.__ul=document.createElement("ul"),this.domElement.appendChild(this.__ul),Km.addClass(this.domElement,"dg"),this.__folders={},this.__controllers=[],this.__rememberedObjects=[],this.__rememberedObjectIndecesToControllers=[],this.__listening=[],i=Cm.defaults(i,{closeOnTop:!1,autoPlace:!0,width:e.DEFAULT_WIDTH}),i=Cm.defaults(i,{resizable:i.autoPlace,hideable:i.autoPlace}),Cm.isUndefined(i.load)?i.load={preset:ug}:i.preset&&(i.load.preset=i.preset),Cm.isUndefined(i.parent)&&i.hideable&&_g.push(this),i.resizable=Cm.isUndefined(i.parent)&&i.resizable,i.autoPlace&&Cm.isUndefined(i.scrollable)&&(i.scrollable=!0);var r,a=pg&&"true"===localStorage.getItem(Tg(0,"isLocal")),s=void 0,o=void 0;if(Object.defineProperties(this,{parent:{get:function(){return i.parent}},scrollable:{get:function(){return i.scrollable}},autoPlace:{get:function(){return i.autoPlace}},closeOnTop:{get:function(){return i.closeOnTop}},preset:{get:function(){return n.parent?n.getRoot().preset:i.load.preset},set:function(e){n.parent?n.getRoot().preset=e:i.load.preset=e,function(e){for(var t=0;t1){var i=n.__li.nextElementSibling;return n.remove(),Mg(e,n.object,n.property,{before:i,factoryArgs:[Cm.toArray(arguments)]})}if(Cm.isArray(t)||Cm.isObject(t)){var r=n.__li.nextElementSibling;return n.remove(),Mg(e,n.object,n.property,{before:r,factoryArgs:[t]})}},name:function(e){return n.__li.firstElementChild.firstElementChild.innerHTML=e,n},listen:function(){return n.__gui.listen(n),n},remove:function(){return n.__gui.remove(n),n}}),n instanceof rg){var i=new ng(n.object,n.property,{min:n.__min,max:n.__max,step:n.__step});Cm.each(["updateDisplay","onChange","onFinishChange","step","min","max"],(function(e){var t=n[e],r=i[e];n[e]=i[e]=function(){var e=Array.prototype.slice.call(arguments);return r.apply(i,e),t.apply(n,e)}})),Km.addClass(t,"has-slider"),n.domElement.insertBefore(i.domElement,n.domElement.firstElementChild)}else if(n instanceof ng){var r=function(t){if(Cm.isNumber(n.__min)&&Cm.isNumber(n.__max)){var i=n.__li.firstElementChild.firstElementChild.innerHTML,r=n.__gui.__listening.indexOf(n)>-1;n.remove();var a=Mg(e,n.object,n.property,{before:n.__li.nextElementSibling,factoryArgs:[n.__min,n.__max,n.__step]});return a.name(i),r&&a.listen(),a}return t};n.min=Cm.compose(r,n.min),n.max=Cm.compose(r,n.max)}else n instanceof Jm?(Km.bind(t,"click",(function(){Km.fakeEvent(n.__checkbox,"click")})),Km.bind(n.__checkbox,"click",(function(e){e.stopPropagation()}))):n instanceof ag?(Km.bind(t,"click",(function(){Km.fakeEvent(n.__button,"click")})),Km.bind(t,"mouseover",(function(){Km.addClass(n.__button,"hover")})),Km.bind(t,"mouseout",(function(){Km.removeClass(n.__button,"hover")}))):n instanceof sg&&(Km.addClass(t,"color"),n.updateDisplay=Cm.compose((function(e){return t.style.borderLeftColor=n.__color.toString(),e}),n.updateDisplay),n.updateDisplay());n.setValue=Cm.compose((function(t){return e.getRoot().__preset_select&&n.isModified()&&wg(e.getRoot(),!0),t}),n.setValue)}(e,l,r),e.__controllers.push(r),r}function Tg(e,t){return document.location.href+"."+t}function Eg(e,t,n){var i=document.createElement("option");i.innerHTML=t,i.value=t,e.__preset_select.appendChild(i),n&&(e.__preset_select.selectedIndex=e.__preset_select.length-1)}function Ag(e,t){t.style.display=e.useLocalStorage?"block":"none"}function Pg(e){var t=void 0;function n(n){return n.preventDefault(),e.width+=t-n.clientX,e.onResize(),t=n.clientX,!1}function i(){Km.removeClass(e.__closeButton,xg.CLASS_DRAG),Km.unbind(window,"mousemove",n),Km.unbind(window,"mouseup",i)}function r(r){return r.preventDefault(),t=r.clientX,Km.addClass(e.__closeButton,xg.CLASS_DRAG),Km.bind(window,"mousemove",n),Km.bind(window,"mouseup",i),!1}e.__resize_handle=document.createElement("div"),Cm.extend(e.__resize_handle.style,{width:"6px",marginLeft:"-3px",height:"200px",cursor:"ew-resize",position:"absolute"}),Km.bind(e.__resize_handle,"mousedown",r),Km.bind(e.__closeButton,"mousedown",r),e.domElement.insertBefore(e.__resize_handle,e.domElement.firstElementChild)}function Rg(e,t){e.domElement.style.width=t+"px",e.__save_row&&e.autoPlace&&(e.__save_row.style.width=t+"px"),e.__closeButton&&(e.__closeButton.style.width=t+"px")}function Cg(e,t){var n={};return Cm.each(e.__rememberedObjects,(function(i,r){var a={},s=e.__rememberedObjectIndecesToControllers[r];Cm.each(s,(function(e,n){a[n]=t?e.initialValue:e.getValue()})),n[r]=a})),n}function Dg(e){0!==e.length&&hg.call(window,(function(){Dg(e)})),Cm.each(e,(function(e){e.updateDisplay()}))}xg.toggleHide=function(){vg=!vg,Cm.each(_g,(function(e){e.domElement.style.display=vg?"none":""}))},xg.CLASS_AUTO_PLACE="a",xg.CLASS_AUTO_PLACE_CONTAINER="ac",xg.CLASS_MAIN="main",xg.CLASS_CONTROLLER_ROW="cr",xg.CLASS_TOO_TALL="taller-than-window",xg.CLASS_CLOSED="closed",xg.CLASS_CLOSE_BUTTON="close-button",xg.CLASS_CLOSE_TOP="close-top",xg.CLASS_CLOSE_BOTTOM="close-bottom",xg.CLASS_DRAG="drag",xg.DEFAULT_WIDTH=245,xg.TEXT_CLOSED="Close Controls",xg.TEXT_OPEN="Open Controls",xg._keydownHandler=function(e){"text"===document.activeElement.type||72!==e.which&&72!==e.keyCode||xg.toggleHide()},Km.bind(window,"keydown",xg._keydownHandler,!1),Cm.extend(xg.prototype,{add:function(e,t){return Mg(this,e,t,{factoryArgs:Array.prototype.slice.call(arguments,2)})},addColor:function(e,t){return Mg(this,e,t,{color:!0})},remove:function(e){this.__ul.removeChild(e.__li),this.__controllers.splice(this.__controllers.indexOf(e),1);var t=this;Cm.defer((function(){t.onResize()}))},destroy:function(){if(this.parent)throw new Error("Only the root GUI should be removed with .destroy(). For subfolders, use gui.removeFolder(folder) instead.");this.autoPlace&&gg.removeChild(this.domElement);var e=this;Cm.each(this.__folders,(function(t){e.removeFolder(t)})),Km.unbind(window,"keydown",xg._keydownHandler,!1),Sg(this)},addFolder:function(e){if(void 0!==this.__folders[e])throw new Error('You already have a folder in this GUI by the name "'+e+'"');var t={name:e,parent:this};t.autoPlace=this.autoPlace,this.load&&this.load.folders&&this.load.folders[e]&&(t.closed=this.load.folders[e].closed,t.load=this.load.folders[e]);var n=new xg(t);this.__folders[e]=n;var i=yg(this,n.domElement);return Km.addClass(i,"folder"),n},removeFolder:function(e){this.__ul.removeChild(e.domElement.parentElement),delete this.__folders[e.name],this.load&&this.load.folders&&this.load.folders[e.name]&&delete this.load.folders[e.name],Sg(e);var t=this;Cm.each(e.__folders,(function(t){e.removeFolder(t)})),Cm.defer((function(){t.onResize()}))},open:function(){this.closed=!1},close:function(){this.closed=!0},hide:function(){this.domElement.style.display="none"},show:function(){this.domElement.style.display=""},onResize:function(){var e=this.getRoot();if(e.scrollable){var t=Km.getOffset(e.__ul).top,n=0;Cm.each(e.__ul.childNodes,(function(t){e.autoPlace&&t===e.__save_row||(n+=Km.getHeight(t))})),window.innerHeight-t-20GUI\'s constructor:\n\n \n\n
\n\n Automatically save\n values to localStorage on exit.\n\n
The values saved to localStorage will\n override those passed to dat.GUI\'s constructor. This makes it\n easier to work incrementally, but localStorage is fragile,\n and your friends may not see the same values you do.\n\n
\n\n
\n\n'),this.parent)throw new Error("You can only call remember on a top level GUI.");var e=this;Cm.each(Array.prototype.slice.call(arguments),(function(t){0===e.__rememberedObjects.length&&function(e){var t=e.__save_row=document.createElement("li");Km.addClass(e.domElement,"has-save"),e.__ul.insertBefore(t,e.__ul.firstChild),Km.addClass(t,"save-row");var n=document.createElement("span");n.innerHTML=" ",Km.addClass(n,"button gears");var i=document.createElement("span");i.innerHTML="Save",Km.addClass(i,"button"),Km.addClass(i,"save");var r=document.createElement("span");r.innerHTML="New",Km.addClass(r,"button"),Km.addClass(r,"save-as");var a=document.createElement("span");a.innerHTML="Revert",Km.addClass(a,"button"),Km.addClass(a,"revert");var s=e.__preset_select=document.createElement("select");if(e.load&&e.load.remembered?Cm.each(e.load.remembered,(function(t,n){Eg(e,n,n===e.preset)})):Eg(e,ug,!1),Km.bind(s,"change",(function(){for(var t=0;t0&&(e.preset=this.preset,e.remembered||(e.remembered={}),e.remembered[this.preset]=Cg(this)),e.folders={},Cm.each(this.__folders,(function(t,n){e.folders[n]=t.getSaveObject()})),e},save:function(){this.load.remembered||(this.load.remembered={}),this.load.remembered[this.preset]=Cg(this),wg(this,!1),this.saveToLocalStorageIfPossible()},saveAs:function(e){this.load.remembered||(this.load.remembered={},this.load.remembered[ug]=Cg(this,!0)),this.load.remembered[e]=Cg(this),this.preset=e,Eg(this,e,!0),this.saveToLocalStorageIfPossible()},revert:function(e){Cm.each(this.__controllers,(function(t){this.getRoot().load.remembered?bg(e||this.getRoot(),t):t.setValue(t.initialValue),t.__onFinishChange&&t.__onFinishChange.call(t,t.getValue())}),this),Cm.each(this.__folders,(function(e){e.revert(e)})),e||wg(this.getRoot(),!1)},listen:function(e){var t=0===this.__listening.length;this.__listening.push(e),t&&Dg(this.__listening)},updateDisplay:function(){Cm.each(this.__controllers,(function(e){e.updateDisplay()})),Cm.each(this.__folders,(function(e){e.updateDisplay()}))}});var Lg=xg;const Ig=(()=>{const e=navigator.userAgent;return/(tablet|ipad|playbook|silk)|(android(?!.*mobi))/i.test(e)?"tablet":/Mobile|Android|iP(hone|od)|IEMobile|BlackBerry|Kindle|Silk-Accelerated|(hpw|web)OS|Opera M(obi|ini)/.test(e)?"mobile":"desktop"})();console.log(Ig);const Ug="mobile"===Ig,Og={},Ng=(e,t="#000000")=>{console.log(`Status information: ${e}`);const n=document.getElementById("status-line");n&&(n.innerText=e,n.style.setProperty("color",t))},Fg=e=>{const t=jg.collectMaterials();nv.updateMaterialUI(Xg,t),Ng(`${e}`),Wg.sceneName=e.replace(/:/g,"_")},Bg=(e,t)=>{return n=void 0,i=void 0,a=function*(){let n=Og[t];n||(yield jg.loadResource(e+".glb",t,(e=>{}),((e,n)=>{n?(Og[t]={scene:n,glb:!0},Fg(e)):Ng(`load ${e}`,"#ff0000")})),n=Og[t]),Ng(`render ${t}`,"#ff0000"),jg.update(void 0,n.scene,n.glb),Fg(t)},new((r=void 0)||(r=Promise))((function(e,t){function s(e){try{l(a.next(e))}catch(e){t(e)}}function o(e){try{l(a.throw(e))}catch(e){t(e)}}function l(t){var n;t.done?e(t.value):(n=t.value,n instanceof r?n:new r((function(e){e(n)}))).then(s,o)}l((a=a.apply(n,i||[])).next())}));var n,i,r,a},zg=()=>{let e=Io;switch(Wg.groundMaterial.toLocaleLowerCase()){default:e=Io;break;case"parquet":e=Uo;break;case"pavement":e=Oo}jg.setGroundMaterial(e)},kg=document.getElementById("container"),Hg=new class{constructor(e={}){const{canvas:t=bt(),context:i=null,depth:r=!0,stencil:a=!1,alpha:s=!1,antialias:o=!1,premultipliedAlpha:l=!0,preserveDrawingBuffer:c=!1,powerPreference:h="default",failIfMajorPerformanceCaveat:d=!1,reverseDepthBuffer:u=!1}=e;let p;if(this.isWebGLRenderer=!0,null!==i){if("undefined"!=typeof WebGLRenderingContext&&i instanceof WebGLRenderingContext)throw new Error("THREE.WebGLRenderer: WebGL 1 is not supported since r163.");p=i.getContextAttributes().alpha}else p=s;const f=new Uint32Array(4),m=new Int32Array(4);let g=null,v=null;const _=[],x=[];this.domElement=t,this.debug={checkShaderErrors:!0,onShaderError:null},this.autoClear=!0,this.autoClearColor=!0,this.autoClearDepth=!0,this.autoClearStencil=!0,this.sortObjects=!0,this.clippingPlanes=[],this.localClippingEnabled=!1,this._outputColorSpace=Ge,this.toneMapping=0,this.toneMappingExposure=1;const y=this;let S=!1,w=0,b=0,M=null,T=-1,E=null;const A=new zt,P=new zt;let R=null;const C=new fi(0);let D=0,L=t.width,I=t.height,U=1,O=null,N=null;const F=new zt(0,0,L,I),B=new zt(0,0,L,I);let z=!1;const k=new Wr;let H=!1,V=!1;const G=new wn,Y=new wn,Z=new jt,ee=new zt,te={background:null,fog:null,environment:null,overrideMaterial:null,isScene:!0};let ne=!1;function ie(){return null===M?U:1}let ae,le,ce,he,de,ue,pe,fe,me,ge,ve,_e,xe,ye,Se,we,be,Me,Te,Ee,Ae,Pe,Re,Ce,De=i;function Le(e,n){return t.getContext(e,n)}try{const e={alpha:!0,depth:r,stencil:a,antialias:o,premultipliedAlpha:l,preserveDrawingBuffer:c,powerPreference:h,failIfMajorPerformanceCaveat:d};if("setAttribute"in t&&t.setAttribute("data-engine",`three.js r${n}`),t.addEventListener("webglcontextlost",Oe,!1),t.addEventListener("webglcontextrestored",Ne,!1),t.addEventListener("webglcontextcreationerror",Fe,!1),null===De){const t="webgl2";if(De=Le(t,e),null===De)throw Le(t)?new Error("Error creating WebGL context with your selected attributes."):new Error("Error creating WebGL context.")}}catch(e){throw console.error("THREE.WebGLRenderer: "+e.message),e}function Ie(){ae=new El(De),ae.init(),Pe=new Sh(De,ae),le=new ol(De,ae,e,Pe),ce=new xh(De,ae),le.reverseDepthBuffer&&u&&ce.buffers.depth.setReversed(!0),he=new Rl(De),de=new sh,ue=new yh(De,ae,ce,de,le,Pe,he),pe=new cl(y),fe=new Tl(y),me=new Jo(De),Re=new al(De,me),ge=new Al(De,me,he,Re),ve=new Dl(De,ge,me,he),Te=new Cl(De,le,ue),we=new ll(de),_e=new ah(y,pe,fe,ae,le,Re,we),xe=new Ph(y,de),ye=new hh,Se=new gh(ae),Me=new rl(y,pe,fe,ce,ve,p,l),be=new vh(y,ve,le),Ce=new Rh(De,he,le,ce),Ee=new sl(De,ae,he),Ae=new Pl(De,ae,he),he.programs=_e.programs,y.capabilities=le,y.extensions=ae,y.properties=de,y.renderLists=ye,y.shadowMap=be,y.state=ce,y.info=he}Ie();const Ue=new Th(y,De);function Oe(e){e.preventDefault(),console.log("THREE.WebGLRenderer: Context Lost."),S=!0}function Ne(){console.log("THREE.WebGLRenderer: Context Restored."),S=!1;const e=he.autoReset,t=be.enabled,n=be.autoUpdate,i=be.needsUpdate,r=be.type;Ie(),he.autoReset=e,be.enabled=t,be.autoUpdate=n,be.needsUpdate=i,be.type=r}function Fe(e){console.error("THREE.WebGLRenderer: A WebGL context could not be created. Reason: ",e.statusMessage)}function Be(e){const t=e.target;t.removeEventListener("dispose",Be),function(e){(function(e){const t=de.get(e).programs;void 0!==t&&(t.forEach((function(e){_e.releaseProgram(e)})),e.isShaderMaterial&&_e.releaseShaderCache(e))})(e),de.remove(e)}(t)}function ze(e,t,n){!0===e.transparent&&2===e.side&&!1===e.forceSinglePass?(e.side=1,e.needsUpdate=!0,Je(e,t,n),e.side=0,e.needsUpdate=!0,Je(e,t,n),e.side=2):Je(e,t,n)}this.xr=Ue,this.getContext=function(){return De},this.getContextAttributes=function(){return De.getContextAttributes()},this.forceContextLoss=function(){const e=ae.get("WEBGL_lose_context");e&&e.loseContext()},this.forceContextRestore=function(){const e=ae.get("WEBGL_lose_context");e&&e.restoreContext()},this.getPixelRatio=function(){return U},this.setPixelRatio=function(e){void 0!==e&&(U=e,this.setSize(L,I,!1))},this.getSize=function(e){return e.set(L,I)},this.setSize=function(e,n,i=!0){Ue.isPresenting?console.warn("THREE.WebGLRenderer: Can't change size while VR device is presenting."):(L=e,I=n,t.width=Math.floor(e*U),t.height=Math.floor(n*U),!0===i&&(t.style.width=e+"px",t.style.height=n+"px"),this.setViewport(0,0,e,n))},this.getDrawingBufferSize=function(e){return e.set(L*U,I*U).floor()},this.setDrawingBufferSize=function(e,n,i){L=e,I=n,U=i,t.width=Math.floor(e*i),t.height=Math.floor(n*i),this.setViewport(0,0,e,n)},this.getCurrentViewport=function(e){return e.copy(A)},this.getViewport=function(e){return e.copy(F)},this.setViewport=function(e,t,n,i){e.isVector4?F.set(e.x,e.y,e.z,e.w):F.set(e,t,n,i),ce.viewport(A.copy(F).multiplyScalar(U).round())},this.getScissor=function(e){return e.copy(B)},this.setScissor=function(e,t,n,i){e.isVector4?B.set(e.x,e.y,e.z,e.w):B.set(e,t,n,i),ce.scissor(P.copy(B).multiplyScalar(U).round())},this.getScissorTest=function(){return z},this.setScissorTest=function(e){ce.setScissorTest(z=e)},this.setOpaqueSort=function(e){O=e},this.setTransparentSort=function(e){N=e},this.getClearColor=function(e){return e.copy(Me.getClearColor())},this.setClearColor=function(){Me.setClearColor.apply(Me,arguments)},this.getClearAlpha=function(){return Me.getClearAlpha()},this.setClearAlpha=function(){Me.setClearAlpha.apply(Me,arguments)},this.clear=function(e=!0,t=!0,n=!0){let i=0;if(e){let e=!1;if(null!==M){const t=M.texture.format;e=t===oe||t===se||t===re}if(e){const e=M.texture.type,t=e===j||e===q||e===X||e===$||e===J||e===Q,n=Me.getClearColor(),i=Me.getClearAlpha(),r=n.r,a=n.g,s=n.b;t?(f[0]=r,f[1]=a,f[2]=s,f[3]=i,De.clearBufferuiv(De.COLOR,0,f)):(m[0]=r,m[1]=a,m[2]=s,m[3]=i,De.clearBufferiv(De.COLOR,0,m))}else i|=De.COLOR_BUFFER_BIT}t&&(i|=De.DEPTH_BUFFER_BIT),n&&(i|=De.STENCIL_BUFFER_BIT,this.state.buffers.stencil.setMask(4294967295)),De.clear(i)},this.clearColor=function(){this.clear(!0,!1,!1)},this.clearDepth=function(){this.clear(!1,!0,!1)},this.clearStencil=function(){this.clear(!1,!1,!0)},this.dispose=function(){t.removeEventListener("webglcontextlost",Oe,!1),t.removeEventListener("webglcontextrestored",Ne,!1),t.removeEventListener("webglcontextcreationerror",Fe,!1),Me.dispose(),ye.dispose(),Se.dispose(),de.dispose(),pe.dispose(),fe.dispose(),ve.dispose(),Re.dispose(),Ce.dispose(),_e.dispose(),Ue.dispose(),Ue.removeEventListener("sessionstart",He),Ue.removeEventListener("sessionend",Ve),je.stop()},this.renderBufferDirect=function(e,t,n,i,r,a){null===t&&(t=te);const s=r.isMesh&&r.matrixWorld.determinant()<0,o=function(e,t,n,i,r){!0!==t.isScene&&(t=te),ue.resetTextureUnits();const a=t.fog,s=i.isMeshStandardMaterial?t.environment:null,o=null===M?y.outputColorSpace:!0===M.isXRRenderTarget?M.texture.colorSpace:We,l=(i.isMeshStandardMaterial?fe:pe).get(i.envMap||s),c=!0===i.vertexColors&&!!n.attributes.color&&4===n.attributes.color.itemSize,h=!!n.attributes.tangent&&(!!i.normalMap||i.anisotropy>0),d=!!n.morphAttributes.position,u=!!n.morphAttributes.normal,p=!!n.morphAttributes.color;let f=0;i.toneMapped&&(null!==M&&!0!==M.isXRRenderTarget||(f=y.toneMapping));const m=n.morphAttributes.position||n.morphAttributes.normal||n.morphAttributes.color,g=void 0!==m?m.length:0,_=de.get(i),x=v.state.lights;if(!0===H&&(!0===V||e!==E)){const t=e===E&&i.id===T;we.setState(i,e,t)}let S=!1;i.version===_.__version?_.needsLights&&_.lightsStateVersion!==x.state.version||_.outputColorSpace!==o||r.isBatchedMesh&&!1===_.batching?S=!0:r.isBatchedMesh||!0!==_.batching?r.isBatchedMesh&&!0===_.batchingColor&&null===r.colorTexture||r.isBatchedMesh&&!1===_.batchingColor&&null!==r.colorTexture||r.isInstancedMesh&&!1===_.instancing?S=!0:r.isInstancedMesh||!0!==_.instancing?r.isSkinnedMesh&&!1===_.skinning?S=!0:r.isSkinnedMesh||!0!==_.skinning?r.isInstancedMesh&&!0===_.instancingColor&&null===r.instanceColor||r.isInstancedMesh&&!1===_.instancingColor&&null!==r.instanceColor||r.isInstancedMesh&&!0===_.instancingMorph&&null===r.morphTexture||r.isInstancedMesh&&!1===_.instancingMorph&&null!==r.morphTexture||_.envMap!==l||!0===i.fog&&_.fog!==a?S=!0:void 0===_.numClippingPlanes||_.numClippingPlanes===we.numPlanes&&_.numIntersection===we.numIntersection?(_.vertexAlphas!==c||_.vertexTangents!==h||_.morphTargets!==d||_.morphNormals!==u||_.morphColors!==p||_.toneMapping!==f||_.morphTargetsCount!==g)&&(S=!0):S=!0:S=!0:S=!0:S=!0:(S=!0,_.__version=i.version);let w=_.currentProgram;!0===S&&(w=Je(i,t,r));let b=!1,A=!1,P=!1;const R=w.getUniforms(),C=_.uniforms;if(ce.useProgram(w.program)&&(b=!0,A=!0,P=!0),i.id!==T&&(T=i.id,A=!0),b||E!==e){ce.buffers.depth.getReversed()?(G.copy(e.projectionMatrix),function(e){const t=e.elements;t[2]=.5*t[2]+.5*t[3],t[6]=.5*t[6]+.5*t[7],t[10]=.5*t[10]+.5*t[11],t[14]=.5*t[14]+.5*t[15]}(G),function(e){const t=e.elements;-1===t[11]?(t[10]=-t[10]-1,t[14]=-t[14]):(t[10]=-t[10],t[14]=1-t[14])}(G),R.setValue(De,"projectionMatrix",G)):R.setValue(De,"projectionMatrix",e.projectionMatrix),R.setValue(De,"viewMatrix",e.matrixWorldInverse);const t=R.map.cameraPosition;void 0!==t&&t.setValue(De,Z.setFromMatrixPosition(e.matrixWorld)),le.logarithmicDepthBuffer&&R.setValue(De,"logDepthBufFC",2/(Math.log(e.far+1)/Math.LN2)),(i.isMeshPhongMaterial||i.isMeshToonMaterial||i.isMeshLambertMaterial||i.isMeshBasicMaterial||i.isMeshStandardMaterial||i.isShaderMaterial)&&R.setValue(De,"isOrthographic",!0===e.isOrthographicCamera),E!==e&&(E=e,A=!0,P=!0)}if(r.isSkinnedMesh){R.setOptional(De,r,"bindMatrix"),R.setOptional(De,r,"bindMatrixInverse");const e=r.skeleton;e&&(null===e.boneTexture&&e.computeBoneTexture(),R.setValue(De,"boneTexture",e.boneTexture,ue))}r.isBatchedMesh&&(R.setOptional(De,r,"batchingTexture"),R.setValue(De,"batchingTexture",r._matricesTexture,ue),R.setOptional(De,r,"batchingIdTexture"),R.setValue(De,"batchingIdTexture",r._indirectTexture,ue),R.setOptional(De,r,"batchingColorTexture"),null!==r._colorsTexture&&R.setValue(De,"batchingColorTexture",r._colorsTexture,ue));const D=n.morphAttributes;var L,O;if(void 0===D.position&&void 0===D.normal&&void 0===D.color||Te.update(r,n,w),(A||_.receiveShadow!==r.receiveShadow)&&(_.receiveShadow=r.receiveShadow,R.setValue(De,"receiveShadow",r.receiveShadow)),i.isMeshGouraudMaterial&&null!==i.envMap&&(C.envMap.value=l,C.flipEnvMap.value=l.isCubeTexture&&!1===l.isRenderTargetTexture?-1:1),i.isMeshStandardMaterial&&null===i.envMap&&null!==t.environment&&(C.envMapIntensity.value=t.environmentIntensity),A&&(R.setValue(De,"toneMappingExposure",y.toneMappingExposure),_.needsLights&&(O=P,(L=C).ambientLightColor.needsUpdate=O,L.lightProbe.needsUpdate=O,L.directionalLights.needsUpdate=O,L.directionalLightShadows.needsUpdate=O,L.pointLights.needsUpdate=O,L.pointLightShadows.needsUpdate=O,L.spotLights.needsUpdate=O,L.spotLightShadows.needsUpdate=O,L.rectAreaLights.needsUpdate=O,L.hemisphereLights.needsUpdate=O),a&&!0===i.fog&&xe.refreshFogUniforms(C,a),xe.refreshMaterialUniforms(C,i,U,I,v.state.transmissionRenderTarget[e.id]),Nc.upload(De,Qe(_),C,ue)),i.isShaderMaterial&&!0===i.uniformsNeedUpdate&&(Nc.upload(De,Qe(_),C,ue),i.uniformsNeedUpdate=!1),i.isSpriteMaterial&&R.setValue(De,"center",r.center),R.setValue(De,"modelViewMatrix",r.modelViewMatrix),R.setValue(De,"normalMatrix",r.normalMatrix),R.setValue(De,"modelMatrix",r.matrixWorld),i.isShaderMaterial||i.isRawShaderMaterial){const e=i.uniformsGroups;for(let t=0,n=e.length;t{function n(){i.forEach((function(e){de.get(e).currentProgram.isReady()&&i.delete(e)})),0!==i.size?setTimeout(n,10):t(e)}null!==ae.get("KHR_parallel_shader_compile")?n():setTimeout(n,10)}))};let ke=null;function He(){je.stop()}function Ve(){je.start()}const je=new Ko;function Xe(e,t,n,i){if(!1===e.visible)return;if(e.layers.test(t.layers))if(e.isGroup)n=e.renderOrder;else if(e.isLOD)!0===e.autoUpdate&&e.update(t);else if(e.isLight)v.pushLight(e),e.castShadow&&v.pushShadow(e);else if(e.isSprite){if(!e.frustumCulled||k.intersectsSprite(e)){i&&ee.setFromMatrixPosition(e.matrixWorld).applyMatrix4(Y);const t=ve.update(e),r=e.material;r.visible&&g.push(e,t,r,n,ee.z,null)}}else if((e.isMesh||e.isLine||e.isPoints)&&(!e.frustumCulled||k.intersectsObject(e))){const t=ve.update(e),r=e.material;if(i&&(void 0!==e.boundingSphere?(null===e.boundingSphere&&e.computeBoundingSphere(),ee.copy(e.boundingSphere.center)):(null===t.boundingSphere&&t.computeBoundingSphere(),ee.copy(t.boundingSphere.center)),ee.applyMatrix4(e.matrixWorld).applyMatrix4(Y)),Array.isArray(r)){const i=t.groups;for(let a=0,s=i.length;a0&&Ze(r,t,n),a.length>0&&Ze(a,t,n),s.length>0&&Ze(s,t,n),ce.buffers.depth.setTest(!0),ce.buffers.depth.setMask(!0),ce.buffers.color.setMask(!0),ce.setPolygonOffset(!1)}function qe(e,t,n,i){if(null!==(!0===n.isScene?n.overrideMaterial:null))return;void 0===v.state.transmissionRenderTarget[i.id]&&(v.state.transmissionRenderTarget[i.id]=new Ht(1,1,{generateMipmaps:!0,type:ae.has("EXT_color_buffer_half_float")||ae.has("EXT_color_buffer_float")?K:j,minFilter:W,samples:4,stencilBuffer:a,resolveDepthBuffer:!1,resolveStencilBuffer:!1,colorSpace:Rt.workingColorSpace}));const r=v.state.transmissionRenderTarget[i.id],s=i.viewport||A;r.setSize(s.z,s.w);const o=y.getRenderTarget();y.setRenderTarget(r),y.getClearColor(C),D=y.getClearAlpha(),D<1&&y.setClearColor(16777215,.5),y.clear(),ne&&Me.render(n);const l=y.toneMapping;y.toneMapping=0;const c=i.viewport;if(void 0!==i.viewport&&(i.viewport=void 0),v.setupLightsView(i),!0===H&&we.setGlobalState(y.clippingPlanes,i),Ze(e,n,i),ue.updateMultisampleRenderTarget(r),ue.updateRenderTargetMipmap(r),!1===ae.has("WEBGL_multisampled_render_to_texture")){let e=!1;for(let r=0,a=t.length;r0)for(let t=0,a=n.length;t0&&qe(i,r,e,t),ne&&Me.render(e),Ye(g,e,t);null!==M&&(ue.updateMultisampleRenderTarget(M),ue.updateRenderTargetMipmap(M)),!0===e.isScene&&e.onAfterRender(y,e,t),Re.resetDefaultState(),T=-1,E=null,x.pop(),x.length>0?(v=x[x.length-1],!0===H&&we.setGlobalState(y.clippingPlanes,v.state.camera)):v=null,_.pop(),g=_.length>0?_[_.length-1]:null},this.getActiveCubeFace=function(){return w},this.getActiveMipmapLevel=function(){return b},this.getRenderTarget=function(){return M},this.setRenderTargetTextures=function(e,t,n){de.get(e.texture).__webglTexture=t,de.get(e.depthTexture).__webglTexture=n;const i=de.get(e);i.__hasExternalTextures=!0,i.__autoAllocateDepthBuffer=void 0===n,i.__autoAllocateDepthBuffer||!0===ae.has("WEBGL_multisampled_render_to_texture")&&(console.warn("THREE.WebGLRenderer: Render-to-texture extension was disabled because an external texture was provided"),i.__useRenderToTexture=!1)},this.setRenderTargetFramebuffer=function(e,t){const n=de.get(e);n.__webglFramebuffer=t,n.__useDefaultFramebuffer=void 0===t},this.setRenderTarget=function(e,t=0,n=0){M=e,w=t,b=n;let i=!0,r=null,a=!1,s=!1;if(e){const o=de.get(e);if(void 0!==o.__useDefaultFramebuffer)ce.bindFramebuffer(De.FRAMEBUFFER,null),i=!1;else if(void 0===o.__webglFramebuffer)ue.setupRenderTarget(e);else if(o.__hasExternalTextures)ue.rebindTextures(e,de.get(e.texture).__webglTexture,de.get(e.depthTexture).__webglTexture);else if(e.depthBuffer){const t=e.depthTexture;if(o.__boundDepthTexture!==t){if(null!==t&&de.has(t)&&(e.width!==t.image.width||e.height!==t.image.height))throw new Error("WebGLRenderTarget: Attached DepthTexture is initialized to the incorrect size.");ue.setupDepthRenderbuffer(e)}}const l=e.texture;(l.isData3DTexture||l.isDataArrayTexture||l.isCompressedArrayTexture)&&(s=!0);const c=de.get(e).__webglFramebuffer;e.isWebGLCubeRenderTarget?(r=Array.isArray(c[t])?c[t][n]:c[t],a=!0):r=e.samples>0&&!1===ue.useMultisampledRTT(e)?de.get(e).__webglMultisampledFramebuffer:Array.isArray(c)?c[n]:c,A.copy(e.viewport),P.copy(e.scissor),R=e.scissorTest}else A.copy(F).multiplyScalar(U).floor(),P.copy(B).multiplyScalar(U).floor(),R=z;if(ce.bindFramebuffer(De.FRAMEBUFFER,r)&&i&&ce.drawBuffers(e,r),ce.viewport(A),ce.scissor(P),ce.setScissorTest(R),a){const i=de.get(e.texture);De.framebufferTexture2D(De.FRAMEBUFFER,De.COLOR_ATTACHMENT0,De.TEXTURE_CUBE_MAP_POSITIVE_X+t,i.__webglTexture,n)}else if(s){const i=de.get(e.texture),r=t||0;De.framebufferTextureLayer(De.FRAMEBUFFER,De.COLOR_ATTACHMENT0,i.__webglTexture,n||0,r)}T=-1},this.readRenderTargetPixels=function(e,t,n,i,r,a,s){if(!e||!e.isWebGLRenderTarget)return void console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");let o=de.get(e).__webglFramebuffer;if(e.isWebGLCubeRenderTarget&&void 0!==s&&(o=o[s]),o){ce.bindFramebuffer(De.FRAMEBUFFER,o);try{const s=e.texture,o=s.format,l=s.type;if(!le.textureFormatReadable(o))return void console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in RGBA or implementation defined format.");if(!le.textureTypeReadable(l))return void console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in UnsignedByteType or implementation defined type.");t>=0&&t<=e.width-i&&n>=0&&n<=e.height-r&&De.readPixels(t,n,i,r,Pe.convert(o),Pe.convert(l),a)}finally{const e=null!==M?de.get(M).__webglFramebuffer:null;ce.bindFramebuffer(De.FRAMEBUFFER,e)}}},this.readRenderTargetPixelsAsync=async function(e,t,n,i,r,a,s){if(!e||!e.isWebGLRenderTarget)throw new Error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");let o=de.get(e).__webglFramebuffer;if(e.isWebGLCubeRenderTarget&&void 0!==s&&(o=o[s]),o){const s=e.texture,l=s.format,c=s.type;if(!le.textureFormatReadable(l))throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in RGBA or implementation defined format.");if(!le.textureTypeReadable(c))throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in UnsignedByteType or implementation defined type.");if(t>=0&&t<=e.width-i&&n>=0&&n<=e.height-r){ce.bindFramebuffer(De.FRAMEBUFFER,o);const e=De.createBuffer();De.bindBuffer(De.PIXEL_PACK_BUFFER,e),De.bufferData(De.PIXEL_PACK_BUFFER,a.byteLength,De.STREAM_READ),De.readPixels(t,n,i,r,Pe.convert(l),Pe.convert(c),0);const s=null!==M?de.get(M).__webglFramebuffer:null;ce.bindFramebuffer(De.FRAMEBUFFER,s);const h=De.fenceSync(De.SYNC_GPU_COMMANDS_COMPLETE,0);return De.flush(),await function(e,t){return new Promise((function(n,i){setTimeout((function r(){switch(e.clientWaitSync(t,e.SYNC_FLUSH_COMMANDS_BIT,0)){case e.WAIT_FAILED:i();break;case e.TIMEOUT_EXPIRED:setTimeout(r,4);break;default:n()}}),4)}))}(De,h),De.bindBuffer(De.PIXEL_PACK_BUFFER,e),De.getBufferSubData(De.PIXEL_PACK_BUFFER,0,a),De.deleteBuffer(e),De.deleteSync(h),a}throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: requested read bounds are out of range.")}},this.copyFramebufferToTexture=function(e,t=null,n=0){!0!==e.isTexture&&(Tt("WebGLRenderer: copyFramebufferToTexture function signature has changed."),t=arguments[0]||null,e=arguments[1]);const i=Math.pow(2,-n),r=Math.floor(e.image.width*i),a=Math.floor(e.image.height*i),s=null!==t?t.x:0,o=null!==t?t.y:0;ue.setTexture2D(e,0),De.copyTexSubImage2D(De.TEXTURE_2D,n,0,0,s,o,r,a),ce.unbindTexture()};const et=De.createFramebuffer(),tt=De.createFramebuffer();this.copyTextureToTexture=function(e,t,n=null,i=null,r=0,a=null){let s,o,l,c,h,d,u,p,f;!0!==e.isTexture&&(Tt("WebGLRenderer: copyTextureToTexture function signature has changed."),i=arguments[0]||null,e=arguments[1],t=arguments[2],a=arguments[3]||0,n=null),null===a&&(0!==r?(Tt("WebGLRenderer: copyTextureToTexture function signature has changed to support src and dst mipmap levels."),a=r,r=0):a=0);const m=e.isCompressedTexture?e.mipmaps[a]:e.image;if(null!==n)s=n.max.x-n.min.x,o=n.max.y-n.min.y,l=n.isBox3?n.max.z-n.min.z:1,c=n.min.x,h=n.min.y,d=n.isBox3?n.min.z:0;else{const t=Math.pow(2,-r);s=Math.floor(m.width*t),o=Math.floor(m.height*t),l=e.isDataArrayTexture?m.depth:e.isData3DTexture?Math.floor(m.depth*t):1,c=0,h=0,d=0}null!==i?(u=i.x,p=i.y,f=i.z):(u=0,p=0,f=0);const g=Pe.convert(t.format),v=Pe.convert(t.type);let _;t.isData3DTexture?(ue.setTexture3D(t,0),_=De.TEXTURE_3D):t.isDataArrayTexture||t.isCompressedArrayTexture?(ue.setTexture2DArray(t,0),_=De.TEXTURE_2D_ARRAY):(ue.setTexture2D(t,0),_=De.TEXTURE_2D),De.pixelStorei(De.UNPACK_FLIP_Y_WEBGL,t.flipY),De.pixelStorei(De.UNPACK_PREMULTIPLY_ALPHA_WEBGL,t.premultiplyAlpha),De.pixelStorei(De.UNPACK_ALIGNMENT,t.unpackAlignment);const x=De.getParameter(De.UNPACK_ROW_LENGTH),y=De.getParameter(De.UNPACK_IMAGE_HEIGHT),S=De.getParameter(De.UNPACK_SKIP_PIXELS),w=De.getParameter(De.UNPACK_SKIP_ROWS),b=De.getParameter(De.UNPACK_SKIP_IMAGES);De.pixelStorei(De.UNPACK_ROW_LENGTH,m.width),De.pixelStorei(De.UNPACK_IMAGE_HEIGHT,m.height),De.pixelStorei(De.UNPACK_SKIP_PIXELS,c),De.pixelStorei(De.UNPACK_SKIP_ROWS,h),De.pixelStorei(De.UNPACK_SKIP_IMAGES,d);const M=e.isDataArrayTexture||e.isData3DTexture,T=t.isDataArrayTexture||t.isData3DTexture;if(e.isDepthTexture){const n=de.get(e),i=de.get(t),m=de.get(n.__renderTarget),g=de.get(i.__renderTarget);ce.bindFramebuffer(De.READ_FRAMEBUFFER,m.__webglFramebuffer),ce.bindFramebuffer(De.DRAW_FRAMEBUFFER,g.__webglFramebuffer);for(let n=0;n=-1&&im.z<=1&&!0===e.layers.test(i.layers),c=e.element;c.style.display=!0===l?"":"none",!0===l&&(e.onBeforeRender(t,n,i),c.style.transform="translate("+-100*e.center.x+"%,"+-100*e.center.y+"%)translate("+(im.x*r+r)+"px,"+(-im.y*a+a)+"px)",c.parentNode!==o&&o.appendChild(c),e.onAfterRender(t,n,i));const u={distanceToCameraSquared:(h=i,d=e,sm.setFromMatrixPosition(h.matrixWorld),om.setFromMatrixPosition(d.matrixWorld),sm.distanceToSquared(om))};s.objects.set(e,u)}for(let t=0,r=e.children.length;t{const t=new Uint8Array(1048576);for(let e=0;e{this.skyEnvironment.changeVisibility(!1),this.backgroundEnvironment.hideBackground(),this.showEnvironment=!0},r=e.toLowerCase();if(r.endsWith(".exr"))this.environmentLoader.loadExr(e,t,!0),n();else if(r.endsWith(".hdr"))this.environmentLoader.loadHdr(e,t,!0),n();else if(r.endsWith(".envmap"))this.environmentLoader.loadEnvmap(e,t,!0),n();else if(r.endsWith(".glb")||r.endsWith(".gltf")){i(e,null);const n=yield this.loadGLTF(t);i(e,n)}}catch(e){console.log(e)}}))}createControls(){var e;null!==(e=this.controls)&&void 0!==e||(this.controls=new Up(this.renderer,this.camera))}changeLightControls(e){var t;e&&!this.transformControls&&(this.transformControls=null===(t=this.controls)||void 0===t?void 0:t.addTransformControl(this.lightSources.getLightSources()[0],this.scene)),this.transformControls&&(this.transformControls.getHelper().visible=e)}setEnvironment(){this.environmentLoader.loadDefaultEnvironment(!0,(()=>new pm({type:dm})),"room environment"),this.environmentLoader.loadDefaultEnvironment(!1,(()=>new pm({type:um})),"front light environment"),this.environmentLoader.loadEnvmap("test64.envmap",wm,!1)}updateSceneDependencies(){this.sceneRenderer.bakedGroundContactShadowPass.needsUpdate=!0,this.updateBounds()}updateBounds(){this.sceneRenderer.updateBounds(this.sceneBounds,this.scaleShadowAndAo)}setGroundMaterial(e){this.groundMaterialType!==e&&(this.groundMaterialType=e,this.updateGround(void 0,Fo(this.groundMaterialType)),this.sceneRenderer.clearCache())}updateGround(e,t){this.groundMesh||(this.groundMesh=new Yi,this.groundMesh.name="groundMesh",this.groundMesh.userData.isFloor=!0,this.groundMesh.receiveShadow=!0,this.sceneRenderer.groundGroup.add(this.groundMesh)),e&&(this.groundMesh.geometry=e),t&&(t.depthWrite=!1,t.polygonOffset=!0,t.polygonOffsetFactor=4,t.polygonOffsetUnits=4,t.needsUpdate=!0,this.groundMesh.material=t,this.groundMesh.userData.isFloor=!0)}update(e,t,n){t&&this.setNewTurntableGroup(t,null!=n&&n),e&&this.properties.rotate!==(null==e?void 0:e.rotate)&&(this.properties.rotate=null==e?void 0:e.rotate,0===this.properties.rotate&&(this.turnTableGroup.rotation.y=0)),e&&this.properties.dimensions!==(null==e?void 0:e.dimensions)&&(this.properties.dimensions=null==e?void 0:e.dimensions,this.updateDimensions()),e&&this.properties.randomOrientation!==(null==e?void 0:e.randomOrientation)&&(this.properties.randomOrientation=null==e?void 0:e.randomOrientation)}updateDimensions(){if(this.properties.dimensions){if(0===this.dimensioningArrows.length)for(let e=0;e<3;++e){const e=new lm(new jt,new jt,{color:0,arrowPixelWidth:10,arrowPixelHeight:15,shaftPixelWidth:3,shaftPixelOffset:1,labelClass:"label",deviceRatio:window.devicePixelRatio});this.dimensioningArrows.push(e),this.dimensioningArrowScene.add(e)}const e=this.sceneRenderer.boundingVolume.bounds,t=this.sceneRenderer.boundingVolume.size,n=.2*Math.min(t.x,t.y,t.z);this.dimensioningArrows[0].setPosition(new jt(e.min.x,e.min.y,e.max.z+n),new jt(e.max.x,e.min.y,e.max.z+n)),this.dimensioningArrows[1].setPosition(new jt(e.min.x-n,e.min.y,e.max.z+n),new jt(e.min.x-n,e.max.y,e.max.z+n)),this.dimensioningArrows[2].setPosition(new jt(e.min.x-n,e.min.y,e.max.z),new jt(e.min.x-n,e.min.y,e.min.z))}else this.dimensioningArrows.forEach((e=>e.setLabel("")))}collectMaterials(){const e=[];return this.scene.traverse((t=>{if(t instanceof Yi&&t.name.length>0){const n=t.material;n&&e.push({materialId:t.name,material:n})}else if(t instanceof Yi&&t.material.name.length>0){const n=t.material;if(n){const i=t.material.name;-1===e.findIndex((e=>e.materialId===i))&&e.push({materialId:i,material:n})}}})),e}updateMaterialProperties(e,t){this.properties.materialNoise!==e.materialNoise&&(this.properties.materialNoise=e.materialNoise,t.forEach((e=>{const t=e.material;t.userData&&"ormMap"in t.userData||(t.roughnessMap=this.properties.materialNoise?this.noiseTexture:null,t.metalnessMap=this.properties.materialNoise?this.noiseTexture:null,t.needsUpdate=!0)})))}resize(e,t){var n;this.camera.aspect=e/t,this.camera.updateProjectionMatrix(),this.renderer.setSize(e,t),this.sceneRenderer.setSize(e,t),null===(n=this.css2Renderer)||void 0===n||n.setSize(e,t)}animate(e){this.properties.rotate>0&&(this.turnTableGroup.rotation.y+=2*Math.PI*e*.001*this.properties.rotate)}prepareRender(e){var t,n;const i=this.environmentLoader.setEnvironment(this.scene,{showEnvironment:this.showEnvironment,environmentRotation:this.environmentRotation,environmentIntensity:this.environmentIntensity});if(i){null===(t=this.groundProjectionSkybox)||void 0===t||t.removeFromParent(),this.groundProjectionSkybox=null;const e=null===(n=this.environmentLoader.currentEnvironment)||void 0===n?void 0:n.equirectangularTexture;this.scene.userData.shadowFromEnvironment=!0,e&&(this.lightSources.currentLightSourceDefinition=no.noLightSources,this.lightSources.updateLightSources(),this.createGroundProjectionSkybox&&(this.groundProjectionSkybox=new Sm(e,1.5,10),this.groundProjectionSkybox.scale.setScalar(this.groundProjectionSkyboxDistance),this.groundProjectionSkybox.name="skybox",this.scene.add(this.groundProjectionSkybox)))}const r=this.createGroundProjectionSkybox&&this.groundProjectionSkybox?2*this.groundProjectionSkyboxDistance:void 0;if(this.sceneRenderer.updateNearAndFarPlaneOfPerspectiveCamera(this.camera,r),i&&this.updateSceneDependencies(),this.sceneRenderer.outlineRenderer.parameters.enabled){this.raycaster.setFromCamera(e,this.camera);const t=this.raycaster.intersectObject(this.turnTableGroup,!0),n=t.length>0?t[0].object:void 0;this.sceneRenderer.selectObjects(n?[n]:[])}}render(e=!0){var t,n;e&&(null===(t=this.controls)||void 0===t||t.update()),this.backgroundEnvironment.update(this.sceneRenderer.width,this.sceneRenderer.height,this.camera),this.sceneRenderer.render(this.scene,this.camera),this.properties.dimensions&&(this.dimensioningArrows.forEach((e=>{e.arrowNeedsUpdate=!0})),this.renderer.autoClear=!1,this.renderer.render(this.dimensioningArrowScene,this.camera),null===(n=this.css2Renderer)||void 0===n||n.render(this.dimensioningArrowScene,this.camera),this.renderer.autoClear=!0)}loadGLTF(e){return bm(this,void 0,void 0,(function*(){const t=new kd;t.setDRACOLoader(this.dracoLoader);const n=yield t.loadAsync(e);return this.updateGLTFScene(n,(e=>{if(e.isMesh){const t=e.material;t instanceof Fa&&!1===t.transparent&&(e.castShadow=!0,e.receiveShadow=!0)}})),this.setNewTurntableGroup(n.scene,!0),n.scene}))}updateGLTFScene(e,t){e.scene.traverse((e=>{e instanceof Yi&&(t(e),e.material instanceof Fa&&(e.material.envMapIntensity=1,e.material.needsUpdate=!0))}))}setNewTurntableGroup(e,t){this.turnTableGroup.clear(),this.scaleShadowAndAo=t,this.setInitialObjectPosition(e),this.setInitialCameraPositionAndRotation(),this.sceneRenderer.environmentLights||this.lightSources.setLightSourcesDistances(this.sceneRenderer.boundingVolume,t),this.sceneRenderer.forceShadowUpdates(!0),this.updateSceneDependencies()}setInitialObjectPosition(e){e.updateMatrixWorld(),this.sceneBounds.setFromObject(e);const t=this.sceneBounds.getSize(new jt),n=this.sceneBounds.getCenter(new jt);e.applyMatrix4((new wn).makeTranslation(-n.x,-this.sceneBounds.min.y,-n.z)),this.sceneBounds.translate(new jt(-n.x,-this.sceneBounds.min.y-t.y/2,-n.z));const i=-t.y/2;this.turnTableGroup.position.y=i,this.turnTableGroup.add(e),this.turnTableGroup.updateMatrixWorld(),this.sceneRenderer.groundLevel=i}setInitialCameraPositionAndRotation(){const e=new jt(-1.5,.8,2.5).normalize();if(this.properties.randomOrientation){const t=4*Math.random()-2,n=.8*Math.random()+.4;e.set(t,n,2.5).normalize()}this.camera.position.copy(e),this.camera.lookAt(new jt(0,0,0)),this.camera.updateMatrixWorld();const t=(new qt).setFromObject(this.turnTableGroup).applyMatrix4(this.camera.matrixWorldInverse),n=this.camera.fov*Math.PI/180/2,i=this.camera.aspect,r=Math.max(-t.min.x/i,t.max.x/i,-t.min.y,t.max.y)/Math.tan(n)+t.max.z+1;this.camera.position.copy(e.multiplyScalar(r)),this.camera.lookAt(new jt(0,0,0)),this.camera.updateMatrixWorld()}constructLoadingGeometry(e){let t=[];if(1===e){const e=[];for(let t=0;t<=230;t+=15){const n=t*Math.PI/180;e.push({x:-Math.cos(n),y:Math.sin(n)+1})}e.push({x:0,y:0});for(let t=60;t>=-180;t-=15){const n=t*Math.PI/180;e.push({x:-Math.cos(n),y:Math.sin(n)-1})}const n=.6,i=2.5*n,r=new Sa(e.map((e=>new jt(e.x,e.y+2+i,0)))),a=new Oa(r,64,n,16,!1),s=new Ia(n,32,16);s.translate(-1,3+i,0);const o=new Ia(n,32,16);o.translate(1,1+i,0);const l=new Ia(n,32,16),c=new Ba({color:14352384,side:2});t=[{geometry:a,material:c,materialId:"",environment:!1},{geometry:s,material:c,materialId:"",environment:!1},{geometry:o,material:c,materialId:"",environment:!1},{geometry:l,material:c,materialId:"",environment:!1}]}else{const e=(()=>{const e=new Fa({side:2});return To((t=>e.map=t),Do,new fi(.859,0,0)),e})();t=[{geometry:new Zi,material:e,materialId:"",environment:!1}]}return(e=>{const t=new ua;return e.forEach((e=>{const n=new Yi(e.geometry,e.material);e.transform&&n.applyMatrix4(e.transform),n.castShadow=!e.environment,n.receiveShadow=!0,t.add(n)})),t})(t)}}(Hg,Vg);jg.dracoLoader.setDecoderPath("./draco/"),jg.dracoLoader.setDecoderConfig({type:"js"}),jg.sceneRenderer.setQualityLevel(Qf),jg.createControls(),jg.setEnvironment(),jg.updateSceneDependencies(),zg();const Xg=new Lg,Yg=Object.assign({},...t.map((e=>({[e.name]:e.url})))),qg=Xg.add(Wg,"glb",Yg).onChange((e=>{if(""!==e){const n=t.findIndex((t=>t.url===e)),i=n>=0?t[n].name:e;Bg(i,e)}}));Xg.add(Wg,"randomOrientation").onChange((()=>jg.update(Wg))),Xg.add(Wg,"dimensions").onChange((()=>jg.update(Wg))),Xg.add(Wg,"groundMaterial",{shadow:"onlyshadow",parquet:"parquet",pavement:"pavement"}).onChange((()=>zg()));const Zg=Xg.addFolder("environment"),Kg=Zg.add(jg,"showEnvironment").onChange((e=>{e&&(Qg.hideSky(),ev.hideBackground())}));Zg.add(jg,"environmentRotation",0,2*Math.PI,.01).onChange((e=>{var t;(null===(t=jg.scene.userData)||void 0===t?void 0:t.environmentDefinition)&&(jg.scene.userData.environmentDefinition.rotation=e)})),Zg.add(jg,"environmentIntensity",0,5,.01).onChange((e=>{var t;(null===(t=jg.scene.userData)||void 0===t?void 0:t.environmentDefinition)&&(jg.scene.userData.environmentDefinition.intensity=e)}));const Jg=Zg.addFolder("sky"),Qg=new class{constructor(e){this.skyEnvironment=e}hideSky(){var e,t;null===(e=this.showSkyController)||void 0===e||e.setValue(!1),null===(t=this.showSkyController)||void 0===t||t.updateDisplay()}addGUI(e,t){this.showSkyController=e.add(this.skyEnvironment.parameters,"visible").onChange((()=>{this.skyEnvironment.updateSky(),t&&t(this.skyEnvironment)}))}}(jg.skyEnvironment);Qg.addGUI(Jg,(e=>{e.parameters.visible&&(Kg.setValue(!1),Kg.updateDisplay(),ev.hideBackground())}));const $g=Zg.addFolder("background"),ev=new class{constructor(e){this._backgroundEnvironment=e}hideBackground(){var e,t;null===(e=this._backgroundTypeController)||void 0===e||e.setValue("None"),null===(t=this._backgroundTypeController)||void 0===t||t.updateDisplay()}addGUI(e,t){const n={backgroundType:""},i=new Map([["None",xd],["Grid Paper",yd],["Concrete",Sd],["Marble",wd],["Granite",bd],["Vorocracks Marble",Md],["Kraft",Td],["Line (slow)",Ed],["Test",Ad]]),r=[];i.forEach(((e,t)=>{r.push(t),this._backgroundEnvironment.parameters.backgroundType===e&&(n.backgroundType=t)})),e.add(n,"backgroundType",r).onChange((e=>{var n;i.has(e)&&(this._backgroundEnvironment.parameters.backgroundType=null!==(n=i.get(e))&&void 0!==n?n:xd,this._backgroundEnvironment.updateBackground(),t&&t(this._backgroundEnvironment))}))}}(jg.backgroundEnvironment);ev.addGUI($g,(e=>{e.parameters.isSet&&(Kg.setValue(!1),Kg.updateDisplay(),Qg.hideSky())})),jg.environmentLoader.addGUI(Zg);const tv=new class{constructor(e){this._qualityLevel="",this._ambientOcclusionType="",this._sceneRenderer=e}addGUI(e,t){this._addRepresentationalGUI(e,t),this._addDebugGUI(e,t);const n=e.addFolder("Shadow type");this._addShadowTypeGUI(n,t);const i=e.addFolder("Shadow and Ambient Occlusion");this._addShadowAndAoGUI(i,t);const r=e.addFolder("Ground Reflection");this._addGroundReflectionGUI(r,t);const a=e.addFolder("Baked Ground Contact Shadow");this._addBakedGroundContactShadowGUI(a,t);const s=e.addFolder("Outline");this._addOutlineGUI(s,t)}_addRepresentationalGUI(e,t){const n=new Map([["LinearSRGBColorSpace",We],["SRGBColorSpace",Ge]]),i=[];n.forEach(((e,t)=>{i.push(t),this._sceneRenderer.renderer.outputColorSpace===e&&(this._sceneRenderer.outputColorSpace=t)})),e.add(this._sceneRenderer,"outputColorSpace",i).onChange((e=>{var i;n.has(e)&&(this._sceneRenderer.renderer.outputColorSpace=null!==(i=n.get(e))&&void 0!==i?i:Ge,t())}));const r=new Map([["NoToneMapping",0],["LinearToneMapping",1],["ReinhardToneMapping",2],["CineonToneMapping",3],["ACESFilmicToneMapping",4]]),a=[];r.forEach(((e,t)=>{a.push(t),this._sceneRenderer.renderer.toneMapping===e&&(this._sceneRenderer.toneMapping=t)})),e.add(this._sceneRenderer,"toneMapping",a).onChange((e=>{var n;r.has(e)&&(this._sceneRenderer.renderer.toneMapping=null!==(n=r.get(e))&&void 0!==n?n:0,t())}))}_addDebugGUI(e,t){const n=new Map([["HIGHEST",Qf],["HIGH",$f],["MEDIUM",em],["LOW","low"]]),i=[];n.forEach(((e,t)=>i.push(t))),e.add(this,"_qualityLevel",i).onChange((e=>{var t;n.has(e)&&this._sceneRenderer.setQualityLevel(null!==(t=n.get(e))&&void 0!==t?t:Qf)})),e.add(this._sceneRenderer,"debugOutput",{"off ":"off","grayscale (no textures)":"grayscale","color buffer":"color","linear depth":"lineardepth","g-buffer normal vector":"g-normal","g-buffer depth":"g-depth","AO pure":"ssao","AO denoised":"ssaodenoise","shadow map":"shadowmap","shadow soft":"shadowsoft","shadow denoised":"shadowdenoise","shadow fade in":"shadowfadein","shadow and AO":"shadowandao","shadow and AO depth":"shadowandaodepth","material AO pass":"materialao","ground reflection base":"groundreflection","ground reflection final":"groundreflectionfinal","baked ground shadow":"bakedgroundshadow","selection outline":"outline","environment map":"environmentmap","light source detection":"lightsourcedetection"}).onChange((()=>t()))}_addShadowTypeGUI(e,t){const n=this._sceneRenderer.screenSpaceShadowMapPass.shadowConfiguration,i=[];n.types.forEach(((e,t)=>{i.push(t)}));const r=()=>{this._sceneRenderer.screenSpaceShadowMapPass.needsUpdate=!0,this._sceneRenderer.screenSpaceShadowMapPass.shadowTypeNeedsUpdate=!0,this._sceneRenderer.shadowAndAoPass.needsUpdate=!0,t()};e.add(n,"shadowType",i).onChange((e=>{this._sceneRenderer.screenSpaceShadowMapPass.switchType(e)&&(a.object=n.currentConfiguration,s.object=n.currentConfiguration,o.object=n.currentConfiguration,a.updateDisplay(),s.updateDisplay(),o.updateDisplay(),r())}));const a=e.add(n.currentConfiguration,"bias",-.001,.001,1e-5).onChange((()=>r())),s=e.add(n.currentConfiguration,"normalBias",-.05,.05).onChange((()=>r())),o=e.add(n.currentConfiguration,"radius",0,100).onChange((()=>r()))}_addShadowAndAoGUI(e,t){const n=()=>{this._sceneRenderer.requestUpdateOfPasses(),t()},i=this._sceneRenderer.shadowAndAoPass.parameters,r=i.shadow,a=this._sceneRenderer.screenSpaceShadowMapPass.parameters,s=i.ao,o=i.poissonDenoise;e.add(i,"enabled").onChange((()=>n())),e.add(i,"applyToMaterial").onChange((()=>{n(),this._sceneRenderer.clearCache()}));const l=new Map([["none",null],["SSAO",0],["SAO",1],["N8AO",2],["HBAO",3],["GTAO",4]]),c=Array.from(l.keys());l.forEach(((e,t)=>{e===s.algorithm&&(this._ambientOcclusionType=t)})),e.add(i,"aoIntensity",0,1).onChange((()=>{n()})),e.add(i,"aoOnGround").onChange((()=>{n(),this._sceneRenderer.clearCache()})),e.add(i,"shadowOnGround").onChange((()=>{n(),this._sceneRenderer.clearCache()})),e.add(i,"shadowIntensity",0,1).onChange((()=>n())),e.add(i,"alwaysUpdate").onChange((()=>n())),e.add(i,"progressiveDenoiseIterations",0,3,1).onChange((()=>n()));const h=e.addFolder("Environment Shadow");h.add(a,"maximumNumberOfLightSources",-1,10,1).onChange((()=>n())),h.add(a,"enableGroundBoundary").onChange((()=>n())),h.add(a,"directionalDependency",0,1,.01).onChange((()=>n())),h.add(a,"directionalExponent",0,2,.01).onChange((()=>n())),h.add(a,"groundBoundary",0,1,.01).onChange((()=>n())),h.add(a,"fadeOutDistance",0,5,.01).onChange((()=>n())),h.add(a,"fadeOutBlur",0,20,1).onChange((()=>n())),h.add(r,"shadowRadius",.001,.5).onChange((()=>n()));const d=e.addFolder("AO");d.add(this,"_ambientOcclusionType",c).onChange((e=>{if(l.has(e)){const t=l.get(e);s.algorithm=void 0!==t?t:0,n()}})),d.add(s,"samples",1,64,1).onChange((()=>n())),d.add(s,"radius",.01,2,.01).onChange((()=>n())),d.add(s,"distanceExponent",.1,4,.1).onChange((()=>n())),d.add(s,"thickness",.01,2,.01).onChange((()=>n())),d.add(s,"distanceFallOff",0,1).onChange((()=>n())),d.add(s,"scale",.01,2,.01).onChange((()=>n())),d.add(s,"bias",1e-4,.01,1e-4).onChange((()=>n())),d.add(s,"screenSpaceRadius").onChange((()=>n()));const u=e.addFolder("Possion Denoise");u.add(o,"iterations",0,4,1).onChange((()=>n())),u.add(o,"samples",0,32,1).onChange((()=>n())),u.add(o,"rings",0,16,.125).onChange((()=>n())),u.add(o,"radiusExponent",.1,4,.01).onChange((()=>n())),u.add(o,"radius",0,50,1).onChange((()=>n())),u.add(o,"depthPhi",0,20,.001).onChange((()=>n())),u.add(o,"normalPhi",0,20,.001).onChange((()=>n()))}_addGroundReflectionGUI(e,t){const n=this._sceneRenderer.parameters.groundReflectionParameters;e.add(n,"enabled"),e.add(n,"intensity",0,1).onChange((()=>t())),e.add(n,"fadeOutDistance",0,4).onChange((()=>t())),e.add(n,"fadeOutExponent",.1,10).onChange((()=>t())),e.add(n,"brightness",0,2).onChange((()=>t())),e.add(n,"blurHorizontal",0,10).onChange((()=>t())),e.add(n,"blurVertical",0,10).onChange((()=>t()))}_addBakedGroundContactShadowGUI(e,t){const n=()=>{this._sceneRenderer.bakedGroundContactShadowPass.applyParameters(),t()},i=this._sceneRenderer.parameters.bakedGroundContactShadowParameters;e.add(i,"enabled").onChange((()=>n())),e.add(i,"cameraHelper").onChange((()=>n())),e.add(i,"alwaysUpdate"),e.add(i,"fadeIn"),e.add(i,"blurMin",0,.2,.001).onChange((()=>n())),e.add(i,"blurMax",0,.5,.01).onChange((()=>n())),e.add(i,"fadeoutFalloff",0,1,.01).onChange((()=>n())),e.add(i,"fadeoutBias",0,.5).onChange((()=>n())),e.add(i,"opacity",0,1,.01).onChange((()=>n())),e.add(i,"maximumPlaneSize",0,50,1).onChange((()=>n())),e.add(i,"cameraFar",.1,10,.1).onChange((()=>n()))}_addOutlineGUI(e,t){const n=()=>{this._sceneRenderer.outlineRenderer.applyParameters(),t()},i=this._sceneRenderer.outlineRenderer.parameters;e.add(i,"enabled"),e.add(i,"edgeStrength",.5,20).onChange((()=>n())),e.add(i,"edgeGlow",0,20).onChange((()=>n())),e.add(i,"edgeThickness",.5,20).onChange((()=>n())),e.add(i,"pulsePeriod",0,5).onChange((()=>n())),e.addColor(i,"visibleEdgeColor").onChange((()=>n())),e.addColor(i,"hiddenEdgeColor").onChange((()=>n()))}}(jg.sceneRenderer);tv.addGUI(Xg,(()=>{}));const nv=new Mm,iv=Xg.addFolder("Light"),rv=new class{constructor(e){this.lightColors=[],this.lightSourceFolders=[],this.lights="none",this.lightSources=e}addGUI(e,t,n){e.add(this.lightSources,"lightControls").onChange(t),e.add(this,"lights",["none","default","fife"]).onChange((e=>{switch(e){default:case"none":this.lightSources.currentLightSourceDefinition=no.noLightSources;break;case"default":this.lightSources.currentLightSourceDefinition=no.defaultLightSources;break;case"fife":this.lightSources.currentLightSourceDefinition=no.fifeLightSources}this.lightSources.updateLightSources(),this.updateGUI(),n()})),this.lightGUI=e,this.updateGUI()}updateGUI(){if(!this.lightGUI)return;const e=this.lightGUI;this.lightSourceFolders.forEach((t=>e.removeFolder(t))),this.lightSourceFolders=[],this.lightColors=[],this.lightSources.getLightSources().forEach((t=>{if(t instanceof Is){this.lightColors.push({color:t.color.getHex()});const n=e.addFolder("Ambient Light");this.lightSourceFolders.push(n),n.add(t,"visible"),n.add(t,"intensity").min(0).max(5).step(.1),n.addColor(this.lightColors[this.lightColors.length-1],"color").onChange((e=>t.color=new fi(e)))}})),this.lightSources.getLightSources().forEach((t=>{var n;if(t instanceof Ls){this.lightColors.push({color:t.color.getHex()});const n=e.addFolder("Directional Light "+(this.lightColors.length-1));this.lightSourceFolders.push(n),n.add(t,"visible"),n.add(t,"intensity").min(0).max(10).step(.1),n.add(t,"castShadow"),n.addColor(this.lightColors[this.lightColors.length-1],"color").onChange((e=>t.color=new fi(e)))}else if(t instanceof Us){this.lightColors.push({color:t.color.getHex()});const i=e.addFolder("Rect area Light "+(this.lightColors.length-1));this.lightSourceFolders.push(i);const r=null===(n=this.lightSources.sceneRenderer)||void 0===n?void 0:n.screenSpaceShadowMapPass.findShadowLightSource(t);i.add(t,"visible"),i.add(t,"intensity").min(0).max(200).step(1),r&&i.add(r,"castShadow"),i.addColor(this.lightColors[this.lightColors.length-1],"color").onChange((e=>t.color=new fi(e)))}}))}}(jg.getLightSources());rv.addGUI(iv,(()=>e=>jg.changeLightControls(e)),(()=>jg.updateSceneDependencies())),window.addEventListener("resize",(()=>{const e=window.innerWidth,t=window.innerHeight;jg.resize(e,t)}),!1);const av=new _t;Hg.domElement.addEventListener("pointermove",(e=>{!1!==e.isPrimary&&(av.x=e.clientX/window.innerWidth*2-1,av.y=-e.clientY/window.innerHeight*2+1)})),(()=>{const e=document.getElementById("holder");e&&(e.ondragover=function(){return this.className="hover",!1},e.ondragend=function(){return this.className="",!1},e.ondrop=function(e){this.className="",e.preventDefault();const t=e.dataTransfer.files[0],n=new FileReader;n.onload=e=>((e,t)=>{((e,t)=>{const n=Og[e];n?(Ng(`render ${e}`,"#ff0000"),jg.update(void 0,n.scene,n.glb),Fg(e)):jg.loadResource(e,t,(e=>{}),((t,n)=>{n?(Og[e]={scene:n,glb:!0},Fg(t),(e=>{Yg.push(e);let t="";Yg.forEach((e=>{t+=``})),qg.domElement.children[0].innerHTML=t,qg.setValue(e),qg.updateDisplay()})(e)):Ng(`load ${t}`,"#ff0000")}))})(e.name,t.target.result)})(t,e),n.readAsDataURL(t)})})();const sv=document.createElement("a"),ov=e=>{const t=Hg.domElement.toDataURL();sv.href=t,sv.download=e,sv.click()},lv=(e,t)=>{const n=jg.sceneRenderer.debugOutput;jg.sceneRenderer.debugOutput=e,jg.prepareRender(new _t),jg.render(!1),ov(t),jg.sceneRenderer.debugOutput=n},cv=document.getElementById("save-button");cv&&(cv.onclick=()=>(()=>{try{ov(Wg.sceneName+".png")}catch(e){console.log(e)}})());const hv=document.getElementById("save-g-buffer-button");let dv,uv;hv&&(hv.onclick=()=>(()=>{try{lv("color",Wg.sceneName+"_color.png"),lv("g-normal",Wg.sceneName+"_normal.png"),lv("g-depth",Wg.sceneName+"_depth.png")}catch(e){console.log(e)}})());const pv=e=>{void 0===dv&&(dv=e),void 0===uv&&(uv=e);const t=e-uv;uv=e,jg.animate(t),fv(),requestAnimationFrame(pv)},fv=()=>{jg.prepareRender(av),jg.render(),Gg.update()};(()=>{const e=t.findIndex((e=>"BrainStem"===e.name));if(e>=0){const n=t[e];Bg(n.name,n.url)}})(),requestAnimationFrame(pv)})(); \ No newline at end of file diff --git a/package-lock.json b/package-lock.json index 1e4b7e8..2c5658f 100644 --- a/package-lock.json +++ b/package-lock.json @@ -10,34 +10,34 @@ "hasInstallScript": true, "license": "ISC", "dependencies": { - "express": "^4.21.1", + "express": "^4.21.2", "lodash": "^4.17.21", - "three": "0.170.0" + "three": "0.171.0" }, "devDependencies": { "@types/dat.gui": "^0.7.13", "@types/express": "^5.0.0", - "@types/node": "^22.9.0", - "@types/three": "^0.169.0", - "@typescript-eslint/eslint-plugin": "8.13.0", - "@typescript-eslint/parser": "8.13.0", - "axios": "^1.7.7", + "@types/node": "^22.10.1", + "@types/three": "^0.170.0", + "@typescript-eslint/eslint-plugin": "8.17.0", + "@typescript-eslint/parser": "8.17.0", + "axios": "^1.7.9", "copy-webpack-plugin": "^12.0.2", "copyfiles": "^2.4.1", "dat.gui": "^0.7.9", - "eslint": "9.14.0", + "eslint": "9.16.0", "eslint-config-prettier": "9.1.0", "eslint-plugin-jest": "28.9.0", "eslint-plugin-node": "11.1.0", "eslint-plugin-prettier": "5.2.1", "install-peers": "^1.0.4", - "npm-check-updates": "^17.1.10", + "npm-check-updates": "^17.1.11", "patch-package": "^8.0.0", - "prettier": "3.3.3", + "prettier": "3.4.2", "raw-loader": "^4.0.2", "ts-loader": "^9.5.1", - "typescript": "^5.6.3", - "webpack": "^5.96.1", + "typescript": "^5.7.2", + "webpack": "^5.97.1", "webpack-cli": "^5.1.4", "webpack-dev-server": "^5.1.0", "webpack-merge": "^6.0.1" @@ -83,13 +83,13 @@ } }, "node_modules/@eslint/config-array": { - "version": "0.18.0", - "resolved": "https://registry.npmjs.org/@eslint/config-array/-/config-array-0.18.0.tgz", - "integrity": "sha512-fTxvnS1sRMu3+JjXwJG0j/i4RT9u4qJ+lqS/yCGap4lH4zZGzQ7tu+xZqQmcMZq5OBZDL4QRxQzRjkWcGt8IVw==", + "version": "0.19.1", + "resolved": "https://registry.npmjs.org/@eslint/config-array/-/config-array-0.19.1.tgz", + "integrity": "sha512-fo6Mtm5mWyKjA/Chy1BYTdn5mGJoDNjC7C64ug20ADsRDGrA85bN3uK3MaKbeRkRuuIEAR5N33Jr1pbm411/PA==", "dev": true, "license": "Apache-2.0", "dependencies": { - "@eslint/object-schema": "^2.1.4", + "@eslint/object-schema": "^2.1.5", "debug": "^4.3.1", "minimatch": "^3.1.2" }, @@ -122,19 +122,22 @@ } }, "node_modules/@eslint/core": { - "version": "0.7.0", - "resolved": "https://registry.npmjs.org/@eslint/core/-/core-0.7.0.tgz", - "integrity": "sha512-xp5Jirz5DyPYlPiKat8jaq0EmYvDXKKpzTbxXMpT9eqlRJkRKIz9AGMdlvYjih+im+QlhWrpvVjl8IPC/lHlUw==", + "version": "0.9.1", + "resolved": "https://registry.npmjs.org/@eslint/core/-/core-0.9.1.tgz", + "integrity": "sha512-GuUdqkyyzQI5RMIWkHhvTWLCyLo1jNK3vzkSyaExH5kHPDHcuL2VOpHjmMY+y3+NC69qAKToBqldTBgYeLSr9Q==", "dev": true, "license": "Apache-2.0", + "dependencies": { + "@types/json-schema": "^7.0.15" + }, "engines": { "node": "^18.18.0 || ^20.9.0 || >=21.1.0" } }, "node_modules/@eslint/eslintrc": { - "version": "3.1.0", - "resolved": "https://registry.npmjs.org/@eslint/eslintrc/-/eslintrc-3.1.0.tgz", - "integrity": "sha512-4Bfj15dVJdoy3RfZmmo86RK1Fwzn6SstsvK9JS+BaVKqC6QQQQyXekNaC+g+LKNgkQ+2VhGAzm6hO40AhMR3zQ==", + "version": "3.2.0", + "resolved": "https://registry.npmjs.org/@eslint/eslintrc/-/eslintrc-3.2.0.tgz", + "integrity": "sha512-grOjVNN8P3hjJn/eIETF1wwd12DdnwFDoyceUJLYYdkpbwq3nLi+4fqrTAONx7XDALqlL220wC/RHSC/QTI/0w==", "dev": true, "license": "MIT", "dependencies": { @@ -180,9 +183,9 @@ } }, "node_modules/@eslint/js": { - "version": "9.14.0", - "resolved": "https://registry.npmjs.org/@eslint/js/-/js-9.14.0.tgz", - "integrity": "sha512-pFoEtFWCPyDOl+C6Ift+wC7Ro89otjigCf5vcuWqWgqNSQbRrpjSvdeE6ofLz4dHmyxD5f7gIdGT4+p36L6Twg==", + "version": "9.16.0", + "resolved": "https://registry.npmjs.org/@eslint/js/-/js-9.16.0.tgz", + "integrity": "sha512-tw2HxzQkrbeuvyj1tG2Yqq+0H9wGoI2IMk4EOsQeX+vmd75FtJAzf+gTA69WF+baUKRYQ3x2kbLE08js5OsTVg==", "dev": true, "license": "MIT", "engines": { @@ -190,9 +193,9 @@ } }, "node_modules/@eslint/object-schema": { - "version": "2.1.4", - "resolved": "https://registry.npmjs.org/@eslint/object-schema/-/object-schema-2.1.4.tgz", - "integrity": "sha512-BsWiH1yFGjXXS2yvrf5LyuoSIIbPrGUWob917o+BTKuZ7qJdxX8aJLRxs1fS9n6r7vESrq1OUqb68dANcFXuQQ==", + "version": "2.1.5", + "resolved": "https://registry.npmjs.org/@eslint/object-schema/-/object-schema-2.1.5.tgz", + "integrity": "sha512-o0bhxnL89h5Bae5T318nFoFzGy+YE5i/gGkoPAgkmTVdRKTiv3p8JHevPiPaMwoloKfEiiaHlawCqaZMqRm+XQ==", "dev": true, "license": "Apache-2.0", "engines": { @@ -200,9 +203,9 @@ } }, "node_modules/@eslint/plugin-kit": { - "version": "0.2.2", - "resolved": "https://registry.npmjs.org/@eslint/plugin-kit/-/plugin-kit-0.2.2.tgz", - "integrity": "sha512-CXtq5nR4Su+2I47WPOlWud98Y5Lv8Kyxp2ukhgFx/eW6Blm18VXJO5WuQylPugRo8nbluoi6GvvxBLqHcvqUUw==", + "version": "0.2.4", + "resolved": "https://registry.npmjs.org/@eslint/plugin-kit/-/plugin-kit-0.2.4.tgz", + "integrity": "sha512-zSkKow6H5Kdm0ZUQUB2kV5JIXqoG0+uH5YADhaEHswm664N9Db8dXSi0nMJpacpMf+MyyglF1vnZohpEg5yUtg==", "dev": true, "license": "Apache-2.0", "dependencies": { @@ -569,9 +572,9 @@ } }, "node_modules/@types/express-serve-static-core": { - "version": "5.0.1", - "resolved": "https://registry.npmjs.org/@types/express-serve-static-core/-/express-serve-static-core-5.0.1.tgz", - "integrity": "sha512-CRICJIl0N5cXDONAdlTv5ShATZ4HEwk6kDDIW2/w9qOWKg+NU/5F8wYRWCrONad0/UKkloNSmmyN/wX4rtpbVA==", + "version": "5.0.2", + "resolved": "https://registry.npmjs.org/@types/express-serve-static-core/-/express-serve-static-core-5.0.2.tgz", + "integrity": "sha512-vluaspfvWEtE4vcSDlKRNer52DvOGrB2xv6diXy6UKyKW0lqZiWHGNApSyxOv+8DE5Z27IzVvE7hNkxg7EXIcg==", "dev": true, "license": "MIT", "dependencies": { @@ -613,13 +616,13 @@ "license": "MIT" }, "node_modules/@types/node": { - "version": "22.9.0", - "resolved": "https://registry.npmjs.org/@types/node/-/node-22.9.0.tgz", - "integrity": "sha512-vuyHg81vvWA1Z1ELfvLko2c8f34gyA0zaic0+Rllc5lbCnbSyuvb2Oxpm6TAUAC/2xZN3QGqxBNggD1nNR2AfQ==", + "version": "22.10.1", + "resolved": "https://registry.npmjs.org/@types/node/-/node-22.10.1.tgz", + "integrity": "sha512-qKgsUwfHZV2WCWLAnVP1JqnpE6Im6h3Y0+fYgMTasNQ7V++CBX5OT1as0g0f+OyubbFqhf6XVNIsmN4IIhEgGQ==", "dev": true, "license": "MIT", "dependencies": { - "undici-types": "~6.19.8" + "undici-types": "~6.20.0" } }, "node_modules/@types/node-forge": { @@ -704,9 +707,9 @@ "license": "MIT" }, "node_modules/@types/three": { - "version": "0.169.0", - "resolved": "https://registry.npmjs.org/@types/three/-/three-0.169.0.tgz", - "integrity": "sha512-oan7qCgJBt03wIaK+4xPWclYRPG9wzcg7Z2f5T8xYTNEF95kh0t0lklxLLYBDo7gQiGLYzE6iF4ta7nXF2bcsw==", + "version": "0.170.0", + "resolved": "https://registry.npmjs.org/@types/three/-/three-0.170.0.tgz", + "integrity": "sha512-CUm2uckq+zkCY7ZbFpviRttY+6f9fvwm6YqSqPfA5K22s9w7R4VnA3rzJse8kHVvuzLcTx+CjNCs2NYe0QFAyg==", "dev": true, "license": "MIT", "dependencies": { @@ -736,17 +739,17 @@ } }, "node_modules/@typescript-eslint/eslint-plugin": { - "version": "8.13.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/eslint-plugin/-/eslint-plugin-8.13.0.tgz", - "integrity": "sha512-nQtBLiZYMUPkclSeC3id+x4uVd1SGtHuElTxL++SfP47jR0zfkZBJHc+gL4qPsgTuypz0k8Y2GheaDYn6Gy3rg==", + "version": "8.17.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/eslint-plugin/-/eslint-plugin-8.17.0.tgz", + "integrity": "sha512-HU1KAdW3Tt8zQkdvNoIijfWDMvdSweFYm4hWh+KwhPstv+sCmWb89hCIP8msFm9N1R/ooh9honpSuvqKWlYy3w==", "dev": true, "license": "MIT", "dependencies": { "@eslint-community/regexpp": "^4.10.0", - "@typescript-eslint/scope-manager": "8.13.0", - "@typescript-eslint/type-utils": "8.13.0", - "@typescript-eslint/utils": "8.13.0", - "@typescript-eslint/visitor-keys": "8.13.0", + "@typescript-eslint/scope-manager": "8.17.0", + "@typescript-eslint/type-utils": "8.17.0", + "@typescript-eslint/utils": "8.17.0", + "@typescript-eslint/visitor-keys": "8.17.0", "graphemer": "^1.4.0", "ignore": "^5.3.1", "natural-compare": "^1.4.0", @@ -770,16 +773,16 @@ } }, "node_modules/@typescript-eslint/parser": { - "version": "8.13.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/parser/-/parser-8.13.0.tgz", - "integrity": "sha512-w0xp+xGg8u/nONcGw1UXAr6cjCPU1w0XVyBs6Zqaj5eLmxkKQAByTdV/uGgNN5tVvN/kKpoQlP2cL7R+ajZZIQ==", + "version": "8.17.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/parser/-/parser-8.17.0.tgz", + "integrity": "sha512-Drp39TXuUlD49F7ilHHCG7TTg8IkA+hxCuULdmzWYICxGXvDXmDmWEjJYZQYgf6l/TFfYNE167m7isnc3xlIEg==", "dev": true, "license": "BSD-2-Clause", "dependencies": { - "@typescript-eslint/scope-manager": "8.13.0", - "@typescript-eslint/types": "8.13.0", - "@typescript-eslint/typescript-estree": "8.13.0", - "@typescript-eslint/visitor-keys": "8.13.0", + "@typescript-eslint/scope-manager": "8.17.0", + "@typescript-eslint/types": "8.17.0", + "@typescript-eslint/typescript-estree": "8.17.0", + "@typescript-eslint/visitor-keys": "8.17.0", "debug": "^4.3.4" }, "engines": { @@ -799,14 +802,14 @@ } }, "node_modules/@typescript-eslint/scope-manager": { - "version": "8.13.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/scope-manager/-/scope-manager-8.13.0.tgz", - "integrity": "sha512-XsGWww0odcUT0gJoBZ1DeulY1+jkaHUciUq4jKNv4cpInbvvrtDoyBH9rE/n2V29wQJPk8iCH1wipra9BhmiMA==", + "version": "8.17.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/scope-manager/-/scope-manager-8.17.0.tgz", + "integrity": "sha512-/ewp4XjvnxaREtqsZjF4Mfn078RD/9GmiEAtTeLQ7yFdKnqwTOgRMSvFz4et9U5RiJQ15WTGXPLj89zGusvxBg==", "dev": true, "license": "MIT", "dependencies": { - "@typescript-eslint/types": "8.13.0", - "@typescript-eslint/visitor-keys": "8.13.0" + "@typescript-eslint/types": "8.17.0", + "@typescript-eslint/visitor-keys": "8.17.0" }, "engines": { "node": "^18.18.0 || ^20.9.0 || >=21.1.0" @@ -817,14 +820,14 @@ } }, "node_modules/@typescript-eslint/type-utils": { - "version": "8.13.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/type-utils/-/type-utils-8.13.0.tgz", - "integrity": "sha512-Rqnn6xXTR316fP4D2pohZenJnp+NwQ1mo7/JM+J1LWZENSLkJI8ID8QNtlvFeb0HnFSK94D6q0cnMX6SbE5/vA==", + "version": "8.17.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/type-utils/-/type-utils-8.17.0.tgz", + "integrity": "sha512-q38llWJYPd63rRnJ6wY/ZQqIzPrBCkPdpIsaCfkR3Q4t3p6sb422zougfad4TFW9+ElIFLVDzWGiGAfbb/v2qw==", "dev": true, "license": "MIT", "dependencies": { - "@typescript-eslint/typescript-estree": "8.13.0", - "@typescript-eslint/utils": "8.13.0", + "@typescript-eslint/typescript-estree": "8.17.0", + "@typescript-eslint/utils": "8.17.0", "debug": "^4.3.4", "ts-api-utils": "^1.3.0" }, @@ -835,6 +838,9 @@ "type": "opencollective", "url": "https://opencollective.com/typescript-eslint" }, + "peerDependencies": { + "eslint": "^8.57.0 || ^9.0.0" + }, "peerDependenciesMeta": { "typescript": { "optional": true @@ -842,9 +848,9 @@ } }, "node_modules/@typescript-eslint/types": { - "version": "8.13.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/types/-/types-8.13.0.tgz", - "integrity": "sha512-4cyFErJetFLckcThRUFdReWJjVsPCqyBlJTi6IDEpc1GWCIIZRFxVppjWLIMcQhNGhdWJJRYFHpHoDWvMlDzng==", + "version": "8.17.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/types/-/types-8.17.0.tgz", + "integrity": "sha512-gY2TVzeve3z6crqh2Ic7Cr+CAv6pfb0Egee7J5UAVWCpVvDI/F71wNfolIim4FE6hT15EbpZFVUj9j5i38jYXA==", "dev": true, "license": "MIT", "engines": { @@ -856,14 +862,14 @@ } }, "node_modules/@typescript-eslint/typescript-estree": { - "version": "8.13.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/typescript-estree/-/typescript-estree-8.13.0.tgz", - "integrity": "sha512-v7SCIGmVsRK2Cy/LTLGN22uea6SaUIlpBcO/gnMGT/7zPtxp90bphcGf4fyrCQl3ZtiBKqVTG32hb668oIYy1g==", + "version": "8.17.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/typescript-estree/-/typescript-estree-8.17.0.tgz", + "integrity": "sha512-JqkOopc1nRKZpX+opvKqnM3XUlM7LpFMD0lYxTqOTKQfCWAmxw45e3qlOCsEqEB2yuacujivudOFpCnqkBDNMw==", "dev": true, "license": "BSD-2-Clause", "dependencies": { - "@typescript-eslint/types": "8.13.0", - "@typescript-eslint/visitor-keys": "8.13.0", + "@typescript-eslint/types": "8.17.0", + "@typescript-eslint/visitor-keys": "8.17.0", "debug": "^4.3.4", "fast-glob": "^3.3.2", "is-glob": "^4.0.3", @@ -885,16 +891,16 @@ } }, "node_modules/@typescript-eslint/utils": { - "version": "8.13.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/utils/-/utils-8.13.0.tgz", - "integrity": "sha512-A1EeYOND6Uv250nybnLZapeXpYMl8tkzYUxqmoKAWnI4sei3ihf2XdZVd+vVOmHGcp3t+P7yRrNsyyiXTvShFQ==", + "version": "8.17.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/utils/-/utils-8.17.0.tgz", + "integrity": "sha512-bQC8BnEkxqG8HBGKwG9wXlZqg37RKSMY7v/X8VEWD8JG2JuTHuNK0VFvMPMUKQcbk6B+tf05k+4AShAEtCtJ/w==", "dev": true, "license": "MIT", "dependencies": { "@eslint-community/eslint-utils": "^4.4.0", - "@typescript-eslint/scope-manager": "8.13.0", - "@typescript-eslint/types": "8.13.0", - "@typescript-eslint/typescript-estree": "8.13.0" + "@typescript-eslint/scope-manager": "8.17.0", + "@typescript-eslint/types": "8.17.0", + "@typescript-eslint/typescript-estree": "8.17.0" }, "engines": { "node": "^18.18.0 || ^20.9.0 || >=21.1.0" @@ -905,17 +911,22 @@ }, "peerDependencies": { "eslint": "^8.57.0 || ^9.0.0" + }, + "peerDependenciesMeta": { + "typescript": { + "optional": true + } } }, "node_modules/@typescript-eslint/visitor-keys": { - "version": "8.13.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/visitor-keys/-/visitor-keys-8.13.0.tgz", - "integrity": "sha512-7N/+lztJqH4Mrf0lb10R/CbI1EaAMMGyF5y0oJvFoAhafwgiRA7TXyd8TFn8FC8k5y2dTsYogg238qavRGNnlw==", + "version": "8.17.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/visitor-keys/-/visitor-keys-8.17.0.tgz", + "integrity": "sha512-1Hm7THLpO6ww5QU6H/Qp+AusUUl+z/CAm3cNZZ0jQvon9yicgO7Rwd+/WWRpMKLYV6p2UvdbR27c86rzCPpreg==", "dev": true, "license": "MIT", "dependencies": { - "@typescript-eslint/types": "8.13.0", - "eslint-visitor-keys": "^3.4.3" + "@typescript-eslint/types": "8.17.0", + "eslint-visitor-keys": "^4.2.0" }, "engines": { "node": "^18.18.0 || ^20.9.0 || >=21.1.0" @@ -925,6 +936,19 @@ "url": "https://opencollective.com/typescript-eslint" } }, + "node_modules/@typescript-eslint/visitor-keys/node_modules/eslint-visitor-keys": { + "version": "4.2.0", + "resolved": "https://registry.npmjs.org/eslint-visitor-keys/-/eslint-visitor-keys-4.2.0.tgz", + "integrity": "sha512-UyLnSehNt62FFhSwjZlHmeokpRK59rcz29j+F1/aDgbkbRTk7wIc9XzdoasMUbRNKDM0qQt/+BJ4BrpFeABemw==", + "dev": true, + "license": "Apache-2.0", + "engines": { + "node": "^18.18.0 || ^20.9.0 || >=21.1.0" + }, + "funding": { + "url": "https://opencollective.com/eslint" + } + }, "node_modules/@webassemblyjs/ast": { "version": "1.14.1", "resolved": "https://registry.npmjs.org/@webassemblyjs/ast/-/ast-1.14.1.tgz", @@ -1350,9 +1374,9 @@ } }, "node_modules/axios": { - "version": "1.7.7", - "resolved": "https://registry.npmjs.org/axios/-/axios-1.7.7.tgz", - "integrity": "sha512-S4kL7XrjgBmvdGut0sN3yJxqYzrDOnivkBiN0OFs6hLiUam3UPvswUo0kqGyhqUZGEOytHyumEdXsAkgCOUf3Q==", + "version": "1.7.9", + "resolved": "https://registry.npmjs.org/axios/-/axios-1.7.9.tgz", + "integrity": "sha512-LhLcE7Hbiryz8oMDdDptSrWowmB4Bl6RCt6sIJKpRB4XtVf0iEgewX3au/pJqm+Py1kCASkb/FFKjxQaLtxJvw==", "dev": true, "license": "MIT", "dependencies": { @@ -1438,9 +1462,9 @@ "license": "MIT" }, "node_modules/bonjour-service": { - "version": "1.2.1", - "resolved": "https://registry.npmjs.org/bonjour-service/-/bonjour-service-1.2.1.tgz", - "integrity": "sha512-oSzCS2zV14bh2kji6vNe7vrpJYCHGvcZnlffFQ1MEoX/WOeQ/teD8SYWKR942OI3INjq8OMNJlbPK5LLLUxFDw==", + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/bonjour-service/-/bonjour-service-1.3.0.tgz", + "integrity": "sha512-3YuAUiSkWykd+2Azjgyxei8OWf8thdn8AITIog2M4UICzoqfjlqr64WIjEXZllf/W6vK1goqleSR6brGomxQqA==", "dev": true, "license": "MIT", "dependencies": { @@ -1566,9 +1590,9 @@ } }, "node_modules/caniuse-lite": { - "version": "1.0.30001678", - "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001678.tgz", - "integrity": "sha512-RR+4U/05gNtps58PEBDZcPWTgEO2MBeoPZ96aQcjmfkBWRIDfN451fW2qyDA9/+HohLLIL5GqiMwA+IB1pWarw==", + "version": "1.0.30001686", + "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001686.tgz", + "integrity": "sha512-Y7deg0Aergpa24M3qLC5xjNklnKnhsmSyR/V89dLZ1n0ucJIFNs7PgR2Yfa/Zf6W79SbBicgtGxZr2juHkEUIA==", "dev": true, "funding": [ { @@ -1930,9 +1954,9 @@ "license": "MIT" }, "node_modules/cross-spawn": { - "version": "7.0.5", - "resolved": "https://registry.npmjs.org/cross-spawn/-/cross-spawn-7.0.5.tgz", - "integrity": "sha512-ZVJrKKYunU38/76t0RMOulHOnUcbU9GbpWKAOZ0mhjr7CX6FVrH+4FrAapSOekrgFQ3f/8gwMEuIft0aKq6Hug==", + "version": "7.0.6", + "resolved": "https://registry.npmjs.org/cross-spawn/-/cross-spawn-7.0.6.tgz", + "integrity": "sha512-uV2QOWP2nWzsy2aMp8aRibhi9dlzF5Hgh5SHaB9OiTGEyDTiJJyx0uy51QXdyWbtAHNua4XJzUKca3OzKUd3vA==", "dev": true, "license": "MIT", "dependencies": { @@ -2092,9 +2116,9 @@ "license": "MIT" }, "node_modules/electron-to-chromium": { - "version": "1.5.54", - "resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.5.54.tgz", - "integrity": "sha512-TX6vHleisn5i/4pekTyy1sdoLXQNy8VFvBK/fJRXSyp7GUO27KioLTG0Qo5wFjM3ZF4ryKinDo4m+IJ+rwUWSw==", + "version": "1.5.71", + "resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.5.71.tgz", + "integrity": "sha512-dB68l59BI75W1BUGVTAEJy45CEVuEGy9qPVVQ8pnHyHMn36PLPPoE1mjLH+lo9rKulO3HC2OhbACI/8tCqJBcA==", "dev": true, "license": "ISC" }, @@ -2209,27 +2233,27 @@ } }, "node_modules/eslint": { - "version": "9.14.0", - "resolved": "https://registry.npmjs.org/eslint/-/eslint-9.14.0.tgz", - "integrity": "sha512-c2FHsVBr87lnUtjP4Yhvk4yEhKrQavGafRA/Se1ouse8PfbfC/Qh9Mxa00yWsZRlqeUB9raXip0aiiUZkgnr9g==", + "version": "9.16.0", + "resolved": "https://registry.npmjs.org/eslint/-/eslint-9.16.0.tgz", + "integrity": "sha512-whp8mSQI4C8VXd+fLgSM0lh3UlmcFtVwUQjyKCFfsp+2ItAIYhlq/hqGahGqHE6cv9unM41VlqKk2VtKYR2TaA==", "dev": true, "license": "MIT", "dependencies": { "@eslint-community/eslint-utils": "^4.2.0", "@eslint-community/regexpp": "^4.12.1", - "@eslint/config-array": "^0.18.0", - "@eslint/core": "^0.7.0", - "@eslint/eslintrc": "^3.1.0", - "@eslint/js": "9.14.0", - "@eslint/plugin-kit": "^0.2.0", + "@eslint/config-array": "^0.19.0", + "@eslint/core": "^0.9.0", + "@eslint/eslintrc": "^3.2.0", + "@eslint/js": "9.16.0", + "@eslint/plugin-kit": "^0.2.3", "@humanfs/node": "^0.16.6", "@humanwhocodes/module-importer": "^1.0.1", - "@humanwhocodes/retry": "^0.4.0", + "@humanwhocodes/retry": "^0.4.1", "@types/estree": "^1.0.6", "@types/json-schema": "^7.0.15", "ajv": "^6.12.4", "chalk": "^4.0.0", - "cross-spawn": "^7.0.2", + "cross-spawn": "^7.0.5", "debug": "^4.3.2", "escape-string-regexp": "^4.0.0", "eslint-scope": "^8.2.0", @@ -2248,8 +2272,7 @@ "lodash.merge": "^4.6.2", "minimatch": "^3.1.2", "natural-compare": "^1.4.0", - "optionator": "^0.9.3", - "text-table": "^0.2.0" + "optionator": "^0.9.3" }, "bin": { "eslint": "bin/eslint.js" @@ -2621,9 +2644,9 @@ } }, "node_modules/express": { - "version": "4.21.1", - "resolved": "https://registry.npmjs.org/express/-/express-4.21.1.tgz", - "integrity": "sha512-YSFlK1Ee0/GC8QaO91tHcDxJiE/X4FbpAyQWkxAvG6AXCuR65YzK8ua6D9hvi/TzUfZMpc+BwuM1IPw8fmQBiQ==", + "version": "4.21.2", + "resolved": "https://registry.npmjs.org/express/-/express-4.21.2.tgz", + "integrity": "sha512-28HqgMZAmih1Czt9ny7qr6ek2qddF4FclbMzwhCREB6OFfH+rXAnuNCwo1/wFvrtbgsQDb4kSbX9de9lFbrXnA==", "license": "MIT", "dependencies": { "accepts": "~1.3.8", @@ -2645,7 +2668,7 @@ "methods": "~1.1.2", "on-finished": "2.4.1", "parseurl": "~1.3.3", - "path-to-regexp": "0.1.10", + "path-to-regexp": "0.1.12", "proxy-addr": "~2.0.7", "qs": "6.13.0", "range-parser": "~1.2.1", @@ -2660,6 +2683,10 @@ }, "engines": { "node": ">= 0.10.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/express" } }, "node_modules/express/node_modules/debug": { @@ -2893,9 +2920,9 @@ } }, "node_modules/flatted": { - "version": "3.3.1", - "resolved": "https://registry.npmjs.org/flatted/-/flatted-3.3.1.tgz", - "integrity": "sha512-X8cqMLLie7KsNUDSdzeN8FYK9rEt4Dt67OsG/DNGnYTSDBG4uFAJFBnUeiV+zCVAvwFy56IjM9sH51jVaEhNxw==", + "version": "3.3.2", + "resolved": "https://registry.npmjs.org/flatted/-/flatted-3.3.2.tgz", + "integrity": "sha512-AiwGJM8YcNOaobumgtng+6NHuOqC3A7MixFeDafM3X9cIUM+xUXoS5Vfgf+OihAYe20fxqNM9yPBXJzRtZ/4eA==", "dev": true, "license": "ISC" }, @@ -3140,12 +3167,12 @@ } }, "node_modules/gopd": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/gopd/-/gopd-1.0.1.tgz", - "integrity": "sha512-d65bNlIadxvpb/A2abVdlqKqV563juRnZ1Wtk6s1sIR8uNsXR70xqIzVqxVf1eTqDunwT2MkczEeaezCKTZhwA==", + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/gopd/-/gopd-1.2.0.tgz", + "integrity": "sha512-ZUKRh6/kUFoAiTAtTYPZJ3hw9wNxx+BIBOijnlG9PnrJsCcSjs1wyyD6vJpaYtgnzDrKYRSqf3OO6Rfa93xsRg==", "license": "MIT", - "dependencies": { - "get-intrinsic": "^1.1.3" + "engines": { + "node": ">= 0.4" }, "funding": { "url": "https://github.com/sponsors/ljharb" @@ -3195,10 +3222,13 @@ } }, "node_modules/has-proto": { - "version": "1.0.3", - "resolved": "https://registry.npmjs.org/has-proto/-/has-proto-1.0.3.tgz", - "integrity": "sha512-SJ1amZAJUiZS+PhsVLf5tGydlaVB8EdFpaSO4gmiUKUOxk8qzn5AIy4ZeJUmh22znIdk/uMAUT2pl3FxzVUH+Q==", + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/has-proto/-/has-proto-1.1.0.tgz", + "integrity": "sha512-QLdzI9IIO1Jg7f9GT1gXpPpXArAn6cS31R1eEZqz08Gc+uQ8/XiqHWt17Fiw+2p6oTTIq5GXEpQkAlA88YRl/Q==", "license": "MIT", + "dependencies": { + "call-bind": "^1.0.7" + }, "engines": { "node": ">= 0.4" }, @@ -3207,9 +3237,9 @@ } }, "node_modules/has-symbols": { - "version": "1.0.3", - "resolved": "https://registry.npmjs.org/has-symbols/-/has-symbols-1.0.3.tgz", - "integrity": "sha512-l3LCuF6MgDNwTDKkdYGEihYjt5pRPbEg46rtlmnSPlUbgmB8LOIrKJbYYFBSbnPaJexMKtiPO8hmeRjRz2Td+A==", + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/has-symbols/-/has-symbols-1.1.0.tgz", + "integrity": "sha512-1cDNdwJ2Jaohmb3sg4OmKaMBwuC48sYni5HUw2DvsC8LjGTLK9h+eb1X6RyuOHe4hT0ULCW68iomhjUoKUqlPQ==", "license": "MIT", "engines": { "node": ">= 0.4" @@ -3917,9 +3947,9 @@ } }, "node_modules/memfs": { - "version": "4.14.0", - "resolved": "https://registry.npmjs.org/memfs/-/memfs-4.14.0.tgz", - "integrity": "sha512-JUeY0F/fQZgIod31Ja1eJgiSxLn7BfQlCnqhwXFBzFHEw63OdLK7VJUJ7bnzNsWgCyoUP5tEp1VRY8rDaYzqOA==", + "version": "4.14.1", + "resolved": "https://registry.npmjs.org/memfs/-/memfs-4.14.1.tgz", + "integrity": "sha512-Fq5CMEth+2iprLJ5mNizRcWuiwRZYjNkUD0zKk224jZunE9CRacTRDK8QLALbMBlNX2y3nY6lKZbesCwDwacig==", "dev": true, "license": "Apache-2.0", "dependencies": { @@ -4166,9 +4196,9 @@ } }, "node_modules/npm-check-updates": { - "version": "17.1.10", - "resolved": "https://registry.npmjs.org/npm-check-updates/-/npm-check-updates-17.1.10.tgz", - "integrity": "sha512-GnN6KbUzC8BpwsRYJntuumgCiagZ0+xxorvUJM9m06d7AlyK9lm3iFsAsnXF3VAZZzpD5QjZvWBwNze61Vywkw==", + "version": "17.1.11", + "resolved": "https://registry.npmjs.org/npm-check-updates/-/npm-check-updates-17.1.11.tgz", + "integrity": "sha512-TR2RuGIH7P3Qrb0jfdC/nT7JWqXPKjDlxuNQt3kx4oNVf1Pn5SBRB7KLypgYZhruivJthgTtfkkyK4mz342VjA==", "dev": true, "license": "Apache-2.0", "bin": { @@ -4181,9 +4211,9 @@ } }, "node_modules/object-inspect": { - "version": "1.13.2", - "resolved": "https://registry.npmjs.org/object-inspect/-/object-inspect-1.13.2.tgz", - "integrity": "sha512-IRZSRuzJiynemAXPYtPe5BoI/RESNYR7TYm50MC5Mqbd3Jmw5y790sErYw3V6SryFJD64b74qQQs9wn5Bg/k3g==", + "version": "1.13.3", + "resolved": "https://registry.npmjs.org/object-inspect/-/object-inspect-1.13.3.tgz", + "integrity": "sha512-kDCGIbxkDSXE3euJZZXzc6to7fCrKHNI/hSRQnRuQ+BWjFNzZwiFF8fj/6o2t2G9/jTj8PSIYTfCLelLZEeRpA==", "license": "MIT", "engines": { "node": ">= 0.4" @@ -4319,9 +4349,9 @@ } }, "node_modules/p-retry": { - "version": "6.2.0", - "resolved": "https://registry.npmjs.org/p-retry/-/p-retry-6.2.0.tgz", - "integrity": "sha512-JA6nkq6hKyWLLasXQXUrO4z8BUZGUt/LjlJxx8Gb2+2ntodU/SS63YZ8b0LUTbQ8ZB9iwOfhEPhg4ykKnn2KsA==", + "version": "6.2.1", + "resolved": "https://registry.npmjs.org/p-retry/-/p-retry-6.2.1.tgz", + "integrity": "sha512-hEt02O4hUct5wtwg4H4KcWgDdm+l1bOaEy/hWzd8xtXB9BqxTWBBhb+2ImAtH4Cv4rPjV76xN3Zumqk3k3AhhQ==", "dev": true, "license": "MIT", "dependencies": { @@ -4447,9 +4477,9 @@ "license": "MIT" }, "node_modules/path-to-regexp": { - "version": "0.1.10", - "resolved": "https://registry.npmjs.org/path-to-regexp/-/path-to-regexp-0.1.10.tgz", - "integrity": "sha512-7lf7qcQidTku0Gu3YDPc8DJ1q7OOucfa/BSsIwjuh56VU7katFvuM8hULfkwB3Fns/rsVF7PwPKVw1sl5KQS9w==", + "version": "0.1.12", + "resolved": "https://registry.npmjs.org/path-to-regexp/-/path-to-regexp-0.1.12.tgz", + "integrity": "sha512-RA1GjUVMnvYFxuqovrEqZoxxW5NUZqbwKtYz/Tt7nXerk0LbLblQmrsgdeOxV5SFHf0UDggjS/bSeOZwt1pmEQ==", "license": "MIT" }, "node_modules/path-type": { @@ -4565,9 +4595,9 @@ } }, "node_modules/prettier": { - "version": "3.3.3", - "resolved": "https://registry.npmjs.org/prettier/-/prettier-3.3.3.tgz", - "integrity": "sha512-i2tDNA0O5IrMO757lfrdQZCc2jPNDVntV0m/+4whiDfWaTKfMNgR7Qz0NAeGz/nRqF4m5/6CLzbP4/liHt12Ew==", + "version": "3.4.2", + "resolved": "https://registry.npmjs.org/prettier/-/prettier-3.4.2.tgz", + "integrity": "sha512-e9MewbtFo+Fevyuxn/4rrcDAaq0IYxPGLvObpQjiZBMAzB9IGmzlnG9RZy3FFas+eBMu2vA0CszMeduow5dIuQ==", "dev": true, "license": "MIT", "bin": { @@ -5285,11 +5315,14 @@ } }, "node_modules/shell-quote": { - "version": "1.8.1", - "resolved": "https://registry.npmjs.org/shell-quote/-/shell-quote-1.8.1.tgz", - "integrity": "sha512-6j1W9l1iAs/4xYBI1SYOVZyFcCis9b4KCLQ8fgAGG07QvzaRLVVRQvAy85yNmmZSjYjg4MWh4gNvlPujU/5LpA==", + "version": "1.8.2", + "resolved": "https://registry.npmjs.org/shell-quote/-/shell-quote-1.8.2.tgz", + "integrity": "sha512-AzqKpGKjrj7EM6rKVQEPpB288oCfnrEIuyoT9cyF4nmGa7V8Zk6f7RRqYisX8X9m+Q7bd632aZW4ky7EhbQztA==", "dev": true, "license": "MIT", + "engines": { + "node": ">= 0.4" + }, "funding": { "url": "https://github.com/sponsors/ljharb" } @@ -5536,9 +5569,9 @@ } }, "node_modules/terser": { - "version": "5.36.0", - "resolved": "https://registry.npmjs.org/terser/-/terser-5.36.0.tgz", - "integrity": "sha512-IYV9eNMuFAV4THUspIRXkLakHnV6XO7FEdtKjf/mDyrnqUg9LnlOn6/RwRvM9SZjR4GUq8Nk8zj67FzVARr74w==", + "version": "5.37.0", + "resolved": "https://registry.npmjs.org/terser/-/terser-5.37.0.tgz", + "integrity": "sha512-B8wRRkmre4ERucLM/uXx4MOV5cbnOlVAqUst+1+iLKPI0dOgFO28f84ptoQt9HEI537PMzfYa/d+GEPKTRXmYA==", "dev": true, "license": "BSD-2-Clause", "dependencies": { @@ -5608,13 +5641,6 @@ "url": "https://opencollective.com/webpack" } }, - "node_modules/text-table": { - "version": "0.2.0", - "resolved": "https://registry.npmjs.org/text-table/-/text-table-0.2.0.tgz", - "integrity": "sha512-N+8UisAXDGk8PFXP4HAzVR9nbfmVJ3zYLAWiTIoqC5v5isinhr+r5uaO8+7r3BMfuNIufIsA7RdpVgacC2cSpw==", - "dev": true, - "license": "MIT" - }, "node_modules/thingies": { "version": "1.21.0", "resolved": "https://registry.npmjs.org/thingies/-/thingies-1.21.0.tgz", @@ -5629,9 +5655,9 @@ } }, "node_modules/three": { - "version": "0.170.0", - "resolved": "https://registry.npmjs.org/three/-/three-0.170.0.tgz", - "integrity": "sha512-FQK+LEpYc0fBD+J8g6oSEyyNzjp+Q7Ks1C568WWaoMRLW+TkNNWmenWeGgJjV105Gd+p/2ql1ZcjYvNiPZBhuQ==", + "version": "0.171.0", + "resolved": "https://registry.npmjs.org/three/-/three-0.171.0.tgz", + "integrity": "sha512-Y/lAXPaKZPcEdkKjh0JOAHVv8OOnv/NDJqm0wjfCzyQmfKxV7zvkwsnBgPBKTzJHToSOhRGQAGbPJObT59B/PQ==", "license": "MIT" }, "node_modules/through2": { @@ -5745,9 +5771,9 @@ } }, "node_modules/ts-api-utils": { - "version": "1.4.0", - "resolved": "https://registry.npmjs.org/ts-api-utils/-/ts-api-utils-1.4.0.tgz", - "integrity": "sha512-032cPxaEKwM+GT3vA5JXNzIaizx388rhsSW79vGRNGXfRRAdEAn2mvk36PvK5HnOchyWZ7afLEXqYCvPCrzuzQ==", + "version": "1.4.3", + "resolved": "https://registry.npmjs.org/ts-api-utils/-/ts-api-utils-1.4.3.tgz", + "integrity": "sha512-i3eMG77UTMD0hZhgRS562pv83RC6ukSAC2GMNWc+9dieh/+jDM5u5YG+NHX6VNDRHQcHwmsTHctP9LhbC3WxVw==", "dev": true, "license": "MIT", "engines": { @@ -5812,9 +5838,9 @@ } }, "node_modules/typescript": { - "version": "5.6.3", - "resolved": "https://registry.npmjs.org/typescript/-/typescript-5.6.3.tgz", - "integrity": "sha512-hjcS1mhfuyi4WW8IWtjP7brDrG2cuDZukyrYrSauoXGNgx0S7zceP07adYkJycEr56BOUTNPzbInooiN3fn1qw==", + "version": "5.7.2", + "resolved": "https://registry.npmjs.org/typescript/-/typescript-5.7.2.tgz", + "integrity": "sha512-i5t66RHxDvVN40HfDd1PsEThGNnlMCMT3jMUuoh9/0TaqWevNontacunWyN02LA9/fIbEWlcHZcgTKb9QoaLfg==", "dev": true, "license": "Apache-2.0", "bin": { @@ -5826,9 +5852,9 @@ } }, "node_modules/undici-types": { - "version": "6.19.8", - "resolved": "https://registry.npmjs.org/undici-types/-/undici-types-6.19.8.tgz", - "integrity": "sha512-ve2KP6f/JnbPBFyobGHuerC9g1FYGn/F8n1LWTwNxCEzd6IfqTwUQcNXgEtmmQ6DlRrC1hrSrBnCZPokRrDHjw==", + "version": "6.20.0", + "resolved": "https://registry.npmjs.org/undici-types/-/undici-types-6.20.0.tgz", + "integrity": "sha512-Ny6QZ2Nju20vw1SRHe3d9jVu6gJ+4e3+MMpqu7pqE5HT6WsTSlce++GQmK5UXS8mzV8DSYHrQH+Xrf2jVcuKNg==", "dev": true, "license": "MIT" }, @@ -5975,17 +6001,17 @@ } }, "node_modules/webpack": { - "version": "5.96.1", - "resolved": "https://registry.npmjs.org/webpack/-/webpack-5.96.1.tgz", - "integrity": "sha512-l2LlBSvVZGhL4ZrPwyr8+37AunkcYj5qh8o6u2/2rzoPc8gxFJkLj1WxNgooi9pnoc06jh0BjuXnamM4qlujZA==", + "version": "5.97.1", + "resolved": "https://registry.npmjs.org/webpack/-/webpack-5.97.1.tgz", + "integrity": "sha512-EksG6gFY3L1eFMROS/7Wzgrii5mBAFe4rIr3r2BTfo7bcc+DWwFZ4OJ/miOuHJO/A85HwyI4eQ0F6IKXesO7Fg==", "dev": true, "license": "MIT", "dependencies": { "@types/eslint-scope": "^3.7.7", "@types/estree": "^1.0.6", - "@webassemblyjs/ast": "^1.12.1", - "@webassemblyjs/wasm-edit": "^1.12.1", - "@webassemblyjs/wasm-parser": "^1.12.1", + "@webassemblyjs/ast": "^1.14.1", + "@webassemblyjs/wasm-edit": "^1.14.1", + "@webassemblyjs/wasm-parser": "^1.14.1", "acorn": "^8.14.0", "browserslist": "^4.24.0", "chrome-trace-event": "^1.0.2", @@ -6470,9 +6496,9 @@ } }, "node_modules/yaml": { - "version": "2.6.0", - "resolved": "https://registry.npmjs.org/yaml/-/yaml-2.6.0.tgz", - "integrity": "sha512-a6ae//JvKDEra2kdi1qzCyrJW/WZCgFi8ydDV+eXExl95t+5R+ijnqHJbz9tmMh8FUjx3iv2fCQ4dclAQlO2UQ==", + "version": "2.6.1", + "resolved": "https://registry.npmjs.org/yaml/-/yaml-2.6.1.tgz", + "integrity": "sha512-7r0XPzioN/Q9kXBro/XPnA6kznR73DHq+GXh5ON7ZozRO6aMjbmiBuKste2wslTFkC5d1dw0GooOCepZXJ2SAg==", "dev": true, "license": "ISC", "bin": { diff --git a/package.json b/package.json index 8f8da77..066c405 100644 --- a/package.json +++ b/package.json @@ -25,34 +25,34 @@ "devDependencies": { "@types/dat.gui": "^0.7.13", "@types/express": "^5.0.0", - "@types/node": "^22.9.0", - "@types/three": "^0.169.0", - "@typescript-eslint/eslint-plugin": "8.13.0", - "@typescript-eslint/parser": "8.13.0", - "axios": "^1.7.7", + "@types/node": "^22.10.1", + "@types/three": "^0.170.0", + "@typescript-eslint/eslint-plugin": "8.17.0", + "@typescript-eslint/parser": "8.17.0", + "axios": "^1.7.9", "copy-webpack-plugin": "^12.0.2", "copyfiles": "^2.4.1", "dat.gui": "^0.7.9", - "eslint": "9.14.0", + "eslint": "9.16.0", "eslint-config-prettier": "9.1.0", "eslint-plugin-jest": "28.9.0", "eslint-plugin-node": "11.1.0", "eslint-plugin-prettier": "5.2.1", "install-peers": "^1.0.4", - "npm-check-updates": "^17.1.10", + "npm-check-updates": "^17.1.11", "patch-package": "^8.0.0", - "prettier": "3.3.3", + "prettier": "3.4.2", "raw-loader": "^4.0.2", "ts-loader": "^9.5.1", - "typescript": "^5.6.3", - "webpack": "^5.96.1", + "typescript": "^5.7.2", + "webpack": "^5.97.1", "webpack-cli": "^5.1.4", "webpack-dev-server": "^5.1.0", "webpack-merge": "^6.0.1" }, "dependencies": { - "express": "^4.21.1", + "express": "^4.21.2", "lodash": "^4.17.21", - "three": "0.170.0" + "three": "0.171.0" } }